00001 #ifndef IDCHANNEL_H_
00002 #define IDCHANNEL_H_
00003
00004 #include "TObject.h"
00005 #include <map>
00006 #include <string>
00007
00010 namespace IDs{
00011 class channel;
00012
00016 enum Detector_t {
00017 kErrorDetector=-1,
00018 kAnyDetector=0,
00019 kGe , kLiquidSc , kNDet , kNDet2 , kScGe ,
00020 kScL , kScR , kScVe , kSiL1_1 , kSiL1_2 ,
00021 kSiL1_3 , kSiL1_4 , kSiL2 , kSiR1_1 , kSiR1_2 ,
00022 kSiR1_3 , kSiR1_4 , kSiR1_sum , kSiR2 , kMuSc ,
00023 kMuScA };
00025 const short num_detector_enums=21;
00026
00034 enum SlowFast_t{
00035 kErrorSlowFast=-1,
00036 kAnySlowFast=0,
00037 kFast=1,
00038 kSlow=2,
00039 kNotApplicable=3 };
00040 }
00041
00046 class IDs::channel:public TObject{
00047 public:
00054 channel(Detector_t det=kAnyDetector, SlowFast_t type=kAnySlowFast);
00055
00060 channel(const std::string& detector , const std::string& type);
00061
00066 channel(const std::string& channel );
00067 virtual ~channel(){};
00068
00069 void Reset(){fDetector=kAnyDetector; fSlowFast=kAnySlowFast;};
00070 public:
00072 Detector_t Detector()const{return fDetector;};
00073 void Detector(const Detector_t& d){ fDetector=d;};
00074
00076 SlowFast_t SlowFast()const{return fSlowFast;};
00077 void SlowFast(const SlowFast_t& d){ fSlowFast=d;};
00078
00084 channel& operator=(const std::string& rhs);
00085
00091 channel& operator=(const char* rhs){ return (*this=std::string(rhs));};
00092
00094 bool operator==(const channel& rhs)const;
00095
00097 bool operator!=(const channel& rhs)const{return !(this->operator==(rhs));};
00103 bool matches(const channel& rhs)const;
00104
00106 bool operator<(const channel& rhs)const;
00108 bool operator>(const channel& rhs)const;
00109
00111 std::string str()const;
00112
00114 bool isValid(){return (fDetector!=kErrorDetector) && (fSlowFast != kErrorSlowFast);};
00115
00117 bool isWildCardDetector() const {return fDetector == kAnyDetector;}
00118
00120 bool isWildCardSlowFast() const {return fSlowFast == kAnySlowFast;}
00121
00125 bool isWildCard() const {return isWildCardDetector() || isWildCardSlowFast();}
00126
00128 bool isFast() const {return fSlowFast==kFast;};
00130 bool isSlow() const {return fSlowFast==kSlow;};
00131
00135 channel GetCorrespondingFastSlow()const;
00136
00138 static std::string GetDetectorString(Detector_t det);
00139
00142 static Detector_t GetDetectorEnum(const std::string& det);
00143
00145 static std::string GetSlowFastString(SlowFast_t sf);
00146
00149 static SlowFast_t GetSlowFastEnum(const std::string& sf);
00150
00152 void Debug()const;
00153
00154 private:
00156 Detector_t fDetector;
00158 SlowFast_t fSlowFast;
00159
00160 ClassDef(IDs::channel,1);
00161 };
00162
00163 inline bool IDs::channel::operator==(const IDs::channel& rhs)const{
00164 return (fDetector == rhs.fDetector) && (fSlowFast== rhs.fSlowFast);
00165 }
00166
00167 inline bool IDs::channel::matches(const channel& rhs)const{
00168 return (isWildCardDetector() || rhs.isWildCardDetector() || fDetector==rhs.fDetector)
00169 && (isWildCardSlowFast() || rhs.isWildCardSlowFast() || fSlowFast==rhs.fSlowFast) ;
00170 }
00171
00172 inline bool IDs::channel::operator>(const IDs::channel& rhs)const{
00173 return fDetector>rhs.fDetector || (fDetector == rhs.fDetector && fSlowFast>rhs.fSlowFast);
00174 }
00175
00176 inline bool IDs::channel::operator<(const IDs::channel& rhs)const{
00177 return fDetector<rhs.fDetector || ( fDetector == rhs.fDetector && fSlowFast<rhs.fSlowFast );
00178 }
00179
00180 inline IDs::channel::channel(Detector_t det, SlowFast_t type):fDetector(det),fSlowFast(type){
00181 }
00182
00183 inline IDs::channel::channel(const std::string& detector , const std::string& type):fDetector(),fSlowFast(kAnySlowFast){
00184 fDetector=GetDetectorEnum(detector);
00185 fSlowFast=GetSlowFastEnum(type);
00186 }
00187
00188 inline IDs::channel::channel(const std::string& channel ):fDetector(),fSlowFast(kAnySlowFast){
00189 *this=channel;
00190 }
00191
00192 std::ostream& operator<< (ostream& os ,const IDs::channel& id);
00193
00194 #endif //IDCHANNEL_H_