Update for running on 2010 data (S. Beole')
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALRawUtils.h
CommitLineData
ee299369 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$ */
e5bbbc4e 7
ee299369 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
feedcab9 21#include <TString.h>
32cd4c24 22//#include "AliCaloRawStreamV3.h"
23class AliCaloRawStreamV3;
e5bbbc4e 24class AliAltroMapping;
ee299369 25class TGraph;
ee299369 26class AliRawReader;
65bdc82f 27class AliEMCALGeometry;
5e3106bc 28class AliCaloCalibPedestal;
16605c06 29class AliCaloRawAnalyzer;
ee299369 30
31class AliEMCALRawUtils : public TObject {
32 public:
16605c06 33 enum fitAlgorithm {kStandard = 0, kFastFit= 1, kNeuralNet = 2, kLogFit = 3, kLMS = 4, kPeakFinder = 5, kCrude = 6};
9f467289 34
16605c06 35 AliEMCALRawUtils(fitAlgorithm fitAlgo = kStandard);
36 AliEMCALRawUtils(AliEMCALGeometry *pGeometry, fitAlgorithm fitAlgo = kStandard);
37 virtual ~AliEMCALRawUtils();
9f467289 38
65bdc82f 39 AliEMCALRawUtils(const AliEMCALRawUtils& rawUtils); //copy ctor
40 AliEMCALRawUtils& operator =(const AliEMCALRawUtils& rawUtils);
41
42 void Digits2Raw();
16605c06 43 void Raw2Digits(AliRawReader *reader, TClonesArray *digitsArr, const AliCaloCalibPedestal* pedbadmap);
65bdc82f 44
82cbdfca 45 void AddDigit(TClonesArray *digitsArr, Int_t id, Int_t lowGain, Int_t amp, Float_t time);
ee299369 46
47 // Signal shape parameters
b4133f05 48 Double_t GetRawFormatHighLowGainFactor() const { return fHighLowGainFactor ;}
09974781 49 Int_t GetRawFormatOrder() const { return fOrder ; }
b4133f05 50 Double_t GetRawFormatTau() const { return fTau ; }
09974781 51 Int_t GetNoiseThreshold() const { return fNoiseThreshold; }
52 Int_t GetNPedSamples() const { return fNPedSamples; }
e2c2134b 53 // get methods for fast fit simulation
54 Double_t GetPedestalValue() const {return fgPedestalValue;}
55 Double_t GetFEENoise() const {return fgFEENoise;}
b4133f05 56
9f467289 57 Bool_t GetRemoveBadChannels() const {return fRemoveBadChannels;}
58 Int_t GetFittingAlgorithm() const {return fFittingAlgorithm; }
59
b4133f05 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; }
9f467289 65 void SetRemoveBadChannels(Bool_t val) {fRemoveBadChannels=val; }
d0b0529a 66 void SetFittingAlgorithm(Int_t val) {fFittingAlgorithm=val; } // not enough to set this variable to switch between algorithms, so should be modified
7643e728 67
e2c2134b 68 // set methods for fast fit simulation
69 void SetFEENoise(Double_t val) {fgFEENoise = val;}
70 void SetRawFormatTimeBins(Int_t val) {fgTimeBins = val;}
7643e728 71
e2c2134b 72 static Int_t GetRawFormatTimeBins() { return fgTimeBins ; }
73 static Double_t GetRawFormatTimeMax() { return fgTimeBins*fgTimeBinWidth; }
82cbdfca 74 static Double_t GetRawFormatTimeBinWidth() { return fgTimeBinWidth; }
85c25c2e 75 static Double_t GetRawFormatTimeBin()
76 { return GetRawFormatTimeMax() / GetRawFormatTimeBins(); }
ee299369 77 Double_t GetRawFormatTimeTrigger() const { return fgTimeTrigger ; }
78 Int_t GetRawFormatThreshold() const { return fgThreshold ; }
79 Int_t GetRawFormatDDLPerSuperModule() const { return fgDDLPerSuperModule ; }
16605c06 80 AliCaloRawAnalyzer *GetRawAnalyzer() const { return fRawAnalyzer;}
81
feedcab9 82 virtual Option_t* GetOption() const { return fOption.Data(); }
16605c06 83 void SetOption(const Option_t* opt) { fOption = opt; }
feedcab9 84
ee299369 85 // Signal shape functions
9f467289 86
16605c06 87 void FitRaw(const Int_t firstTimeBin, const Int_t lastTimeBin, Float_t & amp, Float_t & time) const ;
88 void FitParabola(const TGraph *gSig, Float_t & amp) const ;
ee299369 89 static Double_t RawResponseFunction(Double_t *x, Double_t *par);
7683df1d 90 static Double_t RawResponseFunctionLog(Double_t *x, Double_t *par);
dff7354e 91 Bool_t RawSampledResponse(Double_t dtime, Double_t damp,
92 Int_t * adcH, Int_t * adcL, const Int_t keyErr=0) const;
ee299369 93
ee299369 94
95 private:
96 Double_t fHighLowGainFactor ; // high to low gain factor for the raw RO signal
b4133f05 97 Int_t fOrder ; // order of the gamma function for the RO signal
98 Double_t fTau ; // tau parameter of gamma function for the RO signal
99 Int_t fNoiseThreshold; // threshold to consider signal or noise
100 Int_t fNPedSamples; // number of samples to use in pedestal calculation
ee299369 101
b4133f05 102 static const Int_t fgkOverflowCut = 950; // cut to discriminate overflowed channels
b4133f05 103 static const Int_t fgkRawSignalOverflow = 0x3FF; // maximum signal (10 bits)
7643e728 104 static Int_t fgTimeBins; // number of sampling bins of the raw RO signal
b4133f05 105
106 static Double_t fgTimeTrigger ; // time of the trigger for the RO signal
82cbdfca 107 static Double_t fgTimeBinWidth; // maximum sampled time of the raw RO signal
ee299369 108 static Int_t fgThreshold; // threshold
109 static Int_t fgDDLPerSuperModule; // number of DDL per SuperModule
fe93d365 110 static Int_t fgPedestalValue; // pedestal value for Digits2Raw
111 static Double_t fgFEENoise; // electronics noise in ADC units
feedcab9 112
9f467289 113 AliEMCALGeometry* fGeom; //geometry
114 AliAltroMapping* fMapping[4]; //only two for now
65bdc82f 115
feedcab9 116 TString fOption; //! option passed from Reconstructor
b4133f05 117
9f467289 118 Bool_t fRemoveBadChannels; // select if bad channels are removed before fitting
119 Int_t fFittingAlgorithm; // select the fitting algorithm
16605c06 120 AliCaloRawAnalyzer *fRawAnalyzer; // e.g. for sample selection for fits
9f467289 121
16605c06 122 ClassDef(AliEMCALRawUtils,5) // utilities for raw signal fitting
ee299369 123};
124
125#endif