The Gaudi Framework  v33r0 (d5ea422b)
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 <map>
19 #include <set>
20 // ============================================================================
21 // GaudiKernel
22 // ============================================================================
24 #include "GaudiKernel/Service.h"
25 
26 class IFileAccess;
27 
28 namespace Gaudi {
29  // ============================================================================
81  class ParticlePropertySvc : public extends<Service, IParticlePropertySvc> {
82  public:
83  // typedefs for container type
92  // Inherited Service overrides:
93 
95  StatusCode initialize() override;
97  StatusCode finalize() override;
110  StatusCode push_back( const std::string& particle, int geantId, int jetsetId, double charge, double mass,
111  double tlife, const std::string& evtName, int pythiaId, 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 { return m_idmap[geantId]; }
127  ParticleProperty* find( const std::string& name ) override { return m_namemap[name]; }
129  ParticleProperty* findByStdHepID( int stdHepId ) override { return m_stdhepidmap[stdHepId]; }
131  ParticleProperty* findByPythiaID( int pythiaID ) override { return m_pythiaidmap[pythiaID]; }
133  StatusCode erase( int geantId ) override { return erase( find( geantId ) ); }
135  StatusCode erase( const std::string& name ) override { return erase( find( name ) ); }
137  StatusCode eraseByStdHepID( int stdHepId ) override { return erase( findByStdHepID( stdHepId ) ); }
143 
144  protected:
150  const ParticleProperty* anti( const ParticleProperty* pp ) const;
161  StatusCode parse( const std::string& file );
162  // Text file parsing routine.
163  StatusCode parse();
164  // treat additional particles
166  // compare 2 entries
167  bool diff( const ParticleProperty* o, const ParticleProperty* n, const MSG::Level l = MSG::DEBUG ) const;
168 
169  private:
170  Gaudi::Property<std::string> m_filename{this, "ParticlePropertiesFile", "ParticleTable.txt",
171  "Filename of the particle properties file"};
172  Gaudi::Property<std::vector<std::string>> m_other{this, "OtherFiles", {}, "additional file names"};
174  this, "Particles", {}, "properties to be redefined explicitly"};
175 
181 
182  // local storage of ALL properties
185 
187  };
188 } // namespace Gaudi
189 // =============================================================================
190 // The END
191 // =============================================================================
192 #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
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.
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
std::set< std::unique_ptr< ParticleProperty > > m_owned
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.