The Gaudi Framework  v33r1 (b1225454)
ParticlePropertySvc.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef PARTICLEPROPERTYSVC_PARTICLEPROPERTYSVC_H
12 #define PARTICLEPROPERTYSVC_PARTICLEPROPERTYSVC_H
13 // ============================================================================
14 // Include Files
15 // ============================================================================
16 // STD&STL
17 // ============================================================================
18 #include <deque>
19 #include <map>
20 #include <set>
21 // ============================================================================
22 // GaudiKernel
23 // ============================================================================
25 #include "GaudiKernel/Service.h"
26 
27 class IFileAccess;
28 
29 namespace Gaudi {
30  // ============================================================================
82  class ParticlePropertySvc : public extends<Service, IParticlePropertySvc> {
83  public:
84  // typedefs for container type
93  // Inherited Service overrides:
94 
96  StatusCode initialize() override;
98  StatusCode finalize() override;
111  StatusCode push_back( const std::string& particle, int geantId, int jetsetId, double charge, double mass,
112  double tlife, const std::string& evtName, int pythiaId, double maxWidth ) override;
120  const_iterator begin() const override { return m_vectpp.begin(); }
122  const_iterator end() const override { return m_vectpp.end(); }
124  int size() const override { return m_vectpp.size(); };
126  ParticleProperty* find( int geantId ) override { return m_idmap[geantId]; }
128  ParticleProperty* find( const std::string& name ) override { return m_namemap[name]; }
130  ParticleProperty* findByStdHepID( int stdHepId ) override { return m_stdhepidmap[stdHepId]; }
132  ParticleProperty* findByPythiaID( int pythiaID ) override { return m_pythiaidmap[pythiaID]; }
134  StatusCode erase( int geantId ) override { return erase( find( geantId ) ); }
136  StatusCode erase( const std::string& name ) override { return erase( find( name ) ); }
138  StatusCode eraseByStdHepID( int stdHepId ) override { return erase( findByStdHepID( stdHepId ) ); }
144 
145  protected:
151  const ParticleProperty* anti( const ParticleProperty* pp ) const;
162  StatusCode parse( const std::string& file );
163  // Text file parsing routine.
164  StatusCode parse();
165  // treat additional particles
167  // compare 2 entries
168  bool diff( const ParticleProperty* o, const ParticleProperty* n, const MSG::Level l = MSG::DEBUG ) const;
169 
170  private:
171  Gaudi::Property<std::string> m_filename{this, "ParticlePropertiesFile", "ParticleTable.txt",
172  "Filename of the particle properties file"};
173  Gaudi::Property<std::vector<std::string>> m_other{this, "OtherFiles", {}, "additional file names"};
175  this, "Particles", {}, "properties to be redefined explicitly"};
176 
182 
183  // local storage of ALL properties
186 
188  };
189 } // namespace Gaudi
190 // =============================================================================
191 // The END
192 // =============================================================================
193 #endif
bool diff(const ParticleProperty *o, const ParticleProperty *n, const MSG::Level l=MSG::DEBUG) const
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:35
Implementation of property with value of concrete type.
Definition: Property.h:370
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.
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.
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.
STL class.
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:284
std::map< int, mapped_type > MapStdHepID
std::set< std::string > m_replaced
std::deque< ParticleProperty > m_owned
const ParticleProperty * anti(const ParticleProperty *pp) const
helper (protected) function to find an antiparticle for the given particle ID (StdHepID)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
ParticleProperty * find(int geantId) override
Retrieve a property by geant3 id.
StatusCode erase(const std::string &name) override
Erase a property by particle name.
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:543
T size(T... args)
STL class.
Base class used to extend a class implementing other interfaces.
Definition: extends.h:20
T begin(T... args)
ParticleProperty * findByStdHepID(int stdHepId) override
Retrieve a property by StdHep id.
Gaudi::Property< std::vector< std::string > > m_other
std::map< int, mapped_type > MapID
Abstract interface for a service or tool implementing a read access to files.
Definition: IFileAccess.h:28
MapID m_idmap
Map for geant IDs.
Gaudi::Property< std::string > m_filename
std::map< std::string, mapped_type > MapName
Gaudi::Property< std::vector< std::string > > m_particles
ParticlePropertySvc(const std::string &name, ISvcLocator *svc)
Standard Constructor.
std::map< int, mapped_type > MapPythiaID
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
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1
MapPythiaID m_pythiaidmap
Map for Pythia Ids.