]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSOnlineCalibrationSPDhandler.h
Small optimizations
[u/mrichter/AliRoot.git] / ITS / AliITSOnlineCalibrationSPDhandler.h
1 #ifndef ALI_ITS_ONLINECALIBRATIONSPDHANDLER_H
2 #define ALI_ITS_ONLINECALIBRATIONSPDHANDLER_H
3
4 /* Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
5  * See cxx source for full Copyright notice                               */
6
7 /* $Id$ */
8
9 //////////////////////////////////////////////////////////////////////////
10 // Author: Henrik Tydesjo                                               //
11 // Class that  simplifies the managing of dead and noisy pixels.        //
12 // Has interface to the AliITSOnlineCalibrationSPD container objects    //
13 // through reading and writing to TFile.                                //
14 //////////////////////////////////////////////////////////////////////////
15
16
17 #include "AliITSRawStreamSPD.h"
18 #include <TString.h>
19
20 class TArrayI;
21 class AliITSIntMap;
22
23 class AliITSOnlineCalibrationSPDhandler {
24
25  public:
26   AliITSOnlineCalibrationSPDhandler();
27   AliITSOnlineCalibrationSPDhandler(const AliITSOnlineCalibrationSPDhandler& handle);
28   virtual ~AliITSOnlineCalibrationSPDhandler();
29   AliITSOnlineCalibrationSPDhandler& operator=(const AliITSOnlineCalibrationSPDhandler& handle);
30
31   void    SetFileLocation(const Char_t* loc) {fFileLocation = loc;}
32   TString GetFileLocation() const {return fFileLocation;}
33
34   void    ClearMaps();
35
36   Bool_t  ReadFromFiles();
37   Bool_t  ReadDeadFromFiles();
38   Bool_t  ReadNoisyFromFiles();
39   Bool_t  ReadFromFile(UInt_t module);
40   Bool_t  ReadDeadFromFile(UInt_t module);
41   Bool_t  ReadNoisyFromFile(UInt_t module);
42   Bool_t  ReadFromFileName(const char *fileName);
43   Bool_t  ReadDeadFromFileName(const char *fileName);
44   Bool_t  ReadNoisyFromFileName(const char *fileName);
45
46   void    WriteToFilesAlways();
47   void    WriteToFiles();
48   void    WriteDeadToFiles();
49   void    WriteNoisyToFiles();
50   void    WriteToFile(UInt_t module);  
51   void    WriteDeadToFile(UInt_t module);
52   void    WriteNoisyToFile(UInt_t module);
53
54 #ifndef SPD_DA_OFF
55   Bool_t  ReadModuleFromDB(UInt_t module, Int_t runNr);
56   Bool_t  ReadFromDB(Int_t runNr);
57   Bool_t  WriteToDB(Int_t runNrStart, Int_t runNrEnd);
58 #endif
59   UInt_t  ReadNoisyFromText(const char *fileName);
60   UInt_t  ReadDeadFromText(const char *fileName);
61   void    GenerateDCSConfigFile(const Char_t* fileName);
62
63   TArrayI GetDeadArray(UInt_t module);
64   TArrayI GetNoisyArray(UInt_t module);
65
66   void    ResetDead();
67   void    ResetDeadForChip(UInt_t eqId, UInt_t hs, UInt_t chip);
68   Bool_t  SetDeadPixel(UInt_t eqId, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row);
69   Bool_t  SetDeadPixelM(UInt_t module, UInt_t colM, UInt_t row);
70   Bool_t  UnSetDeadPixel(UInt_t eqId, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row);
71   Bool_t  UnSetDeadPixelM(UInt_t module, UInt_t colM, UInt_t row);
72   Bool_t  IsPixelDead(UInt_t eqId, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) const;
73   Bool_t  IsPixelDeadM(UInt_t module, UInt_t colM, UInt_t row);
74
75   UInt_t  GetNrDead(UInt_t module) const;
76   UInt_t  GetDeadEqIdAt(UInt_t module,UInt_t index);
77   UInt_t  GetDeadHSAt(UInt_t module,UInt_t index);
78   UInt_t  GetDeadChipAt(UInt_t module,UInt_t index);
79   UInt_t  GetDeadColAt(UInt_t module,UInt_t index);
80   UInt_t  GetDeadRowAt(UInt_t module,UInt_t index);
81
82   void    ResetNoisy();
83   void    ResetNoisyForChip(UInt_t eqId, UInt_t hs, UInt_t chip);
84   Bool_t  SetNoisyPixel(UInt_t eqId, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row);
85   Bool_t  SetNoisyPixelM(UInt_t module, UInt_t colM, UInt_t row);
86   Bool_t  UnSetNoisyPixel(UInt_t eqId, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row);
87   Bool_t  UnSetNoisyPixelM(UInt_t module, UInt_t colM, UInt_t row);
88   Bool_t  IsPixelNoisy(UInt_t eqId, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) const;
89   Bool_t  IsPixelNoisyM(UInt_t module, UInt_t colM, UInt_t row);
90
91   UInt_t  GetNrNoisy(UInt_t module) const;
92   UInt_t  GetNoisyEqIdAt(UInt_t module, UInt_t index);
93   UInt_t  GetNoisyHSAt(UInt_t module, UInt_t index);
94   UInt_t  GetNoisyChipAt(UInt_t module, UInt_t index);
95   UInt_t  GetNoisyColAt(UInt_t module, UInt_t index);
96   UInt_t  GetNoisyRowAt(UInt_t module, UInt_t index);
97
98   UInt_t  GetNrDead() const;
99   UInt_t  GetNrNoisy() const;
100   void    PrintDead() const;
101   void    PrintNoisy() const;
102
103   UInt_t  GetNrDiff(AliITSOnlineCalibrationSPDhandler* other) const;
104   UInt_t  GetNrDeadDiff(AliITSOnlineCalibrationSPDhandler* other) const;
105   UInt_t  GetNrNoisyDiff(AliITSOnlineCalibrationSPDhandler* other) const;
106   AliITSOnlineCalibrationSPDhandler* GetDiff(AliITSOnlineCalibrationSPDhandler* other) const;
107   AliITSOnlineCalibrationSPDhandler* GetDeadDiff(AliITSOnlineCalibrationSPDhandler* other) const;
108   AliITSOnlineCalibrationSPDhandler* GetNoisyDiff(AliITSOnlineCalibrationSPDhandler* other) const;
109
110
111  private:
112   TString fFileLocation;             // location (dir) of files to read and write from
113   AliITSIntMap* fDeadPixelMap[240];  // lists of dead pixels for each module
114   AliITSIntMap* fNoisyPixelMap[240]; // lists of noisy pixels for each module
115   UInt_t fNrDead[240];               // nr of dead pixels for each module
116   UInt_t fNrNoisy[240];              // nr of noisy pixels for each module
117                                      
118   Bool_t fModuleMapInited;           // flag to know if arrays below are filled 
119   UInt_t fiDDL[240];                 // iDDL value for each module (inited when used, fModuleMapInited flag)
120   UInt_t fiModule[240];              // iModule value for each module (inited when used, fModuleMapInited flag)
121
122   Int_t    GetKey(UInt_t eqId, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) const 
123     {return eqId*6*10*32*256 + hs*10*32*256 + chip*32*256 + col*256 + row;}
124
125   UInt_t   GetEqIdFromKey(Int_t key) const 
126     {return key/(6*10*32*256);}
127   UInt_t   GetHSFromKey(Int_t key) const 
128     {return (key%(6*10*32*256))/(10*32*256);}
129   UInt_t   GetChipFromKey(Int_t key) const 
130     {return ((key%(6*10*32*256))%(10*32*256))/(32*256);}
131   UInt_t   GetColFromKey(Int_t key) const 
132     {return (((key%(6*10*32*256))%(10*32*256))%(32*256))/256;}
133   UInt_t   GetRowFromKey(Int_t key) const 
134     {return (((key%(6*10*32*256))%(10*32*256))%(32*256))%256;}
135   UInt_t   GetModuleFromKey(Int_t key) const
136     {return AliITSRawStreamSPD::GetModuleNumber(GetEqIdFromKey(key),GetHSFromKey(key),GetChipFromKey(key));}
137   UInt_t   GetColMFromKey(Int_t key) const 
138     {return GetColFromKey(key) + 32 * (GetChipFromKey(key) % 5);}
139
140   void     InitModuleMaps();
141   UInt_t   GetEqIdFromOffline(UInt_t module);
142   UInt_t   GetHSFromOffline(UInt_t module);
143   UInt_t   GetChipFromOffline(UInt_t module, UInt_t colM);
144   UInt_t   GetColFromOffline(UInt_t colM) const;
145
146   Bool_t   IsPixelDeadKey(Int_t key) const;
147   Bool_t   IsPixelDeadMKey(UInt_t module, Int_t key) const;
148   Bool_t   IsPixelNoisyKey(Int_t key) const;
149   Bool_t   IsPixelNoisyMKey(UInt_t module, Int_t key) const;
150
151 };
152
153 #endif