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