1 #ifndef ALICALOCALIBPEDESTAL_H
2 #define ALICALOCALIBPEDESTAL_H
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice */
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 AliCaloRawStreamV3,
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.
19 // \author: Timo Alho (Jyvaskyla), original version.
20 // [Consultant: D. Silvermyr (ORNL)]
21 // Partly based on AliTPCCalibPedestal.
23 // \version $Revision$
26 #include "TProfile2D.h"
28 #include "TObjArray.h"
29 #include "AliEMCALGeoParams.h"
30 class AliCaloRawStreamV3;
31 class AliCaloAltroMapping;
34 class AliCaloCalibPedestal : public TObject {
38 enum kDetType {kPhos, kEmCal, kNone};//The detector types
39 enum kDeadMapEntry{kAlive = 0, kDead, kResurrected, kRecentlyDeceased, kNumDeadMapStates};//The entries being put to the deadmap
41 AliCaloCalibPedestal(kDetType detectorType = kPhos);
42 virtual ~AliCaloCalibPedestal();
44 // copy ctor, and '=' operator, are not fully tested/debugged yet
45 // at least for now; the reference info is not copied from one to the other
46 AliCaloCalibPedestal(const AliCaloCalibPedestal &ped);
47 AliCaloCalibPedestal& operator = (const AliCaloCalibPedestal &source);
49 // Event processing methods:
50 Bool_t ProcessEvent(AliRawReader *rawReader);
51 Bool_t ProcessEvent(AliCaloRawStreamV3 *in);
54 AliCaloAltroMapping **GetAltroMapping() { return fMapping; };
55 void SetAltroMapping(AliCaloAltroMapping **mapp) { fMapping = mapp; };
57 ////////////////////////////
60 TProfile2D * GetPedProfileLowGain(int i) const {return (TProfile2D*)fPedestalLowGain[i];}; // Return a pointer to the low-gain pedestal profile
61 TProfile2D * GetPedProfileHighGain(int i) const {return (TProfile2D*)fPedestalHighGain[i];}; // Return a pointer to the high-gain pedestal profile
62 TProfile2D * GetPedRMSProfileLowGain(int i) const {return (TProfile2D*)fPedestalRMSLowGain[i];}; // Return a pointer to the low-gain rms profile
63 TProfile2D * GetPedRMSProfileHighGain(int i) const {return (TProfile2D*)fPedestalRMSHighGain[i];}; // Return a pointer to the high-gain rms profile
64 TProfile2D * GetPeakProfileLowGain(int i) const {return (TProfile2D*)fPeakMinusPedLowGain[i];}; // Return a pointer to the low-gain peak-pedestal profile
65 TProfile2D * GetPeakProfileHighGain(int i) const {return (TProfile2D*)fPeakMinusPedHighGain[i];}; // Return a pointer to the high-gain peak-pedestal profile
67 // Differences to references:
68 TProfile2D * GetPedProfileLowGainDiff(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPedestalLowGainDiff[i];}; // Return a pointer to the low-gain pedestal profile difference
69 TProfile2D * GetPedProfileHighGainDiff(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPedestalHighGainDiff[i];}; // Return a pointer to the high-gain pedestal profile difference
70 TProfile2D * GetPeakProfileLowGainDiff(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPeakMinusPedLowGainDiff[i];}; // Return a pointer to the low-gain peak-pedestal profile difference
71 TProfile2D * GetPeakProfileHighGainDiff(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPeakMinusPedHighGainDiff[i];}; // Return a pointer to the high-gain peak-pedestal profile difference
73 // Ratio to references:
74 TProfile2D * GetPedProfileLowGainRatio(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPedestalLowGainRatio[i];}; // Return a pointer to the low-gain pedestal profile ratio
75 TProfile2D * GetPedProfileHighGainRatio(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPedestalHighGainRatio[i];}; // Return a pointer to the high-gain pedestal profile ratio
76 TProfile2D * GetPeakProfileLowGainRatio(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPeakMinusPedLowGainRatio[i];}; // Return a pointer to the low-gain peak-pedestal profile ratio
77 TProfile2D * GetPeakProfileHighGainRatio(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPeakMinusPedHighGainRatio[i];}; // Return a pointer to the high-gain peak-pedestal profile ratio
79 TH2D * GetDeadMap(int i) const {return (TH2D*)fDeadMap[i];};
81 // Basic info: getters
82 kDetType GetDetectorType() const {return fDetType;};//Returns if this is a PHOS or EMCAL object
83 TString GetCaloString() const {return fCaloString;}; //Returns if this is a PHOS or EMCAL object
85 int GetColumns() const {return fColumns;}; //The number of columns per module
86 int GetRows() const {return fRows;}; //The number of rows per module
87 int GetModules() const {return fModules;}; //The number of modules
88 int GetRowMin() const {return fRowMin;}; //for histo def.
89 int GetRowMax() const {return fRowMax;}; //for histo def.
90 int GetRowMultiplier() const {return fRowMultiplier;}; //for histo filling
92 // RunNumbers : setters and getters
93 void SetRunNumber(int runNo) {fRunNumber = runNo;};
94 int GetRunNumber() const {return fRunNumber;};
95 int GetRefRunNumber() const {if (fReference) return fReference->GetRunNumber(); else return -1;};
97 // Possibility to select only some samples for the pedestal calculation
98 void SetSelectPedestalSamples(Bool_t flag = kFALSE) {fSelectPedestalSamples = flag;} // select to to use only some range of samples for pedestal calc.
99 Bool_t GetSelectPedestalSamples() const {return fSelectPedestalSamples;} // select to to use only some range of samples for pedestal calc.
100 void SetFirstPedestalSample(int i) {fFirstPedestalSample = i;} // first sample to use
101 void SetLastPedestalSample(int i) {fLastPedestalSample = i;} // last sample to use
102 int GetFirstPedestalSample() const {return fFirstPedestalSample;}; // first sample to use
103 int GetLastPedestalSample() const {return fLastPedestalSample;}; // last sample to use
106 int GetNEvents() const {return fNEvents;};
107 int GetNChanFills() const {return fNChanFills;};
109 /////////////////////////////
111 int GetDeadTowerCount() const {return fDeadTowers;};//Returns the number of dead towers, by counting the bins in peak-pedestal smaller than threshold
112 double GetDeadTowerRatio() const {return fDeadTowers/(double)(fRows*fColumns);}; //returns the percentage of dead towers, relative to a full module
113 int GetDeadTowerNew() const {return fNewDeadTowers;}; //return the new dead towers compared to the reference
114 int GetDeadTowerResurrected() const {return fResurrectedTowers;}; //The the towers resurrected since the reference run
116 void Reset();//Resets the whole class.
117 Bool_t AddInfo(const AliCaloCalibPedestal *ped);//picks up new info from supplied argument
119 //////////////////////////////////////////////////////
120 //Functions related to comparing this with another (reference) run.
121 Bool_t LoadReferenceCalib(TString fileName, TString objectName); //Loads another AliCaloCalibPedestal by name "objectName" from the file "fileName", for reference
122 void ComputeDiffAndRatio();//Actually computes the difference and ratio into the histo's in memory
123 AliCaloCalibPedestal * GetReference() const {return fReference;}; //Get the reference object. Needed for debug, will probably be removed later
124 void ComputeDeadTowers(int threshold = 5, const char * deadMapFile = 0);//Computes the dead tower values
127 Bool_t SaveHistograms(TString fileName, Bool_t saveEmptyHistos = kFALSE); //Saves the histograms to a .root file
131 void ValidateComparisonProfiles(); //Makes sure that fPe..Diff and fPe..Ratio profiles exist
133 //The histograms. We use a TObjArray instead of a simple array,because this gives automatic streaming properties for the
134 //class. A TClonesArray would be more efficient, but it's a bit more difficult to use and it doesn't matter too much
135 //since we have only around 12 objects (maximum) in the array anyway.
136 TObjArray fPedestalLowGain; // pedestal info for low gain
137 TObjArray fPedestalHighGain; // pedestal info for high gain
138 TObjArray fPedestalRMSLowGain; // pedestal rms info for low gain
139 TObjArray fPedestalRMSHighGain; // pedestal rms info for high gain
140 TObjArray fPeakMinusPedLowGain; // (peak-pedestal) info for low gain
141 TObjArray fPeakMinusPedHighGain; // (peak-pedestal) info for high gain
143 //The difference of profiles between this and the reference object
144 TObjArray fPedestalLowGainDiff; //!
145 TObjArray fPedestalHighGainDiff; //!
146 TObjArray fPeakMinusPedLowGainDiff; //!
147 TObjArray fPeakMinusPedHighGainDiff; //!
149 //The ratio of profiles between this and the reference object
150 TObjArray fPedestalLowGainRatio; //!
151 TObjArray fPedestalHighGainRatio; //!
152 TObjArray fPeakMinusPedLowGainRatio; //!
153 TObjArray fPeakMinusPedHighGainRatio; //!
155 TObjArray fDeadMap;//The deadmap
158 int fNEvents; //# total events processed,
159 int fNChanFills; //# total channel fills (NChan * NEvents if not zero-suppressed)
161 //The dead tower counts
163 int fNewDeadTowers; //! Towers that have died since the reference run
164 int fResurrectedTowers; //! Towers that have been resurrected from the dead, compared to the reference
166 AliCaloCalibPedestal * fReference; //! A reference object, for comparing the accumulated results to a previous run
168 kDetType fDetType; //The detector type for this object
169 int fColumns; //The number of columns per module
170 int fRows; //The number of rows per module
171 int fModules; //The number of modules
172 int fRowMin; // Mimimum Row number
173 int fRowMax; // Maximum now number
174 int fRowMultiplier; // Multiplication factor to get proper row range between PHOS and EMCAL
175 TString fCaloString; // id for which detector type we have
176 AliCaloAltroMapping **fMapping; //! Altro Mapping object
177 int fRunNumber; //The run number. Needs to be set by the user.
178 Bool_t fSelectPedestalSamples; // select to to use only some range of samples for pedestal calc.
179 int fFirstPedestalSample; // first sample to use
180 int fLastPedestalSample; // last sample to use
182 //Constants needed by the class: EMCAL ones are kept in AliEMCALGeoParams.h
183 static const int fgkPhosRows = 64; // number of rows per module for PHOS
184 static const int fgkPhosCols = 56; // number of columns per module for PHOS
185 static const int fgkPhosModules = 5; // number of modules for PHOS
187 ClassDef(AliCaloCalibPedestal, 4)