]>
Commit | Line | Data |
---|---|---|
356c3e0c | 1 | #ifndef ALICALOCALIBPEDESTAL_H |
2 | #define ALICALOCALIBPEDESTAL_H | |
3 | ||
a235e2bc | 4 | /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * |
5 | * See cxx source for full Copyright notice */ | |
356c3e0c | 6 | |
a235e2bc | 7 | /* $Id$ */ |
8 | ||
9 | ||
10 | // \file AliCaloCalibPedestal.h | |
11 | // \brief Description: | |
12 | // A help class for monitoring and calibration tools: MOOD, AMORE etc., | |
32cd4c24 | 13 | // that can process events from a standard AliCaloRawStreamV3, |
a235e2bc | 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$ | |
356c3e0c | 25 | |
26 | #include "TProfile2D.h" | |
27 | #include "TH2.h" | |
28 | #include "TObjArray.h" | |
bd3cd9c2 | 29 | #include "AliEMCALGeoParams.h" |
32cd4c24 | 30 | class AliCaloRawStreamV3; |
f4fc542c | 31 | class AliCaloAltroMapping; |
32 | class AliRawReader; | |
356c3e0c | 33 | |
34 | class AliCaloCalibPedestal : public TObject { | |
35 | ||
36 | public: | |
37 | ||
38 | enum kDetType {kPhos, kEmCal, kNone};//The detector types | |
d673ffe2 | 39 | enum kDeadMapEntry{kAlive = 0, kDead, kWarning, kHot, kResurrected, kRecentlyDeceased, kNumDeadMapStates};//The entries being put to the deadmap |
356c3e0c | 40 | |
41 | AliCaloCalibPedestal(kDetType detectorType = kPhos); | |
42 | virtual ~AliCaloCalibPedestal(); | |
43 | ||
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); | |
48 | ||
f4fc542c | 49 | // Event processing methods: |
50 | Bool_t ProcessEvent(AliRawReader *rawReader); | |
32cd4c24 | 51 | Bool_t ProcessEvent(AliCaloRawStreamV3 *in); |
356c3e0c | 52 | |
f4fc542c | 53 | // Mapping handling |
ab962f7b | 54 | AliCaloAltroMapping **GetAltroMapping() const { return fMapping; }; |
f4fc542c | 55 | void SetAltroMapping(AliCaloAltroMapping **mapp) { fMapping = mapp; }; |
56 | ||
b07ee441 | 57 | // Parameter/cut handling |
58 | void SetParametersFromFile(const char *parameterFile); | |
59 | void WriteParametersToFile(const char *parameterFile); | |
60 | ||
356c3e0c | 61 | //////////////////////////// |
62 | //Simple getters | |
63 | // Main profiles: | |
64 | TProfile2D * GetPedProfileLowGain(int i) const {return (TProfile2D*)fPedestalLowGain[i];}; // Return a pointer to the low-gain pedestal profile | |
65 | TProfile2D * GetPedProfileHighGain(int i) const {return (TProfile2D*)fPedestalHighGain[i];}; // Return a pointer to the high-gain pedestal profile | |
3dba9483 | 66 | TProfile2D * GetPedRMSProfileLowGain(int i) const {return (TProfile2D*)fPedestalRMSLowGain[i];}; // Return a pointer to the low-gain rms profile |
67 | TProfile2D * GetPedRMSProfileHighGain(int i) const {return (TProfile2D*)fPedestalRMSHighGain[i];}; // Return a pointer to the high-gain rms profile | |
68 | TProfile2D * GetPeakProfileLowGain(int i) const {return (TProfile2D*)fPeakMinusPedLowGain[i];}; // Return a pointer to the low-gain peak-pedestal profile | |
69 | TProfile2D * GetPeakProfileHighGain(int i) const {return (TProfile2D*)fPeakMinusPedHighGain[i];}; // Return a pointer to the high-gain peak-pedestal profile | |
356c3e0c | 70 | |
71 | // Differences to references: | |
72 | TProfile2D * GetPedProfileLowGainDiff(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPedestalLowGainDiff[i];}; // Return a pointer to the low-gain pedestal profile difference | |
73 | TProfile2D * GetPedProfileHighGainDiff(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPedestalHighGainDiff[i];}; // Return a pointer to the high-gain pedestal profile difference | |
3dba9483 | 74 | TProfile2D * GetPeakProfileLowGainDiff(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPeakMinusPedLowGainDiff[i];}; // Return a pointer to the low-gain peak-pedestal profile difference |
75 | TProfile2D * GetPeakProfileHighGainDiff(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPeakMinusPedHighGainDiff[i];}; // Return a pointer to the high-gain peak-pedestal profile difference | |
356c3e0c | 76 | |
77 | // Ratio to references: | |
78 | TProfile2D * GetPedProfileLowGainRatio(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPedestalLowGainRatio[i];}; // Return a pointer to the low-gain pedestal profile ratio | |
79 | TProfile2D * GetPedProfileHighGainRatio(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPedestalHighGainRatio[i];}; // Return a pointer to the high-gain pedestal profile ratio | |
3dba9483 | 80 | TProfile2D * GetPeakProfileLowGainRatio(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPeakMinusPedLowGainRatio[i];}; // Return a pointer to the low-gain peak-pedestal profile ratio |
81 | TProfile2D * GetPeakProfileHighGainRatio(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPeakMinusPedHighGainRatio[i];}; // Return a pointer to the high-gain peak-pedestal profile ratio | |
356c3e0c | 82 | |
d673ffe2 | 83 | TH2F * GetPeakHighGainHisto(int i) const {return (TH2F*)fPeakMinusPedHighGainHisto[i];}; // Return a pointer to the high-gain peak-pedestal histo |
84 | ||
85 | ||
40164976 | 86 | TH2D * GetDeadMap(int i) const {return (TH2D*)fDeadMap[i];} |
87 | //void SetDeadMap(int i, TH2D *h) const {((TH2D*)fDeadMap[i])=h;} | |
88 | ||
89 | Bool_t IsBadChannel(int imod, int icol, int irow) const; | |
90 | void SetChannelStatus(int imod, int icol, int irow, int status); | |
91 | ||
92 | TObjArray GetDeadMap() const {return fDeadMap;} | |
93 | void SetDeadMap(TObjArray map) {fDeadMap = map;} | |
94 | ||
356c3e0c | 95 | // Basic info: getters |
96 | kDetType GetDetectorType() const {return fDetType;};//Returns if this is a PHOS or EMCAL object | |
f4fc542c | 97 | TString GetCaloString() const {return fCaloString;}; //Returns if this is a PHOS or EMCAL object |
356c3e0c | 98 | |
99 | int GetColumns() const {return fColumns;}; //The number of columns per module | |
100 | int GetRows() const {return fRows;}; //The number of rows per module | |
101 | int GetModules() const {return fModules;}; //The number of modules | |
18db89b7 | 102 | int GetRowMin() const {return fRowMin;}; //for histo def. |
103 | int GetRowMax() const {return fRowMax;}; //for histo def. | |
104 | int GetRowMultiplier() const {return fRowMultiplier;}; //for histo filling | |
356c3e0c | 105 | |
106 | // RunNumbers : setters and getters | |
107 | void SetRunNumber(int runNo) {fRunNumber = runNo;}; | |
108 | int GetRunNumber() const {return fRunNumber;}; | |
109 | int GetRefRunNumber() const {if (fReference) return fReference->GetRunNumber(); else return -1;}; | |
419341ea | 110 | |
3dba9483 | 111 | // Possibility to select only some samples for the pedestal calculation |
112 | void SetSelectPedestalSamples(Bool_t flag = kFALSE) {fSelectPedestalSamples = flag;} // select to to use only some range of samples for pedestal calc. | |
113 | Bool_t GetSelectPedestalSamples() const {return fSelectPedestalSamples;} // select to to use only some range of samples for pedestal calc. | |
114 | void SetFirstPedestalSample(int i) {fFirstPedestalSample = i;} // first sample to use | |
115 | void SetLastPedestalSample(int i) {fLastPedestalSample = i;} // last sample to use | |
116 | int GetFirstPedestalSample() const {return fFirstPedestalSample;}; // first sample to use | |
117 | int GetLastPedestalSample() const {return fLastPedestalSample;}; // last sample to use | |
118 | ||
d673ffe2 | 119 | //Set threshold/event fraction for tower warnings |
120 | void SetDeadThreshold(int i) {fDeadThreshold = i;} // peak - pedestal dead threshold | |
121 | void SetWarningThreshold(int i) {fWarningThreshold = i;} // peak - pedestal warning threshold | |
122 | void SetWarningFraction(double d) {fWarningFraction = d;} // event fraction for warnings | |
123 | int GetDeadThreshold() const {return fDeadThreshold;}; // peak - pedestal dead threshold | |
124 | int GetWarningThreshold() const {return fWarningThreshold;}; // peak - pedestal warning threshold | |
125 | double GetWarningFraction() const {return fWarningFraction;}; // event fraction for warnings | |
126 | // hot towers | |
127 | void SetHotSigma(double d) {fHotSigma = d;} // rms away from normal | |
128 | double GetHotSigma() const {return fHotSigma;}; // rms away from normal | |
129 | ||
419341ea | 130 | // Basic counters |
131 | int GetNEvents() const {return fNEvents;}; | |
132 | int GetNChanFills() const {return fNChanFills;}; | |
356c3e0c | 133 | |
134 | ///////////////////////////// | |
135 | //Analysis functions | |
40164976 | 136 | void SetDeadTowerCount(Int_t dead) {fDeadTowers = dead;};//Returns the number of dead towers, by counting the bins in peak-pedestal smaller than threshold |
356c3e0c | 137 | int GetDeadTowerCount() const {return fDeadTowers;};//Returns the number of dead towers, by counting the bins in peak-pedestal smaller than threshold |
138 | double GetDeadTowerRatio() const {return fDeadTowers/(double)(fRows*fColumns);}; //returns the percentage of dead towers, relative to a full module | |
139 | int GetDeadTowerNew() const {return fNewDeadTowers;}; //return the new dead towers compared to the reference | |
140 | int GetDeadTowerResurrected() const {return fResurrectedTowers;}; //The the towers resurrected since the reference run | |
419341ea | 141 | |
356c3e0c | 142 | void Reset();//Resets the whole class. |
419341ea | 143 | Bool_t AddInfo(const AliCaloCalibPedestal *ped);//picks up new info from supplied argument |
356c3e0c | 144 | |
145 | ////////////////////////////////////////////////////// | |
146 | //Functions related to comparing this with another (reference) run. | |
147 | Bool_t LoadReferenceCalib(TString fileName, TString objectName); //Loads another AliCaloCalibPedestal by name "objectName" from the file "fileName", for reference | |
148 | void ComputeDiffAndRatio();//Actually computes the difference and ratio into the histo's in memory | |
149 | AliCaloCalibPedestal * GetReference() const {return fReference;}; //Get the reference object. Needed for debug, will probably be removed later | |
d673ffe2 | 150 | void ComputeDeadTowers(const char * deadMapFile = 0);//Computes the dead tower values |
151 | void ComputeHotAndWarningTowers(const char * hotMapFile = 0);//Computes the hot tower values | |
152 | ||
356c3e0c | 153 | //Saving functions |
154 | Bool_t SaveHistograms(TString fileName, Bool_t saveEmptyHistos = kFALSE); //Saves the histograms to a .root file | |
155 | ||
156 | private: | |
157 | ||
158 | void ValidateComparisonProfiles(); //Makes sure that fPe..Diff and fPe..Ratio profiles exist | |
159 | ||
160 | //The histograms. We use a TObjArray instead of a simple array,because this gives automatic streaming properties for the | |
161 | //class. A TClonesArray would be more efficient, but it's a bit more difficult to use and it doesn't matter too much | |
162 | //since we have only around 12 objects (maximum) in the array anyway. | |
a235e2bc | 163 | TObjArray fPedestalLowGain; // pedestal info for low gain |
164 | TObjArray fPedestalHighGain; // pedestal info for high gain | |
3dba9483 | 165 | TObjArray fPedestalRMSLowGain; // pedestal rms info for low gain |
166 | TObjArray fPedestalRMSHighGain; // pedestal rms info for high gain | |
a235e2bc | 167 | TObjArray fPeakMinusPedLowGain; // (peak-pedestal) info for low gain |
168 | TObjArray fPeakMinusPedHighGain; // (peak-pedestal) info for high gain | |
d673ffe2 | 169 | |
170 | TObjArray fPeakMinusPedHighGainHisto; // (peak-pedestal TH2F) info for high gain, used for hot towers eveluation | |
356c3e0c | 171 | |
172 | //The difference of profiles between this and the reference object | |
173 | TObjArray fPedestalLowGainDiff; //! | |
174 | TObjArray fPedestalHighGainDiff; //! | |
175 | TObjArray fPeakMinusPedLowGainDiff; //! | |
176 | TObjArray fPeakMinusPedHighGainDiff; //! | |
177 | ||
178 | //The ratio of profiles between this and the reference object | |
179 | TObjArray fPedestalLowGainRatio; //! | |
180 | TObjArray fPedestalHighGainRatio; //! | |
181 | TObjArray fPeakMinusPedLowGainRatio; //! | |
182 | TObjArray fPeakMinusPedHighGainRatio; //! | |
183 | ||
184 | TObjArray fDeadMap;//The deadmap | |
419341ea | 185 | |
186 | // status counters | |
187 | int fNEvents; //# total events processed, | |
188 | int fNChanFills; //# total channel fills (NChan * NEvents if not zero-suppressed) | |
189 | ||
356c3e0c | 190 | //The dead tower counts |
40164976 | 191 | int fDeadTowers; // Number of towers found dead. |
356c3e0c | 192 | int fNewDeadTowers; //! Towers that have died since the reference run |
193 | int fResurrectedTowers; //! Towers that have been resurrected from the dead, compared to the reference | |
194 | ||
195 | AliCaloCalibPedestal * fReference; //! A reference object, for comparing the accumulated results to a previous run | |
196 | ||
197 | kDetType fDetType; //The detector type for this object | |
198 | int fColumns; //The number of columns per module | |
199 | int fRows; //The number of rows per module | |
200 | int fModules; //The number of modules | |
18db89b7 | 201 | int fRowMin; // Mimimum Row number |
202 | int fRowMax; // Maximum now number | |
203 | int fRowMultiplier; // Multiplication factor to get proper row range between PHOS and EMCAL | |
f4fc542c | 204 | TString fCaloString; // id for which detector type we have |
205 | AliCaloAltroMapping **fMapping; //! Altro Mapping object | |
356c3e0c | 206 | int fRunNumber; //The run number. Needs to be set by the user. |
3dba9483 | 207 | Bool_t fSelectPedestalSamples; // select to to use only some range of samples for pedestal calc. |
208 | int fFirstPedestalSample; // first sample to use | |
209 | int fLastPedestalSample; // last sample to use | |
f4fc542c | 210 | |
d673ffe2 | 211 | int fDeadThreshold; // Peak - ped threshold used for dead towers evaluation |
212 | int fWarningThreshold; // Peak - ped threshold used for warm/warning towers evaluation | |
213 | double fWarningFraction; //if(Peak - ped) > threshold in more than this fraction of event -> tower is assigned kWarning | |
214 | double fHotSigma; // if pedestal rms more than fHotSigma away from normal -> tower is assigned kHot | |
215 | ||
bd3cd9c2 | 216 | //Constants needed by the class: EMCAL ones are kept in AliEMCALGeoParams.h |
a235e2bc | 217 | static const int fgkPhosRows = 64; // number of rows per module for PHOS |
218 | static const int fgkPhosCols = 56; // number of columns per module for PHOS | |
219 | static const int fgkPhosModules = 5; // number of modules for PHOS | |
356c3e0c | 220 | |
d673ffe2 | 221 | ClassDef(AliCaloCalibPedestal, 7) |
356c3e0c | 222 | |
223 | }; | |
224 | ||
225 | #endif |