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