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 and noisy pixels. //
7 // Has interface to the AliITSOnlineCalibrationSPD container objects //
8 // through reading and writing to TFile. //
9 //////////////////////////////////////////////////////////////////////////
12 #include "AliITSRawStreamSPD.h"
18 class AliITSOnlineCalibrationSPDhandler {
21 AliITSOnlineCalibrationSPDhandler();
22 AliITSOnlineCalibrationSPDhandler(const AliITSOnlineCalibrationSPDhandler& handle);
23 virtual ~AliITSOnlineCalibrationSPDhandler();
24 AliITSOnlineCalibrationSPDhandler& operator=(const AliITSOnlineCalibrationSPDhandler& handle);
26 void SetFileLocation(const Char_t* loc) {fFileLocation = loc;}
27 TString GetFileLocation() const {return fFileLocation;}
31 Bool_t ReadFromFiles();
32 Bool_t ReadDeadFromFiles();
33 Bool_t ReadNoisyFromFiles();
34 Bool_t ReadFromFile(UInt_t module);
35 Bool_t ReadDeadFromFile(UInt_t module);
36 Bool_t ReadNoisyFromFile(UInt_t module);
37 Bool_t ReadFromFileName(const char *fileName);
38 Bool_t ReadDeadFromFileName(const char *fileName);
39 Bool_t ReadNoisyFromFileName(const char *fileName);
42 void WriteDeadToFiles();
43 void WriteNoisyToFiles();
44 void WriteToFile(UInt_t module);
45 void WriteDeadToFile(UInt_t module);
46 void WriteNoisyToFile(UInt_t module);
49 Bool_t ReadModuleFromDB(UInt_t module, Int_t runNr);
50 Bool_t ReadFromDB(Int_t runNr);
51 Bool_t WriteToDB(Int_t runNrStart, Int_t runNrEnd);
53 UInt_t ReadNoisyFromText(const char *fileName);
54 UInt_t ReadDeadFromText(const char *fileName);
55 void GenerateDCSConfigFile(const Char_t* fileName);
57 TArrayI GetDeadArray(UInt_t module);
58 TArrayI GetNoisyArray(UInt_t module);
61 void ResetDeadForChip(UInt_t eqId, UInt_t hs, UInt_t chip);
62 Bool_t SetDeadPixel(UInt_t eqId, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row);
63 Bool_t SetDeadPixelM(UInt_t module, UInt_t colM, UInt_t row);
64 Bool_t IsPixelDead(UInt_t eqId, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) const;
65 Bool_t IsPixelDeadM(UInt_t module, UInt_t colM, UInt_t row);
67 UInt_t GetNrDead(UInt_t module) const;
68 UInt_t GetDeadEqIdAt(UInt_t module,UInt_t index);
69 UInt_t GetDeadHSAt(UInt_t module,UInt_t index);
70 UInt_t GetDeadChipAt(UInt_t module,UInt_t index);
71 UInt_t GetDeadColAt(UInt_t module,UInt_t index);
72 UInt_t GetDeadRowAt(UInt_t module,UInt_t index);
75 void ResetNoisyForChip(UInt_t eqId, UInt_t hs, UInt_t chip);
76 Bool_t SetNoisyPixel(UInt_t eqId, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row);
77 Bool_t SetNoisyPixelM(UInt_t module, UInt_t colM, UInt_t row);
78 Bool_t IsPixelNoisy(UInt_t eqId, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) const;
79 Bool_t IsPixelNoisyM(UInt_t module, UInt_t colM, UInt_t row);
81 UInt_t GetNrNoisy(UInt_t module) const;
82 UInt_t GetNoisyEqIdAt(UInt_t module, UInt_t index);
83 UInt_t GetNoisyHSAt(UInt_t module, UInt_t index);
84 UInt_t GetNoisyChipAt(UInt_t module, UInt_t index);
85 UInt_t GetNoisyColAt(UInt_t module, UInt_t index);
86 UInt_t GetNoisyRowAt(UInt_t module, UInt_t index);
88 UInt_t GetNrDead() const;
89 UInt_t GetNrNoisy() const;
90 void PrintDead() const;
91 void PrintNoisy() const;
93 UInt_t GetNrDiff(AliITSOnlineCalibrationSPDhandler* other) const;
94 UInt_t GetNrDeadDiff(AliITSOnlineCalibrationSPDhandler* other) const;
95 UInt_t GetNrNoisyDiff(AliITSOnlineCalibrationSPDhandler* other) const;
96 AliITSOnlineCalibrationSPDhandler* GetDiff(AliITSOnlineCalibrationSPDhandler* other) const;
97 AliITSOnlineCalibrationSPDhandler* GetDeadDiff(AliITSOnlineCalibrationSPDhandler* other) const;
98 AliITSOnlineCalibrationSPDhandler* GetNoisyDiff(AliITSOnlineCalibrationSPDhandler* other) const;
102 TString fFileLocation; // location (dir) of files to read and write from
103 AliITSIntMap* fDeadPixelMap[240]; // lists of dead pixels for each module
104 AliITSIntMap* fNoisyPixelMap[240]; // lists of noisy pixels for each module
105 UInt_t fNrDead[240]; // nr of dead pixels for each module
106 UInt_t fNrNoisy[240]; // nr of noisy pixels for each module
108 Bool_t fModuleMapInited; // flag to know if arrays below are filled
109 UInt_t fiDDL[240]; // iDDL value for each module (inited when used, fModuleMapInited flag)
110 UInt_t fiModule[240]; // iModule value for each module (inited when used, fModuleMapInited flag)
112 Int_t GetKey(UInt_t eqId, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) const
113 {return eqId*6*10*32*256 + hs*10*32*256 + chip*32*256 + col*256 + row;}
115 UInt_t GetEqIdFromKey(Int_t key) const
116 {return key/(6*10*32*256);}
117 UInt_t GetHSFromKey(Int_t key) const
118 {return (key%(6*10*32*256))/(10*32*256);}
119 UInt_t GetChipFromKey(Int_t key) const
120 {return ((key%(6*10*32*256))%(10*32*256))/(32*256);}
121 UInt_t GetColFromKey(Int_t key) const
122 {return (((key%(6*10*32*256))%(10*32*256))%(32*256))/256;}
123 UInt_t GetRowFromKey(Int_t key) const
124 {return (((key%(6*10*32*256))%(10*32*256))%(32*256))%256;}
125 UInt_t GetModuleFromKey(Int_t key) const
126 {return AliITSRawStreamSPD::GetModuleNumber(GetEqIdFromKey(key),GetHSFromKey(key),GetChipFromKey(key));}
127 UInt_t GetColMFromKey(Int_t key) const
128 {return GetColFromKey(key) + 32 * (GetChipFromKey(key) % 5);}
130 void InitModuleMaps();
131 UInt_t GetEqIdFromOffline(UInt_t module);
132 UInt_t GetHSFromOffline(UInt_t module);
133 UInt_t GetChipFromOffline(UInt_t module, UInt_t colM);
134 UInt_t GetColFromOffline(UInt_t colM) const;
136 Bool_t IsPixelDeadKey(Int_t key) const;
137 Bool_t IsPixelDeadMKey(UInt_t module, Int_t key) const;
138 Bool_t IsPixelNoisyKey(Int_t key) const;
139 Bool_t IsPixelNoisyMKey(UInt_t module, Int_t key) const;