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