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