00001 00004 #ifndef WIREMAP_H__ 00005 #define WIREMAP_H__ 00006 00007 #include <vector> 00008 #include <string> 00009 00019 00020 class WireMap { 00021 private: 00025 static WireMap* DefaultODB; 00026 00028 unsigned int fRun; 00029 00030 unsigned int fNDets; 00032 std::vector<std::string> fBankName; 00034 std::vector<std::string> fDetName; 00036 std::vector<bool> fEnabled; 00038 std::vector<int> fPedestal; 00040 std::vector<int> fPolarity; 00042 std::vector<int> fOffset; 00044 std::vector<double> fFrequency; 00045 00046 public: 00053 enum key_t { BANK, DETECTOR, ENABLED, 00054 PEDESTAL, POLARITY, TIMESHIFT, 00055 FREQUENCY, UNKNOWN }; 00056 00057 public: 00059 WireMap(); 00065 WireMap(int run, std::string& odb_file); 00066 00067 public: 00069 00070 void SetRun(unsigned int); 00071 void Enable(); 00072 bool Enable(unsigned int); 00073 void Disable(); 00074 bool Disable(unsigned int); 00075 00076 00077 00078 00079 unsigned int GetRun() const; 00081 unsigned int GetNDets() const; 00083 std::vector<std::string>& GetBanks(); 00085 std::vector<std::string>& GetDets(); 00087 std::vector<bool>& GetEnableds(); 00089 std::vector<int>& GetPedestals(); 00091 std::vector<int>& GetPolarities(); 00093 std::vector<int>& GetOffsets(); 00095 std::vector<double>& GetFrequencies(); 00097 00099 00100 00101 00102 00103 00104 00105 00106 00107 00108 00109 void Add(const char bankname[], const char detname[], bool en, int ped, int pol, int off, double freq); 00111 void Add(std::string& bankname, std::string& detname, bool en, int ped, int pol, int off, double freq); 00116 void Add(WireMap& wm, int index); 00118 00122 void UniqueFixes(); 00123 00124 public: 00126 00127 00128 00129 00130 00131 00132 00133 00134 00135 void Load(int run, const std::string& odb_file); 00137 void LoadOver(WireMap&); 00139 00140 void Clear(); 00141 00156 void ResizeToBanks(); 00161 bool AreThereDuplicates(); 00167 void ClearDisabledDuplicateDetectors(); 00168 00177 static WireMap Default(); 00178 00179 private: 00185 static bool IsODBFile(const std::string& fname); 00195 static int GetArraySize(const char (&tmp)[256]); 00204 static key_t GetKey(std::string& key); 00205 00206 public: 00208 void Print(); 00209 }; 00210 00211 #endif 00212