]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliCaloCalibSignal.h
silvermy@ornl.gov - adding AliCaloCalibSignal, from Josh H (UT) and David S (ORNL)
[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 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
25 #include "TGraph.h"
26 #include "TProfile.h"
27 class AliCaloRawStream;
28 class AliRawEventHeaderBase;
29
30 class AliCaloCalibSignal : public TObject {
31   
32  public:
33
34   enum kDetType {kPhos, kEmCal, kNone};//The detector types
35   
36   AliCaloCalibSignal(kDetType detectorType = kPhos); //ctor
37   virtual ~AliCaloCalibSignal(); //dtor
38
39   // copy ctor, and '=' operator, are not fully tested/debugged yet
40   AliCaloCalibSignal(const AliCaloCalibSignal &sig); // copy ctor
41   AliCaloCalibSignal& operator = (const  AliCaloCalibSignal &source); //!
42   
43   Bool_t ProcessEvent(AliCaloRawStream *in, AliRawEventHeaderBase *aliHeader); // added header for time info
44   Bool_t CheckFractionAboveAmp(int *AmpVal, int nTotChan); // check fraction of signals to check for LED events
45
46   ////////////////////////////
47   //Simple getters
48   // need public access to the TGraphs.. 
49   TGraph * GetGraphAmpVsTimeHighGain(int imod, int icol, int irow) const // Return a pointer to the high gain graph
50     { int towId = GetTowerNum(imod, icol, irow); return fGraphAmpVsTimeHighGain[towId];}; //!
51   TGraph * GetGraphAmpVsTimeLowGain(int imod, int icol, int irow) const // Return a pointer to the low gain graph
52     {int towId = GetTowerNum(imod, icol, irow); return fGraphAmpVsTimeLowGain[towId];}; 
53   TGraph * GetGraphAmpVsTimeHighGain(int towId) const // Return a pointer to the high gain graph
54     { return fGraphAmpVsTimeHighGain[towId];}; //!
55   TGraph * GetGraphAmpVsTimeLowGain(int towId) const // Return a pointer to the low gain graph
56     { return fGraphAmpVsTimeLowGain[towId];}; //!       
57
58   // and similarly for the TProfiles
59   TProfile * GetProfAmpVsTimeHighGain(int imod, int icol, int irow) const // Return a pointer to the high gain profile
60     { int towId = GetTowerNum(imod, icol, irow); return fProfAmpVsTimeHighGain[towId];}; //!    
61   TProfile * GetProfAmpVsTimeLowGain(int imod, int icol, int irow) const // Return a pointer to the low gain profile
62     { int towId = GetTowerNum(imod, icol, irow); return fProfAmpVsTimeLowGain[towId];}; //!     
63   TProfile * GetProfAmpVsTimeHighGain(int towId) const // Return a pointer to the high gain profile
64     { return fProfAmpVsTimeHighGain[towId];}; //!       
65   TProfile * GetProfAmpVsTimeLowGain(int towId) const // Return a pointer to the low gain profile
66     { return fProfAmpVsTimeLowGain[towId];}; //!        
67
68   // how many points do we have in each TGraph
69   int GetNHighGain(int imod, int icol, int irow) const //!
70     { int towId = GetTowerNum(imod, icol, irow); return fNHighGain[towId];};    //!
71   int GetNLowGain(int imod, int icol, int irow) const //!
72     { int towId = GetTowerNum(imod, icol, irow); return fNLowGain[towId];};     //!
73   int GetNHighGain(int towId) const { return fNHighGain[towId];};       //!
74   int GetNLowGain(int towId) const { return fNLowGain[towId];}; //!
75
76   // Basic info: getters  
77   kDetType GetDetectorType() const {return fDetType;};//Returns if this is a PHOS or EMCAL object
78   
79   int GetColumns() const {return fColumns;}; //The number of columns per module
80   int GetRows() const {return fRows;}; //The number of rows per module
81   int GetModules() const {return fModules;}; //The number of modules
82   int GetTowerNum(int imod, int icol, int irow) const { return imod*fColumns*fRows + icol*fRows + irow;}; // help index
83
84   // Basic Counters
85   int GetNEvents() const {return fNEvents;};
86   int GetNAcceptedEvents() const {return fNAcceptedEvents;};
87
88   ///////////////////////////////
89   //  Get and Set Cuts
90   // Section for if we should help with the event selection of what is likely LED events
91   void SetAmpCut(double d) { fAmpCut = d; } //!
92   double GetAmpCut() const { return fAmpCut; }; //!
93   void SetReqFractionAboveAmpCutVal(double d) { fReqFractionAboveAmpCutVal = d; } //!
94   double GetReqFractionAboveAmpCutVal() const { return fReqFractionAboveAmpCutVal; }; //!
95   void SetReqFractionAboveAmp(bool b) { fReqFractionAboveAmp = b; } //!
96   double GetReqFractionAboveAmp() const { return fReqFractionAboveAmp; }; //!
97
98   // We may select to only use the averaged info in the TProfiles rather than the
99   // the full in the TGraphs
100   void SetUseAverage(bool b) { fUseAverage = b; } //!
101   double GetUseAverage() const { return fUseAverage; }; //!
102   void SetSecInAverage(int secInAverage) {fSecInAverage = secInAverage;}; // length of the interval that should be used for the average calculation (determines number of bins in TProfile)
103   int GetSecInAverage() const {return fSecInAverage;}; //!
104
105   // Info on time since start of run
106   double GetHour() const { return fHour; }; // time info for current event
107   double GetCurrentHour() const { return fHour; }; // time info for current event (same as GetHour(), just more explicitly named)
108   double GetLatestHour() const { return fLatestHour; }; // the latest time encountered
109   // These times are typically the same, but not necessarily if the events do not come in order 
110   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
111
112   // RunNumbers : setters and getters
113   void SetRunNumber(int runNo) {fRunNumber = runNo;}; //!
114   int GetRunNumber() const {return fRunNumber;};  //!
115   
116   // Start-of-run timestamp : set and get
117   void SetStartTime(int startTime) {fStartTime = startTime;}; //!
118   int GetStartTime() const {return fStartTime;}; //!
119
120   /////////////////////////////
121   //Analysis functions
122   void Reset();//Resets the whole class.
123   Bool_t AddInfo(const AliCaloCalibSignal *sig);//picks up new info from supplied argument  
124
125   //Saving functions
126   Bool_t Save(TString fileName, Bool_t saveEmptyGraphs = kFALSE); //Saves the TGraphs to a .root file
127
128  private:
129
130   void ClearObjects(); // delete old objects and set pointers
131   void Zero(); // set all counters to 0
132   void CreateGraphs(); //! create/setup the TGraphs
133   void CreateProfile(int imod, int icol, int irow, int towerId, int gain,
134                      int nbins, double min, double max); //! create/setup a TProfile
135     
136  private:
137
138   kDetType fDetType; //The detector type for this object
139   int fColumns; //The number of columns per module
140   int fRows;    //The number of rows per module
141   int fModules; //The number of modules
142   int fRunNumber; //The run number. Needs to be set by the user.
143   int fStartTime;  // Time of first event
144
145   double fAmpCut; // amplitude cut value
146   double fReqFractionAboveAmpCutVal; // required fraction that should be above cut
147   bool fReqFractionAboveAmp; // flag to select if we should do some event selection based on amplitudes
148
149   double fHour; // fraction of hour since beginning of run, for amp vs. time graphs, for current event
150   double fLatestHour; // largest fraction of hour since beginning of run, for amp vs. time graphs
151   bool fUseAverage; // flag to average graph points into over a time interval
152   int fSecInAverage; // time interval for the graph averaging
153
154   // status counters
155   int fNEvents; // # events processed
156   int fNAcceptedEvents; // # events accepted
157
158   //Constants needed by the class
159   static const int fgkSampleMax = 1023; // highest possible sample value (10-bit = 0x3ff)
160   static const int fgkSampleMin = 0; // lowest possible sample value 
161   
162   static const int fgkPhosRows = 64; // number of rows per module for PHOS
163   static const int fgkPhosCols = 56; // number of columns per module for PHOS
164   static const int fgkPhosModules = 5; // number of modules for PHOS
165   
166   static const int fgkEmCalRows = 24; // number of rows per module for EMCAL
167   static const int fgkEmCalCols = 48; // number of columns per module for EMCAL
168   static const int fgkEmCalModules = 12; // number of modules for EMCAL
169
170   // From numbers above: PHOS has more possible towers (17920) than EMCAL (13824) 
171   // so use PHOS numbers to set max. array sizes
172   static const int fgkMaxTowers = 17920; // fgkPhosModules * fgkPhosCols * fgkPhosRows; 
173   
174   static const int fgkNumSecInHr = 3600;  // number of seconds in an hour, for the fractional hour conversion on the time graph
175   
176   TGraph *fGraphAmpVsTimeHighGain[fgkMaxTowers]; // Amplitude vs. Time Graph for each high gain channel
177   TGraph *fGraphAmpVsTimeLowGain[fgkMaxTowers]; // Amplitude vs. Time Graph for each low gain channel
178   TProfile *fProfAmpVsTimeHighGain[fgkMaxTowers]; // Amplitude vs. Time Profile for each high gain channel
179   TProfile *fProfAmpVsTimeLowGain[fgkMaxTowers]; // Amplitude vs. Time Profile for each low gain channel
180   
181   int fNHighGain[fgkMaxTowers]; // Number of points for each Amp. vs. Time graph
182   int fNLowGain[fgkMaxTowers]; // Number of points for each Amp. vs. Time graph
183   
184   ClassDef(AliCaloCalibSignal,1)
185     
186 };
187     
188 #endif