1 #ifndef ALI_ITS_ONLINECALIBRATIONSPDHANDLER_H
2 #define ALI_ITS_ONLINECALIBRATIONSPDHANDLER_H
4 //////////////////////////////////////////////////////////////////////////////
5 // Author: Henrik Tydesjo //
6 // Class that simplifies the managing of dead, noisy, and inactive pixels. //
7 // Has interface to the AliITSOnlineCalibrationSPD container objects //
8 // through reading and writing to TFile. //
9 //////////////////////////////////////////////////////////////////////////////
13 #include "AliITSRawStreamSPD.h"
19 class AliITSCalibrationSPD;
21 class AliITSOnlineCalibrationSPDhandler {
24 AliITSOnlineCalibrationSPDhandler();
25 AliITSOnlineCalibrationSPDhandler(const AliITSOnlineCalibrationSPDhandler& handle);
26 virtual ~AliITSOnlineCalibrationSPDhandler();
27 AliITSOnlineCalibrationSPDhandler& operator=(const AliITSOnlineCalibrationSPDhandler& handle);
29 void SetFileLocation(const Char_t* loc) {fFileLocation = loc;}
30 TString GetFileLocation() const {return fFileLocation;}
35 void ResetDeadForChip(UInt_t eq, UInt_t hs, UInt_t chip);
36 void ResetNoisyForChip(UInt_t eq, UInt_t hs, UInt_t chip);
37 void ResetDeadForEq(UInt_t eq);
38 void ResetNoisyForEq(UInt_t eq);
40 Bool_t ReadFromFiles();
41 Bool_t ReadSilentFromFiles();
42 Bool_t ReadDeadFromFiles();
43 Bool_t ReadNoisyFromFiles();
44 Bool_t ReadSilentFromFile(UInt_t eq);
45 Bool_t ReadDeadFromFile(UInt_t eq);
46 Bool_t ReadNoisyFromFile(UInt_t eq);
47 Bool_t ReadSilentFromFileName(const char *fileName);
48 Bool_t ReadDeadFromFileName(const char *fileName, Bool_t inactive=kFALSE);
49 Bool_t ReadNoisyFromFileName(const char *fileName);
51 UInt_t ReadDeadFromText(const char *fileName, UInt_t module);
52 UInt_t ReadNoisyFromText(const char *fileName, UInt_t module);
54 void WriteToFilesAlways();
55 UInt_t WriteToFiles();
56 void WriteSilentToFilesAlways();
57 void WriteDeadToFilesAlways();
58 void WriteNoisyToFilesAlways();
59 UInt_t WriteSilentToFiles();
60 UInt_t WriteDeadToFiles();
61 UInt_t WriteNoisyToFiles();
62 void WriteSilentToFile(UInt_t eq);
63 void WriteDeadToFile(UInt_t eq, Bool_t inactive=kFALSE);
64 void WriteNoisyToFile(UInt_t eq);
67 Bool_t ReadDeadModuleFromDB(UInt_t module, Int_t runNr, Bool_t treeSerial=kFALSE);
68 Bool_t ReadNoisyModuleFromDB(UInt_t module, Int_t runNr, Bool_t treeSerial=kFALSE);
69 Bool_t ReadFromDB(Int_t runNr, Bool_t treeSerial=kFALSE);
70 Bool_t ReadDeadFromDB(Int_t runNr, Bool_t treeSerial=kFALSE);
71 Bool_t ReadNoisyFromDB(Int_t runNr, Bool_t treeSerial=kFALSE);
72 Bool_t ReadDeadFromCalibObj(TObjArray* calObj);
73 Bool_t ReadNoisyFromCalibObj(TObjArray* calObj);
74 Bool_t WriteToDB(Int_t runNrStart, Int_t runNrEnd);
75 Bool_t WriteDeadToDB(Int_t runNrStart, Int_t runNrEnd);
76 Bool_t WriteNoisyToDB(Int_t runNrStart, Int_t runNrEnd);
79 void GenerateDCSConfigFile(const Char_t* fileName);
81 TArrayS GetSilentArray(UInt_t module, Bool_t treeSerial=kFALSE); // temporarily needed
82 TArrayS GetDeadArray(UInt_t module, Bool_t treeSerial=kFALSE);
83 TArrayS GetNoisyArray(UInt_t module, Bool_t treeSerial=kFALSE);
85 TArrayI GetDeadArrayOnline(UInt_t eq);
86 TArrayI GetNoisyArrayOnline(UInt_t eq);
88 void PrintEqSummary();
89 void PrintSilent() const; // silent = dead or inactive
90 void PrintDead() const;
91 void PrintNoisy() const;
93 Bool_t SetDeadPixel(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row);
94 Bool_t SetNoisyPixel(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row);
95 Bool_t SetDeadPixelM(UInt_t module, UInt_t colM, UInt_t row);
96 Bool_t SetNoisyPixelM(UInt_t module, UInt_t colM, UInt_t row);
97 Bool_t UnSetDeadPixel(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row);
98 Bool_t UnSetNoisyPixel(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row);
99 Bool_t UnSetDeadPixelM(UInt_t module, UInt_t colM, UInt_t row);
100 Bool_t UnSetNoisyPixelM(UInt_t module, UInt_t colM, UInt_t row);
101 UInt_t SetDeadChip(UInt_t eq, UInt_t hs, UInt_t chip);
102 UInt_t SetNoisyChip(UInt_t eq, UInt_t hs, UInt_t chip);
103 Bool_t UnSetDeadChip(UInt_t eq, UInt_t hs, UInt_t chip);
104 Bool_t UnSetNoisyChip(UInt_t eq, UInt_t hs, UInt_t chip);
106 Bool_t IsPixelSilent(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) const; // silent = dead or inactive
107 Bool_t IsPixelDead(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) const;
108 Bool_t IsPixelNoisy(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) const;
109 Bool_t IsPixelSilentM(UInt_t module, UInt_t colM, UInt_t row) const;
110 Bool_t IsPixelDeadM(UInt_t module, UInt_t colM, UInt_t row) const;
111 Bool_t IsPixelNoisyM(UInt_t module, UInt_t colM, UInt_t row) const;
112 Bool_t IsPixelSilentKey(Int_t key) const;
113 Bool_t IsPixelDeadKey(Int_t key) const;
114 Bool_t IsPixelNoisyKey(Int_t key) const;
116 UInt_t GetNrSilent() const; // silent = dead or inactive
117 UInt_t GetNrDead() const;
118 UInt_t GetDeadEqIdAt(UInt_t index);
119 UInt_t GetDeadHSAt(UInt_t index);
120 UInt_t GetDeadChipAt(UInt_t index);
121 UInt_t GetDeadColAt(UInt_t index);
122 UInt_t GetDeadRowAt(UInt_t index);
123 UInt_t GetNrNoisy() const;
124 UInt_t GetNoisyEqIdAt(UInt_t index);
125 UInt_t GetNoisyHSAt(UInt_t index);
126 UInt_t GetNoisyChipAt(UInt_t index);
127 UInt_t GetNoisyColAt(UInt_t index);
128 UInt_t GetNoisyRowAt(UInt_t index);
130 UInt_t GetNrSilent(UInt_t module) const; // silent = dead or inactive
131 UInt_t GetNrDead(UInt_t module) const;
132 UInt_t GetDeadEqIdAt(UInt_t module,UInt_t index);
133 UInt_t GetDeadHSAt(UInt_t module,UInt_t index);
134 UInt_t GetDeadChipAt(UInt_t module,UInt_t index);
135 UInt_t GetDeadColAt(UInt_t module,UInt_t index);
136 UInt_t GetDeadRowAt(UInt_t module,UInt_t index);
137 UInt_t GetNrNoisy(UInt_t module) const;
138 UInt_t GetNoisyEqIdAt(UInt_t module, UInt_t index);
139 UInt_t GetNoisyHSAt(UInt_t module, UInt_t index);
140 UInt_t GetNoisyChipAt(UInt_t module, UInt_t index);
141 UInt_t GetNoisyColAt(UInt_t module, UInt_t index);
142 UInt_t GetNoisyRowAt(UInt_t module, UInt_t index);
144 UInt_t GetNrSilentEq(UInt_t eq) const; // silent = dead or inactive
145 UInt_t GetNrDeadEq(UInt_t eq) const;
146 UInt_t GetDeadEqIdAtEq(UInt_t eq, UInt_t index) const;
147 UInt_t GetDeadHSAtEq(UInt_t eq, UInt_t index);
148 UInt_t GetDeadChipAtEq(UInt_t eq, UInt_t index);
149 UInt_t GetDeadColAtEq(UInt_t eq, UInt_t index);
150 UInt_t GetDeadRowAtEq(UInt_t eq, UInt_t index);
151 UInt_t GetNrNoisyEq(UInt_t eq) const;
152 UInt_t GetNoisyEqIdAtEq(UInt_t eq, UInt_t index) const;
153 UInt_t GetNoisyHSAtEq(UInt_t eq, UInt_t index);
154 UInt_t GetNoisyChipAtEq(UInt_t eq, UInt_t index);
155 UInt_t GetNoisyColAtEq(UInt_t eq, UInt_t index);
156 UInt_t GetNoisyRowAtEq(UInt_t eq, UInt_t index);
158 UInt_t GetNrSilentC(UInt_t eq, UInt_t hs, UInt_t chip) const; // silent = dead or inactive
159 UInt_t GetNrDeadC(UInt_t eq, UInt_t hs, UInt_t chip) const;
160 UInt_t GetDeadEqIdAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
161 UInt_t GetDeadHSAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
162 UInt_t GetDeadChipAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
163 UInt_t GetDeadColAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
164 UInt_t GetDeadRowAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
165 UInt_t GetNrNoisyC(UInt_t eq, UInt_t hs, UInt_t chip) const;
166 UInt_t GetNoisyEqIdAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
167 UInt_t GetNoisyHSAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
168 UInt_t GetNoisyChipAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
169 UInt_t GetNoisyColAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
170 UInt_t GetNoisyRowAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
172 const Char_t* GetDeadPixelAsTextC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
173 const Char_t* GetNoisyPixelAsTextC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
176 void ActivateEq(UInt_t eq, Bool_t setval = kTRUE);
177 void ActivateHS(UInt_t eq, UInt_t hs, Bool_t setval = kTRUE);
178 void ActivateChip(UInt_t eq, UInt_t hs, UInt_t chip, Bool_t setval = kTRUE);
180 Bool_t IsActiveEq(UInt_t eq) const;
181 Bool_t IsActiveHS(UInt_t eq, UInt_t hs) const;
182 Bool_t IsActiveChip(UInt_t eq, UInt_t hs, UInt_t chip) const;
185 UInt_t AddSilentFrom(AliITSOnlineCalibrationSPDhandler* other);
186 UInt_t AddDeadFrom(AliITSOnlineCalibrationSPDhandler* other);
187 UInt_t AddNoisyFrom(AliITSOnlineCalibrationSPDhandler* other);
189 UInt_t GetNrDiff(AliITSOnlineCalibrationSPDhandler* other) const;
190 UInt_t GetNrSilentDiff(AliITSOnlineCalibrationSPDhandler* other) const;
191 UInt_t GetNrDeadDiff(AliITSOnlineCalibrationSPDhandler* other) const;
192 UInt_t GetNrNoisyDiff(AliITSOnlineCalibrationSPDhandler* other) const;
193 AliITSOnlineCalibrationSPDhandler* GetDiff(AliITSOnlineCalibrationSPDhandler* other) const;
194 AliITSOnlineCalibrationSPDhandler* GetSilentDiff(AliITSOnlineCalibrationSPDhandler* other) const;
195 AliITSOnlineCalibrationSPDhandler* GetDeadDiff(AliITSOnlineCalibrationSPDhandler* other) const;
196 AliITSOnlineCalibrationSPDhandler* GetNoisyDiff(AliITSOnlineCalibrationSPDhandler* other) const;
200 TString fFileLocation; // location (dir) of files to read and write from
201 AliITSIntMap* fDeadPixelMap[1200]; // lists of dead pixels for each chip
202 AliITSIntMap* fNoisyPixelMap[1200]; // lists of noisy pixels for each chip
203 UInt_t fNrDead[1200]; // nr of dead pixels for each chip
204 UInt_t fNrNoisy[1200]; // nr of noisy pixels for each chip
205 Bool_t fActiveEq[20]; // active bit for each equipment
206 Bool_t fActiveHS[20][6]; // active bit for each half-stave
207 Bool_t fActiveChip[20][6][10]; // active bit for each chip
209 Int_t GetKey(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) const
210 {return eq*6*10*32*256 + hs*10*32*256 + chip*32*256 + col*256 + row;}
211 UInt_t GetEqIdFromKey(Int_t key) const
212 {return key/(6*10*32*256);}
213 UInt_t GetHSFromKey(Int_t key) const
214 {return (key%(6*10*32*256))/(10*32*256);}
215 UInt_t GetChipFromKey(Int_t key) const
216 {return ((key%(6*10*32*256))%(10*32*256))/(32*256);}
217 UInt_t GetColFromKey(Int_t key) const
218 {return (((key%(6*10*32*256))%(10*32*256))%(32*256))/256;}
219 UInt_t GetRowFromKey(Int_t key) const
220 {return (((key%(6*10*32*256))%(10*32*256))%(32*256))%256;}
221 UInt_t GetModuleFromKey(Int_t key) const
222 {return AliITSRawStreamSPD::GetOfflineModuleFromOnline(GetEqIdFromKey(key),GetHSFromKey(key),GetChipFromKey(key));}
223 UInt_t GetColMFromKey(Int_t key) const
224 {return AliITSRawStreamSPD::GetOfflineColFromOnline(GetEqIdFromKey(key),GetHSFromKey(key),GetChipFromKey(key),GetColFromKey(key));}
225 UInt_t GetRowMFromKey(Int_t key) const
226 {return AliITSRawStreamSPD::GetOfflineRowFromOnline(GetEqIdFromKey(key),GetHSFromKey(key),GetChipFromKey(key),GetRowFromKey(key));}
228 UInt_t GetGloChip(UInt_t eq, UInt_t hs, UInt_t chip) const {return eq*60 + hs*10 + chip;}
229 UInt_t GetEqGlo(UInt_t gloChip) const {return gloChip/60;}
230 UInt_t GetHSGlo(UInt_t gloChip) const {return (gloChip%60)/10;}
231 UInt_t GetChipGlo(UInt_t gloChip) const {return (gloChip%60)%10;}
233 void GetChipAndIndexDead(UInt_t module, UInt_t index, UInt_t& gloChip, UInt_t& chipIndex);
234 void GetChipAndIndexNoisy(UInt_t module, UInt_t index, UInt_t& gloChip, UInt_t& chipIndex);
235 void GetChipAndIndexEqDead(UInt_t eq, UInt_t index, UInt_t& gloChip, UInt_t& chipIndex);
236 void GetChipAndIndexEqNoisy(UInt_t eq, UInt_t index, UInt_t& gloChip, UInt_t& chipIndex);
237 void GetChipAndIndexTotDead(UInt_t index, UInt_t& gloChip, UInt_t& chipIndex);
238 void GetChipAndIndexTotNoisy(UInt_t index, UInt_t& gloChip, UInt_t& chipIndex);
240 UInt_t GetEqIdFromOffline(UInt_t module) const;
241 UInt_t GetHSFromOffline(UInt_t module) const;
242 UInt_t GetChipFromOffline(UInt_t module, UInt_t colM) const;
243 UInt_t GetColFromOffline(UInt_t module, UInt_t colM) const;
244 UInt_t GetRowFromOffline(UInt_t module, UInt_t rowM) const;
246 void RecursiveInsertDead(AliITSCalibrationSPD* calibSPD, UInt_t module, Int_t lowInd, Int_t highInd);
247 void RecursiveInsertNoisy(AliITSCalibrationSPD* calibSPD, UInt_t module, Int_t lowInd, Int_t highInd);
249 UInt_t GetNrDeadC2(UInt_t gloChip) const;
250 UInt_t GetDeadEqIdAtC2(UInt_t gloChip, UInt_t index) const;
251 UInt_t GetDeadHSAtC2(UInt_t gloChip, UInt_t index) const;
252 UInt_t GetDeadChipAtC2(UInt_t gloChip, UInt_t index) const;
253 UInt_t GetDeadColAtC2(UInt_t gloChip, UInt_t index) const;
254 UInt_t GetDeadRowAtC2(UInt_t gloChip, UInt_t index) const;
255 UInt_t GetNrNoisyC2(UInt_t gloChip) const;
256 UInt_t GetNoisyEqIdAtC2(UInt_t gloChip, UInt_t index) const;
257 UInt_t GetNoisyHSAtC2(UInt_t gloChip, UInt_t index) const;
258 UInt_t GetNoisyChipAtC2(UInt_t gloChip, UInt_t index) const;
259 UInt_t GetNoisyColAtC2(UInt_t gloChip, UInt_t index) const;
260 UInt_t GetNoisyRowAtC2(UInt_t gloChip, UInt_t index) const;