43 ParticlePropertySvc::ParticlePropertySvc
44 ( const
std::
string& name ,
48 , m_filename ( "ParticleTable.txt" )
66 m_filename +=
"/data/ParticleTable.txt";
69 declareProperty (
"ParticlePropertiesFile" , m_filename ) ;
70 declareProperty (
"OtherFiles" , m_other ) ;
71 declareProperty (
"Particles" , m_particles ) ;
79 {
if ( 0 != *
i ) {
delete *
i ; } }
139 <<
"Properties have been redefined for "
156 <<
"Additional Properties have been read from files: "
165 <<
"Properties have been redefined for "
183 (
const std::string& particle ,
189 const std::string& evtName ,
194 ( particle , geantId , jetsetId ,
195 charge , mass , tlife ,
196 evtName , pythiaId , maxWidth ) ;
198 m_owned.insert ( pp ) ;
200 return push_back( pp );
212 MapID::const_iterator ifind =
m_idmap.find( ID ) ;
215 diff ( ifind->second , pp ) ;
223 const std::string& particle = pp->
particle() ;
225 MapName::const_iterator ifind =
m_namemap.find( particle ) ;
228 diff ( ifind->second , pp ) ;
241 MapStdHepID::const_iterator ifind =
m_stdhepidmap.find( ID ) ;
244 diff ( ifind->second , pp ) ;
259 MapPythiaID::const_iterator ifind =
m_pythiaidmap.find( ID ) ;
262 diff ( ifind->second , pp ) ;
279 typename MAP::iterator
i = m.begin() ;
280 for ( ; m.end() !=
i ; ++
i ) {
if ( i->second == pp ) { break ; } }
281 if ( m.end() !=
i ) { m.erase ( i ) ; }
307 for ( Files::const_iterator
file =
m_other.begin() ;
320 <<
"Format of input file inconsistent with what expected"
321 <<
" - Check you are using ParticleData.txt" <<
endmsg;
335 std::auto_ptr<std::istream> infileptr;
338 if ( infileptr.get() == 0 )
340 log <<
MSG::ERROR <<
"Unable to open properties file : " << file
345 std::istream &infile = *infileptr;
348 <<
"Opened particle properties file : " << file <<
endmsg;
354 infile.getline( line, 255 );
356 if ( line[0] ==
'#' )
continue;
362 #pragma warning(disable:4996)
364 std::string
par, gid, jid, chg, mas, lif,
evt, pyt, mwi ;
365 char* token = strtok( line,
" " );
366 if ( token ) { par = token; token = strtok( NULL,
" " );}
else continue;
367 if ( token ) { gid = token; token = strtok( NULL,
" " );}
else continue;
368 if ( token ) { jid = token; token = strtok( NULL,
" " );}
else continue;
369 if ( token ) { chg = token; token = strtok( NULL,
" " );}
else continue;
370 if ( token ) { mas = token; token = strtok( NULL,
" " );}
else continue;
371 if ( token ) { lif = token; token = strtok( NULL,
" " );}
else continue;
372 if ( token ) { evt = token; token = strtok( NULL,
" " );}
else continue;
373 if ( token ) { pyt = token; token = strtok( NULL,
" " );}
else continue;
374 if ( token ) { mwi = token; token = strtok( NULL,
" " );}
else continue;
375 if ( token != NULL )
continue;
379 double mass = atof( mas.c_str() ) * Gaudi::Units::GeV;
380 double tlife = atof( lif.c_str() ) * Gaudi::Units::s;
381 long ljid = atoi( jid.c_str() );
382 long lgid = atoi( gid.c_str() );
383 long lpyt = atoi( pyt.c_str() ) ;
384 double mW = atof( mwi.c_str() ) * Gaudi::Units::GeV ;
388 ljid = 10000000*lgid;
393 atof( chg.c_str() ), mass, tlife, evt, lpyt, mW ) ;
397 <<
"Error from ParticlePropertySvc::push_back for particle='"
417 if ( 0 == pp ) {
return 0 ; }
418 const int ID = pp->
pdgID() ;
419 const int antiID = -1 * ID ;
423 if ( 0 == ap ) { continue ; }
424 if ( antiID == ap->
pdgID() ) {
return ap ; }
441 if ( 0 == pp ) { continue ; }
456 for (
typename MAP::iterator i = m.begin() ; m.end() !=
i ; ++
i )
457 { result.insert ( i->second ); }
472 for ( Set::iterator i = local.begin() ; local.end() !=
i ; ++
i )
484 for ( Particles::const_iterator ip =
m_particles.begin() ;
487 const std::string
item = *ip ;
488 std::istringstream input( item ) ;
496 std::string p_evtgen ;
511 <<
" Add/Modify the particle: "
512 <<
" name='" << p_name <<
"'"
513 <<
" geant=" << p_geant
514 <<
" jetset=" << p_jetset
515 <<
" charge=" << p_charge
516 <<
" mass=" << p_mass
517 <<
" ltime=" << p_ltime
518 <<
" evtgen='" << p_evtgen <<
"'"
519 <<
" pythia=" << p_pythia
520 <<
" maxwid=" << p_maxwid <<
endmsg ;
527 p_mass * Gaudi::Units::GeV ,
528 p_ltime * Gaudi::Units::s ,
531 p_maxwid * Gaudi::Units::GeV ) ;
537 <<
" could not parse '" << item <<
"'" <<
endmsg ;
548 #pragma warning(push)
549 #pragma warning(disable:1572)
557 if ( o == n ) {
return false ; }
561 if ( 0 == o || 0 == n )
567 bool result = false ;
568 if ( o -> particle () != n -> particle () )
571 log <<
" Name:'" << o -> particle () <<
"'/'" << n -> particle () <<
"'" ;
573 if ( o -> geantID () != n -> geantID () )
576 log <<
" G3ID:" << o -> geantID () <<
"/" << n -> geantID () <<
"'" ;
578 if ( o -> pdgID () != n -> pdgID () )
581 log <<
" PDGID:" << o -> pdgID () <<
"/" << n -> pdgID () <<
"'" ;
583 if ( o -> pythiaID () != n -> pythiaID () )
586 log <<
" PYID:" << o -> pythiaID () <<
"/" << n -> pythiaID () <<
"'" ;
588 if ( o -> charge () != n -> charge () )
591 log <<
" Q:" << o -> charge () <<
"/" << n -> charge () <<
"'" ;
593 if ( o -> mass () != n -> mass () )
596 log <<
" M:" << o -> mass () <<
"/" << n -> mass () <<
"'" ;
598 if ( o -> lifetime () != n -> lifetime () )
601 log <<
" T:" << o -> lifetime () <<
"/" << n -> lifetime () <<
"'" ;
603 if ( o -> evtGenName () != n -> evtGenName () )
606 log <<
" EvtGen:" << o -> evtGenName () <<
"/" << n -> evtGenName () <<
"'" ;
608 if ( o -> maxWidth () != n -> maxWidth () )
611 log <<
" WMAX:" << o -> maxWidth () <<
"/" << n -> maxWidth () <<
"'" ;
613 if ( result ) { log <<
endmsg ; }
int pdgID() const
Get the PDG (= JETSET) ID.
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
StatusCode rebuild()
rebuild "the linear container" from the map
Definition of the MsgStream class used to transmit messages.
VectPP::iterator iterator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
int geantID() const
Get the GEANT3 ID.
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
A trivial class to hold information about a single particle properties.
virtual StatusCode erase(int geantId)
Erase a property by geant3 id.
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
MapName m_namemap
Map for particle names.
StatusCode parse()
Parses the file and fill all the maps.
IFileAccess * m_fileAccess
Files m_other
additional file names
bool isFailure() const
Test for a status code of FAILURE.
#define DECLARE_COMPONENT(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.
std::set< std::string > m_replaced
int jetsetID() const
Get the JETSET(StdHep) ID.
virtual StatusCode initialize()
Initialise the service.
This class is used for returning status codes from appropriate routines.
std::string m_filename
Filename of the particle properties file.
StatusCode setProperties()
Method for setting declared properties to the values specified for the job.
virtual const std::string & name() const
Retrieve name of the service.
MapStdHepID m_stdhepidmap
Map for StdHep Ids.
std::set< ParticleProperty * > Set
const ParticleProperty * anti(const ParticleProperty *pp) const
helper (protected) function to find an antiparticle for the given particle ID (StdHepID) ...
virtual unsigned long release()=0
Release Interface instance.
virtual StatusCode initialize()
Initialization (from CONFIGURED to INITIALIZED).
bool diff(const ParticleProperty *o, const ParticleProperty *n, const MSG::Level l=MSG::DEBUG) const
virtual StatusCode finalize()
Finalise the service.
virtual std::auto_ptr< std::istream > open(const std::string &url)=0
Find the URL and returns an auto_ptr to an input stream interface of an object that can be used to re...
Templated class to add the standard messaging functionalities.
StatusCode addParticles()
MapID m_idmap
Map for geant IDs.
StatusCode service(const std::string &name, const T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn't already exist.
void setAntiParticle(const ParticleProperty *p)
set the pointer to the antiparticle
This is a number of static methods for bootstrapping the Gaudi framework.
StatusCode setAntiParticles()
helper (protected) function to set the valid particle<–>antiparticle relations
VectPP m_vectpp
Vector of all particle properties.
const std::string & particle() const
Get the particle name.
virtual ~ParticlePropertySvc()
Destructor.
int pythiaID() const
Get the Pythia ID.
VectPP::const_iterator const_iterator
virtual StatusCode finalize()
Finalize (from INITIALIZED to CONFIGURED).
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
MapPythiaID m_pythiaidmap
Map for Pythia Ids.