44 ParticlePropertySvc::ParticlePropertySvc
45 ( const
std::
string& name ,
49 , m_filename ( "ParticleTable.txt" )
67 m_filename +=
"/data/ParticleTable.txt";
70 declareProperty (
"ParticlePropertiesFile" , m_filename ) ;
71 declareProperty (
"OtherFiles" , m_other ) ;
72 declareProperty (
"Particles" , m_particles ) ;
77 ParticlePropertySvc::~ParticlePropertySvc()
80 {
if ( 0 != *
i ) {
delete *
i ; } }
100 sc = service(
"VFSSvc",m_fileAccess);
113 if ( !m_particles.empty() )
115 sc = addParticles () ;
131 log <<
MSG::DEBUG <<
"StdHepID Map size =" << m_stdhepidmap.size()
134 log <<
MSG::DEBUG <<
"PythiaID Map size =" << m_pythiaidmap.size()
137 if ( !m_replaced.empty() )
140 <<
"Properties have been redefined for "
141 << m_replaced.size() <<
" particles : "
153 if ( !m_other.empty() )
157 <<
"Additional Properties have been read from files: "
162 if ( !m_replaced.empty() )
166 <<
"Properties have been redefined for "
167 << m_replaced.size() <<
" particles : "
173 m_fileAccess->release();
195 ( particle , geantId , jetsetId ,
196 charge , mass , tlife ,
197 evtName , pythiaId , maxWidth ) ;
199 m_owned.insert ( pp ) ;
201 return push_back( pp );
214 if ( m_idmap.end() != ifind && 0 != m_idmap[ ID ])
216 diff ( ifind->second , pp ) ;
217 m_replaced.insert( m_idmap[ ID ]->particle() ) ;
227 if ( m_namemap.end() != ifind && 0 != m_namemap[ particle ] )
229 diff ( ifind->second , pp ) ;
230 m_replaced.insert( m_namemap[ particle ]->particle() ) ;
233 m_namemap[ particle ] =
pp ;
243 if ( m_stdhepidmap.end() != ifind && 0 != m_stdhepidmap[ ID ])
245 diff ( ifind->second , pp ) ;
246 m_replaced.insert( m_stdhepidmap[ ID ]->particle() ) ;
249 m_stdhepidmap[ ID ] =
pp ;
261 if ( m_pythiaidmap.end() != ifind && 0 != m_pythiaidmap[ ID ])
263 diff ( ifind->second , pp ) ;
264 m_replaced.insert( m_pythiaidmap[ ID ]->particle() ) ;
267 m_pythiaidmap[ ID ] =
pp ;
280 typename MAP::iterator
i = m.begin() ;
281 for ( ; m.end() !=
i ; ++
i ) {
if ( i->second == pp ) { break ; } }
282 if ( m.end() !=
i ) { m.erase ( i ) ; }
290 _remove_ ( m_idmap , pp ) ;
291 _remove_ ( m_namemap , pp ) ;
292 _remove_ ( m_stdhepidmap , pp ) ;
293 _remove_ ( m_pythiaidmap , pp ) ;
317 if ( m_namemap.size() == 0 )
321 <<
"Format of input file inconsistent with what expected"
322 <<
" - Check you are using ParticleData.txt" <<
endmsg;
337 if (m_fileAccess) infileptr = m_fileAccess->open(file);
339 if ( infileptr.
get() == 0 )
341 log <<
MSG::ERROR <<
"Unable to open properties file : " << file
349 <<
"Opened particle properties file : " << file <<
endmsg;
355 infile.getline( line, 255 );
357 if ( line[0] ==
'#' )
continue;
363 #pragma warning(disable:4996)
366 char* token = strtok( line,
" " );
367 if ( token ) { par = token; token = strtok( NULL,
" " );}
else continue;
368 if ( token ) { gid = token; token = strtok( NULL,
" " );}
else continue;
369 if ( token ) { jid = token; token = strtok( NULL,
" " );}
else continue;
370 if ( token ) { chg = token; token = strtok( NULL,
" " );}
else continue;
371 if ( token ) { mas = token; token = strtok( NULL,
" " );}
else continue;
372 if ( token ) { lif = token; token = strtok( NULL,
" " );}
else continue;
373 if ( token ) { evt = token; token = strtok( NULL,
" " );}
else continue;
374 if ( token ) { pyt = token; token = strtok( NULL,
" " );}
else continue;
375 if ( token ) { mwi = token; token = strtok( NULL,
" " );}
else continue;
376 if ( token != NULL )
continue;
382 long ljid = atoi( jid.c_str() );
383 long lgid = atoi( gid.c_str() );
384 long lpyt = atoi( pyt.c_str() ) ;
389 ljid = 10000000*lgid;
393 sc = push_back( par, lgid, ljid,
394 atof( chg.c_str() ), mass, tlife, evt, lpyt, mW ) ;
398 <<
"Error from ParticlePropertySvc::push_back for particle='"
418 if ( 0 == pp ) {
return 0 ; }
419 const int ID = pp->
pdgID() ;
420 const int antiID = -1 * ID ;
421 for (
const_iterator it = m_vectpp.begin() ; m_vectpp.end() != it ; ++it )
424 if ( 0 == ap ) { continue ; }
425 if ( antiID == ap->
pdgID() ) {
return ap ; }
439 for (
iterator ip = m_vectpp.begin() ; m_vectpp.end() != ip ; ++ip )
442 if ( 0 == pp ) { continue ; }
457 for (
typename MAP::iterator i = m.begin() ; m.end() !=
i ; ++
i )
458 { result.
insert ( i->second ); }
466 m_vectpp.reserve ( m_idmap.size() + 100 ) ;
468 _load_ ( m_idmap , local ) ;
469 _load_ ( m_namemap , local ) ;
470 _load_ ( m_stdhepidmap , local ) ;
471 _load_ ( m_pythiaidmap , local ) ;
474 { m_vectpp.push_back ( *i ) ; }
475 return setAntiParticles() ;
486 m_particles.end() != ip ; ++ip )
512 <<
" Add/Modify the particle: "
513 <<
" name='" << p_name <<
"'"
514 <<
" geant=" << p_geant
515 <<
" jetset=" << p_jetset
516 <<
" charge=" << p_charge
517 <<
" mass=" << p_mass
518 <<
" ltime=" << p_ltime
519 <<
" evtgen='" << p_evtgen <<
"'"
520 <<
" pythia=" << p_pythia
521 <<
" maxwid=" << p_maxwid <<
endmsg ;
532 p_maxwid * Gaudi::Units::GeV ) ;
538 <<
" could not parse '" << item <<
"'" <<
endmsg ;
549 #pragma warning(push)
550 #pragma warning(disable:1572)
552 bool ParticlePropertySvc::diff
558 if ( o == n ) {
return false ; }
562 if ( 0 == o || 0 == n )
568 bool result = false ;
569 if ( o -> particle () != n -> particle () )
572 log <<
" Name:'" << o -> particle () <<
"'/'" << n -> particle () <<
"'" ;
574 if ( o -> geantID () != n -> geantID () )
577 log <<
" G3ID:" << o -> geantID () <<
"/" << n -> geantID () <<
"'" ;
579 if ( o -> pdgID () != n -> pdgID () )
582 log <<
" PDGID:" << o -> pdgID () <<
"/" << n -> pdgID () <<
"'" ;
584 if ( o -> pythiaID () != n -> pythiaID () )
587 log <<
" PYID:" << o -> pythiaID () <<
"/" << n -> pythiaID () <<
"'" ;
589 if ( o -> charge () != n -> charge () )
592 log <<
" Q:" << o -> charge () <<
"/" << n -> charge () <<
"'" ;
594 if ( o -> mass () != n -> mass () )
597 log <<
" M:" << o -> mass () <<
"/" << n -> mass () <<
"'" ;
599 if ( o -> lifetime () != n -> lifetime () )
602 log <<
" T:" << o -> lifetime () <<
"/" << n -> lifetime () <<
"'" ;
604 if ( o -> evtGenName () != n -> evtGenName () )
607 log <<
" EvtGen:" << o -> evtGenName () <<
"/" << n -> evtGenName () <<
"'" ;
609 if ( o -> maxWidth () != n -> maxWidth () )
612 log <<
" WMAX:" << o -> maxWidth () <<
"/" << n -> maxWidth () <<
"'" ;
614 if ( result ) { log <<
endmsg ; }