]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSPreprocessorSPD.h
Updated flags
[u/mrichter/AliRoot.git] / ITS / AliITSPreprocessorSPD.h
1 #ifndef ALIITSPREPROCESSORSPD_H
2 #define ALIITSPREPROCESSORSPD_H
3
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5  * See cxx source for full Copyright notice                               */
6
7 /* $Id$ */
8
9 ///////////////////////////////////////////////////////////////////////////
10 // AliITSPreprocessorSPD declaration by P. Nilsson 2005
11 // AUTHOR/CONTACT: Paul.Nilsson@cern.ch
12 //
13 // The purpose of this class is to provide algorithms for identification
14 // of "bad channels" such as dead channels and noisy channels in the SPD
15 ///////////////////////////////////////////////////////////////////////////
16
17 // #include "AliITSGeometry.h"
18 #include <TTask.h>
19 #include <TString.h>
20 #include <TTree.h>
21 #include <TBranch.h>
22 #include <TH2F.h>
23 #include <TClonesArray.h>
24 #include <TObjArray.h>
25 #include <TFile.h>
26 #include <TCollection.h>
27 #include <TKey.h>
28 #include <TDirectory.h>
29
30 #include "AliRun.h"
31 #include "AliRunLoader.h"
32 #include "AliITSLoader.h"
33 #include "AliITSdigitSPD.h"
34 #include "AliITSBadChannelsSPD.h"
35 #include "AliITSBadChannelsAuxSPD.h"
36 #include "AliITSChannelSPD.h"
37 #include "AliCDBId.h"
38 #include "AliCDBManager.h"
39 #include "AliCDBStorage.h"
40 #include "AliCDBMetaData.h"
41 #include "AliCDBLocal.h"
42 #include "AliLog.h"
43
44 class AliITSPreprocessorSPD : public TTask {
45
46  public:
47
48   AliITSPreprocessorSPD(void);                                         // Default constructor
49   AliITSPreprocessorSPD(const char *fileName, const char *mode,        // Standard constructor
50                         const char *fileNameg, const Int_t maxNumberOfEvents);
51   AliITSPreprocessorSPD(const AliITSPreprocessorSPD &prep);            // Default copy constructor
52   AliITSPreprocessorSPD& operator=(const AliITSPreprocessorSPD &prep); // Assignment operator
53   virtual ~AliITSPreprocessorSPD(void);                                // Virtual destructor
54
55   void Init(void);                                      // Initialization of the SPD preprocessor
56   Bool_t Open(const char *fileName, const char *mode,   // Open the input file (of either "daq" or "vme" type)
57               const char *fileNameg);                   // and the galice file
58   Bool_t FindDeadChannels(void);                        // Find dead channels
59   Bool_t FindDeadChannelsInModule(UInt_t module);       // Find dead channels in a module
60   Bool_t FindNoisyChannels(void);                       // Locate the noisy channels among the digits
61   Bool_t FindNoisyChannelsInModuleAlgo0(UInt_t module); // Locate the noisy channels in a module (for real data)
62   Bool_t FindNoisyChannelsInModuleAlgo1(UInt_t module); // Locate the noisy channels in a module (for calibration data)
63   Bool_t Store(AliCDBId &Id, AliCDBMetaData *md);               // Write the final object to the calibration database
64                                                         // Returns kTRUE if successful
65   Bool_t GetVMEHistograms(TFile *vmeFile);              // Get pre-filled digit histograms from input VME file
66   void MarkNoisyChannels(void);                         // Mark all found noisy channels among the digits
67   void PrintChannels(void);                             // Print all found bad channels to stdout
68
69   // Getters and setters
70   void SetMaximumNumberOfEvents(UInt_t n)      // Set the maximum number of events
71     { fMaximumNumberOfEvents = n; };           // (filling of noisy channel histograms will stop)
72   UInt_t GetMaximumNumberOfEvents(void) const  // Get the maximum number of events
73     { return fMaximumNumberOfEvents; };
74
75   void SetGeometryMode(UInt_t mode);           // Set the geometry mode
76   UInt_t GetGeometryMode(void) const           // Get the geometry mode
77     { return fGeometryMode; };                 // (kALICEGeometry is default, alt is kTestBeamGeometry)
78
79   void SetThreshold(UInt_t t)                  // Set the noisy channel threshold
80     { fThreshold = t; };                       // (A channel has to fire mode times than this value to be noisy)
81   void SetThreshold(Double_t t)                // Set the noisy channel threshold (overloaded)
82     { fThreshold = (UInt_t)t; };               // (A channel has to fire mode times than this value to be noisy)
83   UInt_t GetThreshold(void) const              // Get the noisy channel threshold
84     { return fThreshold; };                    // (A channel has to fire mode times than this value to be noisy)
85
86   void SetThresholdRatio(Double_t r)           // Set the noisy channel threshold ratio
87     { fThresholdRatio = r; };                  // (threshold to average neighboring channels)
88   Double_t GetThresholdRatio(void) const       // Get the noisy channel threshold ratio
89     { return fThresholdRatio; };               // (threshold to average neighboring channels)
90
91   void SelectAlgorithm(UInt_t a)               // Select algorithm for read data or calibration data
92     { fSelectedAlgorithm = a; };               // (either kOptimizedForRealData or kOptimizedForCalibrationData)
93   UInt_t GetSelectedAlgorithm(void) const      // Get the selected algorithm for read data or calibration data
94     { return fSelectedAlgorithm; };            // (either kOptimizedForRealData or kOptimizedForCalibrationData)
95
96   // Geometry mode constants
97   enum { kTestBeamGeometry, kALICEGeometry };
98
99   // Algorithm constants
100   enum { kOptimizedForRealData, kOptimizedForRealDataRMS, kOptimizedForCalibrationData };
101
102   // Noisy/dead pixel encoding (0001b, 0010b) used with the digit TObject statusbit
103   enum { kNoisyChannel = 1, kDeadChannel = 2 };
104
105   // Replace later with reading from geometry object
106   // During the 2004 test beam, 4 modules were used but had internal hardware addresses of 0,1,4,5
107   enum { kNumberOfTestBeamSPDModules = 6, kNumberOfSPDModules = 240 };
108   enum { kNumberOfColumns = 160, kNumberOfRows = 256 }; // In one module/ladder
109   enum { kNumberOfChannels = 40960 }; // 5*8192
110
111  private:
112
113   void ConvertObjToIntArray(void);             // Convert the bad channel TObjArray to an Int_t array
114   void SetFakeNoisyChannel(Int_t module, Int_t column, Int_t row);
115                                                // For testing purposes it is possible to add fake noisy channels
116                                                // to the noisy pixel tree. These will be added to the hit histograms
117   void CreateHistograms(void);                 // Create digit histograms
118   void CreateNoisyChannelsTree(void);          // Create noisy channels tree
119   TClonesArray *CreateDigitsArray(void) const; // Create the SPD digits array
120   Bool_t CreateGeometryObj(void);              // Creation of geometry object
121   Bool_t GetITSDigits(const char *fileName);   // Get the ITS digits
122   Bool_t GetgAlice(void);                      // Get the gAlice object
123   Bool_t FillHistograms(void);                 // Fill the histograms with digits
124   void SetNumberOfModules(UInt_t n)            // Set the number of modules
125     { fNumberOfModules = n; };
126   UInt_t GetNumberOfModules(void) const        // Get the number of modules
127     { return fNumberOfModules; };
128
129   // AliITSGeometry *fGeometryObj;             //! Pointer to the geometry object
130   AliITSLoader *fITSLoader;                    //! ITS loader
131   AliRunLoader *fRunLoader;                    //! Run Loader
132   Double_t fThresholdRatio;                    //! Noisy channel ratio
133   UInt_t fThreshold;                           //! Noisy channel threshold
134   UInt_t fMaximumNumberOfEvents;               //! Maximum number of events per histograms
135   UInt_t fNumberOfModules;                     //! Number of modules, used for digit histograms
136   UInt_t fHighestModuleNumber;                 //! The highest module number with found bad channels
137   UInt_t fNumberOfColumns;                     //! Number of SPD columns
138   UInt_t fNumberOfRows;                        //! Number of SPD rows
139   UInt_t fSelectedAlgorithm;                   //! Removal algorithm selection, either set to
140                                                //! kOptimizedForRealData or kOptimizedForCalibrationData
141   UInt_t fGeometryMode;                        //! Geometry mode (kALICEGeometry is default, alt is kTestBeamGeometry)
142   Int_t *fNumberOfBadChannels;                 //! Total number of bad channels counter
143   Int_t fIndex;                                //! Bad channels array index to be stored in fBadChannelsIndexArray
144   Bool_t fInit;                                //! Initialization boolean (true when histograms are created)
145   Bool_t fVMEMode;                             //! Initialization boolean (true when using a VME file as input)
146   TObjArray *fDigitsHistogram;                 //! Digits histogram array
147   TObjArray *fBadChannelsObjArray;             //! Bad channels array (size unknown initially)
148   Int_t *fBadChannelsIntArray;                 //! Bad channels array
149   Int_t *fBadChannelsIndexArray;               //! Indices for the bad channels
150   AliITSBadChannelsSPD *fBadChannelsContainer; //! Container object for database storage
151
152   ClassDef(AliITSPreprocessorSPD,1)
153 };
154
155 #endif