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 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).
18 // \author: Josh Hamblen (UTenn), original version.
19 // [Consultant: D. Silvermyr (ORNL)]
20 // Partly based on AliCaloCalibPedestal.
22 // \version $Revision: $
27 #include "AliEMCALGeoParams.h"
28 class AliCaloRawStreamV3;
29 class AliCaloAltroMapping;
31 class AliRawEventHeaderBase;
33 class AliCaloCalibSignal : public TObject {
37 enum kDetType {kPhos, kEmCal, kNone};//The detector types
39 AliCaloCalibSignal(kDetType detectorType = kPhos); //ctor
40 virtual ~AliCaloCalibSignal(); //dtor
42 // copy ctor, and '=' operator, are not fully tested/debugged yet
43 AliCaloCalibSignal(const AliCaloCalibSignal &sig); // copy ctor
44 AliCaloCalibSignal& operator = (const AliCaloCalibSignal &source); //!
46 // Event processing methods:
47 Bool_t ProcessEvent(AliRawReader *rawReader);
48 Bool_t ProcessEvent(AliCaloRawStreamV3 *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
52 AliCaloAltroMapping **GetAltroMapping() { return fMapping; };
53 void SetAltroMapping(AliCaloAltroMapping **mapp) { fMapping = mapp; };
55 ////////////////////////////
58 TTree * GetTreeAmpVsTime() const { return fTreeAmpVsTime; } //!
59 TTree * GetTreeAvgAmpVsTime() const {return fTreeAvgAmpVsTime; } //!
60 TTree * GetTreeLEDAmpVsTime() const {return fTreeLEDAmpVsTime; } //!
61 TTree * GetTreeLEDAvgAmpVsTime() const {return fTreeLEDAvgAmpVsTime; } //!
63 // how many points do we have for each tower&gain
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];}; //!
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];}; //!
76 // Basic info: getters
77 kDetType GetDetectorType() const {return fDetType;};//Returns if this is a PHOS or EMCAL object
78 TString GetCaloString() const {return fCaloString;}; //Returns if this is a PHOS or EMCAL object
80 int GetColumns() const {return fColumns;}; //The number of columns per module
81 int GetRows() const {return fRows;}; //The number of rows per module
82 int GetLEDRefs() const {return fLEDRefs;}; //The number of LED references/monitors per module
83 int GetModules() const {return fModules;}; //The number of modules
84 int GetTowerNum(int imod, int icol, int irow) const { return (imod*fColumns*fRows + icol*fRows + irow);}; // help index
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
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;
94 }; // return the module, column, row, and gain for a given channel number
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
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;
104 }; // return the module, stripModule, and gain for a given reference number
107 int GetNEvents() const {return fNEvents;};
108 int GetNAcceptedEvents() const {return fNAcceptedEvents;};
110 ///////////////////////////////
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; } //!
118 bool GetReqFractionAboveAmp() const { return fReqFractionAboveAmp; }; //!
120 // We may select to get averaged info
121 void SetUseAverage(bool b) { fUseAverage = b; } //!
122 bool GetUseAverage() const { return fUseAverage; }; //!
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;}; //!
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
133 // RunNumbers : setters and getters
134 void SetRunNumber(int runNo) {fRunNumber = runNo;}; //!
135 int GetRunNumber() const {return fRunNumber;}; //!
137 // Start-of-run timestamp : set and get
138 void SetStartTime(int startTime) {fStartTime = startTime;}; //!
139 int GetStartTime() const {return fStartTime;}; //!
141 /////////////////////////////
143 void ResetInfo();// trees and counters.
144 Bool_t AddInfo(const AliCaloCalibSignal *sig);//picks up new info from supplied argument
147 Bool_t Save(TString fileName); //Saves the objects to a .root file
148 Bool_t Analyze(); // makes average tree and summary tree
152 void DeleteTrees(); // delete old objects and set pointers
153 void Zero(); // set all counters to 0
154 void CreateTrees(); //! create/setup the TTrees
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
161 int fLEDRefs; //The number of LED references/monitors per module
162 int fModules; //The number of modules
163 TString fCaloString; // id for which detector type we have
164 AliCaloAltroMapping **fMapping; //! Altro Mapping object
165 int fRunNumber; //The run number. Needs to be set by the user.
166 int fStartTime; // Time of first event
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
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
178 int fNEvents; // # events processed
179 int fNAcceptedEvents; // # events accepted
181 //Constants needed by the class: EMCAL ones are kept in AliEMCALGeoParams.h
182 static const int fgkPhosRows = 64; // number of rows per module for PHOS
183 static const int fgkPhosCols = 56; // number of columns per module for PHOS
184 static const int fgkPhosLEDRefs = 0; // no LED monitor channels for PHOS
185 static const int fgkPhosModules = 5; // number of modules for PHOS
187 // From numbers above: PHOS has more possible towers (17920) than EMCAL (13824)
188 // so use PHOS numbers to set max. array sizes
189 static const int fgkMaxTowers = 17920; // fgkPhosModules * fgkPhosCols * fgkPhosRows;
190 // for LED references; maximum from EMCAL
191 static const int fgkMaxRefs = 288; // AliEMCALGeoParams::fgkEMCALModules * AliEMCALGeoParams::fgkEMCALLEDRefs
193 static const int fgkNumSecInHr = 3600; // number of seconds in an hour, for the fractional hour conversion on the time graph
196 TTree *fTreeAmpVsTime; // stores channel, gain, amp, and time info
197 TTree *fTreeAvgAmpVsTime; // same, for averages
198 TTree *fTreeLEDAmpVsTime; // same, for LED reference
199 TTree *fTreeLEDAvgAmpVsTime; // same, for LED reference - averages
202 int fNHighGain[fgkMaxTowers]; // Number of Amp. vs. Time readings per tower
203 int fNLowGain[fgkMaxTowers]; // same, for low gain
204 int fNRef[fgkMaxRefs * 2]; // same, for LED refs; *2 for both gains
206 ClassDef(AliCaloCalibSignal, 4) // don't forget to change version if you change class member list..