AliRoot Core  ee782a0 (ee782a0)
AliCaloCalibPedestal.h
Go to the documentation of this file.
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 //________________________________________________________________________
18 //
35 //________________________________________________________________________
36 
37 #include "TProfile.h"
38 #include "TProfile2D.h"
39 #include "TH2.h"
40 #include "TObjArray.h"
41 
42 #include "AliEMCALGeoParams.h"
43 class AliCaloRawStreamV3;
44 class AliCaloAltroMapping;
45 class AliRawReader;
46 
47 class AliCaloCalibPedestal : public TObject
48 {
49 
50  public:
51 
54 
57 
58  AliCaloCalibPedestal(kDetType detectorType = kEmCal);
59  virtual ~AliCaloCalibPedestal();
60 
61  // copy ctor, and '=' operator, are not fully tested/debugged yet
62  // at least for now; the reference info is not copied from one to the other
65 
66  // Event processing methods:
67  Bool_t ProcessEvent(AliRawReader *rawReader);
68  Bool_t ProcessEvent(AliCaloRawStreamV3 *in);
69 
70  // Mapping handling
71  AliCaloAltroMapping **GetAltroMapping() const { return fMapping ; }
72  void SetAltroMapping(AliCaloAltroMapping **mapp) { fMapping = mapp ; }
73 
74  // Parameter/cut handling
75  void SetParametersFromFile(const char *parameterFile);
76  void WriteParametersToFile(const char *parameterFile);
77 
79  // Simple getters
80 
81  // * Main profiles:
82 
84  TProfile2D * GetPedProfileLowGain (int i) { ValidateProfiles() ; return (TProfile2D*)fPedestalLowGain [i] ; }
86  TProfile2D * GetPedProfileHighGain(int i) { ValidateProfiles() ; return (TProfile2D*)fPedestalHighGain[i] ; }
87 
89  TProfile * GetPedLEDRefProfileLowGain (int i) { ValidateProfiles() ; return (TProfile*)fPedestalLEDRefLowGain [i] ; }
91  TProfile * GetPedLEDRefProfileHighGain(int i) { ValidateProfiles() ; return (TProfile*)fPedestalLEDRefHighGain[i] ; }
92 
94  TProfile2D * GetPeakProfileLowGain (int i) { ValidateProfiles() ; return (TProfile2D*)fPeakMinusPedLowGain [i] ; }
96  TProfile2D * GetPeakProfileHighGain(int i) { ValidateProfiles() ; return (TProfile2D*)fPeakMinusPedHighGain[i] ; }
97 
98  // * Differences to references:
99 
101  TProfile2D * GetPedProfileLowGainDiff (int i) { ValidateComparisonProfiles() ; return (TProfile2D*)fPedestalLowGainDiff [i] ; }
103  TProfile2D * GetPedProfileHighGainDiff(int i) { ValidateComparisonProfiles() ; return (TProfile2D*)fPedestalHighGainDiff[i] ; }
104 
109 
111  TProfile2D * GetPeakProfileLowGainDiff (int i) { ValidateComparisonProfiles() ; return (TProfile2D*)fPeakMinusPedLowGainDiff [i] ; }
113  TProfile2D * GetPeakProfileHighGainDiff(int i) { ValidateComparisonProfiles() ; return (TProfile2D*)fPeakMinusPedHighGainDiff[i] ; }
114 
115  // * Ratio to references:
116 
118  TProfile2D * GetPedProfileLowGainRatio (int i) { ValidateComparisonProfiles() ; return (TProfile2D*)fPedestalLowGainRatio [i] ; }
120  TProfile2D * GetPedProfileHighGainRatio(int i) { ValidateComparisonProfiles() ; return (TProfile2D*)fPedestalHighGainRatio[i] ; }
121 
126 
128  TProfile2D * GetPeakProfileLowGainRatio (int i) { ValidateComparisonProfiles() ; return (TProfile2D*)fPeakMinusPedLowGainRatio [i] ; }
130  TProfile2D * GetPeakProfileHighGainRatio(int i) { ValidateComparisonProfiles() ; return (TProfile2D*)fPeakMinusPedHighGainRatio[i] ; }
131 
133  TH2F * GetPeakHighGainHisto(int i) { ValidateProfiles() ; return (TH2F*)fPeakMinusPedHighGainHisto[i] ; }
134 
135  // * Bad channels:
136 
138  TH2D * GetDeadMap(int i) { ValidateProfiles() ; return (TH2D*)fDeadMap[i] ; }
139 //void SetDeadMap(int i, TH2D *h) { ((TH2D*)fDeadMap[i])=h ; }
140 
142  void SetDeadMap(TObjArray map) { fDeadMap = map ; }
143 
144  Bool_t IsBadChannel (int imod, int icol, int irow) const;
145  void SetChannelStatus(int imod, int icol, int irow, int status);
146  Int_t GetChannelStatus(int imod, int icol, int irow) const { return (Int_t)((TH2D*)fDeadMap[imod])->GetBinContent(icol, irow) ; }
147 
149  // Basic info
150 
151  // * getters
152 
154  kDetType GetDetectorType() const { return fDetType ; }
156  TString GetCaloString() const { return fCaloString ; }
157 
158  int GetColumns() const { return fColumns ; } //The number of columns per module
159  int GetRows() const { return fRows ; } //The number of rows per module
160  int GetLEDRefs() const { return fLEDRefs ; } //The number of LED references/monitors per module
161  int GetModules() const { return fModules ; } //The number of modules
162  int GetRowMin() const { return fRowMin ; } //for histo def.
163  int GetRowMax() const { return fRowMax ; } //for histo def.
164  int GetRowMultiplier() const { return fRowMultiplier ; } //for histo filling
165 
166  // * RunNumbers : setters and getters
167  void SetRunNumber(int runNo) { fRunNumber = runNo ; }
168  int GetRunNumber() const { return fRunNumber ; }
169  int GetRefRunNumber() const { if (fReference) return fReference->GetRunNumber(); else return -1 ; }
170 
171  // * Possibility to select only some samples for the pedestal calculation
172 
174  void SetSelectPedestalSamples(Bool_t flag = kFALSE) { fSelectPedestalSamples = flag ; }
177 
178  void SetFirstPedestalSample(int i) { fFirstPedestalSample = i ; } // first sample to use
179  void SetLastPedestalSample (int i) { fLastPedestalSample = i ; } // last sample to use
180  int GetFirstPedestalSample() const { return fFirstPedestalSample ; } // first sample to use
181  int GetLastPedestalSample () const { return fLastPedestalSample ; } // last sample to use
182 
183  // * Set threshold/event fraction for tower warnings
184  void SetDeadThreshold(int i) { fDeadThreshold = i ; } // peak - pedestal dead threshold
185  void SetWarningThreshold(int i) { fWarningThreshold = i ; } // peak - pedestal warning threshold
186  void SetWarningFraction(double d) { fWarningFraction = d ; } // event fraction for warnings
187  int GetDeadThreshold() const { return fDeadThreshold ; } // peak - pedestal dead threshold
188  int GetWarningThreshold() const { return fWarningThreshold ; } // peak - pedestal warning threshold
189  double GetWarningFraction() const { return fWarningFraction ; } // event fraction for warnings
190 
191  // * hot towers
192  void SetHotSigma(double d) { fHotSigma = d ; } // rms away from normal
193  double GetHotSigma() const { return fHotSigma ; } // rms away from normal
194 
195  // * Basic counters
196  int GetNEvents() const { return fNEvents ; }
197  int GetNChanFills() const { return fNChanFills ; }
198 
200  //Analysis functions
201 
203  void SetDeadTowerCount(Int_t dead) { fDeadTowers = dead ; }
205  int GetDeadTowerCount() const { return fDeadTowers ; }
207  double GetDeadTowerRatio() const { return fDeadTowers/(double)(fRows*fColumns) ; }
209  int GetDeadTowerNew() const { return fNewDeadTowers ; }
211  int GetDeadTowerResurrected() const { return fResurrectedTowers ; }
212 
213  void Reset();
214 
215  Bool_t AddInfo(AliCaloCalibPedestal *ped);
216 
218  //Functions related to comparing this with another (reference) run.
219  Bool_t LoadReferenceCalib(TString fileName, TString objectName);
220 
223  Bool_t SetReference(AliCaloCalibPedestal *ref);
224 
225  void ComputeDiffAndRatio();
226  void ComputeDeadTowers(const char * deadMapFile = 0);
227  void ComputeHotAndWarningTowers(const char * hotMapFile = 0);
228 
229  // Saving functions
230  Bool_t SaveHistograms(TString fileName, Bool_t saveEmptyHistos = kFALSE);
231 
232  void Init() { ValidateProfiles() ; } // do basic setup
233 
234  private:
235 
236  void ValidateProfiles();
237  void CompressAndSetOwner();
239 
241  // The histograms. We use a TObjArray instead of a simple array,because this gives automatic streaming properties for the
242  // class. A TClonesArray would be more efficient, but it's a bit more difficult to use and it doesn't matter too much
243  // since we have only one object per module in the array anyway.
244 
251 
253 
254  // The difference of profiles between this and the reference object
261 
262  // The ratio of profiles between this and the reference object
269 
271 
272  // Status counters
273  int fNEvents;
275 
276  // The dead tower counts
280 
282 
284 
285  int fColumns;
286  int fRows;
287 
288  int fLEDRefs;
289  int fModules;
290 
291  int fRowMin;
292  int fRowMax;
294 
295  TString fCaloString;
296  AliCaloAltroMapping **fMapping;
297 
299 
303 
307  double fHotSigma;
308 
309  // Constants needed by the class: EMCAL ones are kept in AliEMCALGeoParams.h
310  static const int fgkPhosRows = 64;
311  static const int fgkPhosCols = 56;
312  static const int fgkPhosLEDRefs = 1;
313  static const int fgkPhosModules = 5;
314 
316  ClassDef(AliCaloCalibPedestal, 8) ;
318 
319 };
320 
321 #endif // ALICALOCALIBPEDESTAL_H
int fRowMin
Minimum Row number.
Bool_t fSelectPedestalSamples
select to to use only some range of samples for pedestal calc.
Int_t GetChannelStatus(int imod, int icol, int irow) const
TProfile2D * GetPedProfileHighGain(int i)
double fHotSigma
if pedestal rms more than fHotSigma away from normal -> tower is assigned kHot
TProfile2D * GetPedProfileLowGain(int i)
kDetType GetDetectorType() const
TProfile * GetPedLEDRefProfileHighGainDiff(int i)
int fWarningThreshold
Peak - ped threshold used for warm/warning towers evaluation.
TProfile2D * GetPeakProfileHighGain(int i)
TProfile2D * GetPeakProfileLowGainDiff(int i)
TProfile * GetPedLEDRefProfileHighGain(int i)
void ValidateProfiles()
Make sure that basic histos/profiles exist.
AliCaloCalibPedestal & operator=(AliCaloCalibPedestal &source)
Assignment operator; use copy ctor to make life easy..
double fWarningFraction
if(Peak - ped) > threshold in more than this fraction of event -> tower is assigned kWarning ...
double GetWarningFraction() const
Bool_t ProcessEvent(AliRawReader *rawReader)
kDetType
The detector types.
TProfile2D * GetPeakProfileLowGainRatio(int i)
TObjArray fPedestalLEDRefHighGain
Pedestal LEDRef info for high gain.
TObjArray fPedestalLowGainRatio
! The ratio of profiles between pedestal low gain and the reference object
#define TObjArray
TObjArray fPeakMinusPedHighGain
(peak-pedestal) info for high gain
int fLEDRefs
The number of LED references/monitors per module.
int fNChanFills
Total number of channel fills (NChan * NEvents if not zero-suppressed)
kDeadMapEntry
The entries being put to the deadmap.
void SetChannelStatus(int imod, int icol, int irow, int status)
TObjArray fPedestalHighGainDiff
! Difference of profiles between pedestal high gain and the reference object
TH2F * GetPeakHighGainHisto(int i)
AliCaloCalibPedestal(kDetType detectorType=kEmCal)
TObjArray fPeakMinusPedHighGainDiff
! Difference of profiles between peak high gain and the reference object
AliCaloCalibPedestal * fReference
! A reference object, for comparing the accumulated results to a previous run
void SetWarningFraction(double d)
Bool_t LoadReferenceCalib(TString fileName, TString objectName)
Loads another AliCaloCalibPedestal by name "objectName" from the file "fileName", for reference...
int fDeadTowers
Number of towers found dead.
TProfile * GetPedLEDRefProfileLowGain(int i)
TProfile2D * GetPeakProfileHighGainRatio(int i)
void ComputeHotAndWarningTowers(const char *hotMapFile=0)
Computes/finds the hot/noisy tower values.
double GetDeadTowerRatio() const
TObjArray fPeakMinusPedLowGainRatio
! The ratio of profiles between peak low gain and the reference object
TString fileName(const char *dir, int runNumber, const char *da, int i, const char *type)
int fModules
The number of modules.
static const int fgkPhosLEDRefs
No LED monitor channels for PHOS, set to 1 just to keep code simpler (also create LEDRef histos for P...
void ValidateComparisonProfiles()
Make sure that fPedestalLowGainDiff and fPedestalHighGainDiff profiles exist.
int fResurrectedTowers
! Towers that have been resurrected from the dead, compared to the reference
void SetAltroMapping(AliCaloAltroMapping **mapp)
TObjArray fPeakMinusPedLowGainDiff
! Difference of profiles between peak low gain and the reference object
TString fCaloString
ID for which detector type we have.
virtual ~AliCaloCalibPedestal()
Destructor.
int GetLastPedestalSample() const
void WriteParametersToFile(const char *parameterFile)
Write parameters in file.
void SetDeadMap(TObjArray map)
kDetType fDetType
The detector type for this object.
TProfile2D * GetPedProfileHighGainRatio(int i)
int fDeadThreshold
Peak - ped threshold used for dead towers evaluation.
int GetDeadTowerResurrected() const
static const int fgkPhosCols
Number of columns per module for PHOS.
TObjArray fPedestalLowGain
Pedestal info for low gain.
Bool_t IsBadChannel(int imod, int icol, int irow) const
int fColumns
The number of columns per module.
void SetRunNumber(int runNo)
TProfile2D * GetPedProfileLowGainRatio(int i)
TProfile * GetPedLEDRefProfileLowGainRatio(int i)
Bool_t GetSelectPedestalSamples() const
Get select to to use only some range of samples for pedestal calc.
TObjArray fDeadMap
The dead map.
int fRows
The number of rows per module.
void ComputeDeadTowers(const char *deadMapFile=0)
TProfile * GetPedLEDRefProfileLowGainDiff(int i)
TObjArray fPeakMinusPedHighGainHisto
(peak-pedestal TH2F) info for high gain, used for hot towers eveluation
pedestal/bad map monitoring and calibration tools
static const int fgkPhosRows
Number of rows per module for PHOS.
TObjArray fPedestalHighGainRatio
! The ratio of profiles between pedestal high gain and the reference object
Bool_t SaveHistograms(TString fileName, Bool_t saveEmptyHistos=kFALSE)
Saves all the histograms (or profiles, to be accurate) to the designated file.
TObjArray fPedestalLEDRefHighGainDiff
! Difference of profiles between pedestal LED high gain and the reference object
TProfile * GetPedLEDRefProfileHighGainRatio(int i)
static const int fgkPhosModules
Number of modules for PHOS.
int fRowMultiplier
Multiplication factor to get proper row range between PHOS and EMCAL.
int fNewDeadTowers
! Towers that have died since the reference run
void SetParametersFromFile(const char *parameterFile)
AliCaloAltroMapping ** fMapping
! Altro Mapping object
int fLastPedestalSample
Last sample to use.
AliCaloCalibPedestal * GetReference() const
Get the reference object. Needed for debug, will probably be removed later.
TProfile2D * GetPeakProfileHighGainDiff(int i)
int fNEvents
Total number of events processed,.
int fRowMax
Maximum Row number.
void Reset()
Resets arrays/histograms.
TObjArray fPedestalHighGain
Pedestal info for high gain.
int fFirstPedestalSample
first sample to use
TProfile2D * GetPedProfileHighGainDiff(int i)
TObjArray fPedestalLowGainDiff
! Difference of profiles between pedestal low gain and the reference object
TProfile2D * GetPeakProfileLowGain(int i)
TObjArray fPedestalLEDRefHighGainRatio
! The ratio of profiles between pedestal LED high gain and the reference object
void SetDeadTowerCount(Int_t dead)
TObjArray fPeakMinusPedHighGainRatio
! The ratio of profiles between peak high gain and the reference object
TString GetCaloString() const
void SetSelectPedestalSamples(Bool_t flag=kFALSE)
Set select to to use only some range of samples for pedestal calc.
int fRunNumber
The run number. Needs to be set by the user.
TObjArray fPedestalLEDRefLowGainDiff
! Difference of profiles between pedestal LED low gain and the reference object
Bool_t AddInfo(AliCaloCalibPedestal *ped)
Picks up new info from supplied argument.
AliCaloAltroMapping ** GetAltroMapping() const
int GetFirstPedestalSample() const
TProfile2D * GetPedProfileLowGainDiff(int i)
TObjArray fPedestalLEDRefLowGain
Pedestal LEDRef info for low gain.
TObjArray fPeakMinusPedLowGain
(peak-pedestal) info for low gain
Bool_t SetReference(AliCaloCalibPedestal *ref)
Set reference object.
TObjArray fPedestalLEDRefLowGainRatio
! The ratio of profiles between pedestal LED low gain and the reference object