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