]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSOnlineCalibrationSPDhandler.h
Switch from TArrayI to TArrayS in the list of bad pixels in the SPD calibration objec...
[u/mrichter/AliRoot.git] / ITS / AliITSOnlineCalibrationSPDhandler.h
1 #ifndef ALI_ITS_ONLINECALIBRATIONSPDHANDLER_H
2 #define ALI_ITS_ONLINECALIBRATIONSPDHANDLER_H
3
4 //////////////////////////////////////////////////////////////////////////
5 // Author: Henrik Tydesjo                                               //
6 // Class that  simplifies the managing of dead and noisy pixels.        //
7 // Has interface to the AliITSOnlineCalibrationSPD container objects    //
8 // through reading and writing to TFile.                                //
9 //////////////////////////////////////////////////////////////////////////
10
11 /* $Id$   */
12
13 #include "AliITSRawStreamSPD.h"
14 #include <TString.h>
15
16 class TArrayS;
17 class AliITSIntMap;
18 class AliITSCalibrationSPD;
19
20 class AliITSOnlineCalibrationSPDhandler {
21
22  public:
23   AliITSOnlineCalibrationSPDhandler();
24   AliITSOnlineCalibrationSPDhandler(const AliITSOnlineCalibrationSPDhandler& handle);
25   virtual ~AliITSOnlineCalibrationSPDhandler();
26   AliITSOnlineCalibrationSPDhandler& operator=(const AliITSOnlineCalibrationSPDhandler& handle);
27
28   void    SetFileLocation(const Char_t* loc) {fFileLocation = loc;}
29   TString GetFileLocation() const {return fFileLocation;}
30
31   void    ClearMaps();
32   void    ResetDead();
33   void    ResetNoisy();
34   void    ResetDeadForChip(UInt_t eq, UInt_t hs, UInt_t chip);
35   void    ResetNoisyForChip(UInt_t eq, UInt_t hs, UInt_t chip);
36   void    ResetDeadForEq(UInt_t eq);
37   void    ResetNoisyForEq(UInt_t eq);
38
39   Bool_t  ReadFromFiles();
40   Bool_t  ReadDeadFromFiles();
41   Bool_t  ReadNoisyFromFiles();
42   Bool_t  ReadDeadFromFile(UInt_t eq);
43   Bool_t  ReadNoisyFromFile(UInt_t eq);
44   Bool_t  ReadDeadFromFileName(const char *fileName);
45   Bool_t  ReadNoisyFromFileName(const char *fileName);
46   UInt_t  ReadDeadFromText(const char *fileName, UInt_t module);
47   UInt_t  ReadNoisyFromText(const char *fileName, UInt_t module);
48
49   void    WriteToFilesAlways();
50   UInt_t  WriteToFiles();
51   void    WriteDeadToFilesAlways();
52   void    WriteNoisyToFilesAlways();
53   UInt_t  WriteDeadToFiles();
54   UInt_t  WriteNoisyToFiles();
55   void    WriteDeadToFile(UInt_t eq);
56   void    WriteNoisyToFile(UInt_t eq);
57
58 #ifndef SPD_DA_OFF
59   Bool_t  ReadDeadModuleFromDB(UInt_t module, Int_t runNr, Bool_t treeSerial=kFALSE);
60   Bool_t  ReadNoisyModuleFromDB(UInt_t module, Int_t runNr, Bool_t treeSerial=kFALSE);
61   Bool_t  ReadFromDB(Int_t runNr, Bool_t treeSerial=kFALSE);
62   Bool_t  ReadDeadFromDB(Int_t runNr, Bool_t treeSerial=kFALSE);
63   Bool_t  ReadNoisyFromDB(Int_t runNr, Bool_t treeSerial=kFALSE);
64   Bool_t  ReadDeadFromCalibObj(TObjArray* calObj);
65   Bool_t  ReadNoisyFromCalibObj(TObjArray* calObj);
66   Bool_t  WriteToDB(Int_t runNrStart, Int_t runNrEnd);
67   Bool_t  WriteDeadToDB(Int_t runNrStart, Int_t runNrEnd);
68   Bool_t  WriteNoisyToDB(Int_t runNrStart, Int_t runNrEnd);
69 #endif
70
71   void    GenerateDCSConfigFile(const Char_t* fileName);
72
73   TArrayS GetDeadArray(UInt_t module, Bool_t treeSerial=kFALSE);
74   TArrayS GetNoisyArray(UInt_t module, Bool_t treeSerial=kFALSE);
75   TArrayS GetDeadArrayOnline(UInt_t eq);
76   TArrayS GetNoisyArrayOnline(UInt_t eq);
77
78   void    PrintEqSummary();
79   void    PrintDead() const;
80   void    PrintNoisy() const;
81
82   Bool_t  SetDeadPixel(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row);
83   Bool_t  SetNoisyPixel(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row);
84   Bool_t  SetDeadPixelM(UInt_t module, UInt_t colM, UInt_t row);
85   Bool_t  SetNoisyPixelM(UInt_t module, UInt_t colM, UInt_t row);
86   Bool_t  UnSetDeadPixel(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row);
87   Bool_t  UnSetNoisyPixel(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row);
88   Bool_t  UnSetDeadPixelM(UInt_t module, UInt_t colM, UInt_t row);
89   Bool_t  UnSetNoisyPixelM(UInt_t module, UInt_t colM, UInt_t row);
90   UInt_t  SetDeadChip(UInt_t eq, UInt_t hs, UInt_t chip);
91   UInt_t  SetNoisyChip(UInt_t eq, UInt_t hs, UInt_t chip);
92   Bool_t  UnSetDeadChip(UInt_t eq, UInt_t hs, UInt_t chip);
93   Bool_t  UnSetNoisyChip(UInt_t eq, UInt_t hs, UInt_t chip);
94
95   Bool_t  IsPixelDead(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) const;
96   Bool_t  IsPixelNoisy(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) const;
97   Bool_t  IsPixelDeadM(UInt_t module, UInt_t colM, UInt_t row) const;
98   Bool_t  IsPixelNoisyM(UInt_t module, UInt_t colM, UInt_t row) const;
99   Bool_t  IsPixelDeadKey(Int_t key) const;
100   Bool_t  IsPixelNoisyKey(Int_t key) const;
101
102   UInt_t  GetNrDead() const;
103   UInt_t  GetNrNoisy() const;
104   UInt_t  GetDeadEqIdAt(UInt_t index);
105   UInt_t  GetNoisyEqIdAt(UInt_t index);
106   UInt_t  GetDeadHSAt(UInt_t index);
107   UInt_t  GetNoisyHSAt(UInt_t index);
108   UInt_t  GetDeadChipAt(UInt_t index);
109   UInt_t  GetNoisyChipAt(UInt_t index);
110   UInt_t  GetDeadColAt(UInt_t index);
111   UInt_t  GetNoisyColAt(UInt_t index);
112   UInt_t  GetDeadRowAt(UInt_t index);
113   UInt_t  GetNoisyRowAt(UInt_t index);
114
115   UInt_t  GetNrDead(UInt_t module) const;
116   UInt_t  GetNrNoisy(UInt_t module) const;
117   UInt_t  GetDeadEqIdAt(UInt_t module,UInt_t index);
118   UInt_t  GetNoisyEqIdAt(UInt_t module, UInt_t index);
119   UInt_t  GetDeadHSAt(UInt_t module,UInt_t index);
120   UInt_t  GetNoisyHSAt(UInt_t module, UInt_t index);
121   UInt_t  GetDeadChipAt(UInt_t module,UInt_t index);
122   UInt_t  GetNoisyChipAt(UInt_t module, UInt_t index);
123   UInt_t  GetDeadColAt(UInt_t module,UInt_t index);
124   UInt_t  GetNoisyColAt(UInt_t module, UInt_t index);
125   UInt_t  GetDeadRowAt(UInt_t module,UInt_t index);
126   UInt_t  GetNoisyRowAt(UInt_t module, UInt_t index);
127
128   UInt_t  GetNrDeadEq(UInt_t eq) const;
129   UInt_t  GetNrNoisyEq(UInt_t eq) const;
130   UInt_t  GetDeadEqIdAtEq(UInt_t eq, UInt_t index) const;
131   UInt_t  GetNoisyEqIdAtEq(UInt_t eq, UInt_t index) const;
132   UInt_t  GetDeadHSAtEq(UInt_t eq, UInt_t index);
133   UInt_t  GetNoisyHSAtEq(UInt_t eq, UInt_t index);
134   UInt_t  GetDeadChipAtEq(UInt_t eq, UInt_t index);
135   UInt_t  GetNoisyChipAtEq(UInt_t eq, UInt_t index);
136   UInt_t  GetDeadColAtEq(UInt_t eq, UInt_t index);
137   UInt_t  GetNoisyColAtEq(UInt_t eq, UInt_t index);
138   UInt_t  GetDeadRowAtEq(UInt_t eq, UInt_t index);
139   UInt_t  GetNoisyRowAtEq(UInt_t eq, UInt_t index);
140
141   UInt_t  GetNrDeadC(UInt_t eq, UInt_t hs, UInt_t chip) const;
142   UInt_t  GetNrNoisyC(UInt_t eq, UInt_t hs, UInt_t chip) const;
143   UInt_t  GetDeadEqIdAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
144   UInt_t  GetNoisyEqIdAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
145   UInt_t  GetDeadHSAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
146   UInt_t  GetNoisyHSAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
147   UInt_t  GetDeadChipAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
148   UInt_t  GetNoisyChipAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
149   UInt_t  GetDeadColAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
150   UInt_t  GetNoisyColAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
151   UInt_t  GetDeadRowAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
152   UInt_t  GetNoisyRowAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
153
154   const Char_t* GetDeadPixelAsTextC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
155   const Char_t* GetNoisyPixelAsTextC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
156
157   UInt_t  AddDeadFrom(AliITSOnlineCalibrationSPDhandler* other);
158   UInt_t  AddNoisyFrom(AliITSOnlineCalibrationSPDhandler* other);
159
160   UInt_t  GetNrDiff(AliITSOnlineCalibrationSPDhandler* other) const;
161   UInt_t  GetNrDeadDiff(AliITSOnlineCalibrationSPDhandler* other) const;
162   UInt_t  GetNrNoisyDiff(AliITSOnlineCalibrationSPDhandler* other) const;
163   AliITSOnlineCalibrationSPDhandler* GetDiff(AliITSOnlineCalibrationSPDhandler* other) const;
164   AliITSOnlineCalibrationSPDhandler* GetDeadDiff(AliITSOnlineCalibrationSPDhandler* other) const;
165   AliITSOnlineCalibrationSPDhandler* GetNoisyDiff(AliITSOnlineCalibrationSPDhandler* other) const;
166
167
168  private:
169   TString fFileLocation;              // location (dir) of files to read and write from
170   AliITSIntMap* fDeadPixelMap[1200];  // lists of dead pixels for each chip
171   AliITSIntMap* fNoisyPixelMap[1200]; // lists of noisy pixels for each chip
172   UInt_t fNrDead[1200];               // nr of dead pixels for each chip
173   UInt_t fNrNoisy[1200];              // nr of noisy pixels for each chip
174                                      
175   Int_t    GetKey(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) const 
176     {return eq*6*10*32*256 + hs*10*32*256 + chip*32*256 + col*256 + row;}
177   UInt_t   GetEqIdFromKey(Int_t key) const 
178     {return key/(6*10*32*256);}
179   UInt_t   GetHSFromKey(Int_t key) const 
180     {return (key%(6*10*32*256))/(10*32*256);}
181   UInt_t   GetChipFromKey(Int_t key) const 
182     {return ((key%(6*10*32*256))%(10*32*256))/(32*256);}
183   UInt_t   GetColFromKey(Int_t key) const 
184     {return (((key%(6*10*32*256))%(10*32*256))%(32*256))/256;}
185   UInt_t   GetRowFromKey(Int_t key) const 
186     {return (((key%(6*10*32*256))%(10*32*256))%(32*256))%256;}
187   UInt_t   GetModuleFromKey(Int_t key) const
188     {return AliITSRawStreamSPD::GetOfflineModuleFromOnline(GetEqIdFromKey(key),GetHSFromKey(key),GetChipFromKey(key));}
189   UInt_t   GetColMFromKey(Int_t key) const 
190     {return AliITSRawStreamSPD::GetOfflineColFromOnline(GetEqIdFromKey(key),GetHSFromKey(key),GetChipFromKey(key),GetColFromKey(key));}
191   UInt_t   GetRowMFromKey(Int_t key) const 
192     {return AliITSRawStreamSPD::GetOfflineRowFromOnline(GetEqIdFromKey(key),GetHSFromKey(key),GetChipFromKey(key),GetRowFromKey(key));}
193   
194   UInt_t   GetGloChip(UInt_t eq, UInt_t hs, UInt_t chip) const
195     {return eq*6*10 + hs*10 + chip;}
196
197   void     GetChipAndIndexDead(UInt_t module, UInt_t index, UInt_t& gloChip, UInt_t& chipIndex);
198   void     GetChipAndIndexNoisy(UInt_t module, UInt_t index, UInt_t& gloChip, UInt_t& chipIndex);
199   void     GetChipAndIndexEqDead(UInt_t eq, UInt_t index, UInt_t& gloChip, UInt_t& chipIndex);
200   void     GetChipAndIndexEqNoisy(UInt_t eq, UInt_t index, UInt_t& gloChip, UInt_t& chipIndex);
201   void     GetChipAndIndexTotDead(UInt_t index, UInt_t& gloChip, UInt_t& chipIndex);
202   void     GetChipAndIndexTotNoisy(UInt_t index, UInt_t& gloChip, UInt_t& chipIndex);
203
204   UInt_t   GetEqIdFromOffline(UInt_t module) const;
205   UInt_t   GetHSFromOffline(UInt_t module) const;
206   UInt_t   GetChipFromOffline(UInt_t module, UInt_t colM) const;
207   UInt_t   GetColFromOffline(UInt_t module, UInt_t colM) const;
208   UInt_t   GetRowFromOffline(UInt_t module, UInt_t rowM) const;
209
210   void     RecursiveInsertDead(AliITSCalibrationSPD* calibSPD, UInt_t module, Int_t lowInd, Int_t highInd);
211   void     RecursiveInsertNoisy(AliITSCalibrationSPD* calibSPD, UInt_t module, Int_t lowInd, Int_t highInd);
212
213   UInt_t   GetNrDeadC2(UInt_t gloChip) const;
214   UInt_t   GetNrNoisyC2(UInt_t gloChip) const;
215   UInt_t   GetDeadEqIdAtC2(UInt_t gloChip, UInt_t index) const;
216   UInt_t   GetNoisyEqIdAtC2(UInt_t gloChip, UInt_t index) const;
217   UInt_t   GetDeadHSAtC2(UInt_t gloChip, UInt_t index) const;
218   UInt_t   GetNoisyHSAtC2(UInt_t gloChip, UInt_t index) const;
219   UInt_t   GetDeadChipAtC2(UInt_t gloChip, UInt_t index) const;
220   UInt_t   GetNoisyChipAtC2(UInt_t gloChip, UInt_t index) const;
221   UInt_t   GetDeadColAtC2(UInt_t gloChip, UInt_t index) const;
222   UInt_t   GetNoisyColAtC2(UInt_t gloChip, UInt_t index) const;
223   UInt_t   GetDeadRowAtC2(UInt_t gloChip, UInt_t index) const;    
224   UInt_t   GetNoisyRowAtC2(UInt_t gloChip, UInt_t index) const;
225
226 };
227
228 #endif