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 AliCaloRawStream,
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 class AliCaloRawStream;
30 class AliCaloAltroMapping;
33 class AliCaloCalibPedestal : public TObject {
37 enum kDetType {kPhos, kEmCal, kNone};//The detector types
38 enum kDeadMapEntry{kAlive = 0, kDead, kResurrected, kRecentlyDeceased, kNumDeadMapStates};//The entries being put to the deadmap
40 AliCaloCalibPedestal(kDetType detectorType = kPhos);
41 virtual ~AliCaloCalibPedestal();
43 // copy ctor, and '=' operator, are not fully tested/debugged yet
44 // at least for now; the reference info is not copied from one to the other
45 AliCaloCalibPedestal(const AliCaloCalibPedestal &ped);
46 AliCaloCalibPedestal& operator = (const AliCaloCalibPedestal &source);
48 //Functions to ask for the constants (in case a GUI needs them, for an example
49 static const int GetSampleMax() {return fgkSampleMax;};
50 static const int GetSampleMin() {return fgkSampleMin;};
52 // Event processing methods:
53 Bool_t ProcessEvent(AliRawReader *rawReader);
54 Bool_t ProcessEvent(AliCaloRawStream *in);
57 AliCaloAltroMapping **GetAltroMapping() { return fMapping; };
58 void SetAltroMapping(AliCaloAltroMapping **mapp) { fMapping = mapp; };
60 ////////////////////////////
63 TProfile2D * GetPedProfileLowGain(int i) const {return (TProfile2D*)fPedestalLowGain[i];}; // Return a pointer to the low-gain pedestal profile
64 TProfile2D * GetPedProfileHighGain(int i) const {return (TProfile2D*)fPedestalHighGain[i];}; // Return a pointer to the high-gain pedestal profile
65 TProfile2D * GetPeakProfileLowGain(int i) const {return (TProfile2D*)fPeakMinusPedLowGain[i];}; // Return a pointer to the low-gain pedestal profile
66 TProfile2D * GetPeakProfileHighGain(int i) const {return (TProfile2D*)fPeakMinusPedHighGain[i];}; // Return a pointer to the high-gain pedestal profile
68 // Differences to references:
69 TProfile2D * GetPedProfileLowGainDiff(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPedestalLowGainDiff[i];}; // Return a pointer to the low-gain pedestal profile difference
70 TProfile2D * GetPedProfileHighGainDiff(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPedestalHighGainDiff[i];}; // Return a pointer to the high-gain pedestal profile difference
71 TProfile2D * GetPeakProfileLowGainDiff(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPeakMinusPedLowGainDiff[i];}; // Return a pointer to the low-gain pedestal profile difference
72 TProfile2D * GetPeakProfileHighGainDiff(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPeakMinusPedHighGainDiff[i];}; // Return a pointer to the high-gain pedestal profile difference
74 // Ratio to references:
75 TProfile2D * GetPedProfileLowGainRatio(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPedestalLowGainRatio[i];}; // Return a pointer to the low-gain pedestal profile ratio
76 TProfile2D * GetPedProfileHighGainRatio(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPedestalHighGainRatio[i];}; // Return a pointer to the high-gain pedestal profile ratio
77 TProfile2D * GetPeakProfileLowGainRatio(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPeakMinusPedLowGainRatio[i];}; // Return a pointer to the low-gain pedestal profile ratio
78 TProfile2D * GetPeakProfileHighGainRatio(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPeakMinusPedHighGainRatio[i];}; // Return a pointer to the high-gain pedestal profile ratio
80 TH2D * GetDeadMap(int i) const {return (TH2D*)fDeadMap[i];};
82 // Basic info: getters
83 kDetType GetDetectorType() const {return fDetType;};//Returns if this is a PHOS or EMCAL object
84 TString GetCaloString() const {return fCaloString;}; //Returns if this is a PHOS or EMCAL object
86 int GetColumns() const {return fColumns;}; //The number of columns per module
87 int GetRows() const {return fRows;}; //The number of rows per module
88 int GetModules() const {return fModules;}; //The number of modules
90 // RunNumbers : setters and getters
91 void SetRunNumber(int runNo) {fRunNumber = runNo;};
92 int GetRunNumber() const {return fRunNumber;};
93 int GetRefRunNumber() const {if (fReference) return fReference->GetRunNumber(); else return -1;};
96 int GetNEvents() const {return fNEvents;};
97 int GetNChanFills() const {return fNChanFills;};
99 /////////////////////////////
101 int GetDeadTowerCount() const {return fDeadTowers;};//Returns the number of dead towers, by counting the bins in peak-pedestal smaller than threshold
102 double GetDeadTowerRatio() const {return fDeadTowers/(double)(fRows*fColumns);}; //returns the percentage of dead towers, relative to a full module
103 int GetDeadTowerNew() const {return fNewDeadTowers;}; //return the new dead towers compared to the reference
104 int GetDeadTowerResurrected() const {return fResurrectedTowers;}; //The the towers resurrected since the reference run
106 void Reset();//Resets the whole class.
107 Bool_t AddInfo(const AliCaloCalibPedestal *ped);//picks up new info from supplied argument
109 //////////////////////////////////////////////////////
110 //Functions related to comparing this with another (reference) run.
111 Bool_t LoadReferenceCalib(TString fileName, TString objectName); //Loads another AliCaloCalibPedestal by name "objectName" from the file "fileName", for reference
112 void ComputeDiffAndRatio();//Actually computes the difference and ratio into the histo's in memory
113 AliCaloCalibPedestal * GetReference() const {return fReference;}; //Get the reference object. Needed for debug, will probably be removed later
114 void ComputeDeadTowers(int threshold = 5, const char * deadMapFile = 0);//Computes the dead tower values
118 Bool_t SaveHistograms(TString fileName, Bool_t saveEmptyHistos = kFALSE); //Saves the histograms to a .root file
122 void ValidateComparisonProfiles(); //Makes sure that fPe..Diff and fPe..Ratio profiles exist
124 //The histograms. We use a TObjArray instead of a simple array,because this gives automatic streaming properties for the
125 //class. A TClonesArray would be more efficient, but it's a bit more difficult to use and it doesn't matter too much
126 //since we have only around 12 objects (maximum) in the array anyway.
127 TObjArray fPedestalLowGain; // pedestal info for low gain
128 TObjArray fPedestalHighGain; // pedestal info for high gain
129 TObjArray fPeakMinusPedLowGain; // (peak-pedestal) info for low gain
130 TObjArray fPeakMinusPedHighGain; // (peak-pedestal) info for high gain
132 //The difference of profiles between this and the reference object
133 TObjArray fPedestalLowGainDiff; //!
134 TObjArray fPedestalHighGainDiff; //!
135 TObjArray fPeakMinusPedLowGainDiff; //!
136 TObjArray fPeakMinusPedHighGainDiff; //!
138 //The ratio of profiles between this and the reference object
139 TObjArray fPedestalLowGainRatio; //!
140 TObjArray fPedestalHighGainRatio; //!
141 TObjArray fPeakMinusPedLowGainRatio; //!
142 TObjArray fPeakMinusPedHighGainRatio; //!
144 TObjArray fDeadMap;//The deadmap
147 int fNEvents; //# total events processed,
148 int fNChanFills; //# total channel fills (NChan * NEvents if not zero-suppressed)
150 //The dead tower counts
152 int fNewDeadTowers; //! Towers that have died since the reference run
153 int fResurrectedTowers; //! Towers that have been resurrected from the dead, compared to the reference
155 AliCaloCalibPedestal * fReference; //! A reference object, for comparing the accumulated results to a previous run
157 kDetType fDetType; //The detector type for this object
158 int fColumns; //The number of columns per module
159 int fRows; //The number of rows per module
160 int fModules; //The number of modules
161 TString fCaloString; // id for which detector type we have
162 AliCaloAltroMapping **fMapping; //! Altro Mapping object
163 int fRunNumber; //The run number. Needs to be set by the user.
165 //Constants needed by the class
166 static const int fgkSampleMax = 1023; // highest possible sample value (10-bit = 0x3ff)
167 static const int fgkSampleMin = 0; // lowest possible sample value
169 static const int fgkPhosRows = 64; // number of rows per module for PHOS
170 static const int fgkPhosCols = 56; // number of columns per module for PHOS
171 static const int fgkPhosModules = 5; // number of modules for PHOS
173 static const int fgkEmCalRows = 24; // number of rows per module for EMCAL
174 static const int fgkEmCalCols = 48; // number of columns per module for EMCAL
175 static const int fgkEmCalModules = 12; // number of modules for EMCAL
177 ClassDef(AliCaloCalibPedestal,1)