]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliCaloCalibPedestal.h
TPCNoiseMapComponent included into build (Kelly)
[u/mrichter/AliRoot.git] / EMCAL / AliCaloCalibPedestal.h
1 #ifndef ALICALOCALIBPEDESTAL_H
2 #define ALICALOCALIBPEDESTAL_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 // \file AliCaloCalibPedestal.h
11 //   \brief Description:
12 //   A help class for monitoring and calibration tools: MOOD, AMORE etc.,
13 //   that can process events from a standard AliCaloRawStream,
14 //   most usually from LED/pulser runs. It stores signal info as
15 //   typical (highest) amplitude, and pedestal info in geometrically-binned
16 //   2D profiles of the detectors (EMCAL and PHOS).
17 //   Comparisons (ratios and differences) can be done with references.
18
19 //   \author: Timo Alho (Jyvaskyla), original version. 
20 //   [Consultant: D. Silvermyr (ORNL)]
21 //   Partly based on AliTPCCalibPedestal.
22 //   
23 //   \version $Revision$
24 //   \date $Date$
25
26 #include "TProfile2D.h"
27 #include "TH2.h"
28 #include "TObjArray.h"
29 class AliCaloRawStream;
30
31 class AliCaloCalibPedestal : public TObject {
32   
33  public:
34
35   enum kDetType {kPhos, kEmCal, kNone};//The detector types
36   enum kDeadMapEntry{kAlive = 0, kDead, kResurrected, kRecentlyDeceased, kNumDeadMapStates};//The entries being put to the deadmap
37   
38   AliCaloCalibPedestal(kDetType detectorType = kPhos);
39   virtual ~AliCaloCalibPedestal();
40
41   // copy ctor, and '=' operator, are not fully tested/debugged yet
42   // at least for now; the reference info is not copied from one to the other
43   AliCaloCalibPedestal(const AliCaloCalibPedestal &ped); 
44   AliCaloCalibPedestal& operator = (const  AliCaloCalibPedestal &source);
45   
46   //Functions to ask for the constants (in case a GUI needs them, for an example
47   static const int GetSampleMax() {return fgkSampleMax;};
48   static const int GetSampleMin() {return fgkSampleMin;};
49   
50   Bool_t ProcessEvent(AliCaloRawStream    *in);
51   
52   ////////////////////////////
53   //Simple getters
54   // Main profiles:
55   TProfile2D * GetPedProfileLowGain(int i) const {return (TProfile2D*)fPedestalLowGain[i];};    // Return a pointer to the low-gain pedestal profile
56   TProfile2D * GetPedProfileHighGain(int i) const {return (TProfile2D*)fPedestalHighGain[i];};  // Return a pointer to the high-gain pedestal profile
57   TProfile2D * GetPeakProfileLowGain(int i) const {return (TProfile2D*)fPeakMinusPedLowGain[i];};       // Return a pointer to the low-gain pedestal profile
58   TProfile2D * GetPeakProfileHighGain(int i) const {return (TProfile2D*)fPeakMinusPedHighGain[i];};     // Return a pointer to the high-gain pedestal profile
59   
60   // Differences to references:
61   TProfile2D * GetPedProfileLowGainDiff(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPedestalLowGainDiff[i];};     // Return a pointer to the low-gain pedestal profile difference
62   TProfile2D * GetPedProfileHighGainDiff(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPedestalHighGainDiff[i];};   // Return a pointer to the high-gain pedestal profile difference
63   TProfile2D * GetPeakProfileLowGainDiff(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPeakMinusPedLowGainDiff[i];};        // Return a pointer to the low-gain pedestal profile difference
64   TProfile2D * GetPeakProfileHighGainDiff(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPeakMinusPedHighGainDiff[i];};      // Return a pointer to the high-gain pedestal profile difference
65   
66   // Ratio to references:
67   TProfile2D * GetPedProfileLowGainRatio(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPedestalLowGainRatio[i];};   // Return a pointer to the low-gain pedestal profile ratio
68   TProfile2D * GetPedProfileHighGainRatio(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPedestalHighGainRatio[i];}; // Return a pointer to the high-gain pedestal profile ratio
69   TProfile2D * GetPeakProfileLowGainRatio(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPeakMinusPedLowGainRatio[i];};      // Return a pointer to the low-gain pedestal profile ratio
70   TProfile2D * GetPeakProfileHighGainRatio(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPeakMinusPedHighGainRatio[i];};    // Return a pointer to the high-gain pedestal profile ratio
71   
72   TH2D * GetDeadMap(int i) const {return (TH2D*)fDeadMap[i];};
73
74   // Basic info: getters  
75   kDetType GetDetectorType() const {return fDetType;};//Returns if this is a PHOS or EMCAL object
76   
77   int GetColumns() const {return fColumns;}; //The number of columns per module
78   int GetRows() const {return fRows;}; //The number of rows per module
79   int GetModules() const {return fModules;}; //The number of modules
80
81   // RunNumbers : setters and getters
82   void SetRunNumber(int runNo) {fRunNumber = runNo;};
83   int GetRunNumber() const {return fRunNumber;};
84   int GetRefRunNumber() const {if (fReference) return fReference->GetRunNumber(); else return -1;};
85   
86   /////////////////////////////
87   //Analysis functions
88   int GetDeadTowerCount() const {return fDeadTowers;};//Returns the number of dead towers, by counting the bins in peak-pedestal smaller than threshold
89   double GetDeadTowerRatio() const {return fDeadTowers/(double)(fRows*fColumns);}; //returns the percentage of dead towers, relative to a full module
90   int GetDeadTowerNew() const {return fNewDeadTowers;}; //return the new dead towers compared to the reference
91   int GetDeadTowerResurrected() const {return fResurrectedTowers;}; //The the towers resurrected since the reference run
92   void Reset();//Resets the whole class.
93   
94   //////////////////////////////////////////////////////
95   //Functions related to comparing this with another (reference) run.
96   Bool_t LoadReferenceCalib(TString fileName, TString objectName); //Loads another AliCaloCalibPedestal by name "objectName" from the file "fileName", for reference
97   void ComputeDiffAndRatio();//Actually computes the difference and ratio into the histo's in memory
98   AliCaloCalibPedestal * GetReference() const {return fReference;}; //Get the reference object. Needed for debug, will probably be removed later
99   void ComputeDeadTowers(int threshold = 5, const char * deadMapFile = 0);//Computes the dead tower values
100   
101   
102   //Saving functions
103   Bool_t SaveHistograms(TString fileName, Bool_t saveEmptyHistos = kFALSE); //Saves the histograms to a .root file
104   
105  private:
106   
107   void ValidateComparisonProfiles(); //Makes sure that fPe..Diff and fPe..Ratio profiles exist
108   
109   //The histograms. We use a TObjArray instead of a simple array,because this gives automatic streaming properties for the
110   //class. A TClonesArray would be more efficient, but it's a bit more difficult to use and it doesn't matter too much
111   //since we have only around 12 objects (maximum) in the array anyway.
112   TObjArray fPedestalLowGain; // pedestal info for low gain
113   TObjArray fPedestalHighGain; // pedestal info for high gain
114   TObjArray fPeakMinusPedLowGain; // (peak-pedestal) info for low gain
115   TObjArray fPeakMinusPedHighGain; // (peak-pedestal) info for high gain
116   
117   //The difference of profiles between this and the reference object
118   TObjArray fPedestalLowGainDiff; //!
119   TObjArray fPedestalHighGainDiff; //!
120   TObjArray fPeakMinusPedLowGainDiff; //!
121   TObjArray fPeakMinusPedHighGainDiff; //!
122   
123   //The ratio of profiles between this and the reference object
124   TObjArray fPedestalLowGainRatio; //!
125   TObjArray fPedestalHighGainRatio; //!
126   TObjArray fPeakMinusPedLowGainRatio; //!
127   TObjArray fPeakMinusPedHighGainRatio; //!
128   
129   TObjArray fDeadMap;//The deadmap
130   
131   //The dead tower counts
132   int fDeadTowers; //!
133   int fNewDeadTowers; //! Towers that have died since the reference run
134   int fResurrectedTowers; //! Towers that have been resurrected from the dead, compared to the reference
135   
136   AliCaloCalibPedestal * fReference; //! A reference object, for comparing the accumulated results to a previous run
137   
138   kDetType fDetType; //The detector type for this object
139   int fColumns; //The number of columns per module
140   int fRows;    //The number of rows per module
141   int fModules; //The number of modules
142   int fRunNumber; //The run number. Needs to be set by the user.
143   
144   //Constants needed by the class
145   static const int fgkSampleMax = 1023; // highest possible sample value (10-bit = 0x3ff)
146   static const int fgkSampleMin = 0; // lowest possible sample value 
147   
148   static const int fgkPhosRows = 64; // number of rows per module for PHOS
149   static const int fgkPhosCols = 56; // number of columns per module for PHOS
150   static const int fgkPhosModules = 5; // number of modules for PHOS
151   
152   static const int fgkEmCalRows = 24; // number of rows per module for EMCAL
153   static const int fgkEmCalCols = 48; // number of columns per module for EMCAL
154   static const int fgkEmCalModules = 12; // number of modules for EMCAL
155   
156   ClassDef(AliCaloCalibPedestal,1)
157
158 };
159     
160 #endif