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"
14 #include "GaudiKernel/IParticlePropertySvc.h"
15 
16 class IFileAccess;
17 
18 namespace Gaudi {
19 // ============================================================================
71 class ParticlePropertySvc: public extends1<Service,IParticlePropertySvc>
72 {
73 public:
74  // typedefs for container type
76  typedef std::map< int, mapped_type > MapID ;
77  typedef std::map< std::string, mapped_type > MapName ;
78  typedef std::map< int, mapped_type > MapStdHepID ;
79  typedef std::map< int, mapped_type > MapPythiaID ;
83  // Inherited Service overrides:
84 
86  StatusCode initialize() override;
88  StatusCode finalize() override;
102  ( const std::string& particle ,
103  int geantId ,
104  int jetsetId ,
105  double charge ,
106  double mass ,
107  double tlife ,
108  const std::string& evtName ,
109  int pythiaId ,
110  double maxWidth ) override ;
118  const_iterator begin() const override { return m_vectpp.begin() ; }
120  const_iterator end () const override { return m_vectpp.end() ; }
122  int size() const override { return m_vectpp.size() ; };
124  ParticleProperty* find( int geantId ) override
125  { return m_idmap[ geantId ] ; }
127  ParticleProperty* find( const std::string& name ) override
128  { return m_namemap[ name ] ; }
130  ParticleProperty* findByStdHepID( int stdHepId ) override
131  { return m_stdhepidmap[ stdHepId ] ; }
133  ParticleProperty* findByPythiaID( int pythiaID ) override
134  { return m_pythiaidmap[ pythiaID ]; }
136  StatusCode erase( int geantId ) override
137  { return erase ( find ( geantId ) ) ; }
139  StatusCode erase( const std::string& name ) override
140  { return erase ( find ( name ) ) ; }
142  StatusCode eraseByStdHepID( int stdHepId ) override
143  { return erase( findByStdHepID ( stdHepId ) ) ; }
148  ParticlePropertySvc ( const std::string& name , ISvcLocator* svc );
150  ~ParticlePropertySvc() override = default;
151 protected:
157  const ParticleProperty* anti
158  ( const ParticleProperty* pp ) const ;
165  StatusCode rebuild() ;
167  StatusCode erase ( const ParticleProperty* pp ) ;
169  StatusCode parse ( const std::string& file ) ;
170  // Text file parsing routine.
171  StatusCode parse();
172  // treat additional particles
174  // compare 2 entries
175  bool diff
176  ( const ParticleProperty* o ,
177  const ParticleProperty* n ,
178  const MSG::Level l = MSG::DEBUG ) const ;
179 private:
180  typedef std::vector<std::string> Files ;
181  typedef std::vector<std::string> Particles ;
182 
183  std::string m_filename = "ParticleTable.txt" ;
184  Files m_other ;
185  // properties to be redefined explicitly
186  Particles m_particles ;
187 
189  MapID m_idmap;
190  MapName m_namemap;
191  MapStdHepID m_stdhepidmap;
192  MapPythiaID m_pythiaidmap;
193 
194  // local storage of ALL properties
195  std::set<std::unique_ptr<ParticleProperty>> m_owned ;
196  std::set<std::string> m_replaced ;
197 
199 };
200 } // namespace Gaudi
201 // =============================================================================
202 // The END
203 // =============================================================================
204 #endif
205 // =============================================================================
206 
207 
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.
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
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.
std::set< std::string > m_replaced
std::vector< ParticleProperty * > VectPP
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) ...
std::map< int, mapped_type > MapPythiaID
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
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.