]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCALRawUtils.h
Neural Net signal fitter code from Paola/Catania
[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 TF1;
27 class AliRawReader;
28 class AliEMCALGeometry;
29 class AliCaloCalibPedestal;
30
31 class AliEMCALRawUtils : public TObject {
32  public:
33   AliEMCALRawUtils();
34   AliEMCALRawUtils(AliEMCALGeometry *pGeometry);
35   virtual ~AliEMCALRawUtils();
36         
37   enum fitAlgorithm {kStandard = 0, kFastFit= 1, kNeuralNet = 2};
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, AliCaloCalibPedestal* pedbadmap);
44
45   void AddDigit(TClonesArray *digitsArr, Int_t id, Int_t lowGain, Int_t amp, Float_t time);
46
47   // Signal shape parameters
48   Double_t GetRawFormatHighLowGainFactor() const { return fHighLowGainFactor ;}
49   Int_t GetRawFormatOrder()                const { return fOrder ; }   
50   Double_t GetRawFormatTau()               const { return fTau ; }    
51   Int_t GetNoiseThreshold()                const { return fNoiseThreshold; }
52   Int_t GetNPedSamples()                   const { return fNPedSamples; }
53   // get methods for fast fit simulation
54   Double_t GetPedestalValue()  const {return fgPedestalValue;}
55   Double_t GetFEENoise()       const {return fgFEENoise;}
56
57   Bool_t GetRemoveBadChannels()   const {return fRemoveBadChannels;}
58   Int_t  GetFittingAlgorithm()    const {return fFittingAlgorithm; }
59         
60   void SetRawFormatHighLowGainFactor(Double_t val) {fHighLowGainFactor=val;}
61   void SetRawFormatOrder(Int_t val)                {fOrder=val; }   
62   void SetRawFormatTau(Double_t val)               {fTau=val; }    
63   void SetNoiseThreshold(Int_t val)                {fNoiseThreshold=val; }
64   void SetNPedSamples(Int_t val)                   {fNPedSamples=val; }
65   void SetRemoveBadChannels(Bool_t val)            {fRemoveBadChannels=val; }
66   void SetFittingAlgorithm(Int_t val)              {fFittingAlgorithm=val; }
67
68   // set methods for fast fit simulation
69   void SetFEENoise(Double_t val)                   {fgFEENoise = val;}
70   void SetRawFormatTimeBins(Int_t val)             {fgTimeBins = val;}
71   
72   static Int_t GetRawFormatTimeBins() { return fgTimeBins ; }    
73   static Double_t GetRawFormatTimeMax() { return fgTimeBins*fgTimeBinWidth; }   
74   static Double_t GetRawFormatTimeBinWidth() { return fgTimeBinWidth; }   
75   static Double_t GetRawFormatTimeBin() 
76   { return GetRawFormatTimeMax() / GetRawFormatTimeBins(); }   
77   Double_t GetRawFormatTimeTrigger() const { return fgTimeTrigger ; }
78   Int_t GetRawFormatThreshold() const { return fgThreshold ; }       
79   Int_t GetRawFormatDDLPerSuperModule() const { return fgDDLPerSuperModule ; } 
80         
81   virtual Option_t* GetOption() const { return fOption.Data(); }
82   void SetOption(Option_t* opt) { fOption = opt; }
83
84   // Signal shape functions
85         
86   void FitRaw(TGraph * gSig, TF1* signalF, const Int_t lastTimeBin, Float_t & amp, Float_t & time, Float_t & ped, Float_t & ampEstimate, Float_t & timeEstimate, Float_t & pedEstimate, const Float_t cut = 0) const ;
87   static Double_t RawResponseFunction(Double_t *x, Double_t *par); 
88   Bool_t   RawSampledResponse(Double_t dtime, Double_t damp, Int_t * adcH, Int_t * adcL) const;  
89
90
91  private:
92   Double_t fHighLowGainFactor ;         // high to low gain factor for the raw RO signal
93   Int_t fOrder ;                        // order of the gamma function for the RO signal
94   Double_t fTau ;                       // tau parameter of gamma function for the RO signal
95   Int_t fNoiseThreshold;                // threshold to consider signal or noise
96   Int_t fNPedSamples;                   // number of samples to use in pedestal calculation
97
98   static const Int_t fgkOverflowCut = 950;  // cut to discriminate overflowed channels
99   static const Int_t fgkRawSignalOverflow = 0x3FF; // maximum signal (10 bits)
100   static Int_t fgTimeBins; // number of sampling bins of the raw RO signal
101
102   static Double_t fgTimeTrigger ;       // time of the trigger for the RO signal 
103   static Double_t fgTimeBinWidth;       // maximum sampled time of the raw RO signal                             
104   static Int_t fgThreshold;             // threshold
105   static Int_t fgDDLPerSuperModule;     // number of DDL per SuperModule
106   static Int_t fgPedestalValue;         // pedestal value for Digits2Raw
107   static Double_t fgFEENoise;           // electronics noise in ADC units
108
109   AliEMCALGeometry* fGeom;              //geometry
110   AliAltroMapping*  fMapping[4];        //only two for now
111
112   TString fOption;                      //! option passed from Reconstructor
113
114   Bool_t fRemoveBadChannels;            // select if bad channels are removed before fitting
115   Int_t  fFittingAlgorithm;             // select the fitting algorithm
116
117   ClassDef(AliEMCALRawUtils,4)          // utilities for raw signal fitting
118 };
119
120 #endif