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