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