ParticlePropertySvc.h
Go to the documentation of this file.
1 #ifndef PARTICLEPROPERTYSVC_PARTICLEPROPERTYSVC_H
2 #define PARTICLEPROPERTYSVC_PARTICLEPROPERTYSVC_H
3 // ============================================================================
4 // Include Files
5 // ============================================================================
6 // STD&STL
7 // ============================================================================
8 #include <map>
9 #include <set>
10 // ============================================================================
11 // GaudiKernel
12 // ============================================================================
13 #include "GaudiKernel/Service.h"
15 
16 class IFileAccess;
17 
18 namespace Gaudi {
19 // ============================================================================
71 class ParticlePropertySvc: public extends<Service,
72  IParticlePropertySvc>
73 {
74 public:
75  // typedefs for container type
84  // Inherited Service overrides:
85 
87  StatusCode initialize() override;
89  StatusCode finalize() override;
103  ( const std::string& particle ,
104  int geantId ,
105  int jetsetId ,
106  double charge ,
107  double mass ,
108  double tlife ,
109  const std::string& evtName ,
110  int pythiaId ,
111  double maxWidth ) override ;
119  const_iterator begin() const override { return m_vectpp.begin() ; }
121  const_iterator end () const override { return m_vectpp.end() ; }
123  int size() const override { return m_vectpp.size() ; };
125  ParticleProperty* find( int geantId ) override
126  { return m_idmap[ geantId ] ; }
128  ParticleProperty* find( const std::string& name ) override
129  { return m_namemap[ name ] ; }
131  ParticleProperty* findByStdHepID( int stdHepId ) override
132  { return m_stdhepidmap[ stdHepId ] ; }
134  ParticleProperty* findByPythiaID( int pythiaID ) override
135  { return m_pythiaidmap[ pythiaID ]; }
137  StatusCode erase( int geantId ) override
138  { return erase ( find ( geantId ) ) ; }
140  StatusCode erase( const std::string& name ) override
141  { return erase ( find ( name ) ) ; }
143  StatusCode eraseByStdHepID( int stdHepId ) override
144  { return erase( findByStdHepID ( stdHepId ) ) ; }
151  ~ParticlePropertySvc() override = default;
152 protected:
158  const ParticleProperty* anti
159  ( const ParticleProperty* pp ) const ;
166  StatusCode rebuild() ;
168  StatusCode erase ( const ParticleProperty* pp ) ;
170  StatusCode parse ( const std::string& file ) ;
171  // Text file parsing routine.
172  StatusCode parse();
173  // treat additional particles
175  // compare 2 entries
176  bool diff
177  ( const ParticleProperty* o ,
178  const ParticleProperty* n ,
179  const MSG::Level l = MSG::DEBUG ) const ;
180 private:
183 
184  std::string m_filename = "ParticleTable.txt" ;
185  Files m_other ;
186  // properties to be redefined explicitly
187  Particles m_particles ;
188 
190  MapID m_idmap;
191  MapName m_namemap;
192  MapStdHepID m_stdhepidmap;
193  MapPythiaID m_pythiaidmap;
194 
195  // local storage of ALL properties
198 
200 };
201 } // namespace Gaudi
202 // =============================================================================
203 // The END
204 // =============================================================================
205 #endif
206 // =============================================================================
207 
208 
StatusCode rebuild()
rebuild "the linear container" from the map
VectPP::iterator iterator
int size() const override
Get the container size.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
std::map< int, mapped_type > MapStdHepID
This service provides access to particle properties.
StatusCode eraseByStdHepID(int stdHepId) override
Erase a property by StdHep id ???
VectPP::const_iterator const_iterator
A trivial class to hold information about a single particle properties.
std::map< std::string, mapped_type > MapName
StatusCode erase(int geantId) override
Erase a property by geant3 id.
ParticleProperty * findByPythiaID(int pythiaID) override
Retrieve a property by Pythia id.
StatusCode finalize() override
Finalise the service.
std::vector< ParticleProperty * > VectPP
StatusCode initialize() override
Initialise the service.
MapName m_namemap
Map for particle names.
StatusCode parse()
Parses the file and fill all the maps.
T end(T...args)
ParticleProperty * find(const std::string &name) override
Retrieve a property by particle name.
~ParticlePropertySvc() override=default
Destructor.
Files m_other
additional file names
SmartIF< IFileAccess > m_fileAccess
STL class.
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) override
Create a new particle property.
STL class.
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:319
std::set< std::string > m_replaced
std::vector< std::string > Files
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
ParticleProperty * find(int geantId) override
Retrieve a property by geant3 id.
std::vector< std::string > Particles
std::string m_filename
Filename of the particle properties file.
StatusCode erase(const std::string &name) override
Erase a property by particle name.
list file
Definition: ana.py:160
const_iterator end() const override
Get a const reference to the end of the container.
MapStdHepID m_stdhepidmap
Map for StdHep Ids.
dictionary l
Definition: gaudirun.py:421
const ParticleProperty * anti(const ParticleProperty *pp) const
helper (protected) function to find an antiparticle for the given particle ID (StdHepID) ...
T size(T...args)
STL class.
std::map< int, mapped_type > MapPythiaID
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
T begin(T...args)
ParticleProperty * findByStdHepID(int stdHepId) override
Retrieve a property by StdHep id.
bool diff(const ParticleProperty *o, const ParticleProperty *n, const MSG::Level l=MSG::DEBUG) const
std::map< int, mapped_type > MapID
Abstract interface for a service or tool implementing a read access to files.
Definition: IFileAccess.h:18
std::set< std::unique_ptr< ParticleProperty > > m_owned
MapID m_idmap
Map for geant IDs.
ParticlePropertySvc(const std::string &name, ISvcLocator *svc)
Standard Constructor.
StatusCode setAntiParticles()
helper (protected) function to set the valid particle<–>antiparticle relations
ParticleProperty * mapped_type
const_iterator begin() const override
Get a const reference to the beginning of the container.
VectPP m_vectpp
Vector of all particle properties.
VectPP::const_iterator const_iterator
Helper functions to set/get the application return code.
Definition: __init__.py:1
MapPythiaID m_pythiaidmap
Map for Pythia Ids.