New macro for visualization of the HMPID clusters (Jouri)
[u/mrichter/AliRoot.git] / EMCAL / AliCaloCalibPedestal.h
CommitLineData
356c3e0c 1#ifndef ALICALOCALIBPEDESTAL_H
2#define ALICALOCALIBPEDESTAL_H
3
4/* \file AliCaloCalibPedestal.h
5 \brief Description:
6 A help class for monitoring and calibration tools: MOOD, AMORE etc.,
7 that can process events from a standard AliCaloRawStream,
8 most usually from LED/pulser runs. It stores signal info as
9 typical (highest) amplitude, and pedestal info in geometrically-binned
10 2D profiles of the detectors (EMCAL and PHOS).
11 Comparisons (ratios and differences) can be done with references.
12
13 \author: Timo Alho (Jyvaskyla), original version.
14 [Consultant: D. Silvermyr (ORNL)]
15 Partly based on AliTPCCalibPedestal.
16
17 \version $Revision$
18 \date $Date$
19*/
20
21#include "TProfile2D.h"
22#include "TH2.h"
23#include "TObjArray.h"
24#include "AliCaloRawStream.h"
25
26class AliCaloCalibPedestal : public TObject {
27
28 public:
29
30 enum kDetType {kPhos, kEmCal, kNone};//The detector types
31 enum kDeadMapEntry{kAlive = 0, kDead, kResurrected, kRecentlyDeceased, kNumDeadMapStates};//The entries being put to the deadmap
32
33 AliCaloCalibPedestal(kDetType detectorType = kPhos);
34 virtual ~AliCaloCalibPedestal();
35
36 // copy ctor, and '=' operator, are not fully tested/debugged yet
37 // at least for now; the reference info is not copied from one to the other
38 AliCaloCalibPedestal(const AliCaloCalibPedestal &ped);
39 AliCaloCalibPedestal& operator = (const AliCaloCalibPedestal &source);
40
41 //Functions to ask for the constants (in case a GUI needs them, for an example
42 static const int GetSampleMax() {return fgkSampleMax;};
43 static const int GetSampleMin() {return fgkSampleMin;};
44
45 Bool_t ProcessEvent(AliCaloRawStream *in);
46
47 ////////////////////////////
48 //Simple getters
49 // Main profiles:
50 TProfile2D * GetPedProfileLowGain(int i) const {return (TProfile2D*)fPedestalLowGain[i];}; // Return a pointer to the low-gain pedestal profile
51 TProfile2D * GetPedProfileHighGain(int i) const {return (TProfile2D*)fPedestalHighGain[i];}; // Return a pointer to the high-gain pedestal profile
52 TProfile2D * GetPeakProfileLowGain(int i) const {return (TProfile2D*)fPeakMinusPedLowGain[i];}; // Return a pointer to the low-gain pedestal profile
53 TProfile2D * GetPeakProfileHighGain(int i) const {return (TProfile2D*)fPeakMinusPedHighGain[i];}; // Return a pointer to the high-gain pedestal profile
54
55 // Differences to references:
56 TProfile2D * GetPedProfileLowGainDiff(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPedestalLowGainDiff[i];}; // Return a pointer to the low-gain pedestal profile difference
57 TProfile2D * GetPedProfileHighGainDiff(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPedestalHighGainDiff[i];}; // Return a pointer to the high-gain pedestal profile difference
58 TProfile2D * GetPeakProfileLowGainDiff(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPeakMinusPedLowGainDiff[i];}; // Return a pointer to the low-gain pedestal profile difference
59 TProfile2D * GetPeakProfileHighGainDiff(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPeakMinusPedHighGainDiff[i];}; // Return a pointer to the high-gain pedestal profile difference
60
61 // Ratio to references:
62 TProfile2D * GetPedProfileLowGainRatio(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPedestalLowGainRatio[i];}; // Return a pointer to the low-gain pedestal profile ratio
63 TProfile2D * GetPedProfileHighGainRatio(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPedestalHighGainRatio[i];}; // Return a pointer to the high-gain pedestal profile ratio
64 TProfile2D * GetPeakProfileLowGainRatio(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPeakMinusPedLowGainRatio[i];}; // Return a pointer to the low-gain pedestal profile ratio
65 TProfile2D * GetPeakProfileHighGainRatio(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPeakMinusPedHighGainRatio[i];}; // Return a pointer to the high-gain pedestal profile ratio
66
67 TH2D * GetDeadMap(int i) const {return (TH2D*)fDeadMap[i];};
68
69 // Basic info: getters
70 kDetType GetDetectorType() const {return fDetType;};//Returns if this is a PHOS or EMCAL object
71
72 int GetColumns() const {return fColumns;}; //The number of columns per module
73 int GetRows() const {return fRows;}; //The number of rows per module
74 int GetModules() const {return fModules;}; //The number of modules
75
76 // RunNumbers : setters and getters
77 void SetRunNumber(int runNo) {fRunNumber = runNo;};
78 int GetRunNumber() const {return fRunNumber;};
79 int GetRefRunNumber() const {if (fReference) return fReference->GetRunNumber(); else return -1;};
80
81 /////////////////////////////
82 //Analysis functions
83 int GetDeadTowerCount() const {return fDeadTowers;};//Returns the number of dead towers, by counting the bins in peak-pedestal smaller than threshold
84 double GetDeadTowerRatio() const {return fDeadTowers/(double)(fRows*fColumns);}; //returns the percentage of dead towers, relative to a full module
85 int GetDeadTowerNew() const {return fNewDeadTowers;}; //return the new dead towers compared to the reference
86 int GetDeadTowerResurrected() const {return fResurrectedTowers;}; //The the towers resurrected since the reference run
87 void Reset();//Resets the whole class.
88
89 //////////////////////////////////////////////////////
90 //Functions related to comparing this with another (reference) run.
91 Bool_t LoadReferenceCalib(TString fileName, TString objectName); //Loads another AliCaloCalibPedestal by name "objectName" from the file "fileName", for reference
92 void ComputeDiffAndRatio();//Actually computes the difference and ratio into the histo's in memory
93 AliCaloCalibPedestal * GetReference() const {return fReference;}; //Get the reference object. Needed for debug, will probably be removed later
94 void ComputeDeadTowers(int threshold = 5, const char * deadMapFile = 0);//Computes the dead tower values
95
96
97 //Saving functions
98 Bool_t SaveHistograms(TString fileName, Bool_t saveEmptyHistos = kFALSE); //Saves the histograms to a .root file
99
100 private:
101
102 void ValidateComparisonProfiles(); //Makes sure that fPe..Diff and fPe..Ratio profiles exist
103
104 //The histograms. We use a TObjArray instead of a simple array,because this gives automatic streaming properties for the
105 //class. A TClonesArray would be more efficient, but it's a bit more difficult to use and it doesn't matter too much
106 //since we have only around 12 objects (maximum) in the array anyway.
107 TObjArray fPedestalLowGain;
108 TObjArray fPedestalHighGain;
109 TObjArray fPeakMinusPedLowGain;
110 TObjArray fPeakMinusPedHighGain;
111
112 //The difference of profiles between this and the reference object
113 TObjArray fPedestalLowGainDiff; //!
114 TObjArray fPedestalHighGainDiff; //!
115 TObjArray fPeakMinusPedLowGainDiff; //!
116 TObjArray fPeakMinusPedHighGainDiff; //!
117
118 //The ratio of profiles between this and the reference object
119 TObjArray fPedestalLowGainRatio; //!
120 TObjArray fPedestalHighGainRatio; //!
121 TObjArray fPeakMinusPedLowGainRatio; //!
122 TObjArray fPeakMinusPedHighGainRatio; //!
123
124 TObjArray fDeadMap;//The deadmap
125
126 //The dead tower counts
127 int fDeadTowers; //!
128 int fNewDeadTowers; //! Towers that have died since the reference run
129 int fResurrectedTowers; //! Towers that have been resurrected from the dead, compared to the reference
130
131 AliCaloCalibPedestal * fReference; //! A reference object, for comparing the accumulated results to a previous run
132
133 kDetType fDetType; //The detector type for this object
134 int fColumns; //The number of columns per module
135 int fRows; //The number of rows per module
136 int fModules; //The number of modules
137 int fRunNumber; //The run number. Needs to be set by the user.
138
139 //Constants needed by the class
140 static const int fgkSampleMax = 1023;
141 static const int fgkSampleMin = 0;
142
143 static const int fgkPhosRows = 64;
144 static const int fgkPhosCols = 56;
145 static const int fgkPhosModules = 5;
146
147 static const int fgkEmCalRows = 24;
148 static const int fgkEmCalCols = 48;
149 static const int fgkEmCalModules = 12;
150
151
152 public:
153
154 ClassDef(AliCaloCalibPedestal,1)
155
156};
157
158#endif