00001 #ifndef TSetupData_h__
00002 #define TSetupData_h__
00003
00004 #include <vector>
00005 #include <map>
00006 #include <set>
00007 #include <string>
00008
00009 #include <TObject.h>
00010
00024 class TSetupData : public TObject{
00025 private:
00026 public:
00028 static TSetupData* Instance();
00029
00033
00034
00035 std::map<std::string, std::string> fBankToDetectorMap;
00037 std::map<std::string, double> fBankToClockTickMap;
00039 std::map<std::string, int> fBankToBitMap;
00041 std::map<std::string, double> fBankToADCSlopeCalibMap;
00043 std::map<std::string, double> fBankToADCOffsetCalibMap;
00045 std::map<std::string, double> fBankToTimeShift;
00047 std::map<std::string, int> fBankToPolarityMap;
00049 std::map<std::string, int> fBankToPedestalMap;
00051 std::map<std::string, bool> fBankToEnableBitMap;
00053
00055 std::string GetBankName(std::string DetectorName) const;
00058 std::string GetDetectorName(std::string BankName) const {
00059 if (fBankToDetectorMap.find(BankName)->second != "blank")
00060 return fBankToDetectorMap.find(BankName)->second;
00061 else
00062 return BankName;
00063 };
00064
00066 void GetAllDetectors(std::map<std::string,std::string>& detectors)const;
00068 void GetAllDetectors(std::vector<std::string>& detectors)const;
00069
00072
00073
00074 double GetClockTick(const std::string& BankName) const{ return GetValue(fBankToClockTickMap,BankName);}
00075 int GetNBits(const std::string& BankName) const{ return GetValue(fBankToBitMap,BankName);}
00077 double GetADCSlopeCalib(const std::string& BankName) const{ return GetValue(fBankToADCSlopeCalibMap,BankName); };
00079 double GetADCOffsetCalib(const std::string& BankName) const{ return GetValue(fBankToADCOffsetCalibMap,BankName); };
00081 double GetTimeShift(const std::string& BankName) const{ return GetValue(fBankToTimeShift,BankName); };
00083 int GetTriggerPolarity(const std::string& BankName)const{return GetValue(fBankToPolarityMap,BankName);};
00084 int GetPedestal(const std::string& BankName)const{return GetValue(fBankToPedestalMap,BankName);};
00085 bool GetEnableBit(const std::string& BankName)const {return GetValue(fBankToEnableBitMap, BankName);};
00087
00091
00093 bool SetDetectorName(std::string BankName, std::string value) {
00094 std::map< std::string, std::string >::iterator it;
00095 for (it = fBankToDetectorMap.begin(); it != fBankToDetectorMap.end(); ++it)
00096 if (it->second == value)
00097 return false;
00098 fBankToDetectorMap[BankName] = value;
00099 return true;
00100 }
00101 void SetClockTick(std::string BankName, double value) { fBankToClockTickMap[BankName]=value; }
00102 void SetNBits(std::string BankName, int value) { fBankToBitMap[BankName]=value; }
00103 void SetTimeShift(std::string BankName, double value) { fBankToTimeShift[BankName]=value; }
00104 void SetTriggerPolarity(std::string BankName, int value) { fBankToPolarityMap[BankName]=value; }
00105 void SetPedestal(std::string BankName, int value) { fBankToPedestalMap[BankName]=value; }
00106 void SetADCSlopeCalib(std::string BankName, double value) { fBankToADCSlopeCalibMap[BankName] = value; }
00107 void SetADCOffsetCalib(std::string BankName, double value) { fBankToADCOffsetCalibMap[BankName] = value; };
00108 void SetEnableBit(std::string BankName, bool value){fBankToEnableBitMap[BankName] = value;};
00110
00111 static bool IsFADC(const std::string& BankName) { return BankName[0] == 'N'; }
00112 static bool IsHoustonCAEN(const std::string& BankName) { return BankName.substr(2,2) == "UH"; }
00113 static bool IsBostonCAEN(const std::string& BankName) { return BankName.substr(2,2) == "BU"; }
00114 static bool IsSlow(const std::string& BankName) { return (*BankName.end() -1 ) == 'S'; }
00115 static bool IsFast(const std::string& BankName) { return (*(BankName.end() -1) == 'F' || BankName.substr(0,2) == "Sc" ); }
00116
00117 bool IsEnable(const std::string& BankName){return GetEnableBit(BankName);}
00118
00119 private:
00120
00121
00122 double GetValue(const std::map<std::string,double>& map,
00123 const std::string& BankName)const{
00124 std::map<std::string, double>::const_iterator it=map.find(BankName);
00125 if(it!=map.end()) return it->second;
00126 return 0.;
00127 }
00128
00129 int GetValue(const std::map<std::string,int>& map,
00130 const std::string& BankName)const{
00131 std::map<std::string, int>::const_iterator it=map.find(BankName);
00132 if(it!=map.end()) return it->second;
00133 return 0;
00134 }
00135
00136 bool GetValue(const std::map<std::string,bool>& map,
00137 const std::string& BankName)const{
00138 std::map<std::string, bool>::const_iterator it=map.find(BankName);
00139 if(it!=map.end()) return it->second;
00140 return false;
00141 }
00142
00143 ClassDef(TSetupData, 3)
00144
00145 };
00146 #endif