1 #ifndef ALICALOCALIBSIGNAL_H
2 #define ALICALOCALIBSIGNAL_H
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice */
7 /* $Id: AliCaloCalibSignal.h $ */
9 // \file AliCaloCalibSignal.h
10 // \brief Description:
11 // A help class for monitoring and calibration tools: MOOD, AMORE etc.,
12 // that can process events from a standard AliCaloRawStream,
13 // most usually from LED/pulser runs. It stores signal info as
14 // typical (highest) amplitude vs time in TGraphs (one per channel)
15 // or TProfiles if we decide to just store the averages (and not all points)
16 // for the detectors (EMCAL and PHOS).
18 // \author: Josh Hamblen (UTenn), original version.
19 // [Consultant: D. Silvermyr (ORNL)]
20 // Partly based on AliCaloCalibPedestal.
22 // \version $Revision: $
27 class AliCaloRawStream;
28 class AliCaloAltroMapping;
30 class AliRawEventHeaderBase;
32 class AliCaloCalibSignal : public TObject {
36 enum kDetType {kPhos, kEmCal, kNone};//The detector types
38 AliCaloCalibSignal(kDetType detectorType = kPhos); //ctor
39 virtual ~AliCaloCalibSignal(); //dtor
41 // copy ctor, and '=' operator, are not fully tested/debugged yet
42 AliCaloCalibSignal(const AliCaloCalibSignal &sig); // copy ctor
43 AliCaloCalibSignal& operator = (const AliCaloCalibSignal &source); //!
45 // Event processing methods:
46 Bool_t ProcessEvent(AliRawReader *rawReader);
47 Bool_t ProcessEvent(AliCaloRawStream *in, AliRawEventHeaderBase *aliHeader); // added header for time info
48 Bool_t CheckFractionAboveAmp(int *AmpVal, int nTotChan); // check fraction of signals to check for LED events
51 AliCaloAltroMapping **GetAltroMapping() { return fMapping; };
52 void SetAltroMapping(AliCaloAltroMapping **mapp) { fMapping = mapp; };
54 ////////////////////////////
56 // need public access to the TGraphs..
57 TGraph * GetGraphAmpVsTimeHighGain(int imod, int icol, int irow) const // Return a pointer to the high gain graph
58 { int towId = GetTowerNum(imod, icol, irow); return fGraphAmpVsTimeHighGain[towId];}; //!
59 TGraph * GetGraphAmpVsTimeLowGain(int imod, int icol, int irow) const // Return a pointer to the low gain graph
60 {int towId = GetTowerNum(imod, icol, irow); return fGraphAmpVsTimeLowGain[towId];};
61 TGraph * GetGraphAmpVsTimeHighGain(int towId) const // Return a pointer to the high gain graph
62 { return fGraphAmpVsTimeHighGain[towId];}; //!
63 TGraph * GetGraphAmpVsTimeLowGain(int towId) const // Return a pointer to the low gain graph
64 { return fGraphAmpVsTimeLowGain[towId];}; //!
66 // and similarly for the TProfiles
67 TProfile * GetProfAmpVsTimeHighGain(int imod, int icol, int irow) const // Return a pointer to the high gain profile
68 { int towId = GetTowerNum(imod, icol, irow); return fProfAmpVsTimeHighGain[towId];}; //!
69 TProfile * GetProfAmpVsTimeLowGain(int imod, int icol, int irow) const // Return a pointer to the low gain profile
70 { int towId = GetTowerNum(imod, icol, irow); return fProfAmpVsTimeLowGain[towId];}; //!
71 TProfile * GetProfAmpVsTimeHighGain(int towId) const // Return a pointer to the high gain profile
72 { return fProfAmpVsTimeHighGain[towId];}; //!
73 TProfile * GetProfAmpVsTimeLowGain(int towId) const // Return a pointer to the low gain profile
74 { return fProfAmpVsTimeLowGain[towId];}; //!
76 // how many points do we have in each TGraph
77 int GetNHighGain(int imod, int icol, int irow) const //!
78 { int towId = GetTowerNum(imod, icol, irow); return fNHighGain[towId];}; //!
79 int GetNLowGain(int imod, int icol, int irow) const //!
80 { int towId = GetTowerNum(imod, icol, irow); return fNLowGain[towId];}; //!
81 int GetNHighGain(int towId) const { return fNHighGain[towId];}; //!
82 int GetNLowGain(int towId) const { return fNLowGain[towId];}; //!
84 // Basic info: getters
85 kDetType GetDetectorType() const {return fDetType;};//Returns if this is a PHOS or EMCAL object
86 TString GetCaloString() const {return fCaloString;}; //Returns if this is a PHOS or EMCAL object
88 int GetColumns() const {return fColumns;}; //The number of columns per module
89 int GetRows() const {return fRows;}; //The number of rows per module
90 int GetModules() const {return fModules;}; //The number of modules
91 int GetTowerNum(int imod, int icol, int irow) const { return imod*fColumns*fRows + icol*fRows + irow;}; // help index
94 int GetNEvents() const {return fNEvents;};
95 int GetNAcceptedEvents() const {return fNAcceptedEvents;};
97 ///////////////////////////////
99 // Section for if we should help with the event selection of what is likely LED events
100 void SetAmpCut(double d) { fAmpCut = d; } //!
101 double GetAmpCut() const { return fAmpCut; }; //!
102 void SetReqFractionAboveAmpCutVal(double d) { fReqFractionAboveAmpCutVal = d; } //!
103 double GetReqFractionAboveAmpCutVal() const { return fReqFractionAboveAmpCutVal; }; //!
104 void SetReqFractionAboveAmp(bool b) { fReqFractionAboveAmp = b; } //!
105 double GetReqFractionAboveAmp() const { return fReqFractionAboveAmp; }; //!
107 // We may select to only use the averaged info in the TProfiles rather than the
108 // the full in the TGraphs
109 void SetUseAverage(bool b) { fUseAverage = b; } //!
110 double GetUseAverage() const { return fUseAverage; }; //!
111 void SetSecInAverage(int secInAverage) {fSecInAverage = secInAverage;}; // length of the interval that should be used for the average calculation (determines number of bins in TProfile)
112 int GetSecInAverage() const {return fSecInAverage;}; //!
114 // Info on time since start of run
115 double GetHour() const { return fHour; }; // time info for current event
116 double GetCurrentHour() const { return fHour; }; // time info for current event (same as GetHour(), just more explicitly named)
117 double GetLatestHour() const { return fLatestHour; }; // the latest time encountered
118 // These times are typically the same, but not necessarily if the events do not come in order
119 void SetLatestHour(double d) { fLatestHour = d; }; // could be useful when we know the length of the run (i.e. after it is over), e.g. for PreProcessor
121 // RunNumbers : setters and getters
122 void SetRunNumber(int runNo) {fRunNumber = runNo;}; //!
123 int GetRunNumber() const {return fRunNumber;}; //!
125 // Start-of-run timestamp : set and get
126 void SetStartTime(int startTime) {fStartTime = startTime;}; //!
127 int GetStartTime() const {return fStartTime;}; //!
129 /////////////////////////////
131 void Reset();//Resets the whole class.
132 Bool_t AddInfo(const AliCaloCalibSignal *sig);//picks up new info from supplied argument
135 Bool_t Save(TString fileName, Bool_t saveEmptyGraphs = kFALSE); //Saves the TGraphs to a .root file
139 void ClearObjects(); // delete old objects and set pointers
140 void Zero(); // set all counters to 0
141 void CreateGraphs(); //! create/setup the TGraphs
142 void CreateProfile(int imod, int icol, int irow, int towerId, int gain,
143 int nbins, double min, double max); //! create/setup a TProfile
147 kDetType fDetType; //The detector type for this object
148 int fColumns; //The number of columns per module
149 int fRows; //The number of rows per module
150 int fModules; //The number of modules
151 TString fCaloString; // id for which detector type we have
152 AliCaloAltroMapping **fMapping; //! Altro Mapping object
153 int fRunNumber; //The run number. Needs to be set by the user.
154 int fStartTime; // Time of first event
156 double fAmpCut; // amplitude cut value
157 double fReqFractionAboveAmpCutVal; // required fraction that should be above cut
158 bool fReqFractionAboveAmp; // flag to select if we should do some event selection based on amplitudes
160 double fHour; // fraction of hour since beginning of run, for amp vs. time graphs, for current event
161 double fLatestHour; // largest fraction of hour since beginning of run, for amp vs. time graphs
162 bool fUseAverage; // flag to average graph points into over a time interval
163 int fSecInAverage; // time interval for the graph averaging
166 int fNEvents; // # events processed
167 int fNAcceptedEvents; // # events accepted
169 //Constants needed by the class
170 static const int fgkSampleMax = 1023; // highest possible sample value (10-bit = 0x3ff)
171 static const int fgkSampleMin = 0; // lowest possible sample value
173 static const int fgkPhosRows = 64; // number of rows per module for PHOS
174 static const int fgkPhosCols = 56; // number of columns per module for PHOS
175 static const int fgkPhosModules = 5; // number of modules for PHOS
177 static const int fgkEmCalRows = 24; // number of rows per module for EMCAL
178 static const int fgkEmCalCols = 48; // number of columns per module for EMCAL
179 static const int fgkEmCalModules = 12; // number of modules for EMCAL
181 // From numbers above: PHOS has more possible towers (17920) than EMCAL (13824)
182 // so use PHOS numbers to set max. array sizes
183 static const int fgkMaxTowers = 17920; // fgkPhosModules * fgkPhosCols * fgkPhosRows;
185 static const int fgkNumSecInHr = 3600; // number of seconds in an hour, for the fractional hour conversion on the time graph
187 TGraph *fGraphAmpVsTimeHighGain[fgkMaxTowers]; // Amplitude vs. Time Graph for each high gain channel
188 TGraph *fGraphAmpVsTimeLowGain[fgkMaxTowers]; // Amplitude vs. Time Graph for each low gain channel
189 TProfile *fProfAmpVsTimeHighGain[fgkMaxTowers]; // Amplitude vs. Time Profile for each high gain channel
190 TProfile *fProfAmpVsTimeLowGain[fgkMaxTowers]; // Amplitude vs. Time Profile for each low gain channel
192 int fNHighGain[fgkMaxTowers]; // Number of points for each Amp. vs. Time graph
193 int fNLowGain[fgkMaxTowers]; // Number of points for each Amp. vs. Time graph
195 ClassDef(AliCaloCalibSignal,1)