00001 #ifndef CellIDEncoder_h
00002 #define CellIDEncoder_h 1
00003
00004 #include "EVENT/LCCollection.h"
00005 #include "UTIL/BitField64.h"
00006 #include "IMPL/LCFlagImpl.h"
00007
00008 #include <string>
00009
00010
00011
00012
00013 namespace EVENT{
00014 class SimCalorimeterHit ;
00015 class RawCalorimeterHit ;
00016 class CalorimeterHit ;
00017 class TrackerData ;
00018 class TrackerPulse ;
00019 class TrackerRawData ;
00020 class SimTrackerHit ;
00021 class TrackerHit ;
00022 class TrackerHitPlane ;
00023 class TrackerHitZCylinder ;
00024 }
00025
00026 namespace UTIL{
00027
00028
00032 template <class T>
00033 int CellIDEncoder_cellID1Bit() { return -1 ; }
00034
00036 template<> int CellIDEncoder_cellID1Bit<EVENT::SimCalorimeterHit>() ;
00037
00039 template<> int CellIDEncoder_cellID1Bit<EVENT::RawCalorimeterHit>() ;
00040
00042 template<> int CellIDEncoder_cellID1Bit<EVENT::CalorimeterHit>() ;
00043
00045 template<> int CellIDEncoder_cellID1Bit<EVENT::TrackerData>() ;
00046
00048 template<> int CellIDEncoder_cellID1Bit<EVENT::TrackerPulse>() ;
00049
00051 template<> int CellIDEncoder_cellID1Bit<EVENT::TrackerRawData>() ;
00052
00054 template<> int CellIDEncoder_cellID1Bit<EVENT::TrackerHit>() ;
00055
00057 template<> int CellIDEncoder_cellID1Bit<EVENT::TrackerHitPlane>() ;
00058
00060 template<> int CellIDEncoder_cellID1Bit<EVENT::TrackerHitZCylinder>() ;
00061
00063 template<> int CellIDEncoder_cellID1Bit<EVENT::SimTrackerHit>() ;
00064
00065
00068 template <class T>
00069 void CellIDEncoder_setCellID(T* hit, int low, int high) {
00070
00071 hit->setCellID0( low ) ;
00072 hit->setCellID1( high ) ;
00073 }
00074
00075
00076
00077
00078
00079
00080
00081
00099 template <class T>
00100 class CellIDEncoder : public BitField64 {
00101
00102 public:
00103
00104 CellIDEncoder( const CellIDEncoder&) = delete ;
00105 CellIDEncoder& operator=(const CellIDEncoder&) = delete ;
00106
00109 CellIDEncoder( const std::string& cellIDEncoding , EVENT::LCCollection* col) :
00110
00111 BitField64( cellIDEncoding ),
00112
00113 _col( col ) {
00114
00115 _col->parameters().setValue( EVENT::LCIO::CellIDEncoding , cellIDEncoding ) ;
00116
00117 setCellIDFlag() ;
00118 }
00119
00120 inline void setCellID( T* hit) {
00121
00122 CellIDEncoder_setCellID( hit , lowWord() , highWord() ) ;
00123 }
00124
00127 void setCellIDFlag() {
00128
00129 int bit = CellIDEncoder_cellID1Bit<typename T::lcobject_type>() ;
00130
00131 if( bit >= 0 ) {
00132
00133 IMPL::LCFlagImpl f( _col->getFlag() ) ;
00134
00135 if( highestBit() > 31 ) {
00136
00137
00138 f.setBit( bit ) ;
00139
00140 } else {
00141
00142 f.unsetBit( bit ) ;
00143 }
00144
00145 _col->setFlag( f.getFlag() ) ;
00146 }
00147 }
00148
00149 protected:
00150
00151
00152
00153
00154 EVENT::LCCollection* _col ;
00155
00156 } ;
00157
00158
00159
00160
00161 }
00162 #endif
00163
00164