MUON + CheckCompiler
[u/mrichter/AliRoot.git] / EMCAL / AliCaloRawAnalyzer.h
CommitLineData
168c7b3c 1// -*- mode: c++ -*-
57839add 2#ifndef ALICALORAWANALYZER_H
3#define ALICALORAWANALYZER_H
d655d7dd 4/**************************************************************************
5 * This file is property of and copyright by *
e37e3c84 6 * the Relatvistic Heavy Ion Group (RHIG), Yale University, US, 2009 *
d655d7dd 7 * *
8 * Primary Author: Per Thomas Hille <p.t.hille@fys.uio.no> *
9 * *
10 * Contributors are mentioned in the code where appropriate. *
11 * Please report bugs to p.t.hille@fys.uio.no *
12 * *
13 * Permission to use, copy, modify and distribute this software and its *
14 * documentation strictly for non-commercial purposes is hereby granted *
15 * without fee, provided that the above copyright notice appears in all *
16 * copies and that both the copyright notice and this permission notice *
17 * appear in the supporting documentation. The authors make no claims *
18 * about the suitability of this software for any purpose. It is *
19 * provided "as is" without express or implied warranty. *
20 **************************************************************************/
21
22//Base class for extraction
23//of signal amplitude and peak position
57839add 24//From CALO Calorimeter RAW data
4074cc41 25
d655d7dd 26#include "Rtypes.h"
27#include "TObject.h"
e37e3c84 28#include <vector>
4074cc41 29#include "TObjArray.h"
30#include "AliCaloFitResults.h"
168c7b3c 31#include "AliCaloConstants.h"
92d9f317 32using namespace ALTRO;
33using namespace CALO;
168c7b3c 34
d655d7dd 35
57839add 36class AliCaloBunchInfo;
4074cc41 37
d655d7dd 38
57839add 39class AliCaloRawAnalyzer : public TObject
d655d7dd 40{
4074cc41 41public:
48a2e3eb 42 AliCaloRawAnalyzer(const char *name="AliCaloRawAnalyzer", const char *nameshort="RawAna");
0eb3189c 43 virtual ~AliCaloRawAnalyzer() { ; }
4074cc41 44
99730246 45 virtual AliCaloFitResults Evaluate( const std::vector<AliCaloBunchInfo> &/*bunchvector*/,
8a3ad886 46 UInt_t /*altrocfg1*/, UInt_t /*altrocfg2*/ ) = 0;
4074cc41 47
f67ce0df 48 static void PrintBunches( const std::vector<AliCaloBunchInfo> &bunchvector );
8a3ad886 49 static void PrintBunch ( const AliCaloBunchInfo &bunch );
168c7b3c 50
92d9f317 51 int PreFitEvaluateSamples( const std::vector<AliCaloBunchInfo> &bunchvector,
8a3ad886 52 UInt_t altrocfg1, UInt_t altrocfg2, Int_t & index,
53 Float_t & maxf, short & maxamp, short & maxampindex,
54 Float_t & ped, int & first, int & last, int acut);
92d9f317 55
8a3ad886 56 void SetTimeConstraint (int min, int max );
57 void SetVerbose (bool verbose = true){ fVerbose = verbose; }
58 void SetIsZeroSuppressed(bool iszs = true) { fIsZerosupressed = iszs ; }
59 void SetAmpCut (Float_t cut) { fAmpCut = cut ; }
60 void SetFitArrayCut(Int_t cut) { fFitArrayCut = cut ; }
61 void SetNsampleCut (Int_t cut) { fNsampleCut = cut ; }
62 void SetOverflowCut(Int_t cut) { fOverflowCut = cut ; }
63 void SetNsamplePed (Int_t i) { fNsamplePed = i ; }
64 void SetL1Phase (Double_t phase) { fL1Phase = phase ; }
f57baa2d 65
8a3ad886 66 bool GetIsZeroSuppressed() const { return fIsZerosupressed;}
67 Float_t GetAmpCut() const { return fAmpCut ; }
68 Int_t GetFitArrayCut() const { return fFitArrayCut ; }
69 Int_t GetNsampleCut() const { return fNsampleCut ; }
70 Int_t GetOverflowCut() const { return fOverflowCut ; }
71 Int_t GetNsamplePed() const { return fNsamplePed ; }
57839add 72
73 // access to array info
74 Double_t GetReversed(const int i) const { return fReversed[i]; }
8a3ad886 75 const char * GetAlgoName() const { return fName ; }
76 const char * GetAlgoAbbr() const { return fNameShort ; }
77 Algo::fitAlgorithm GetAlgo() const { return fAlgo ; }
d655d7dd 78
947c8e28 79 Double_t CalculateChi2(const Double_t amp, const Double_t time,
8a3ad886 80 const Int_t first, const Int_t last,
81 const Double_t adcErr=1,
82 const Double_t tau=2.35) const;
83
947c8e28 84 void CalculateMeanAndRMS(const Int_t first, const Int_t last,
8a3ad886 85 Double_t & mean, Double_t & rms);
86
87 short Max( const AliCaloBunchInfo *const bunch, int * maxindex) const;
88
9dfd5c8d 89 UShort_t Max(const UShort_t *data, const int length ) const;
8a3ad886 90
507751ce 91 bool CheckBunchEdgesForMax( const AliCaloBunchInfo *const bunch) const;
8a3ad886 92
9dfd5c8d 93 bool IsInTimeRange( const int maxindex, const int maxtime, const int mintime ) const;
8a3ad886 94
95 Float_t ReverseAndSubtractPed( const AliCaloBunchInfo *bunch,
96 UInt_t altrocfg1, UInt_t altrocfg2,
97 double * outarray ) const;
98
99 int SelectBunch( const std::vector<AliCaloBunchInfo> &bunchvector,
100 short * maxampbin, short * maxamplitude );
101
102 void SelectSubarray( const Double_t *date, int length, short maxindex,
103 int * first, int * last, int cut) const;
104
57839add 105 Float_t EvaluatePedestal(const UShort_t * const data, const int length ) const;
396baaf6 106
0eb3189c 107 // Used in AliCaloRawAnalyzerFitter
108 Float_t GetTau() const { return fTau ; }
109 void SetTau (Float_t tau) { fTau = tau ; }
110 Bool_t GetFixTau() const { return fFixTau ; }
111 void SetFixTau(Bool_t b) { fFixTau = b ; }
112
9dfd5c8d 113protected:
92d9f317 114 Double_t fReversed[ALTROMAXSAMPLES]; //Reversed sequence of samples (pedestalsubtracted)
d655d7dd 115 int fMinTimeIndex; //The timebin of the max signal value must be between fMinTimeIndex and fMaxTimeIndex
116 int fMaxTimeIndex; //The timebin of the max signal value must be between fMinTimeIndex and fMaxTimeIndex
117 int fFitArrayCut; //Cut on ADC value (after ped. subtraction) for signals used for fit
118 Float_t fAmpCut; //Max ADC - pedestal must be higher than this befor attemting to extract the amplitude
119 int fNsampleCut; //Minimum number of sample require before attemting to extract signal parameters
2cd0ffda 120 int fOverflowCut; // value when ADC starts to saturate
f57baa2d 121 int fNsamplePed; //Number of samples used for pedestal calculation (first in bunch)
d655d7dd 122 bool fIsZerosupressed; //Wether or not the data is zeros supressed, by default its assumed that the baseline is also subtracted if set to true
8a3ad886 123
d655d7dd 124 bool fVerbose; //Print debug information to std out if set to true
e37e3c84 125 char fName[256]; // Name of the algorithm
48a2e3eb 126 char fNameShort[256]; // Abbrevation for the name
8a3ad886 127
9dfd5c8d 128 Algo::fitAlgorithm fAlgo; // Which algorithm to use
8a3ad886 129
9dfd5c8d 130 Double_t fL1Phase; // Phase of the ADC sampling clock relative to the LHC clock
0eb3189c 131 Double_t fAmp; // The amplitude in entities of ADC counts
132 Double_t fTof; // The amplitude in entities of ADC counts
133 Float_t fTau; // Rise time of the signal (peak position = t0 +tau), by defauly it is 235 ns
134 Bool_t fFixTau; // Fixed fit parameter or not, used in AliCaloRawAnalyzerFitter
135
136 ClassDef(AliCaloRawAnalyzer, 3)
e37e3c84 137
d655d7dd 138};
139
140#endif