Line data Source code
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"
28 : class AliCaloRawStreamV3;
29 : class AliCaloAltroMapping;
30 : class AliRawReader;
31 : class AliCaloRawAnalyzer;
32 :
33 : class 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 :
42 : private:
43 : //Just declare them, avoid compilation warning
44 : AliCaloCalibSignal(const AliCaloCalibSignal & /*sig*/); // copy ctor
45 : AliCaloCalibSignal& operator = (const AliCaloCalibSignal &/*source*/); // assing operator
46 :
47 : public:
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 0 : AliCaloAltroMapping **GetAltroMapping() const { return fMapping; };
56 0 : void SetAltroMapping(AliCaloAltroMapping **mapp) { fMapping = mapp; };
57 :
58 : // Fitter / Analyzer
59 0 : Int_t GetFittingAlgorithm() const {return fFittingAlgorithm; }
60 : void SetFittingAlgorithm(Int_t val) ;
61 0 : 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 0 : TTree * GetTreeAmpVsTime() const { return fTreeAmpVsTime; } //!
71 0 : TTree * GetTreeAvgAmpVsTime() const {return fTreeAvgAmpVsTime; } //!
72 0 : TTree * GetTreeLEDAmpVsTime() const {return fTreeLEDAmpVsTime; } //!
73 0 : 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 0 : { int towId = GetTowerNum(imod, icol, irow); return fNHighGain[towId];}; //!
78 : int GetNLowGain(int imod, int icol, int irow) const //!
79 0 : { int towId = GetTowerNum(imod, icol, irow); return fNLowGain[towId];}; //!
80 0 : int GetNHighGain(int towId) const { return fNHighGain[towId];}; //!
81 0 : 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 0 : { int refId = GetRefNum(imod, istripMod, igain); return fNRef[refId];}; //!
86 0 : int GetNRef(int refId) const { return fNRef[refId];}; //!
87 :
88 : // Basic info: getters
89 0 : kDetType GetDetectorType() const {return fDetType;};//Returns if this is a PHOS or EMCAL object
90 0 : TString GetCaloString() const {return fCaloString;}; //Returns if this is a PHOS or EMCAL object
91 :
92 0 : int GetColumns() const {return fColumns;}; //The number of columns per module
93 0 : int GetRows() const {return fRows;}; //The number of rows per module
94 0 : int GetLEDRefs() const {return fLEDRefs;}; //The number of LED references/monitors per module
95 0 : int GetModules() const {return fModules;}; //The number of modules
96 :
97 0 : int GetTowerNum(const int imod, const int icol, const int irow) const { return (imod*fColumns*fRows + icol*fRows + irow);}; // help index
98 :
99 0 : 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 0 : 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 0 : int GetNEvents() const {return fNEvents;};
112 0 : 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 0 : void SetAmpCut(double d) { fAmpCut = d; } //!
118 0 : double GetAmpCut() const { return fAmpCut; }; //!
119 0 : void SetReqFractionAboveAmpCutVal(double d) { fReqFractionAboveAmpCutVal = d; } //!
120 0 : double GetReqFractionAboveAmpCutVal() const { return fReqFractionAboveAmpCutVal; }; //!
121 0 : void SetReqFractionAboveAmp(bool b) { fReqFractionAboveAmp = b; } //!
122 0 : bool GetReqFractionAboveAmp() const { return fReqFractionAboveAmp; }; //!
123 : // also for LED Reference/Mon channels
124 0 : void SetAmpCutLEDRef(double d) { fAmpCutLEDRef = d; } //!
125 0 : double GetAmpCutLEDRef() const { return fAmpCutLEDRef; }; //!
126 0 : void SetReqLEDRefAboveAmpCutVal(bool b) { fReqLEDRefAboveAmpCutVal = b; } //!
127 0 : bool GetReqLEDRefAboveAmpCutVal() const { return fReqLEDRefAboveAmpCutVal; }; //!
128 :
129 : // We may select to get averaged info
130 0 : void SetUseAverage(bool b) { fUseAverage = b; } //!
131 0 : bool GetUseAverage() const { return fUseAverage; }; //!
132 0 : 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 0 : int GetSecInAverage() const {return fSecInAverage;}; //!
134 :
135 0 : void SetDownscale(int i) {fDownscale = i;}; //!
136 0 : int GetDownscale() const {return fDownscale;}; //!
137 :
138 : // Info on time since start of run
139 0 : double GetHour() const { return fHour; }; // time info for current event
140 0 : double GetCurrentHour() const { return fHour; }; // time info for current event (same as GetHour(), just more explicitly named)
141 0 : 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 0 : 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 0 : void SetRunNumber(int runNo) {fRunNumber = runNo;}; //!
147 0 : int GetRunNumber() const {return fRunNumber;}; //!
148 :
149 : // Start-of-run timestamp : set and get
150 0 : void SetStartTime(int startTime) {fStartTime = startTime;}; //!
151 0 : 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: EMCal+DCal has more possible towers than PHOS
207 : static const int fgkMaxTowers = 23040;// AliEMCALGeoParams::fgkEMCALModules * AliEMCALGeoParams::fgkEMCALCols * AliEMCALGeoParams::fgkEMCALRows;
208 : // for LED references; maximum from EMCAL
209 : static const int fgkMaxRefs = 480; // AliEMCALGeoParams::fgkEMCALModules * AliEMCALGeoParams::fgkEMCALLEDRefs;
210 :
211 : static const int fgkNumSecInHr = 3600; // number of seconds in an hour, for the fractional hour conversion on the time graph
212 :
213 : // trees
214 : TTree *fTreeAmpVsTime; // stores channel, gain, amp, and time info
215 : TTree *fTreeAvgAmpVsTime; // same, for averages
216 : TTree *fTreeLEDAmpVsTime; // same, for LED reference
217 : TTree *fTreeLEDAvgAmpVsTime; // same, for LED reference - averages
218 :
219 : // counters
220 : int fNHighGain[fgkMaxTowers]; // Number of Amp. vs. Time readings per tower
221 : int fNLowGain[fgkMaxTowers]; // same, for low gain
222 : int fNRef[fgkMaxRefs * 2]; // same, for LED refs; *2 for both gains
223 :
224 42 : ClassDef(AliCaloCalibSignal, 9) // don't forget to change version if you change class member list..
225 :
226 : };
227 :
228 : #endif
|