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