]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/SPECTRA/PiKaPr/ITSsa/AliITSsadEdxFitter.h
Including time.h
[u/mrichter/AliRoot.git] / PWGLF / SPECTRA / PiKaPr / ITSsa / AliITSsadEdxFitter.h
1 #ifndef ALIITSSADEDXFITTER_H
2 #define ALIITSSADEDXFITTER_H
3 /* Copyright(c) 2007-2011, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 /* $Id$ */
7
8 ///////////////////////////////////////////////////////////////////////
9 // Class with the fits algorithms to be used in the identified       //
10 // spectra analysis using the ITS in stand-alone mode                //
11 // Author: E.Biolcati, biolcati@to.infn.it                           //
12 //         F.Prino, prino@to.infn.it                                 //
13 ///////////////////////////////////////////////////////////////////////
14
15 #include <TObject.h>
16 #include "AliITSPIDResponse.h"
17
18 class TGraph;
19
20 class AliITSsadEdxFitter  : public TObject {
21
22  public:
23   AliITSsadEdxFitter();
24   AliITSsadEdxFitter(Bool_t isMC);
25   virtual ~AliITSsadEdxFitter(){
26     delete fITSpid;
27   };
28
29   Double_t CalcSigma(Int_t code,Float_t x) const;
30   Int_t InitializeMeanPosParam(Int_t code,Float_t x);
31   Int_t InitializeMeanPosBB(Int_t code,Float_t x);
32   void Initialize(TH1F* h,Int_t code,Int_t bin); 
33
34   void GetFitPar(Double_t *fitpar, Double_t *fitparerr) const;
35   Double_t GetFitPar(Int_t nparam) const {
36     if(nparam<9) return fFitPars[nparam];
37     return -1.;
38   }
39   Double_t GetFitParError(Int_t nparam) const {
40     if(nparam<9) return fFitParErrors[nparam];
41     return -1.;
42   }
43
44   void DoFitTail(TH1F *h, Int_t bin, Int_t code);
45   void DoFit(TH1F *h, Int_t bin, Int_t code, TGraph *gres);
46   void DoFitProton(TH1F *h, Int_t bin, Int_t code, TGraph *gres);
47   void DoFitOnePeak(TH1F *h, Int_t bin, Int_t signedcode);
48   void DoFitProtonFirst(TH1F *h, Int_t bin, Int_t signedcode, TGraph *gres);
49   void FillHisto(TH1F *hsps, Int_t bin, Float_t binsize, Int_t code);
50   void FillHistoMC(TH1F *hsps, Int_t bin, Int_t code, TH1F *h);
51   Bool_t IsGoodBin(Int_t bin,Int_t code);
52
53   void SetMCConfig(){
54     fIsMC=kTRUE;
55     if(fITSpid) delete fITSpid;
56     fITSpid=new AliITSPIDResponse(kTRUE);         
57   }
58   void SetDataConfig(){
59     fIsMC=kFALSE;
60     if(fITSpid) delete fITSpid;
61     fITSpid=new AliITSPIDResponse(kFALSE);        
62   }
63
64   void SetInitializationOption(Char_t opt){
65     fOptInit=opt;
66   }
67
68   void SetUseLoglikelihoodFit(){
69     fFitOption="LL0R+";
70   }
71   void SetUseChisquareFit(){
72     fFitOption="0R+";
73   }
74   void SetUseMinuitImproveFit(){
75     fFitOption="M0R+";
76   }
77
78   void SetRangeStep1(Double_t dxlow=-0.2, Double_t dxup=0.3){
79     fRangeStep1[0]=dxlow;
80     fRangeStep1[1]=dxup;
81   }
82   void SetRangeStep2(Double_t dxlow=-0.1, Double_t dxup=0.4){
83     fRangeStep2[0]=dxlow;
84     fRangeStep2[1]=dxup;
85   }
86   void SetRangeStep3(Double_t dxlow=-0.1, Double_t dxup=2.5){
87     fRangeStep3[0]=dxlow;
88     fRangeStep3[1]=dxup;
89   }
90   void SetRangeFinalStep(Double_t dxlow=-3.5, Double_t dxup=3.5){
91     fRangeStep4[0]=dxlow;
92     fRangeStep4[1]=dxup;
93   }
94   void SetLimitsOnSigmaPion(Double_t smin=0.95, Double_t smax=1.05){
95     fLimitsOnSigmaPion[0]=smin;
96     fLimitsOnSigmaPion[1]=smax;
97   }
98   void SetLimitsOnSigmaKaon(Double_t smin=0.95, Double_t smax=1.05){
99     fLimitsOnSigmaKaon[0]=smin;
100     fLimitsOnSigmaKaon[1]=smax;
101   }
102   void SetLimitsOnSigmaProton(Double_t smin=0.95, Double_t smax=1.05){
103     fLimitsOnSigmaProton[0]=smin;
104     fLimitsOnSigmaProton[1]=smax;
105   }
106   void SetBinsUsedPion(Int_t bmin=2, Int_t bmax=14){
107     fBinsUsedPion[0]=bmin;
108     fBinsUsedPion[1]=bmax;
109   }
110   void SetBinsUsedKaon(Int_t bmin=7, Int_t bmax=12){
111     fBinsUsedKaon[0]=bmin;
112     fBinsUsedKaon[1]=bmax;
113   }
114   void SetBinsUsedProton(Int_t bmin=8, Int_t bmax=17){
115     fBinsUsedProton[0]=bmin;
116     fBinsUsedProton[1]=bmax;
117   }
118
119   void PrintAll() const;
120   void PrintInitialValues() const;
121   void CalcResidual(TH1F *h,TF1 *fun,TGraph *gres) const;
122   Double_t GausPlusTail(const Double_t x, const Double_t mean, Double_t rms, Double_t c, Double_t slope, Double_t cut ) const;  
123   Double_t GausOnBackground(const Double_t* x, const Double_t *par) const;
124   void DrawFitFunction(TF1 *fun) const;
125
126  private:
127   AliITSsadEdxFitter(const AliITSsadEdxFitter& s);
128   AliITSsadEdxFitter& operator=(const AliITSsadEdxFitter& s);
129
130   Double_t fFitPars[9];       // array with fit parameters
131   Double_t fFitParErrors[9];  // array with fit parameter errors
132   Double_t fFitpar[3];     // array with fit parameters for sel. peak
133   Double_t fFitparErr[3];  // array with fit parameter errors for sel. peak
134   Double_t fRangeStep1[2]; // Range for Step1 (w.r.t pion peak)
135   Double_t fRangeStep2[2]; // Range for Step2 (w.r.t kaon/proton peak)
136   Double_t fRangeStep3[2]; // Range for Step3 (w.r.t proton/kaon peak)
137   Double_t fRangeStep4[2]; // Range for Last Fit
138   Double_t fLimitsOnSigmaPion[2]; // limits on sigma pions
139   Double_t fLimitsOnSigmaKaon[2]; // limits on sigma kaons
140   Double_t fLimitsOnSigmaProton[2]; // limits on sigma protons
141   
142   Double_t fExpPionMean;    // expected mean for pion peak
143   Double_t fExpKaonMean;    // expected mean for kaon peak
144   Double_t fExpProtonMean;  // expected mean for proton peak
145   Double_t fExpPionMeanRange;    // expected range for pion peak mean
146   Double_t fExpKaonMeanRange;    // expected range for kaon peak mean
147   Double_t fExpProtonMeanRange;  // expected range for proton peak mean
148   Double_t fExpPionSigma;   // expected sigma for pion peak
149   Double_t fExpKaonSigma;   // expected sigma for kaon peak
150   Double_t fExpProtonSigma; // expected sigma for proton peak
151   Double_t fExpPionAmpl;    // epxeted area under pion peak
152
153   Int_t fBinsUsedPion[2];   // limits on bins used pions
154   Int_t fBinsUsedKaon[2];   // limits on bins used kaons
155   Int_t fBinsUsedProton[2]; // limits on bins used protons
156
157   Bool_t fIsMC;                 // flag MC/data
158   Char_t fOptInit;              // option for initialization
159   TString fFitOption;           // option for fitting
160   AliITSPIDResponse* fITSpid;   // ITS pid object
161
162
163   ClassDef(AliITSsadEdxFitter,4);
164 };
165
166 #endif
167