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 */
8 //_________________________________________________________________________
9 // Utility Class for handling Raw data
10 // Does all transitions from Digits to Raw and vice versa,
11 // for simu and reconstruction
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.
18 //*-- Author: Marco van Leeuwen (LBL)
20 #include "TObject.h" // for ROOT types
22 //#include "AliCaloRawStreamV3.h"
23 class AliCaloRawStreamV3;
24 class AliAltroMapping;
27 class AliEMCALGeometry;
28 class AliCaloCalibPedestal;
29 class AliCaloRawAnalyzer;
30 class AliEMCALTriggerRawDigitMaker;
31 class AliEMCALTriggerData;
33 class AliEMCALRawUtils : public TObject {
35 enum fitAlgorithm {kStandard = 0, kFastFit= 1, kNeuralNet = 2, kLogFit = 3, kLMS = 4, kPeakFinder = 5, kCrude = 6};
37 AliEMCALRawUtils(fitAlgorithm fitAlgo = kStandard);
38 AliEMCALRawUtils(AliEMCALGeometry *pGeometry, fitAlgorithm fitAlgo = kStandard);
39 virtual ~AliEMCALRawUtils();
41 AliEMCALRawUtils(const AliEMCALRawUtils& rawUtils); //copy ctor
42 AliEMCALRawUtils& operator =(const AliEMCALRawUtils& rawUtils);
45 void Raw2Digits(AliRawReader *reader, TClonesArray *digitsArr, const AliCaloCalibPedestal* pedbadmap,
46 TClonesArray *digitsTRG=0x0, AliEMCALTriggerData* trgData = 0x0);
48 void AddDigit(TClonesArray *digitsArr, Int_t id, Int_t lowGain, Float_t amp, Float_t time, Float_t chi2, Int_t ndf);
49 // void AddDigit(TClonesArray *digitsArr, Int_t id, Int_t timeSamples[], Int_t nSamples);
50 void TrimDigits(TClonesArray *digitsArr);
52 // Signal shape parameters
53 Double_t GetRawFormatHighLowGainFactor() const { return fHighLowGainFactor ;}
54 Int_t GetRawFormatOrder() const { return fOrder ; }
55 Double_t GetRawFormatTau() const { return fTau ; }
56 Int_t GetNoiseThreshold() const { return fNoiseThreshold; }
57 Int_t GetNPedSamples() const { return fNPedSamples; }
59 // get methods for fast fit simulation
60 Int_t GetPedestalValue() const {return fgPedestalValue;}
61 Double_t GetFEENoise() const {return fgFEENoise;}
63 Bool_t GetRemoveBadChannels() const {return fRemoveBadChannels;}
64 Int_t GetFittingAlgorithm() const {return fFittingAlgorithm; }
65 Float_t GetTimeMax() const {return fTimeMax ;}
66 Float_t GetTimeMin() const {return fTimeMin ;}
67 Bool_t UseFALTRO() const {return fUseFALTRO; }
69 void SetRawFormatHighLowGainFactor(Double_t val) {fHighLowGainFactor=val;}
70 void SetRawFormatOrder(Int_t val) {fOrder=val; }
71 void SetRawFormatTau(Double_t val) {fTau=val; }
72 void SetNoiseThreshold(Int_t val) {fNoiseThreshold=val; }
73 void SetNPedSamples(Int_t val) {fNPedSamples=val; }
74 void SetRemoveBadChannels(Bool_t val) {fRemoveBadChannels=val; }
75 void SetFittingAlgorithm(Int_t val) ;
76 void SetTimeMin(Float_t t) {fTimeMin = t ;}
77 void SetTimeMax(Float_t t) {fTimeMax = t ;}
78 void SetFALTROUsage(Bool_t val) {fUseFALTRO=val; }
80 // set methods for fast fit simulation
81 void SetFEENoise(Double_t val) {fgFEENoise = val;}
82 void SetRawFormatTimeBins(Int_t val) {fgTimeBins = val;}
83 void SetPedestalValue(Int_t val) {fgPedestalValue = val;}
85 static Int_t GetRawFormatTimeBins() { return fgTimeBins ; }
86 static Double_t GetRawFormatTimeMax() { return fgTimeBins*fgTimeBinWidth; }
87 static Double_t GetRawFormatTimeBinWidth() { return fgTimeBinWidth; }
88 static Double_t GetRawFormatTimeBin()
89 { return GetRawFormatTimeMax() / GetRawFormatTimeBins(); }
90 Double_t GetRawFormatTimeTrigger() const { return fgTimeTrigger ; }
91 Int_t GetRawFormatThreshold() const { return fgThreshold ; }
92 Int_t GetRawFormatDDLPerSuperModule() const { return fgDDLPerSuperModule ; }
93 AliCaloRawAnalyzer *GetRawAnalyzer() const { return fRawAnalyzer;}
95 virtual Option_t* GetOption() const { return fOption.Data(); }
96 void SetOption(const Option_t* opt) { fOption = opt; }
98 // Signal shape functions
100 void FitRaw(const Int_t firstTimeBin, const Int_t lastTimeBin, Float_t & amp, Float_t & time, Float_t & chi2, Bool_t & fitDone) const ;
101 void FitParabola(const TGraph *gSig, Float_t & amp) const ;
102 static Double_t RawResponseFunction(Double_t *x, Double_t *par);
103 static Double_t RawResponseFunctionLog(Double_t *x, Double_t *par);
104 Bool_t RawSampledResponse(Double_t dtime, Double_t damp, Int_t * adcH, Int_t * adcL, const Int_t keyErr=0) const;
106 static void CalculateChi2(const Double_t* t,const Double_t* y,const Int_t nPoints,
107 const Double_t sig, const Double_t tau, const Double_t amp, const Double_t t0, Double_t &chi2);
110 Double_t fHighLowGainFactor ; // high to low gain factor for the raw RO signal
111 Int_t fOrder ; // order of the gamma function for the RO signal
112 Double_t fTau ; // tau parameter of gamma function for the RO signal
113 Int_t fNoiseThreshold; // threshold to consider signal or noise
114 Int_t fNPedSamples; // number of samples to use in pedestal calculation
116 static const Int_t fgkOverflowCut = 950; // cut to discriminate overflowed channels
117 static const Int_t fgkRawSignalOverflow = 0x3FF; // maximum signal (10 bits)
118 static Int_t fgTimeBins; // number of sampling bins of the raw RO signal
120 static Double_t fgTimeTrigger ; // time of the trigger for the RO signal
121 static Double_t fgTimeBinWidth; // maximum sampled time of the raw RO signal
122 static Int_t fgThreshold; // threshold
123 static Int_t fgDDLPerSuperModule; // number of DDL per SuperModule
124 static Int_t fgPedestalValue; // pedestal value for Digits2Raw
125 static Double_t fgFEENoise; // electronics noise in ADC units
127 AliEMCALGeometry* fGeom; // geometry
128 AliAltroMapping* fMapping[4]; // only two for now
130 TString fOption; //! option passed from Reconstructor
132 Bool_t fRemoveBadChannels; // select if bad channels are removed before fitting
133 Int_t fFittingAlgorithm; // select the fitting algorithm
134 Float_t fTimeMin; // minimum threshold for the time of the signal
135 Float_t fTimeMax; // maximum threshold for the time of the signal
136 Bool_t fUseFALTRO; // use FALTRO and pass it to the digits
138 AliCaloRawAnalyzer *fRawAnalyzer; // e.g. for sample selection for fits
140 AliEMCALTriggerRawDigitMaker* fTriggerRawDigitMaker;
142 ClassDef(AliEMCALRawUtils,7) // utilities for raw signal fitting