SensorThickness was defined twice. Set inner chip thickness to 250mum to bypass bug...
[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;
a37750fa 31class AliCaloRawAnalyzer;
bd83f412 32
33class 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
a37750fa 41
2d5f3a10 42private:
43 //Just declare them, avoid compilation warning
44 AliCaloCalibSignal(const AliCaloCalibSignal & /*sig*/); // copy ctor
45 AliCaloCalibSignal& operator = (const AliCaloCalibSignal &/*source*/); // assing operator
46
47public:
f4fc542c 48 // Event processing methods:
49 Bool_t ProcessEvent(AliRawReader *rawReader);
b07ee441 50 Bool_t ProcessEvent(AliCaloRawStreamV3 *in, UInt_t Timestamp); // added header for time info
afae9650 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
bd83f412 53
f4fc542c 54 // Mapping handling
ab962f7b 55 AliCaloAltroMapping **GetAltroMapping() const { return fMapping; };
f4fc542c 56 void SetAltroMapping(AliCaloAltroMapping **mapp) { fMapping = mapp; };
57
a37750fa 58 // Fitter / Analyzer
59 Int_t GetFittingAlgorithm() const {return fFittingAlgorithm; }
60 void SetFittingAlgorithm(Int_t val) ;
61 AliCaloRawAnalyzer *GetRawAnalyzer() const { return fRawAnalyzer;}
62
b07ee441 63 // Parameter/cut handling
64 void SetParametersFromFile(const char *parameterFile);
65 void WriteParametersToFile(const char *parameterFile);
66
bd83f412 67 ////////////////////////////
68 //Simple getters
8bcca84c 69 // for TTree
70 TTree * GetTreeAmpVsTime() const { return fTreeAmpVsTime; } //!
71 TTree * GetTreeAvgAmpVsTime() const {return fTreeAvgAmpVsTime; } //!
5e99faca 72 TTree * GetTreeLEDAmpVsTime() const {return fTreeLEDAmpVsTime; } //!
73 TTree * GetTreeLEDAvgAmpVsTime() const {return fTreeLEDAvgAmpVsTime; } //!
8bcca84c 74
75 // how many points do we have for each tower&gain
bd83f412 76 int GetNHighGain(int imod, int icol, int irow) const //!
77 { int towId = GetTowerNum(imod, icol, irow); return fNHighGain[towId];}; //!
78 int GetNLowGain(int imod, int icol, int irow) const //!
79 { int towId = GetTowerNum(imod, icol, irow); return fNLowGain[towId];}; //!
80 int GetNHighGain(int towId) const { return fNHighGain[towId];}; //!
81 int GetNLowGain(int towId) const { return fNLowGain[towId];}; //!
82
5e99faca 83 // also for LED reference
afae9650 84 int GetNRef(const int imod, const int istripMod, const int igain) const //!
5e99faca 85 { int refId = GetRefNum(imod, istripMod, igain); return fNRef[refId];}; //!
86 int GetNRef(int refId) const { return fNRef[refId];}; //!
87
bd83f412 88 // Basic info: getters
89 kDetType GetDetectorType() const {return fDetType;};//Returns if this is a PHOS or EMCAL object
f4fc542c 90 TString GetCaloString() const {return fCaloString;}; //Returns if this is a PHOS or EMCAL object
91
bd83f412 92 int GetColumns() const {return fColumns;}; //The number of columns per module
93 int GetRows() const {return fRows;}; //The number of rows per module
5e99faca 94 int GetLEDRefs() const {return fLEDRefs;}; //The number of LED references/monitors per module
bd83f412 95 int GetModules() const {return fModules;}; //The number of modules
8bcca84c 96
ab962f7b 97 int GetTowerNum(const int imod, const int icol, const int irow) const { return (imod*fColumns*fRows + icol*fRows + irow);}; // help index
8bcca84c 98
ab962f7b 99 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
bd83f412 103
5e99faca 104 // LED reference indexing
ab962f7b 105 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
5e99faca 109
bd83f412 110 // Basic Counters
111 int GetNEvents() const {return fNEvents;};
112 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 void SetAmpCut(double d) { fAmpCut = d; } //!
118 double GetAmpCut() const { return fAmpCut; }; //!
119 void SetReqFractionAboveAmpCutVal(double d) { fReqFractionAboveAmpCutVal = d; } //!
120 double GetReqFractionAboveAmpCutVal() const { return fReqFractionAboveAmpCutVal; }; //!
121 void SetReqFractionAboveAmp(bool b) { fReqFractionAboveAmp = b; } //!
8bcca84c 122 bool GetReqFractionAboveAmp() const { return fReqFractionAboveAmp; }; //!
30aa89b0 123 // also for LED Reference/Mon channels
124 void SetAmpCutLEDRef(double d) { fAmpCutLEDRef = d; } //!
125 double GetAmpCutLEDRef() const { return fAmpCutLEDRef; }; //!
126 void SetReqLEDRefAboveAmpCutVal(bool b) { fReqLEDRefAboveAmpCutVal = b; } //!
127 bool GetReqLEDRefAboveAmpCutVal() const { return fReqLEDRefAboveAmpCutVal; }; //!
bd83f412 128
8bcca84c 129 // We may select to get averaged info
bd83f412 130 void SetUseAverage(bool b) { fUseAverage = b; } //!
8bcca84c 131 bool GetUseAverage() const { return fUseAverage; }; //!
bd83f412 132 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 int GetSecInAverage() const {return fSecInAverage;}; //!
134
7e90bc07 135 void SetDownscale(int i) {fDownscale = i;}; //!
136 int GetDownscale() const {return fDownscale;}; //!
137
bd83f412 138 // Info on time since start of run
139 double GetHour() const { return fHour; }; // time info for current event
140 double GetCurrentHour() const { return fHour; }; // time info for current event (same as GetHour(), just more explicitly named)
141 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 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 void SetRunNumber(int runNo) {fRunNumber = runNo;}; //!
147 int GetRunNumber() const {return fRunNumber;}; //!
148
149 // Start-of-run timestamp : set and get
150 void SetStartTime(int startTime) {fStartTime = startTime;}; //!
151 int GetStartTime() const {return fStartTime;}; //!
152
153 /////////////////////////////
154 //Analysis functions
8bcca84c 155 void ResetInfo();// trees and counters.
bd83f412 156 Bool_t AddInfo(const AliCaloCalibSignal *sig);//picks up new info from supplied argument
157
158 //Saving functions
8bcca84c 159 Bool_t Save(TString fileName); //Saves the objects to a .root file
160 Bool_t Analyze(); // makes average tree and summary tree
bd83f412 161
162 private:
8bcca84c 163
164 void DeleteTrees(); // delete old objects and set pointers
bd83f412 165 void Zero(); // set all counters to 0
8bcca84c 166 void CreateTrees(); //! create/setup the TTrees
bd83f412 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
5e99faca 173 int fLEDRefs; //The number of LED references/monitors per module
bd83f412 174 int fModules; //The number of modules
f4fc542c 175 TString fCaloString; // id for which detector type we have
176 AliCaloAltroMapping **fMapping; //! Altro Mapping object
a37750fa 177 Int_t fFittingAlgorithm; // select the fitting algorithm
178 AliCaloRawAnalyzer *fRawAnalyzer; //! e.g. for sample selection for fits
bd83f412 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
30aa89b0 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
bd83f412 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
7e90bc07 194 int fDownscale; // to select 1 out every N (fDownscale) events
195
bd83f412 196 // status counters
197 int fNEvents; // # events processed
198 int fNAcceptedEvents; // # events accepted
199
bd3cd9c2 200 //Constants needed by the class: EMCAL ones are kept in AliEMCALGeoParams.h
bd83f412 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
5e99faca 203 static const int fgkPhosLEDRefs = 0; // no LED monitor channels for PHOS
bd83f412 204 static const int fgkPhosModules = 5; // number of modules for PHOS
205
bd83f412 206 // From numbers above: PHOS has more possible towers (17920) than EMCAL (13824)
207 // so use PHOS numbers to set max. array sizes
208 static const int fgkMaxTowers = 17920; // fgkPhosModules * fgkPhosCols * fgkPhosRows;
5e99faca 209 // for LED references; maximum from EMCAL
bd3cd9c2 210 static const int fgkMaxRefs = 288; // AliEMCALGeoParams::fgkEMCALModules * AliEMCALGeoParams::fgkEMCALLEDRefs
5e99faca 211
bd83f412 212 static const int fgkNumSecInHr = 3600; // number of seconds in an hour, for the fractional hour conversion on the time graph
213
8bcca84c 214 // trees
215 TTree *fTreeAmpVsTime; // stores channel, gain, amp, and time info
5e99faca 216 TTree *fTreeAvgAmpVsTime; // same, for averages
217 TTree *fTreeLEDAmpVsTime; // same, for LED reference
218 TTree *fTreeLEDAvgAmpVsTime; // same, for LED reference - averages
8bcca84c 219
220 // counters
5e99faca 221 int fNHighGain[fgkMaxTowers]; // Number of Amp. vs. Time readings per tower
222 int fNLowGain[fgkMaxTowers]; // same, for low gain
223 int fNRef[fgkMaxRefs * 2]; // same, for LED refs; *2 for both gains
bd83f412 224
a37750fa 225 ClassDef(AliCaloCalibSignal, 8) // don't forget to change version if you change class member list..
bd83f412 226
227};
228
229#endif