Move the selection of the fitting algorithm from Raw2Digits to FitRaw
[u/mrichter/AliRoot.git] / ITS / AliITSOnlineCalibrationSPDhandler.h
CommitLineData
b15de2d2 1#ifndef ALI_ITS_ONLINECALIBRATIONSPDHANDLER_H
2#define ALI_ITS_ONLINECALIBRATIONSPDHANDLER_H
3
b696414b 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//////////////////////////////////////////////////////////////////////////////
b15de2d2 10
60d9faf6 11/* $Id$ */
e03405c9 12
53ae21ce 13#include "AliITSRawStreamSPD.h"
14#include <TString.h>
b15de2d2 15
60d9faf6 16class TArrayI;
e03405c9 17class TArrayS;
53ae21ce 18class AliITSIntMap;
ed041840 19class AliITSTriggerConditions;
6727e2db 20class AliITSCalibrationSPD;
b15de2d2 21
22class AliITSOnlineCalibrationSPDhandler {
23
24 public:
25 AliITSOnlineCalibrationSPDhandler();
b15de2d2 26 AliITSOnlineCalibrationSPDhandler(const AliITSOnlineCalibrationSPDhandler& handle);
27 virtual ~AliITSOnlineCalibrationSPDhandler();
28 AliITSOnlineCalibrationSPDhandler& operator=(const AliITSOnlineCalibrationSPDhandler& handle);
53ae21ce 29
30 void SetFileLocation(const Char_t* loc) {fFileLocation = loc;}
31 TString GetFileLocation() const {return fFileLocation;}
32
b15de2d2 33 void ClearMaps();
6727e2db 34 void ResetDead();
35 void ResetNoisy();
36 void ResetDeadForChip(UInt_t eq, UInt_t hs, UInt_t chip);
37 void ResetNoisyForChip(UInt_t eq, UInt_t hs, UInt_t chip);
38 void ResetDeadForEq(UInt_t eq);
39 void ResetNoisyForEq(UInt_t eq);
b15de2d2 40
53ae21ce 41 Bool_t ReadFromFiles();
b696414b 42 Bool_t ReadSilentFromFiles();
53ae21ce 43 Bool_t ReadDeadFromFiles();
44 Bool_t ReadNoisyFromFiles();
b696414b 45 Bool_t ReadSilentFromFile(UInt_t eq);
6727e2db 46 Bool_t ReadDeadFromFile(UInt_t eq);
47 Bool_t ReadNoisyFromFile(UInt_t eq);
b696414b 48 Bool_t ReadSilentFromFileName(const char *fileName);
49 Bool_t ReadDeadFromFileName(const char *fileName, Bool_t inactive=kFALSE);
53ae21ce 50 Bool_t ReadNoisyFromFileName(const char *fileName);
b696414b 51
6727e2db 52 UInt_t ReadDeadFromText(const char *fileName, UInt_t module);
53 UInt_t ReadNoisyFromText(const char *fileName, UInt_t module);
ed041840 54 void ReadPITConditionsFromText(const char *fileName);
53ae21ce 55
3479cee3 56 void WriteToFilesAlways();
6727e2db 57 UInt_t WriteToFiles();
b696414b 58 void WriteSilentToFilesAlways();
6727e2db 59 void WriteDeadToFilesAlways();
60 void WriteNoisyToFilesAlways();
b696414b 61 UInt_t WriteSilentToFiles();
6727e2db 62 UInt_t WriteDeadToFiles();
63 UInt_t WriteNoisyToFiles();
b696414b 64 void WriteSilentToFile(UInt_t eq);
65 void WriteDeadToFile(UInt_t eq, Bool_t inactive=kFALSE);
6727e2db 66 void WriteNoisyToFile(UInt_t eq);
53ae21ce 67
68#ifndef SPD_DA_OFF
3db964b1 69 Bool_t ReadDeadModuleFromDB(UInt_t module, Int_t runNr, const Char_t *storage="default", Bool_t treeSerial=kFALSE);
70 Bool_t ReadNoisyModuleFromDB(UInt_t module, Int_t runNr, const Char_t *storage="default", Bool_t treeSerial=kFALSE);
71 Bool_t ReadFromDB(Int_t runNr, const Char_t *storage="default", Bool_t treeSerial=kFALSE);
72 Bool_t ReadDeadFromDB(Int_t runNr, const Char_t *storage="default", Bool_t treeSerial=kFALSE);
73 Bool_t ReadNoisyFromDB(Int_t runNr, const Char_t *storage="default", Bool_t treeSerial=kFALSE);
74 Bool_t ReadDeadFromDBasNoisy(Int_t runNr, const Char_t *storage="default", Bool_t treeSerial=kFALSE);
6727e2db 75 Bool_t ReadDeadFromCalibObj(TObjArray* calObj);
76 Bool_t ReadNoisyFromCalibObj(TObjArray* calObj);
3db964b1 77 Bool_t WriteToDB(Int_t runNrStart, Int_t runNrEnd, const Char_t *storage="default");
78 Bool_t WriteDeadToDB(Int_t runNrStart, Int_t runNrEnd, const Char_t *storage="default");
79 Bool_t WriteDeadToDBasNoisy(Int_t runNrStart, Int_t runNrEnd, const Char_t *storage="default");
80 Bool_t WriteNoisyToDB(Int_t runNrStart, Int_t runNrEnd, const Char_t *storage="default");
ed041840 81 Bool_t WritePITConditionsToDB(Int_t runNrStart, Int_t runNrEnd, const Char_t *storage="default");
53ae21ce 82#endif
53ae21ce 83
6727e2db 84 void GenerateDCSConfigFile(const Char_t* fileName);
b15de2d2 85
b696414b 86 TArrayS GetSilentArray(UInt_t module, Bool_t treeSerial=kFALSE); // temporarily needed
e03405c9 87 TArrayS GetDeadArray(UInt_t module, Bool_t treeSerial=kFALSE);
88 TArrayS GetNoisyArray(UInt_t module, Bool_t treeSerial=kFALSE);
b696414b 89
60d9faf6 90 TArrayI GetDeadArrayOnline(UInt_t eq);
91 TArrayI GetNoisyArrayOnline(UInt_t eq);
53ae21ce 92
6727e2db 93 void PrintEqSummary();
b696414b 94 void PrintSilent() const; // silent = dead or inactive
6727e2db 95 void PrintDead() const;
96 void PrintNoisy() const;
53ae21ce 97
6727e2db 98 Bool_t SetDeadPixel(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row);
99 Bool_t SetNoisyPixel(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row);
100 Bool_t SetDeadPixelM(UInt_t module, UInt_t colM, UInt_t row);
53ae21ce 101 Bool_t SetNoisyPixelM(UInt_t module, UInt_t colM, UInt_t row);
6727e2db 102 Bool_t UnSetDeadPixel(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row);
103 Bool_t UnSetNoisyPixel(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row);
104 Bool_t UnSetDeadPixelM(UInt_t module, UInt_t colM, UInt_t row);
3479cee3 105 Bool_t UnSetNoisyPixelM(UInt_t module, UInt_t colM, UInt_t row);
6727e2db 106
ed041840 107 Bool_t SetInactiveChipInPITmask(UInt_t eq, UInt_t hs, UInt_t chip);
108 Bool_t UnSetInactiveChipInPITmask(UInt_t eq, UInt_t hs, UInt_t chip);
109
478d804c 110 Bool_t IsPixelBad(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) const;
b696414b 111 Bool_t IsPixelSilent(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) const; // silent = dead or inactive
6727e2db 112 Bool_t IsPixelDead(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) const;
113 Bool_t IsPixelNoisy(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) const;
478d804c 114 Bool_t IsPixelBadM(UInt_t module, UInt_t colM, UInt_t row) const;
b696414b 115 Bool_t IsPixelSilentM(UInt_t module, UInt_t colM, UInt_t row) const;
6727e2db 116 Bool_t IsPixelDeadM(UInt_t module, UInt_t colM, UInt_t row) const;
117 Bool_t IsPixelNoisyM(UInt_t module, UInt_t colM, UInt_t row) const;
478d804c 118 Bool_t IsPixelBadKey(Int_t key) const;
b696414b 119 Bool_t IsPixelSilentKey(Int_t key) const;
6727e2db 120 Bool_t IsPixelDeadKey(Int_t key) const;
121 Bool_t IsPixelNoisyKey(Int_t key) const;
b15de2d2 122
478d804c 123 UInt_t GetNrBad() const; // bad = silent or noisy
b696414b 124 UInt_t GetNrSilent() const; // silent = dead or inactive
6727e2db 125 UInt_t GetNrDead() const;
478d804c 126 UInt_t GetDeadEqIdAt(UInt_t index) const;
127 UInt_t GetDeadHSAt(UInt_t index) const;
128 UInt_t GetDeadChipAt(UInt_t index) const;
129 UInt_t GetDeadColAt(UInt_t index) const;
130 UInt_t GetDeadRowAt(UInt_t index) const;
b696414b 131 UInt_t GetNrNoisy() const;
478d804c 132 UInt_t GetNoisyEqIdAt(UInt_t index) const;
133 UInt_t GetNoisyHSAt(UInt_t index) const;
134 UInt_t GetNoisyChipAt(UInt_t index) const;
135 UInt_t GetNoisyColAt(UInt_t index) const;
136 UInt_t GetNoisyRowAt(UInt_t index) const;
6727e2db 137
478d804c 138
139 UInt_t GetNrBad(UInt_t module) const; // bad = silent or noisy
b696414b 140 UInt_t GetNrSilent(UInt_t module) const; // silent = dead or inactive
6727e2db 141 UInt_t GetNrDead(UInt_t module) const;
bb292d31 142 UInt_t GetNrDeadSingle(UInt_t module) const;
478d804c 143 UInt_t GetDeadEqIdAt(UInt_t module,UInt_t index) const;
144 UInt_t GetDeadHSAt(UInt_t module,UInt_t index) const;
145 UInt_t GetDeadChipAt(UInt_t module,UInt_t index) const;
146 UInt_t GetDeadColAt(UInt_t module,UInt_t index) const;
147 UInt_t GetDeadRowAt(UInt_t module,UInt_t index) const;
b696414b 148 UInt_t GetNrNoisy(UInt_t module) const;
bb292d31 149 UInt_t GetNrNoisySingle(UInt_t module) const;
478d804c 150 UInt_t GetNoisyEqIdAt(UInt_t module, UInt_t index) const;
151 UInt_t GetNoisyHSAt(UInt_t module, UInt_t index) const;
152 UInt_t GetNoisyChipAt(UInt_t module, UInt_t index) const;
153 UInt_t GetNoisyColAt(UInt_t module, UInt_t index) const;
154 UInt_t GetNoisyRowAt(UInt_t module, UInt_t index) const;
53ae21ce 155
478d804c 156 UInt_t GetNrBadEq(UInt_t eq) const; // bad = silent or noisy
b696414b 157 UInt_t GetNrSilentEq(UInt_t eq) const; // silent = dead or inactive
6727e2db 158 UInt_t GetNrDeadEq(UInt_t eq) const;
6727e2db 159 UInt_t GetDeadEqIdAtEq(UInt_t eq, UInt_t index) const;
478d804c 160 UInt_t GetDeadHSAtEq(UInt_t eq, UInt_t index) const;
161 UInt_t GetDeadChipAtEq(UInt_t eq, UInt_t index) const;
162 UInt_t GetDeadColAtEq(UInt_t eq, UInt_t index) const;
163 UInt_t GetDeadRowAtEq(UInt_t eq, UInt_t index) const;
b696414b 164 UInt_t GetNrNoisyEq(UInt_t eq) const;
165 UInt_t GetNoisyEqIdAtEq(UInt_t eq, UInt_t index) const;
478d804c 166 UInt_t GetNoisyHSAtEq(UInt_t eq, UInt_t index) const;
167 UInt_t GetNoisyChipAtEq(UInt_t eq, UInt_t index) const;
168 UInt_t GetNoisyColAtEq(UInt_t eq, UInt_t index) const;
169 UInt_t GetNoisyRowAtEq(UInt_t eq, UInt_t index) const;
6727e2db 170
478d804c 171 UInt_t GetNrBadC(UInt_t eq, UInt_t hs, UInt_t chip) const; // bad = silent or noisy
b696414b 172 UInt_t GetNrSilentC(UInt_t eq, UInt_t hs, UInt_t chip) const; // silent = dead or inactive
6727e2db 173 UInt_t GetNrDeadC(UInt_t eq, UInt_t hs, UInt_t chip) const;
6727e2db 174 UInt_t GetDeadEqIdAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
6727e2db 175 UInt_t GetDeadHSAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
6727e2db 176 UInt_t GetDeadChipAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
6727e2db 177 UInt_t GetDeadColAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
6727e2db 178 UInt_t GetDeadRowAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
b696414b 179 UInt_t GetNrNoisyC(UInt_t eq, UInt_t hs, UInt_t chip) const;
180 UInt_t GetNoisyEqIdAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
181 UInt_t GetNoisyHSAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
182 UInt_t GetNoisyChipAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
183 UInt_t GetNoisyColAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
6727e2db 184 UInt_t GetNoisyRowAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
185
186 const Char_t* GetDeadPixelAsTextC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
187 const Char_t* GetNoisyPixelAsTextC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
188
478d804c 189 void ActivateALL();
190 void ActivateEq(UInt_t eq, Bool_t setval = kTRUE);
191 void ActivateHS(UInt_t eq, UInt_t hs, Bool_t setval = kTRUE);
192 void ActivateChip(UInt_t eq, UInt_t hs, UInt_t chip, Bool_t setval = kTRUE);
193
194 void UnSetDeadALL();
195 void SetDeadEq(UInt_t eq, Bool_t setval = kTRUE);
196 void SetDeadHS(UInt_t eq, UInt_t hs, Bool_t setval = kTRUE);
197 void SetDeadChip(UInt_t eq, UInt_t hs, UInt_t chip, Bool_t setval = kTRUE);
198
199 Bool_t IsActiveEq(UInt_t eq) const;
200 Bool_t IsActiveHS(UInt_t eq, UInt_t hs) const;
201 Bool_t IsActiveChip(UInt_t eq, UInt_t hs, UInt_t chip) const;
202
203 Bool_t IsDeadEq(UInt_t eq) const;
204 Bool_t IsDeadHS(UInt_t eq, UInt_t hs) const;
205 Bool_t IsDeadChip(UInt_t eq, UInt_t hs, UInt_t chip) const;
b696414b 206
478d804c 207 Bool_t IsSilentEq(UInt_t eq) const;
208 Bool_t IsSilentHS(UInt_t eq, UInt_t hs) const;
209 Bool_t IsSilentChip(UInt_t eq, UInt_t hs, UInt_t chip) const;
b696414b 210
c53f028c 211 Bool_t IsNoisyChip(UInt_t eq, UInt_t hs, UInt_t chip) const;
b696414b 212
213 UInt_t AddSilentFrom(AliITSOnlineCalibrationSPDhandler* other);
6727e2db 214 UInt_t AddDeadFrom(AliITSOnlineCalibrationSPDhandler* other);
215 UInt_t AddNoisyFrom(AliITSOnlineCalibrationSPDhandler* other);
b15de2d2 216
53ae21ce 217 UInt_t GetNrDiff(AliITSOnlineCalibrationSPDhandler* other) const;
b696414b 218 UInt_t GetNrSilentDiff(AliITSOnlineCalibrationSPDhandler* other) const;
53ae21ce 219 UInt_t GetNrDeadDiff(AliITSOnlineCalibrationSPDhandler* other) const;
220 UInt_t GetNrNoisyDiff(AliITSOnlineCalibrationSPDhandler* other) const;
221 AliITSOnlineCalibrationSPDhandler* GetDiff(AliITSOnlineCalibrationSPDhandler* other) const;
b696414b 222 AliITSOnlineCalibrationSPDhandler* GetSilentDiff(AliITSOnlineCalibrationSPDhandler* other) const;
53ae21ce 223 AliITSOnlineCalibrationSPDhandler* GetDeadDiff(AliITSOnlineCalibrationSPDhandler* other) const;
224 AliITSOnlineCalibrationSPDhandler* GetNoisyDiff(AliITSOnlineCalibrationSPDhandler* other) const;
ed041840 225 AliITSTriggerConditions * GetTriggerConditions() const {return fTriggerConditions;}
53ae21ce 226
ed041840 227 AliITSTriggerConditions *fTriggerConditions; // PIT conditions (mask, parameters name, parameters values)
53ae21ce 228
b15de2d2 229 private:
6727e2db 230 TString fFileLocation; // location (dir) of files to read and write from
231 AliITSIntMap* fDeadPixelMap[1200]; // lists of dead pixels for each chip
232 AliITSIntMap* fNoisyPixelMap[1200]; // lists of noisy pixels for each chip
233 UInt_t fNrDead[1200]; // nr of dead pixels for each chip
234 UInt_t fNrNoisy[1200]; // nr of noisy pixels for each chip
b696414b 235 Bool_t fActiveEq[20]; // active bit for each equipment
236 Bool_t fActiveHS[20][6]; // active bit for each half-stave
237 Bool_t fActiveChip[20][6][10]; // active bit for each chip
478d804c 238 Bool_t fDeadEq[20]; // dead bit for each equipment
239 Bool_t fDeadHS[20][6]; // dead bit for each half-stave
240 Bool_t fDeadChip[20][6][10]; // dead bit for each chip
b696414b 241
6727e2db 242 Int_t GetKey(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) const
243 {return eq*6*10*32*256 + hs*10*32*256 + chip*32*256 + col*256 + row;}
53ae21ce 244 UInt_t GetEqIdFromKey(Int_t key) const
245 {return key/(6*10*32*256);}
246 UInt_t GetHSFromKey(Int_t key) const
247 {return (key%(6*10*32*256))/(10*32*256);}
248 UInt_t GetChipFromKey(Int_t key) const
249 {return ((key%(6*10*32*256))%(10*32*256))/(32*256);}
250 UInt_t GetColFromKey(Int_t key) const
251 {return (((key%(6*10*32*256))%(10*32*256))%(32*256))/256;}
252 UInt_t GetRowFromKey(Int_t key) const
253 {return (((key%(6*10*32*256))%(10*32*256))%(32*256))%256;}
254 UInt_t GetModuleFromKey(Int_t key) const
6727e2db 255 {return AliITSRawStreamSPD::GetOfflineModuleFromOnline(GetEqIdFromKey(key),GetHSFromKey(key),GetChipFromKey(key));}
53ae21ce 256 UInt_t GetColMFromKey(Int_t key) const
6727e2db 257 {return AliITSRawStreamSPD::GetOfflineColFromOnline(GetEqIdFromKey(key),GetHSFromKey(key),GetChipFromKey(key),GetColFromKey(key));}
258 UInt_t GetRowMFromKey(Int_t key) const
259 {return AliITSRawStreamSPD::GetOfflineRowFromOnline(GetEqIdFromKey(key),GetHSFromKey(key),GetChipFromKey(key),GetRowFromKey(key));}
260
b696414b 261 UInt_t GetGloChip(UInt_t eq, UInt_t hs, UInt_t chip) const {return eq*60 + hs*10 + chip;}
262 UInt_t GetEqGlo(UInt_t gloChip) const {return gloChip/60;}
263 UInt_t GetHSGlo(UInt_t gloChip) const {return (gloChip%60)/10;}
264 UInt_t GetChipGlo(UInt_t gloChip) const {return (gloChip%60)%10;}
6727e2db 265
478d804c 266 void GetChipAndIndexDead(UInt_t module, UInt_t index, UInt_t& gloChip, UInt_t& chipIndex) const;
267 void GetChipAndIndexNoisy(UInt_t module, UInt_t index, UInt_t& gloChip, UInt_t& chipIndex) const;
268 void GetChipAndIndexEqDead(UInt_t eq, UInt_t index, UInt_t& gloChip, UInt_t& chipIndex) const;
269 void GetChipAndIndexEqNoisy(UInt_t eq, UInt_t index, UInt_t& gloChip, UInt_t& chipIndex) const;
270 void GetChipAndIndexTotDead(UInt_t index, UInt_t& gloChip, UInt_t& chipIndex) const;
271 void GetChipAndIndexTotNoisy(UInt_t index, UInt_t& gloChip, UInt_t& chipIndex) const;
6727e2db 272
273 UInt_t GetEqIdFromOffline(UInt_t module) const;
274 UInt_t GetHSFromOffline(UInt_t module) const;
275 UInt_t GetChipFromOffline(UInt_t module, UInt_t colM) const;
276 UInt_t GetColFromOffline(UInt_t module, UInt_t colM) const;
277 UInt_t GetRowFromOffline(UInt_t module, UInt_t rowM) const;
278
279 void RecursiveInsertDead(AliITSCalibrationSPD* calibSPD, UInt_t module, Int_t lowInd, Int_t highInd);
280 void RecursiveInsertNoisy(AliITSCalibrationSPD* calibSPD, UInt_t module, Int_t lowInd, Int_t highInd);
281
282 UInt_t GetNrDeadC2(UInt_t gloChip) const;
6727e2db 283 UInt_t GetDeadEqIdAtC2(UInt_t gloChip, UInt_t index) const;
6727e2db 284 UInt_t GetDeadHSAtC2(UInt_t gloChip, UInt_t index) const;
6727e2db 285 UInt_t GetDeadChipAtC2(UInt_t gloChip, UInt_t index) const;
6727e2db 286 UInt_t GetDeadColAtC2(UInt_t gloChip, UInt_t index) const;
6727e2db 287 UInt_t GetDeadRowAtC2(UInt_t gloChip, UInt_t index) const;
b696414b 288 UInt_t GetNrNoisyC2(UInt_t gloChip) const;
289 UInt_t GetNoisyEqIdAtC2(UInt_t gloChip, UInt_t index) const;
290 UInt_t GetNoisyHSAtC2(UInt_t gloChip, UInt_t index) const;
291 UInt_t GetNoisyChipAtC2(UInt_t gloChip, UInt_t index) const;
292 UInt_t GetNoisyColAtC2(UInt_t gloChip, UInt_t index) const;
6727e2db 293 UInt_t GetNoisyRowAtC2(UInt_t gloChip, UInt_t index) const;
b15de2d2 294
295};
296
297#endif