LCIO  "2.7.4"
 All Classes Namespaces Functions Variables Typedefs Friends Pages
PIDHandler.h
1 #ifndef PIDHandler_h
2 #define PIDHandler_h 1
3 
4 #include "UTIL/CollectionParameterMap.h"
5 
6 #include "EVENT/LCCollection.h"
7 #include "Exceptions.h"
8 
9 #include "IMPL/ParticleIDImpl.h"
10 #include "IMPL/ReconstructedParticleImpl.h"
11 
12 #include <lcio.h>
13 
14 #include <string>
15 
16 using namespace lcio ;
17 
18 
19 namespace UTIL{
20 
21 
36  class PIDHandler {
37 
38  typedef CollectionParameterMap CPM ;
39  typedef std::map< int, StringVec > PNM ;
40  typedef std::map< CPM::map_type::mapped_type , CPM::map_type::key_type > CPMINV ;
41 
42 
43  public:
44 
49  PIDHandler( const LCCollection* col ) ;
50 
56  PIDHandler( LCCollection* col ) ;
57 
58 
61  ~PIDHandler() ;
62 
65  int addAlgorithm( const std::string& algoName, const 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 
83  const ParticleID& getParticleID( LCObject* particle , int algorithmID ) ;
84 
85 
88  ParticleIDVec getParticleIDs( LCObject* p , int id ) ;
89 
90 
94  void setParticleIDUsed( IMPL::ReconstructedParticleImpl* particle , int algorithmID ) ;
95 
96 
99  const StringVec& getParameterNames( int algorithmID ) ;
100 
103  const IntVec& getAlgorithmIDs() ;
104 
105 
108  void setParticleID( LCObject* p ,
109  int userType,
110  int PDG,
111  float likelihood,
112  int algorithmID,
113  const FloatVec& params
114  ) ;
115 
116  protected:
117 
118  int nextID() { return ++_maxID ; }
119  void init( const LCCollection* col ) ;
120 
121  PIDHandler();
122 
123  LCCollection* _col ;
124  CPM _cpm ;
125  int _type ;
126  int _maxID ;
127  PNM _pNames ;
128  CPMINV _cpmInv ;
129  IntVec _ids ;
130 
131  } ;
132 
133 
136  class UnknownAlgorithm : public Exception {
137 
138  protected:
139  UnknownAlgorithm() { /*no_op*/ ; }
140  public:
141  virtual ~UnknownAlgorithm() throw() { /*no_op*/; }
142 
143  UnknownAlgorithm( std::string text ){
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
std::vector< std::string > StringVec
Vector of strings.
Definition: LCIOSTLTypes.h:16
int getParameterIndex(int algorithmID, const std::string &pName)
The index of parameter pName for the algorithm with algorithmID - throws UnknownAlgoritm.
Definition: PIDHandler.cc:184
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's kinematic variables.
Definition: PIDHandler.cc:231
Helper class for setting and retrieving an std::map<string,int> as collection parameters.
Definition: CollectionParameterMap.h:26
Convenient class for setting and retrieving particle id information attached to ReconstructedParticle...
Definition: PIDHandler.h:36
std::vector< ParticleID * > ParticleIDVec
Vector of (pointers to) ParticleIDs.
Definition: ParticleID.h:16
std::vector< float > FloatVec
Vector of floats.
Definition: LCIOSTLTypes.h:18
const StringVec & getParameterNames(int algorithmID)
The names of parameters for the algorithm with algorithmID - throws UnknownAlgoritm.
Definition: PIDHandler.cc:211
void setParticleID(LCObject *p, int userType, int PDG, float likelihood, int algorithmID, const FloatVec &params)
Set the particleID information for this particle (or cluster) - throws UnknownAlgorithm.
Definition: PIDHandler.cc:378
const std::string & getAlgorithmName(int algoID)
Return the name of the algorithm with id - throws UnknownAlgorithm.
Definition: PIDHandler.cc:169
const IntVec & getAlgorithmIDs()
Return the IDs of all known Algorithms.
Definition: PIDHandler.cc:224
Persistent interface for LCIO ParticleIDs.
Definition: ParticleID.h:28
int addAlgorithm(const std::string &algoName, const StringVec &parameterNames)
Add a new algorithm and return the corresponding algorithm id.
Definition: PIDHandler.cc:126
int getAlgorithmID(const std::string &algoName)
Return the typeID of algorithm algoName - throws UnknownAlgorithm.
Definition: PIDHandler.cc:157
std::vector< int > IntVec
Vector of ints.
Definition: LCIOSTLTypes.h:22
The generic collection used in LCIO.
Definition: LCCollection.h:29
const ParticleID & getParticleID(LCObject *particle, int algorithmID)
Return the (first) ParticleID object for the given algorithm and particle (or cluster) - throws Unkno...
Definition: PIDHandler.cc:322
~PIDHandler()
Update the collection parameter when going out of scope.
Definition: PIDHandler.cc:109
ParticleIDVec getParticleIDs(LCObject *p, int id)
Return all PID objects for a given algorithm - ordered with decreasing likelihood - throws UnknownAlg...
Definition: PIDHandler.cc:279
Implementation of ReconstructedParticle.
Definition: ReconstructedParticleImpl.h:22