]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCALRawUtils.h
adding first sketch of a DCS publisher component for global HLT data points
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALRawUtils.h
1 #ifndef ALIEMCALRAWUTILS_H
2 #define ALIEMCALRAWUTILS_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice     */
5
6 /* $Id$ */
7
8 //_________________________________________________________________________
9 //  Utility Class for handling Raw data
10 //  Does all transitions from Digits to Raw and vice versa, 
11 //  for simu and reconstruction
12 //
13 //  Note: the current version is still simplified. Only 
14 //    one raw signal per digit is generated; either high-gain or low-gain
15 //    Need to add concurrent high and low-gain info in the future
16 //    No pedestal is added to the raw signal.
17 //
18 //*-- Author: Marco van Leeuwen (LBL)
19 //
20 #include "TObject.h" // for ROOT types
21 #include <TString.h>
22 //#include "AliCaloRawStreamV3.h"
23 class AliCaloRawStreamV3;
24 class AliAltroMapping;
25 class TGraph;
26 class AliRawReader;
27 class AliEMCALGeometry;
28 class AliCaloCalibPedestal;
29 class AliCaloRawAnalyzer;
30
31 class AliEMCALRawUtils : public TObject {
32  public:
33   enum fitAlgorithm {kStandard = 0, kFastFit= 1, kNeuralNet = 2, kLogFit = 3, kLMS = 4, kPeakFinder = 5, kCrude = 6};
34         
35  AliEMCALRawUtils(fitAlgorithm fitAlgo = kStandard);
36   AliEMCALRawUtils(AliEMCALGeometry *pGeometry, fitAlgorithm fitAlgo = kStandard);
37   virtual ~AliEMCALRawUtils();
38         
39   AliEMCALRawUtils(const AliEMCALRawUtils& rawUtils);  //copy ctor
40   AliEMCALRawUtils& operator =(const AliEMCALRawUtils& rawUtils);
41
42   void Digits2Raw();
43   void Raw2Digits(AliRawReader *reader, TClonesArray *digitsArr, const AliCaloCalibPedestal* pedbadmap,
44                                   TClonesArray *digitsTRG=0x0);
45
46   void AddDigit(TClonesArray *digitsArr, Int_t id, Int_t lowGain, Int_t amp, Float_t time);
47   void AddDigit(TClonesArray *digitsArr, Int_t id, Int_t timeSamples[], Int_t nSamples);
48
49   // Signal shape parameters
50   Double_t GetRawFormatHighLowGainFactor() const { return fHighLowGainFactor ;}
51   Int_t GetRawFormatOrder()                const { return fOrder ; }   
52   Double_t GetRawFormatTau()               const { return fTau ; }    
53   Int_t GetNoiseThreshold()                const { return fNoiseThreshold; }
54   Int_t GetNPedSamples()                   const { return fNPedSamples; }
55   // get methods for fast fit simulation
56   Double_t GetPedestalValue()  const {return fgPedestalValue;}
57   Double_t GetFEENoise()       const {return fgFEENoise;}
58
59   Bool_t GetRemoveBadChannels() const {return fRemoveBadChannels;}
60   Int_t  GetFittingAlgorithm()  const {return fFittingAlgorithm; }
61   Bool_t UseFALTRO()            const {return fUseFALTRO; }
62         
63   void SetRawFormatHighLowGainFactor(Double_t val) {fHighLowGainFactor=val;}
64   void SetRawFormatOrder(Int_t val)                {fOrder=val; }   
65   void SetRawFormatTau(Double_t val)               {fTau=val; }    
66   void SetNoiseThreshold(Int_t val)                {fNoiseThreshold=val; }
67   void SetNPedSamples(Int_t val)                   {fNPedSamples=val; }
68   void SetRemoveBadChannels(Bool_t val)            {fRemoveBadChannels=val; }
69   void SetFittingAlgorithm(Int_t val) ;             
70   void SetFALTROUsage(Bool_t val)                  {fUseFALTRO=val; }
71         
72   // set methods for fast fit simulation
73   void SetFEENoise(Double_t val)                   {fgFEENoise = val;}
74   void SetRawFormatTimeBins(Int_t val)             {fgTimeBins = val;}
75   
76   static Int_t GetRawFormatTimeBins() { return fgTimeBins ; }    
77   static Double_t GetRawFormatTimeMax() { return fgTimeBins*fgTimeBinWidth; }   
78   static Double_t GetRawFormatTimeBinWidth() { return fgTimeBinWidth; }   
79   static Double_t GetRawFormatTimeBin() 
80   { return GetRawFormatTimeMax() / GetRawFormatTimeBins(); }   
81   Double_t GetRawFormatTimeTrigger() const { return fgTimeTrigger ; }
82   Int_t GetRawFormatThreshold() const { return fgThreshold ; }       
83   Int_t GetRawFormatDDLPerSuperModule() const { return fgDDLPerSuperModule ; } 
84   AliCaloRawAnalyzer *GetRawAnalyzer() const { return fRawAnalyzer;}
85
86   virtual Option_t* GetOption() const { return fOption.Data(); }
87   void SetOption(const Option_t* opt) { fOption = opt; }
88
89   // Signal shape functions
90         
91   void FitRaw(const Int_t firstTimeBin, const Int_t lastTimeBin, Float_t & amp, Float_t & time) const ;
92   void FitParabola(const TGraph *gSig, Float_t & amp) const ; 
93   static Double_t RawResponseFunction(Double_t *x, Double_t *par); 
94   static Double_t RawResponseFunctionLog(Double_t *x, Double_t *par); 
95   Bool_t   RawSampledResponse(Double_t dtime, Double_t damp, Int_t * adcH, Int_t * adcL, const Int_t keyErr=0) const;  
96
97
98  private:
99   Double_t fHighLowGainFactor ;         // high to low gain factor for the raw RO signal
100   Int_t fOrder ;                        // order of the gamma function for the RO signal
101   Double_t fTau ;                       // tau parameter of gamma function for the RO signal
102   Int_t fNoiseThreshold;                // threshold to consider signal or noise
103   Int_t fNPedSamples;                   // number of samples to use in pedestal calculation
104
105   static const Int_t fgkOverflowCut = 950;  // cut to discriminate overflowed channels
106   static const Int_t fgkRawSignalOverflow = 0x3FF; // maximum signal (10 bits)
107   static Int_t fgTimeBins; // number of sampling bins of the raw RO signal
108
109   static Double_t fgTimeTrigger ;       // time of the trigger for the RO signal 
110   static Double_t fgTimeBinWidth;       // maximum sampled time of the raw RO signal                             
111   static Int_t fgThreshold;             // threshold
112   static Int_t fgDDLPerSuperModule;     // number of DDL per SuperModule
113   static Int_t fgPedestalValue;         // pedestal value for Digits2Raw
114   static Double_t fgFEENoise;           // electronics noise in ADC units
115
116   AliEMCALGeometry* fGeom;              //geometry
117   AliAltroMapping*  fMapping[4];        //only two for now
118
119   TString fOption;                      //! option passed from Reconstructor
120
121   Bool_t fRemoveBadChannels;            // select if bad channels are removed before fitting
122   Int_t  fFittingAlgorithm;             // select the fitting algorithm
123   Bool_t fUseFALTRO;                                    // use FALTRO and pass it to the digits
124         
125   AliCaloRawAnalyzer *fRawAnalyzer;     // e.g. for sample selection for fits
126
127   ClassDef(AliEMCALRawUtils,6)          // utilities for raw signal fitting
128 };
129
130 #endif