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