![]() |
|
|
Generated: 18 Jul 2008 |
#include <ParticlePropertySvc.h>
Inheritance diagram for ParticlePropertySvc:


The settable property of this service is the ParticlePropertiesFile, an ASCII file containing the list of properties for the particles. The default file is: "$PARAMFILESROOT/data/ParticleTable.txt" or if $PARAMFILESROOT is not defined "ParticleTable.txt"
// read additional properties ParticlePropertySvc.OtherFiles = { "$SOMELOCATION1/file1.txt" , "$SOMELOCATION2/file2.txt" } ;
2) Add possibility to modify only certain partiles through the new property "Particles" (default is enpty list), Each line is interpreted as a line in particle data table, e.g.
// redefine the properties of H_20 and H_30 particles: ParticlePropertySvc.Particles = { "H_20 88 35 0.0 120.0 9.4e-26 Higgs'0 35 0.0e+00" , "H_30 89 36 0.0 40.0 1.0e-12 A0 36 0.0e+00" } ;
The replaces/modified particles are reported.
Definition at line 75 of file ParticlePropertySvc.h.
Public Types | |
| typedef ParticleProperty * | mapped_type |
| typedef std::map< int, mapped_type > | MapID |
| typedef std::map< std::string, mapped_type > | MapName |
| typedef std::map< int, mapped_type > | MapStdHepID |
| typedef std::map< int, mapped_type > | MapPythiaID |
| typedef IParticlePropertySvc::VectPP | VectPP |
| typedef IParticlePropertySvc::const_iterator | const_iterator |
| typedef IParticlePropertySvc::iterator | iterator |
| typedef std::set< ParticleProperty * > | Set |
Public Member Functions | |
| virtual StatusCode | initialize () |
| Initialise the service. | |
| virtual StatusCode | finalize () |
| Finalise the service. | |
| virtual StatusCode | queryInterface (const InterfaceID &riid, void **ppvInterface) |
| Query the interfaces. | |
| virtual const InterfaceID & | type () const |
| Service type. | |
| virtual StatusCode | push_back (const std::string &particle, int geantId, int jetsetId, double charge, double mass, double tlife, const std::string &evtName, int pythiaId, double maxWidth) |
| Create a new particle property. | |
| virtual StatusCode | push_back (ParticleProperty *pp) |
| Add a new particle property. | |
| virtual const_iterator | begin () const |
| Get a const reference to the begining of the container. | |
| virtual const_iterator | end () const |
| Get a const reference to the end of the container. | |
| virtual int | size () const |
| Get the container size. | |
| virtual ParticleProperty * | find (int geantId) |
| Retrieve a property by geant3 id. | |
| virtual ParticleProperty * | find (const std::string &name) |
| Retrieve a property by particle name. | |
| virtual ParticleProperty * | findByStdHepID (int stdHepId) |
| Retrieve a property by StdHep id. | |
| virtual ParticleProperty * | findByPythiaID (int pythiaID) |
| Retrieve a property by Pythia id. | |
| virtual StatusCode | erase (int geantId) |
| Erase a property by geant3 id. | |
| virtual StatusCode | erase (const std::string &name) |
| Erase a property by particle name. | |
| virtual StatusCode | eraseByStdHepID (int stdHepId) |
| Erase a property by StdHep id ??? | |
| ParticlePropertySvc (const std::string &name, ISvcLocator *svc) | |
| Standard Constructor. | |
| virtual | ~ParticlePropertySvc () |
| Destructor. | |
Protected Member Functions | |
| const ParticleProperty * | anti (const ParticleProperty *pp) const |
| helper (protected) function to find an antiparticle for the given particle ID (StdHepID) | |
| StatusCode | setAntiParticles () |
| helper (protected) function to set the valid particle<-->antiparticle relations | |
| StatusCode | rebuild () |
| rebuild "the linear container" from the map | |
| StatusCode | erase (const ParticleProperty *pp) |
| remove particle property from all maps | |
| StatusCode | parse (const std::string &file) |
| parse the file | |
| StatusCode | parse () |
| Parses the file and fill all the maps. | |
| StatusCode | addParticles () |
| bool | diff (const ParticleProperty *o, const ParticleProperty *n, const MSG::Level l=MSG::DEBUG) const |
Private Types | |
| typedef std::vector< std::string > | Files |
| typedef std::vector< std::string > | Particles |
Private Attributes | |
| std::string | m_filename |
| Filename of the particle properties file. | |
| Files | m_other |
| additional file names | |
| Particles | m_particles |
| VectPP | m_vectpp |
| Vector of all particle properties. | |
| MapID | m_idmap |
| Map for geant IDs. | |
| MapName | m_namemap |
| Map for particle names. | |
| MapStdHepID | m_stdhepidmap |
| Map for StdHep Ids. | |
| MapPythiaID | m_pythiaidmap |
| Map for Pythia Ids. | |
| Set | m_owned |
| std::set< std::string > | m_replaced |
| IFileAccess * | m_fileAccess |
Definition at line 81 of file ParticlePropertySvc.h.
| typedef std::map< int, mapped_type > ParticlePropertySvc::MapID |
Definition at line 82 of file ParticlePropertySvc.h.
| typedef std::map< std::string, mapped_type > ParticlePropertySvc::MapName |
Definition at line 83 of file ParticlePropertySvc.h.
| typedef std::map< int, mapped_type > ParticlePropertySvc::MapStdHepID |
Definition at line 84 of file ParticlePropertySvc.h.
| typedef std::map< int, mapped_type > ParticlePropertySvc::MapPythiaID |
Definition at line 85 of file ParticlePropertySvc.h.
| typedef std::set<ParticleProperty*> ParticlePropertySvc::Set |
Definition at line 89 of file ParticlePropertySvc.h.
typedef std::vector<std::string> ParticlePropertySvc::Files [private] |
Definition at line 193 of file ParticlePropertySvc.h.
typedef std::vector<std::string> ParticlePropertySvc::Particles [private] |
Definition at line 194 of file ParticlePropertySvc.h.
| ParticlePropertySvc::ParticlePropertySvc | ( | const std::string & | name, | |
| ISvcLocator * | svc | |||
| ) |
Standard Constructor.
| name | String with service name | |
| svc | Pointer to service locator interface |
Definition at line 46 of file ParticlePropertySvc.cpp.
00048 : Service( name, svc ) 00049 // the default name of input data file 00050 , m_filename ( "ParticleTable.txt" ) 00051 , m_other () 00052 , m_particles () 00053 // storages : 00054 , m_vectpp () 00055 , m_idmap () 00056 , m_namemap () 00057 , m_stdhepidmap() 00058 , m_pythiaidmap() 00059 // 00060 , m_owned () 00061 , m_replaced () 00062 , m_fileAccess (0) 00063 { 00064 // Redefine the default name: 00065 if( NULL != getenv("PARAMFILESROOT") ) 00066 { 00067 m_filename = getenv( "PARAMFILESROOT" ) ; 00068 m_filename += "/data/ParticleTable.txt" ; 00069 } 00070 // 00071 declareProperty ( "ParticlePropertiesFile" , m_filename ) ; 00072 declareProperty ( "OtherFiles" , m_other ) ; 00073 declareProperty ( "Particles" , m_particles ) ; 00074 }
| ParticlePropertySvc::~ParticlePropertySvc | ( | ) | [virtual] |
Destructor.
Definition at line 78 of file ParticlePropertySvc.cpp.
References std::set< _Key, _Compare, _Alloc >::begin(), std::set< _Key, _Compare, _Alloc >::end(), and m_owned.
00079 { 00080 for ( Set::iterator i = m_owned.begin(); i != m_owned.end() ; ++i ) 00081 { if ( 0 != *i ) { delete *i ; } } 00082 }
| StatusCode ParticlePropertySvc::initialize | ( | ) | [virtual] |
Initialise the service.
Reimplemented from Service.
Definition at line 91 of file ParticlePropertySvc.cpp.
References addParticles(), MSG::DEBUG, std::vector< _Tp, _Alloc >::empty(), endreq(), MSG::ERROR, MSG::INFO, Service::initialize(), StatusCode::isFailure(), m_fileAccess, m_idmap, m_namemap, m_particles, m_pythiaidmap, m_replaced, m_stdhepidmap, Service::msgSvc(), Service::name(), parse(), Service::service(), Service::setProperties(), StatusCode::SUCCESS, and Gaudi::Utils::toString().
00092 { 00093 StatusCode sc = Service::initialize(); 00094 if ( sc.isFailure() ) { return sc ; } 00095 00096 MsgStream log( msgSvc() , name() ) ; 00097 00098 sc = setProperties(); 00099 if ( sc.isFailure() ) 00100 { 00101 log << MSG::ERROR << " Could not set the properties " << endreq ; 00102 return sc ; 00103 } 00104 00105 00106 sc = service("VFSSvc",m_fileAccess); 00107 if ( sc.isFailure() ) 00108 { 00109 log << MSG::ERROR << " Cannot retrieve the VFS service " << endreq ; 00110 return sc ; 00111 } 00112 00113 sc = parse(); 00114 if ( sc.isFailure() ) 00115 { 00116 log << MSG::ERROR << " Could not parse the file " << endreq ; 00117 return sc ; 00118 } 00119 if ( !m_particles.empty() ) 00120 { 00121 sc = addParticles () ; 00122 if ( sc.isFailure() ) 00123 { 00124 log << MSG::ERROR << " Could not treat particles! " << endreq ; 00125 return sc ; 00126 } 00127 } 00128 log << MSG::DEBUG << "ParticleProperties parsed successfully" << endreq; 00129 00130 log << MSG::DEBUG << "Access properties" << endreq; 00131 // For debugging purposes print out the size of the internal maps 00132 // particle name as key: all particles in database are present here 00133 log << MSG::DEBUG << "NameMap size =" << m_namemap.size() << endreq; 00134 // Geant3 ID as key: all particles in database are present here 00135 log << MSG::DEBUG << "GeantID Map size =" << m_idmap.size() << endreq; 00136 // StdHep ID as key: some particles have no valid StdHep ID 00137 log << MSG::DEBUG << "StdHepID Map size =" << m_stdhepidmap.size() 00138 << endreq; 00139 // Pythia ID as key: some particles are not defined in Pythia 00140 log << MSG::DEBUG << "PythiaID Map size =" << m_pythiaidmap.size() 00141 << endreq; 00142 00143 if ( !m_replaced.empty() ) 00144 { 00145 log << MSG::INFO 00146 << "Properties have beed redefined for " 00147 << m_replaced.size() << " particles : " 00148 << Gaudi::Utils::toString( m_replaced ) 00149 << endreq ; 00150 } 00151 00152 return StatusCode::SUCCESS ; 00153 }
| StatusCode ParticlePropertySvc::finalize | ( | ) | [virtual] |
Finalise the service.
finalize the base class
Reimplemented from Service.
Definition at line 157 of file ParticlePropertySvc.cpp.
References MSG::ALWAYS, std::vector< _Tp, _Alloc >::empty(), endreq(), Service::finalize(), MSG::INFO, m_fileAccess, m_other, m_replaced, Service::msgSvc(), Service::name(), IInterface::release(), and Gaudi::Utils::toString().
00158 { 00159 if ( !m_other.empty() ) 00160 { 00161 MsgStream log( msgSvc() , name() ) ; 00162 log << MSG::INFO 00163 << "Additional Properties have beed read from files: " 00164 << Gaudi::Utils::toString ( m_other ) 00165 << endreq ; 00166 } 00167 00168 if ( !m_replaced.empty() ) 00169 { 00170 MsgStream log( msgSvc() , name() ) ; 00171 log << MSG::ALWAYS 00172 << "Properties have beed redefined for " 00173 << m_replaced.size() << " particles : " 00174 << Gaudi::Utils::toString( m_replaced ) 00175 << endreq ; 00176 } 00177 00178 if (m_fileAccess) { 00179 m_fileAccess->release(); 00180 m_fileAccess = 0; 00181 } 00182 00184 return Service::finalize () ; 00185 }
| StatusCode ParticlePropertySvc::queryInterface | ( | const InterfaceID & | riid, | |
| void ** | ppvInterface | |||
| ) | [virtual] |
Query the interfaces.
< IMPORTANT: increment the reference counter
Reimplemented from Service.
Definition at line 190 of file ParticlePropertySvc.cpp.
References StatusCode::FAILURE, IID_IParticlePropertySvc, Service::queryInterface(), and StatusCode::SUCCESS.
00192 { 00193 // chech the placeholder for result 00194 if ( !ppvInterface ) { return StatusCode::FAILURE ; } 00195 // 00196 *ppvInterface = 0; 00197 // 00198 if ( riid == IID_IParticlePropertySvc ) 00199 { 00200 *ppvInterface = static_cast<IParticlePropertySvc*>(this); 00201 addRef(); 00202 return StatusCode::SUCCESS ; 00203 } 00204 // 00205 return Service::queryInterface( riid, ppvInterface ) ; 00206 }
| const InterfaceID & ParticlePropertySvc::type | ( | ) | const [virtual] |
Service type.
Reimplemented from Service.
Definition at line 86 of file ParticlePropertySvc.cpp.
References IID_IParticlePropertySvc.
00087 { return IID_IParticlePropertySvc; }
| StatusCode ParticlePropertySvc::push_back | ( | const std::string & | particle, | |
| int | geantId, | |||
| int | jetsetId, | |||
| double | charge, | |||
| double | mass, | |||
| double | tlife, | |||
| const std::string & | evtName, | |||
| int | pythiaId, | |||
| double | maxWidth | |||
| ) | [virtual] |
Create a new particle property.
| geantId | Geant3 ID of the particle. | |
| jetsetId | Jetset ID of the particle. | |
| charge | Particle charge (/e). | |
| mass | Particle mass (GeV). | |
| tlife | Particle lifetime (s). | |
| evtName | String name of the particle in EvtGen. | |
| pythiaId | Pythia ID of the particle. |
Implements IParticlePropertySvc.
Definition at line 211 of file ParticlePropertySvc.cpp.
Referenced by addParticles(), and parse().
00220 { 00221 ParticleProperty* pp = new ParticleProperty 00222 ( particle , geantId , jetsetId , 00223 charge , mass , tlife , 00224 evtName , pythiaId , maxWidth ) ; 00225 // 00226 m_owned.insert ( pp ) ; 00227 // 00228 return push_back( pp ); 00229 }
| StatusCode ParticlePropertySvc::push_back | ( | ParticleProperty * | pp | ) | [virtual] |
Add a new particle property.
| pp,a | particle property class. |
Implements IParticlePropertySvc.
Definition at line 233 of file ParticlePropertySvc.cpp.
References diff(), StatusCode::FAILURE, ParticleProperty::geantID(), ParticleProperty::jetsetID(), m_idmap, m_namemap, m_pythiaidmap, m_replaced, m_stdhepidmap, ParticleProperty::particle(), ParticleProperty::pythiaID(), and rebuild().
00234 { 00235 if ( 0 == pp ) { return StatusCode::FAILURE ; } 00236 // 00237 { // try to add into Geant(3)ID map 00238 const int ID = pp->geantID() ; 00239 // is this already in the map? 00240 MapID::const_iterator ifind = m_idmap.find( ID ) ; 00241 if ( m_idmap.end() != ifind && 0 != m_idmap[ ID ]) 00242 { 00243 diff ( ifind->second , pp ) ; 00244 m_replaced.insert( m_idmap[ ID ]->particle() ) ; 00245 } 00246 // put it into the map 00247 m_idmap[ ID ] = pp ; 00248 } 00249 // 00250 { // try to add into Name map 00251 const std::string& particle = pp->particle() ; 00252 // is this already in the map? 00253 MapName::const_iterator ifind = m_namemap.find( particle ) ; 00254 if ( m_namemap.end() != ifind && 0 != m_namemap[ particle ] ) 00255 { 00256 diff ( ifind->second , pp ) ; 00257 m_replaced.insert( m_namemap[ particle ]->particle() ) ; 00258 } 00259 // put it into the map 00260 m_namemap[ particle ] = pp ; 00261 } 00262 // 00263 // add to StdHep map only if StdHep ID different from zero and if 00264 // not Cerenkov (StdHep ID = gamma) 00265 if ( 0 != pp->jetsetID() && "Tcherenkov" != pp->particle() ) 00266 { // try to add into StdHepID map 00267 const int ID = pp->jetsetID() ; 00268 // is this already in the map? 00269 MapStdHepID::const_iterator ifind = m_stdhepidmap.find( ID ) ; 00270 if ( m_stdhepidmap.end() != ifind && 0 != m_stdhepidmap[ ID ]) 00271 { 00272 diff ( ifind->second , pp ) ; 00273 m_replaced.insert( m_stdhepidmap[ ID ]->particle() ) ; 00274 } 00275 // put it into the map 00276 m_stdhepidmap[ ID ] = pp ; 00277 } 00278 // 00279 // add to Pythia map only if Pythia ID is different from 00280 // zero ( StdHep id is always different from zero in this case ) 00281 if ( 0 != pp->pythiaID() && 00282 0 != pp->jetsetID() && 00283 "Tcherenkov" != pp->particle() ) 00284 { // try to add into PythiaID map 00285 const int ID = pp->pythiaID() ; 00286 // is this already in the map? 00287 MapPythiaID::const_iterator ifind = m_pythiaidmap.find( ID ) ; 00288 if ( m_pythiaidmap.end() != ifind && 0 != m_pythiaidmap[ ID ]) 00289 { 00290 diff ( ifind->second , pp ) ; 00291 m_replaced.insert( m_pythiaidmap[ ID ]->particle() ) ; 00292 } 00293 // put it into the map 00294 m_pythiaidmap[ ID ] = pp ; 00295 } 00296 // 00297 return rebuild() ; 00298 }
| virtual const_iterator ParticlePropertySvc::begin | ( | ) | const [inline, virtual] |
Get a const reference to the begining of the container.
Implements IParticlePropertySvc.
Definition at line 130 of file ParticlePropertySvc.h.
References std::vector< _Tp, _Alloc >::begin(), and m_vectpp.
| virtual const_iterator ParticlePropertySvc::end | ( | ) | const [inline, virtual] |
Get a const reference to the end of the container.
Implements IParticlePropertySvc.
Definition at line 132 of file ParticlePropertySvc.h.
References std::vector< _Tp, _Alloc >::end(), and m_vectpp.
| virtual int ParticlePropertySvc::size | ( | ) | const [inline, virtual] |
Get the container size.
Implements IParticlePropertySvc.
Definition at line 134 of file ParticlePropertySvc.h.
References m_vectpp, and std::vector< _Tp, _Alloc >::size().
| virtual ParticleProperty* ParticlePropertySvc::find | ( | int | geantId | ) | [inline, virtual] |
Retrieve a property by geant3 id.
Implements IParticlePropertySvc.
Definition at line 136 of file ParticlePropertySvc.h.
References m_idmap.
Referenced by erase().
00137 { return m_idmap[ geantId ] ; }
| virtual ParticleProperty* ParticlePropertySvc::find | ( | const std::string & | name | ) | [inline, virtual] |
Retrieve a property by particle name.
Implements IParticlePropertySvc.
Definition at line 139 of file ParticlePropertySvc.h.
References m_namemap, and Service::name().
| virtual ParticleProperty* ParticlePropertySvc::findByStdHepID | ( | int | stdHepId | ) | [inline, virtual] |
Retrieve a property by StdHep id.
Implements IParticlePropertySvc.
Definition at line 142 of file ParticlePropertySvc.h.
References m_stdhepidmap.
Referenced by eraseByStdHepID().
00143 { return m_stdhepidmap[ stdHepId ] ; }
| virtual ParticleProperty* ParticlePropertySvc::findByPythiaID | ( | int | pythiaID | ) | [inline, virtual] |
Retrieve a property by Pythia id.
Implements IParticlePropertySvc.
Definition at line 145 of file ParticlePropertySvc.h.
References m_pythiaidmap.
00146 { return m_pythiaidmap[ pythiaID ]; }
| virtual StatusCode ParticlePropertySvc::erase | ( | int | geantId | ) | [inline, virtual] |
Erase a property by geant3 id.
Implements IParticlePropertySvc.
Definition at line 148 of file ParticlePropertySvc.h.
References find().
Referenced by erase(), and eraseByStdHepID().
| virtual StatusCode ParticlePropertySvc::erase | ( | const std::string & | name | ) | [inline, virtual] |
Erase a property by particle name.
Implements IParticlePropertySvc.
Definition at line 151 of file ParticlePropertySvc.h.
References erase(), find(), and Service::name().
| virtual StatusCode ParticlePropertySvc::eraseByStdHepID | ( | int | stdHepId | ) | [inline, virtual] |
Erase a property by StdHep id ???
Implements IParticlePropertySvc.
Definition at line 154 of file ParticlePropertySvc.h.
References erase(), and findByStdHepID().
00155 { return erase( findByStdHepID ( stdHepId ) ) ; }
| const ParticleProperty * ParticlePropertySvc::anti | ( | const ParticleProperty * | pp | ) | const [protected] |
helper (protected) function to find an antiparticle for the given particle ID (StdHepID)
| pp | pointer to particle property |
Definition at line 437 of file ParticlePropertySvc.cpp.
References std::vector< _Tp, _Alloc >::begin(), std::vector< _Tp, _Alloc >::end(), m_vectpp, and ParticleProperty::pdgID().
Referenced by setAntiParticles().
00438 { 00439 if ( 0 == pp ) { return 0 ; } 00440 const int ID = pp->pdgID() ; 00441 const int antiID = -1 * ID ; 00442 for ( const_iterator it = m_vectpp.begin() ; m_vectpp.end() != it ; ++it ) 00443 { 00444 const ParticleProperty* ap = *it ; 00445 if ( 0 == ap ) { continue ; } // CONTINUE 00446 if ( antiID == ap->pdgID() ) { return ap ; } // RETURN 00447 }; 00448 // 00449 return pp ; // RETURN 00450 }
| StatusCode ParticlePropertySvc::setAntiParticles | ( | ) | [protected] |
helper (protected) function to set the valid particle<-->antiparticle relations
Definition at line 457 of file ParticlePropertySvc.cpp.
References anti(), std::vector< _Tp, _Alloc >::begin(), std::vector< _Tp, _Alloc >::end(), m_vectpp, and StatusCode::SUCCESS.
Referenced by rebuild().
00458 { 00459 // initialize particle<-->antiParticle relations 00460 for ( iterator ip = m_vectpp.begin() ; m_vectpp.end() != ip ; ++ip ) 00461 { 00462 ParticleProperty* pp = *ip ; 00463 if ( 0 == pp ) { continue ; } // CONTINUE 00464 const ParticleProperty* ap = anti ( pp ) ; 00465 if ( 0 != ap ) { pp->setAntiParticle( ap ) ; } 00466 } 00467 return StatusCode::SUCCESS ; 00468 }
| StatusCode ParticlePropertySvc::rebuild | ( | ) | [protected] |
rebuild "the linear container" from the map
Definition at line 483 of file ParticlePropertySvc.cpp.
References _load_(), std::set< _Key, _Compare, _Alloc >::begin(), std::vector< _Tp, _Alloc >::clear(), std::set< _Key, _Compare, _Alloc >::end(), m_idmap, m_namemap, m_pythiaidmap, m_stdhepidmap, m_vectpp, std::vector< _Tp, _Alloc >::push_back(), std::vector< _Tp, _Alloc >::reserve(), and setAntiParticles().
Referenced by erase(), and push_back().
00484 { 00485 Set local ; 00486 m_vectpp.clear() ; 00487 m_vectpp.reserve ( m_idmap.size() + 100 ) ; 00488 // load information from maps into the set 00489 _load_ ( m_idmap , local ) ; 00490 _load_ ( m_namemap , local ) ; 00491 _load_ ( m_stdhepidmap , local ) ; 00492 _load_ ( m_pythiaidmap , local ) ; 00493 // load information from set to the linear container vector 00494 for ( Set::iterator i = local.begin() ; local.end() != i ; ++i ) 00495 { m_vectpp.push_back ( *i ) ; } 00496 return setAntiParticles() ; 00497 }
| StatusCode ParticlePropertySvc::erase | ( | const ParticleProperty * | pp | ) | [protected] |
remove particle property from all maps
Definition at line 313 of file ParticlePropertySvc.cpp.
References _remove_(), StatusCode::FAILURE, m_idmap, m_namemap, m_pythiaidmap, m_stdhepidmap, and rebuild().
00314 { 00315 if ( 0 == pp ) { return StatusCode::FAILURE ; } 00316 00317 _remove_ ( m_idmap , pp ) ; 00318 _remove_ ( m_namemap , pp ) ; 00319 _remove_ ( m_stdhepidmap , pp ) ; 00320 _remove_ ( m_pythiaidmap , pp ) ; 00321 // 00322 return rebuild() ; 00323 }
| StatusCode ParticlePropertySvc::parse | ( | const std::string & | file | ) | [protected] |
parse the file
Definition at line 356 of file ParticlePropertySvc.cpp.
References std::basic_string< _CharT, _Traits, _Alloc >::c_str(), endreq(), MSG::ERROR, StatusCode::FAILURE, std::auto_ptr< _Tp >::get(), std::basic_istream< _CharT, _Traits >::getline(), Gaudi::Units::GeV, MSG::INFO, StatusCode::isFailure(), m_fileAccess, Service::msgSvc(), Service::name(), IFileAccess::open(), push_back(), Gaudi::Units::s, and StatusCode::SUCCESS.
00357 { 00358 StatusCode sc = StatusCode::FAILURE; 00359 00360 MsgStream log( msgSvc(), name() ); 00361 char line[ 255 ]; 00362 00363 std::auto_ptr<std::istream> infileptr; 00364 if (m_fileAccess) infileptr = m_fileAccess->open(file); 00365 00366 if ( infileptr.get() == 0 ) 00367 { 00368 log << MSG::ERROR << "Unable to open properties file : " << file 00369 << endreq; 00370 return StatusCode::FAILURE ; 00371 } 00372 00373 std::istream &infile = *infileptr; 00374 sc = StatusCode::SUCCESS; 00375 log << MSG::INFO 00376 << "Opened particle properties file : " << file << endreq; 00377 00378 while( infile ) 00379 { 00380 // parse each line of the file (comment lines begin with # in the cdf 00381 // file, 00382 infile.getline( line, 255 ); 00383 00384 if ( line[0] == '#' ) continue; 00385 00386 std::string par, gid, jid, chg, mas, lif, evt, pyt, mwi ; 00387 char* token = strtok( line, " " ); 00388 if ( token ) { par = token; token = strtok( NULL, " " );} else continue; 00389 if ( token ) { gid = token; token = strtok( NULL, " " );} else continue; 00390 if ( token ) { jid = token; token = strtok( NULL, " " );} else continue; 00391 if ( token ) { chg = token; token = strtok( NULL, " " );} else continue; 00392 if ( token ) { mas = token; token = strtok( NULL, " " );} else continue; 00393 if ( token ) { lif = token; token = strtok( NULL, " " );} else continue; 00394 if ( token ) { evt = token; token = strtok( NULL, " " );} else continue; 00395 if ( token ) { pyt = token; token = strtok( NULL, " " );} else continue; 00396 if ( token ) { mwi = token; token = strtok( NULL, " " );} else continue; 00397 if ( token != NULL ) continue; 00398 00399 // In SICb cdf file mass and lifetime units are GeV and sec, specify it so 00400 // that they are converted to Gaudi units (MeV and ns) 00401 double mass = atof( mas.c_str() ) * Gaudi::Units::GeV; 00402 double tlife = atof( lif.c_str() ) * Gaudi::Units::s; 00403 long ljid = atoi( jid.c_str() ); 00404 long lgid = atoi( gid.c_str() ); 00405 long lpyt = atoi( pyt.c_str() ) ; 00406 double mW = atof( mwi.c_str() ) * Gaudi::Units::GeV ; 00407 00408 // Change the particles that do not corresopond to a pdg number 00409 if ( ljid == 0 ) { 00410 ljid = 10000000*lgid; 00411 } 00412 00413 // add a particle property 00414 sc = push_back( par, lgid, ljid, 00415 atof( chg.c_str() ), mass, tlife, evt, lpyt, mW ) ; 00416 if ( sc.isFailure() ) 00417 { 00418 log << MSG::ERROR 00419 << "Error from ParticlePropertySvc::push_back for particle='" 00420 << par << "'" << endreq ; 00421 } 00422 00423 } 00424 00425 //infile.close(); 00426 00427 return StatusCode::SUCCESS ; 00428 }
| StatusCode ParticlePropertySvc::parse | ( | ) | [protected] |
Parses the file and fill all the maps.
Definition at line 327 of file ParticlePropertySvc.cpp.
References std::vector< _Tp, _Alloc >::begin(), std::vector< _Tp, _Alloc >::end(), endreq(), MSG::ERROR, StatusCode::FAILURE, StatusCode::isFailure(), m_filename, m_namemap, m_other, Service::msgSvc(), and Service::name().
Referenced by initialize().
00328 { 00329 00330 // parse "the main" file 00331 StatusCode sc = parse ( m_filename ) ; 00332 if ( sc.isFailure() ) { return sc ; } 00333 00334 // parse "other" files 00335 for ( Files::const_iterator file = m_other.begin() ; 00336 m_other.end() != file ; ++file ) 00337 { 00338 sc = parse ( *file ) ; 00339 if ( sc.isFailure() ) { return sc ; } 00340 } 00341 00342 // Now check that the file format was consistent with what parser 00343 // expected 00344 if ( m_namemap.size() == 0 ) 00345 { 00346 MsgStream log( msgSvc(), name() ); 00347 log << MSG::ERROR 00348 << "Format of input file inconsistent with what expected" 00349 << " - Check you are using ParticleData.txt" << endreq; 00350 return StatusCode::FAILURE; 00351 } 00352 00353 return sc; 00354 }
| StatusCode ParticlePropertySvc::addParticles | ( | ) | [protected] |
Definition at line 501 of file ParticlePropertySvc.cpp.
References MSG::ALWAYS, std::vector< _Tp, _Alloc >::begin(), std::vector< _Tp, _Alloc >::end(), endreq(), MSG::ERROR, StatusCode::FAILURE, Gaudi::Units::GeV, StatusCode::isFailure(), m_particles, Service::msgSvc(), Service::name(), push_back(), Gaudi::Units::s, and StatusCode::SUCCESS.
Referenced by initialize().
00502 { 00503 00504 MsgStream log ( msgSvc() , name() ) ; 00505 // loop over all "explicit" particles 00506 for ( Particles::const_iterator ip = m_particles.begin() ; 00507 m_particles.end() != ip ; ++ip ) 00508 { 00509 const std::string item = *ip ; 00510 std::istringstream input( item ) ; 00511 // get the name 00512 std::string p_name ; 00513 int p_geant ; 00514 int p_jetset ; 00515 double p_charge ; 00516 double p_mass ; 00517 double p_ltime ; 00518 std::string p_evtgen ; 00519 int p_pythia ; 00520 double p_maxwid ; 00521 if ( input 00522 >> p_name 00523 >> p_geant 00524 >> p_jetset 00525 >> p_charge 00526 >> p_mass 00527 >> p_ltime 00528 >> p_evtgen 00529 >> p_pythia 00530 >> p_maxwid ) 00531 { 00532 log << MSG::ALWAYS 00533 << " Add/Modify the particle: " 00534 << " name='" << p_name << "'" 00535 << " geant=" << p_geant 00536 << " jetset=" << p_jetset 00537 << " charge=" << p_charge 00538 << " mass=" << p_mass 00539 << " ltime=" << p_ltime 00540 << " evtgen='" << p_evtgen << "'" 00541 << " pythia=" << p_pythia 00542 << " maxwid=" << p_maxwid << endreq ; 00543 // 00544 StatusCode sc = push_back 00545 ( p_name , 00546 p_geant , 00547 p_jetset , 00548 p_charge , 00549 p_mass * Gaudi::Units::GeV , 00550 p_ltime * Gaudi::Units::s , 00551 p_evtgen , 00552 p_pythia , 00553 p_maxwid * Gaudi::Units::GeV ) ; 00554 if ( sc.isFailure() ) { return sc ; } // RETURN 00555 } 00556 else 00557 { 00558 log << MSG::ERROR 00559 << " could not parse '" << item << "'" << endreq ; 00560 return StatusCode::FAILURE ; // RETURN 00561 } 00562 } 00563 // 00564 return StatusCode::SUCCESS ; 00565 }
| bool ParticlePropertySvc::diff | ( | const ParticleProperty * | o, | |
| const ParticleProperty * | n, | |||
| const MSG::Level | l = MSG::DEBUG | |||
| ) | const [protected] |
Definition at line 568 of file ParticlePropertySvc.cpp.
References endreq(), name, and MSG::WARNING.
Referenced by push_back().
00571 { 00572 // 00573 if ( o == n ) { return false ; } 00574 // 00575 MsgStream log ( msgSvc() , name() ) ; 00576 log << l ; 00577 if ( 0 == o || 0 == n ) 00578 { 00579 log << MSG::WARNING << " ParticleProperty* point to NULL" << endreq ; 00580 return true ; // RETURN 00581 } 00582 // 00583 bool result = false ; 00584 if ( o -> particle () != n -> particle () ) 00585 { 00586 result = true ; 00587 log << " Name:'" << o -> particle () << "'/'" << n -> particle () << "'" ; 00588 } 00589 if ( o -> geantID () != n -> geantID () ) 00590 { 00591 result = true ; 00592 log << " G3ID:" << o -> geantID () << "/" << n -> geantID () << "'" ; 00593 } 00594 if ( o -> pdgID () != n -> pdgID () ) 00595 { 00596 result = true ; 00597 log << " PDGID:" << o -> pdgID () << "/" << n -> pdgID () << "'" ; 00598 } 00599 if ( o -> pythiaID () != n -> pythiaID () ) 00600 { 00601 result = true ; 00602 log << " PYID:" << o -> pythiaID () << "/" << n -> pythiaID () << "'" ; 00603 } 00604 if ( o -> charge () != n -> charge () ) 00605 { 00606 result = true ; 00607 log << " Q:" << o -> charge () << "/" << n -> charge () << "'" ; 00608 } 00609 if ( o -> mass () != n -> mass () ) 00610 { 00611 result = true ; 00612 log << " M:" << o -> mass () << "/" << n -> mass () << "'" ; 00613 } 00614 if ( o -> lifetime () != n -> lifetime () ) 00615 { 00616 result = true ; 00617 log << " T:" << o -> lifetime () << "/" << n -> lifetime () << "'" ; 00618 } 00619 if ( o -> evtGenName () != n -> evtGenName () ) 00620 { 00621 result = true ; 00622 log << " EvtGen:" << o -> evtGenName () << "/" << n -> evtGenName () << "'" ; 00623 } 00624 if ( o -> maxWidth () != n -> maxWidth () ) 00625 { 00626 result = true ; 00627 log << " WMAX:" << o -> maxWidth () << "/" << n -> maxWidth () << "'" ; 00628 } 00629 if ( result ) { log << endreq ; } 00630 // 00631 return result ; 00632 }
std::string ParticlePropertySvc::m_filename [private] |
Filename of the particle properties file.
Definition at line 196 of file ParticlePropertySvc.h.
Referenced by parse().
Files ParticlePropertySvc::m_other [private] |
additional file names
Definition at line 197 of file ParticlePropertySvc.h.
Referenced by finalize(), and parse().
Particles ParticlePropertySvc::m_particles [private] |
Definition at line 199 of file ParticlePropertySvc.h.
Referenced by addParticles(), and initialize().
VectPP ParticlePropertySvc::m_vectpp [private] |
Vector of all particle properties.
Definition at line 201 of file ParticlePropertySvc.h.
Referenced by anti(), begin(), end(), rebuild(), setAntiParticles(), and size().
MapID ParticlePropertySvc::m_idmap [private] |
Map for geant IDs.
Definition at line 202 of file ParticlePropertySvc.h.
Referenced by erase(), find(), initialize(), push_back(), and rebuild().
MapName ParticlePropertySvc::m_namemap [private] |
Map for particle names.
Definition at line 203 of file ParticlePropertySvc.h.
Referenced by erase(), find(), initialize(), parse(), push_back(), and rebuild().
Map for StdHep Ids.
Definition at line 204 of file ParticlePropertySvc.h.
Referenced by erase(), findByStdHepID(), initialize(), push_back(), and rebuild().
Map for Pythia Ids.
Definition at line 205 of file ParticlePropertySvc.h.
Referenced by erase(), findByPythiaID(), initialize(), push_back(), and rebuild().
Set ParticlePropertySvc::m_owned [private] |
std::set<std::string> ParticlePropertySvc::m_replaced [private] |
Definition at line 209 of file ParticlePropertySvc.h.
Referenced by finalize(), initialize(), and push_back().
IFileAccess* ParticlePropertySvc::m_fileAccess [private] |
Definition at line 211 of file ParticlePropertySvc.h.
Referenced by finalize(), initialize(), and parse().