LCIO  02.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PIDHandler.h
Go to the documentation of this file.
1 #ifndef PIDHandler_h
2 #define PIDHandler_h 1
3 
5 
6 #include "EVENT/LCCollection.h"
7 #include "Exceptions.h"
8 
9 #include "IMPL/ParticleIDImpl.h"
11 
12 #include <lcio.h>
13 
14 #include <string>
15 
16 namespace UTIL{
17 
18 
33  class PIDHandler {
34 
38 
39 
40  public:
41  PIDHandler() = default ;
42  PIDHandler(const PIDHandler& ) = delete ;
43  PIDHandler& operator=(const PIDHandler& ) = delete ;
44 
49  PIDHandler( const EVENT::LCCollection* col ) ;
50 
57 
58 
61  ~PIDHandler() ;
62 
65  int addAlgorithm( const std::string& algoName, const EVENT::StringVec& parameterNames ) ;
66 
69  int getAlgorithmID( const std::string& algoName ) ;
70 
73  const std::string& getAlgorithmName( int algoID ) ;
74 
77  int getParameterIndex( int algorithmID, const std::string& pName ) ;
78 
84  const EVENT::ParticleID& getParticleID( EVENT::LCObject* particle , int algorithmID ) ;
85 
86 
90 
91 
95  void setParticleIDUsed( IMPL::ReconstructedParticleImpl* particle , int algorithmID ) ;
96 
97 
100  const EVENT::StringVec& getParameterNames( int algorithmID ) ;
101 
104  const EVENT::IntVec& getAlgorithmIDs() ;
105 
106 
109  void setParticleID( EVENT::LCObject* p ,
110  int userType,
111  int PDG,
112  float likelihood,
113  int algorithmID,
114  const EVENT::FloatVec& params
115  ) ;
116 
117  protected:
118 
119  int nextID() { return ++_maxID ; }
120  void init( const EVENT::LCCollection* col ) ;
121 
122 
124  CPM _cpm{} ;
125  int _type{0} ;
126  int _maxID{0} ;
130 
131  } ;
132 
133 
137 
138  protected:
139  UnknownAlgorithm() { /*no_op*/ ; }
140  public:
141  virtual ~UnknownAlgorithm() { /*no_op*/; }
142 
144  message = "lcio::UnknownAlgorithm: " + text ;
145  }
146  };
147 
148 
149 
150 
151 } // namespace
152 #endif
153 
154 
The generic object that is held in an LCCollection.
Definition: LCObject.h:30
Base exception class for LCIO - all other exceptions extend this.
Definition: Exceptions.h:21
int getParameterIndex(int algorithmID, const std::string &pName)
The index of parameter pName for the algorithm with algorithmID - throws UnknownAlgoritm.
Definition: PIDHandler.cc:185
void init(const EVENT::LCCollection *col)
Definition: PIDHandler.cc:41
CollectionParameterMap CPM
Definition: PIDHandler.h:35
Exception for unknown algorithms.
Definition: PIDHandler.h:136
void setParticleIDUsed(IMPL::ReconstructedParticleImpl *particle, int algorithmID)
Set the particleID algorithm that is used for this particle&#39;s kinematic variables.
Definition: PIDHandler.cc:232
PIDHandler()=default
Helper class for setting and retrieving an std::map&lt;string,int&gt; as collection parameters.
PIDHandler & operator=(const PIDHandler &)=delete
Convenient class for setting and retrieving particle id information attached to ReconstructedParticle...
Definition: PIDHandler.h:33
virtual ~UnknownAlgorithm()
Definition: PIDHandler.h:141
const EVENT::StringVec & getParameterNames(int algorithmID)
The names of parameters for the algorithm with algorithmID - throws UnknownAlgoritm.
Definition: PIDHandler.cc:212
EVENT::IntVec _ids
Definition: PIDHandler.h:129
const std::string & getAlgorithmName(int algoID)
Return the name of the algorithm with id - throws UnknownAlgorithm.
Definition: PIDHandler.cc:170
STL class.
const EVENT::IntVec & getAlgorithmIDs()
Return the IDs of all known Algorithms.
Definition: PIDHandler.cc:225
std::map< CPM::map_type::mapped_type, CPM::map_type::key_type > CPMINV
Definition: PIDHandler.h:37
int addAlgorithm(const std::string &algoName, const EVENT::StringVec &parameterNames)
Add a new algorithm and return the corresponding algorithm id.
Definition: PIDHandler.cc:127
Persistent interface for LCIO ParticleIDs.
Definition: ParticleID.h:28
int getAlgorithmID(const std::string &algoName)
Return the typeID of algorithm algoName - throws UnknownAlgorithm.
Definition: PIDHandler.cc:158
void setParticleID(EVENT::LCObject *p, int userType, int PDG, float likelihood, int algorithmID, const EVENT::FloatVec &params)
Set the particleID information for this particle (or cluster) - throws UnknownAlgorithm.
Definition: PIDHandler.cc:367
EVENT::ParticleIDVec getParticleIDs(EVENT::LCObject *p, int id)
Return all PID objects for a given algorithm - ordered with decreasing likelihood - throws UnknownAlg...
Definition: PIDHandler.cc:280
EVENT::LCCollection * _col
Definition: PIDHandler.h:123
The generic collection used in LCIO.
Definition: LCCollection.h:29
const EVENT::ParticleID & getParticleID(EVENT::LCObject *particle, int algorithmID)
Return the (first) ParticleID object for the given algorithm and particle (or cluster) - throws Unkno...
Definition: PIDHandler.cc:323
std::string message
Definition: Exceptions.h:25
~PIDHandler()
Update the collection parameter when going out of scope.
Definition: PIDHandler.cc:110
std::map< int, EVENT::StringVec > PNM
Definition: PIDHandler.h:36
UnknownAlgorithm(std::string text)
Definition: PIDHandler.h:143
Implementation of ReconstructedParticle.