]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - EMCAL/AliCaloCalibSignal.h
Implement comparison of sim and rec CDB's, by default for the TPC/RecoParam only
[u/mrichter/AliRoot.git] / EMCAL / AliCaloCalibSignal.h
... / ...
CommitLineData
1#ifndef ALICALOCALIBSIGNAL_H
2#define ALICALOCALIBSIGNAL_H
3
4/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice */
6
7/* $Id: AliCaloCalibSignal.h $ */
8
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 AliCaloRawStreamV3,
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).
17
18// \author: Josh Hamblen (UTenn), original version.
19// [Consultant: D. Silvermyr (ORNL)]
20// Partly based on AliCaloCalibPedestal.
21//
22// \version $Revision: $
23// \date $Date: $
24
25#include "TString.h"
26#include "TTree.h"
27#include "AliEMCALGeoParams.h"
28class AliCaloRawStreamV3;
29class AliCaloAltroMapping;
30class AliRawReader;
31class AliCaloRawAnalyzer;
32
33class AliCaloCalibSignal : public TObject {
34
35 public:
36
37 enum kDetType {kPhos, kEmCal, kNone};//The detector types
38
39 AliCaloCalibSignal(kDetType detectorType = kPhos); //ctor
40 virtual ~AliCaloCalibSignal(); //dtor
41
42private:
43 //Just declare them, avoid compilation warning
44 AliCaloCalibSignal(const AliCaloCalibSignal & /*sig*/); // copy ctor
45 AliCaloCalibSignal& operator = (const AliCaloCalibSignal &/*source*/); // assing operator
46
47public:
48 // Event processing methods:
49 Bool_t ProcessEvent(AliRawReader *rawReader);
50 Bool_t ProcessEvent(AliCaloRawStreamV3 *in, UInt_t Timestamp); // added header for time info
51 Bool_t CheckFractionAboveAmp(const int *AmpVal, int resultArray[]) const; // check fraction of signals to check for LED events
52 Bool_t CheckLEDRefAboveAmp(const int *AmpVal, int resultArray[]) const; // check if LED Ref is also above cut
53
54 // Mapping handling
55 AliCaloAltroMapping **GetAltroMapping() const { return fMapping; };
56 void SetAltroMapping(AliCaloAltroMapping **mapp) { fMapping = mapp; };
57
58 // Fitter / Analyzer
59 Int_t GetFittingAlgorithm() const {return fFittingAlgorithm; }
60 void SetFittingAlgorithm(Int_t val) ;
61 AliCaloRawAnalyzer *GetRawAnalyzer() const { return fRawAnalyzer;}
62
63 // Parameter/cut handling
64 void SetParametersFromFile(const char *parameterFile);
65 void WriteParametersToFile(const char *parameterFile);
66
67 ////////////////////////////
68 //Simple getters
69 // for TTree
70 TTree * GetTreeAmpVsTime() const { return fTreeAmpVsTime; } //!
71 TTree * GetTreeAvgAmpVsTime() const {return fTreeAvgAmpVsTime; } //!
72 TTree * GetTreeLEDAmpVsTime() const {return fTreeLEDAmpVsTime; } //!
73 TTree * GetTreeLEDAvgAmpVsTime() const {return fTreeLEDAvgAmpVsTime; } //!
74
75 // how many points do we have for each tower&gain
76 int GetNHighGain(int imod, int icol, int irow) const //!
77 { int towId = GetTowerNum(imod, icol, irow); return fNHighGain[towId];}; //!
78 int GetNLowGain(int imod, int icol, int irow) const //!
79 { int towId = GetTowerNum(imod, icol, irow); return fNLowGain[towId];}; //!
80 int GetNHighGain(int towId) const { return fNHighGain[towId];}; //!
81 int GetNLowGain(int towId) const { return fNLowGain[towId];}; //!
82
83 // also for LED reference
84 int GetNRef(const int imod, const int istripMod, const int igain) const //!
85 { int refId = GetRefNum(imod, istripMod, igain); return fNRef[refId];}; //!
86 int GetNRef(int refId) const { return fNRef[refId];}; //!
87
88 // Basic info: getters
89 kDetType GetDetectorType() const {return fDetType;};//Returns if this is a PHOS or EMCAL object
90 TString GetCaloString() const {return fCaloString;}; //Returns if this is a PHOS or EMCAL object
91
92 int GetColumns() const {return fColumns;}; //The number of columns per module
93 int GetRows() const {return fRows;}; //The number of rows per module
94 int GetLEDRefs() const {return fLEDRefs;}; //The number of LED references/monitors per module
95 int GetModules() const {return fModules;}; //The number of modules
96
97 int GetTowerNum(const int imod, const int icol, const int irow) const { return (imod*fColumns*fRows + icol*fRows + irow);}; // help index
98
99 int GetChannelNum(const int imod, const int icol, const int irow, const int igain) const { return (igain*fModules*fColumns*fRows + imod*fColumns*fRows + icol*fRows + irow);}; // channel number with gain included
100
101 Bool_t DecodeChannelNum(const int chanId,
102 int *imod, int *icol, int *irow, int *igain) const; // return the module, column, row, and gain for a given channel number
103
104 // LED reference indexing
105 int GetRefNum(const int imod, const int istripMod, const int igain) const { return (igain*fModules*fLEDRefs + imod*fLEDRefs + istripMod);}; // channel number with gain included
106
107 Bool_t DecodeRefNum(const int refId,
108 int *imod, int *istripMod, int *igain) const; // return the module, stripModule, and gain for a given reference number
109
110 // Basic Counters
111 int GetNEvents() const {return fNEvents;};
112 int GetNAcceptedEvents() const {return fNAcceptedEvents;};
113
114 ///////////////////////////////
115 // Get and Set Cuts
116 // Section for if we should help with the event selection of what is likely LED events
117 void SetAmpCut(double d) { fAmpCut = d; } //!
118 double GetAmpCut() const { return fAmpCut; }; //!
119 void SetReqFractionAboveAmpCutVal(double d) { fReqFractionAboveAmpCutVal = d; } //!
120 double GetReqFractionAboveAmpCutVal() const { return fReqFractionAboveAmpCutVal; }; //!
121 void SetReqFractionAboveAmp(bool b) { fReqFractionAboveAmp = b; } //!
122 bool GetReqFractionAboveAmp() const { return fReqFractionAboveAmp; }; //!
123 // also for LED Reference/Mon channels
124 void SetAmpCutLEDRef(double d) { fAmpCutLEDRef = d; } //!
125 double GetAmpCutLEDRef() const { return fAmpCutLEDRef; }; //!
126 void SetReqLEDRefAboveAmpCutVal(bool b) { fReqLEDRefAboveAmpCutVal = b; } //!
127 bool GetReqLEDRefAboveAmpCutVal() const { return fReqLEDRefAboveAmpCutVal; }; //!
128
129 // We may select to get averaged info
130 void SetUseAverage(bool b) { fUseAverage = b; } //!
131 bool GetUseAverage() const { return fUseAverage; }; //!
132 void SetSecInAverage(int secInAverage) {fSecInAverage = secInAverage;}; // length of the interval that should be used for the average calculation (determines number of bins in TProfile)
133 int GetSecInAverage() const {return fSecInAverage;}; //!
134
135 void SetDownscale(int i) {fDownscale = i;}; //!
136 int GetDownscale() const {return fDownscale;}; //!
137
138 // Info on time since start of run
139 double GetHour() const { return fHour; }; // time info for current event
140 double GetCurrentHour() const { return fHour; }; // time info for current event (same as GetHour(), just more explicitly named)
141 double GetLatestHour() const { return fLatestHour; }; // the latest time encountered
142 // These times are typically the same, but not necessarily if the events do not come in order
143 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
144
145 // RunNumbers : setters and getters
146 void SetRunNumber(int runNo) {fRunNumber = runNo;}; //!
147 int GetRunNumber() const {return fRunNumber;}; //!
148
149 // Start-of-run timestamp : set and get
150 void SetStartTime(int startTime) {fStartTime = startTime;}; //!
151 int GetStartTime() const {return fStartTime;}; //!
152
153 /////////////////////////////
154 //Analysis functions
155 void ResetInfo();// trees and counters.
156 Bool_t AddInfo(const AliCaloCalibSignal *sig);//picks up new info from supplied argument
157
158 //Saving functions
159 Bool_t Save(TString fileName); //Saves the objects to a .root file
160 Bool_t Analyze(); // makes average tree and summary tree
161
162 private:
163
164 void DeleteTrees(); // delete old objects and set pointers
165 void Zero(); // set all counters to 0
166 void CreateTrees(); //! create/setup the TTrees
167
168 private:
169
170 kDetType fDetType; //The detector type for this object
171 int fColumns; //The number of columns per module
172 int fRows; //The number of rows per module
173 int fLEDRefs; //The number of LED references/monitors per module
174 int fModules; //The number of modules
175 TString fCaloString; // id for which detector type we have
176 AliCaloAltroMapping **fMapping; //! Altro Mapping object
177 Int_t fFittingAlgorithm; // select the fitting algorithm
178 AliCaloRawAnalyzer *fRawAnalyzer; //! e.g. for sample selection for fits
179 int fRunNumber; //The run number. Needs to be set by the user.
180 int fStartTime; // Time of first event
181
182 double fAmpCut; // amplitude cut value
183 double fReqFractionAboveAmpCutVal; // required fraction that should be above cut
184 bool fReqFractionAboveAmp; // flag to select if we should do some event selection based on amplitudes
185
186 double fAmpCutLEDRef; // amplitude cut value for LED reference
187 bool fReqLEDRefAboveAmpCutVal; // flag to select if we should require that signal is also seen in LED Reference/Monitoring channel
188
189 double fHour; // fraction of hour since beginning of run, for amp vs. time graphs, for current event
190 double fLatestHour; // largest fraction of hour since beginning of run, for amp vs. time graphs
191 bool fUseAverage; // flag to average graph points into over a time interval
192 int fSecInAverage; // time interval for the graph averaging
193
194 int fDownscale; // to select 1 out every N (fDownscale) events
195
196 // status counters
197 int fNEvents; // # events processed
198 int fNAcceptedEvents; // # events accepted
199
200 //Constants needed by the class: EMCAL ones are kept in AliEMCALGeoParams.h
201 static const int fgkPhosRows = 64; // number of rows per module for PHOS
202 static const int fgkPhosCols = 56; // number of columns per module for PHOS
203 static const int fgkPhosLEDRefs = 0; // no LED monitor channels for PHOS
204 static const int fgkPhosModules = 5; // number of modules for PHOS
205
206 // From numbers above: PHOS has more possible towers (17920) than EMCAL (13824)
207 // so use PHOS numbers to set max. array sizes
208 static const int fgkMaxTowers = 17920; // fgkPhosModules * fgkPhosCols * fgkPhosRows;
209 // for LED references; maximum from EMCAL
210 static const int fgkMaxRefs = 288; // AliEMCALGeoParams::fgkEMCALModules * AliEMCALGeoParams::fgkEMCALLEDRefs
211
212 static const int fgkNumSecInHr = 3600; // number of seconds in an hour, for the fractional hour conversion on the time graph
213
214 // trees
215 TTree *fTreeAmpVsTime; // stores channel, gain, amp, and time info
216 TTree *fTreeAvgAmpVsTime; // same, for averages
217 TTree *fTreeLEDAmpVsTime; // same, for LED reference
218 TTree *fTreeLEDAvgAmpVsTime; // same, for LED reference - averages
219
220 // counters
221 int fNHighGain[fgkMaxTowers]; // Number of Amp. vs. Time readings per tower
222 int fNLowGain[fgkMaxTowers]; // same, for low gain
223 int fNRef[fgkMaxRefs * 2]; // same, for LED refs; *2 for both gains
224
225 ClassDef(AliCaloCalibSignal, 8) // don't forget to change version if you change class member list..
226
227};
228
229#endif