00001 #ifndef PIDHandler_h
00002 #define PIDHandler_h 1
00003
00004 #include "UTIL/CollectionParameterMap.h"
00005
00006 #include "EVENT/LCCollection.h"
00007 #include "Exceptions.h"
00008
00009 #include "IMPL/ParticleIDImpl.h"
00010 #include "IMPL/ReconstructedParticleImpl.h"
00011
00012 #include <lcio.h>
00013
00014 #include <string>
00015
00016 namespace UTIL{
00017
00018
00033 class PIDHandler {
00034
00035 typedef CollectionParameterMap CPM ;
00036 typedef std::map< int, EVENT::StringVec > PNM ;
00037 typedef std::map< CPM::map_type::mapped_type , CPM::map_type::key_type > CPMINV ;
00038
00039
00040 public:
00041 PIDHandler() = default ;
00042 PIDHandler(const PIDHandler& ) = delete ;
00043 PIDHandler& operator=(const PIDHandler& ) = delete ;
00044
00049 PIDHandler( const EVENT::LCCollection* col ) ;
00050
00056 PIDHandler( EVENT::LCCollection* col ) ;
00057
00058
00061 ~PIDHandler() ;
00062
00065 int addAlgorithm( const std::string& algoName, const EVENT::StringVec& parameterNames ) ;
00066
00069 int getAlgorithmID( const std::string& algoName ) ;
00070
00073 const std::string& getAlgorithmName( int algoID ) ;
00074
00077 int getParameterIndex( int algorithmID, const std::string& pName ) ;
00078
00084 const EVENT::ParticleID& getParticleID( EVENT::LCObject* particle , int algorithmID ) ;
00085
00086
00089 EVENT::ParticleIDVec getParticleIDs( EVENT::LCObject* p , int id ) ;
00090
00091
00095 void setParticleIDUsed( IMPL::ReconstructedParticleImpl* particle , int algorithmID ) ;
00096
00097
00100 const EVENT::StringVec& getParameterNames( int algorithmID ) ;
00101
00104 const EVENT::IntVec& getAlgorithmIDs() ;
00105
00106
00109 void setParticleID( EVENT::LCObject* p ,
00110 int userType,
00111 int PDG,
00112 float likelihood,
00113 int algorithmID,
00114 const EVENT::FloatVec& params
00115 ) ;
00116
00117 protected:
00118
00119 int nextID() { return ++_maxID ; }
00120 void init( const EVENT::LCCollection* col ) ;
00121
00122
00123 EVENT::LCCollection* _col{NULL} ;
00124 CPM _cpm{} ;
00125 int _type{0} ;
00126 int _maxID{0} ;
00127 PNM _pNames{} ;
00128 CPMINV _cpmInv{} ;
00129 EVENT::IntVec _ids{} ;
00130
00131 } ;
00132
00133
00136 class UnknownAlgorithm : public EVENT::Exception {
00137
00138 protected:
00139 UnknownAlgorithm() { ; }
00140 public:
00141 virtual ~UnknownAlgorithm() throw() { ; }
00142
00143 UnknownAlgorithm( std::string text ){
00144 message = "lcio::UnknownAlgorithm: " + text ;
00145 }
00146 };
00147
00148
00149
00150
00151 }
00152 #endif
00153
00154