]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FLOW/AliFlowTasks/AliFlowBayesianPID.h
added combined pid class
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowTasks / AliFlowBayesianPID.h
1 #ifndef AliFlowBayesianPID_h
2 #define AliFlowBayesianPID_h
3
4 #include "TObject.h"
5 #include "AliESDpid.h"
6 #include "AliPIDResponse.h"
7
8 class TDatabasePDG;
9 class AliESDEvent;
10 class AliESDtrack;
11 class TH2D;
12 class TSpline3;
13 class TF1;
14 class AliTOFGeometry;
15 class AliTOFT0maker;
16
17 /*
18 HOW TO
19
20 1) in your main program:
21
22   AliFlowBayesianPID *mypid = new AliFlowBayesianPID();
23
24 or (if you want a global AliESDpid object)
25
26   AliESDpid *PIDesd = new AliESDpid();
27   ....
28   gROOT->LoadMacro("AliFlowBayesianPID.cxx++g");
29   AliFlowBayesianPID *mypid = new AliFlowBayesianPID(PIDesd);
30
31 for data starting from the PbPb pass2 reconstruction
32
33   mypid->SetNewTrackParam();
34
35
36 2) pass the pointer to your task
37
38 3) In your Task Exec:
39      mypid->SetDetResponse(esdEvent, centrality,AliESDpid::kTOF_T0,kFALSE); // centrality = PbPb centrality class (0-100%) or -1 for pp collisions
40      for(...){ // track loop
41      mypid->ComputeProb(track,centrality);
42      Float_t *prob = mypid->GetProb(); // Bayesian Probability (from 0 to 4) (Combined TPC || TOF) including a tuning of priors and TOF mismatch parameterization
43
44      // for the single detector weights (no priors)
45      Float_t *tpcWeight = mypid->GetWeights(0); // TPC weights (equal weights in case of no kTPCpid)
46      Float_t *tofWeight = mypid->GetWeights(1); // TOF weights (equal weights in case of no kTOFpid)
47
48      // more tools
49      TSpline3 *mismatchShape = mypid->GetMismatch(); // time distribution of mismatched tracks - L/c (L is the distance of the pad from the PV)
50      TF1 *tpcprob = mypid->GetTPCprob(); // normalized TPC response function (in Nsigmas)  
51      TF1 *tofprob = mypid->GetTOFprob(); // normalized TOF response function (in Nsigmas)  
52
53      TH2D *hPr = mypid->GetHistoPriors(isp); // 2D (centrality - pT) histo for the priors of specie-isp (centrality < 0 means pp collisions)
54                                              // all the priors are normalized to the pion ones
55
56   }
57
58 */
59
60 class AliFlowBayesianPID : public AliPIDResponse {
61  public:
62   AliFlowBayesianPID(AliESDpid *esdpid=NULL); 
63   virtual ~AliFlowBayesianPID() {};
64   
65   // virtual method of AliPIDResponse
66   virtual Float_t NumberOfSigmasTOF(const AliVParticle *vtrack, AliPID::EParticleType type) const {if(vtrack || type) printf("Don't call AliFlowBayesianPID::NumberOfSigmasTOF method\n"); return 0.0;} // do not use it
67
68   // setter
69   void SetMC(Bool_t flag = kTRUE){fIsMC=flag;} // actually do nothing
70   void SetDetResponse(AliESDEvent *esd,Float_t centrality=-1.0,EStartTimeType_t flagStart=AliESDpid::kTOF_T0,Bool_t recomputeT0TOF=kFALSE);
71   void SetNewTrackParam(Bool_t flag=kTRUE){fNewTrackParam=flag;};
72
73   // getter
74   AliESDpid* GetESDpid(){return fPIDesd;};
75   TH2D *GetHistoPriors(Int_t specie){if(specie >=0 && specie < 5) return hPriors[specie]; else return NULL;};
76   TSpline3 *GetMismatch();  
77   TF1 *GetTOFprob(){return fTOFResponse;};
78   TF1 *GetTPCprob(){return fTPCResponse;};
79   Float_t *GetWeights(Int_t det){if(det < fNdetectors && det >= 0){return fWeights[det];} else{return NULL;}};
80   Float_t *GetProb(){return fProb;};
81   Float_t GetTOFMismWeight(){return fWTofMism;};
82   Float_t GetTOFMismProb(){return fProbTofMism;};
83   Float_t GetMassOverZ(){return fMassTOF;};
84   Float_t GetZ(){return fZ;};
85
86   // methods for Bayesina Combined PID
87   void ComputeWeights(AliESDtrack *t,Float_t centr=-1.0);
88   void ComputeProb(AliESDtrack *t,Float_t centr=-1.0);
89
90   void SetTOFres(Float_t res){fTOFres=res;};
91
92  private: 
93   void SetPriors();
94
95   static const Int_t fNdetectors = 2;
96
97   AliESDpid *fPIDesd;//ESDpid object
98   TDatabasePDG *fDB; // Database pdg
99   Double_t fMass[5]; // mass for el(0),mu(1),pi(2),K(3),p(4)
100   TH2D* hPriors[5]; // histo with priors (hardcoded)
101
102   Bool_t fNewTrackParam; // switch for new tracking resolution TOF parameterization
103   Bool_t fIsMC; // switch if MC data
104   Float_t fTOFres; // TOF res needed only if T0-TOF should be recomputed
105
106   TSpline3 *fMism; // function for mismatch
107   AliTOFGeometry *fTofGeo; // TOF geometry needed to reproduce mismatch shape
108
109   AliFlowBayesianPID(const AliFlowBayesianPID&); // not implemented
110   AliFlowBayesianPID& operator=(const AliFlowBayesianPID&); // not implemented 
111
112   TF1 *fTOFResponse; // TOF Gaussian+tail response function (tail at 1.1 sigma)
113   TF1 *fTPCResponse; // TPC Gaussian+tail response function (tail at 1.8 sigma)
114
115   AliTOFT0maker *fTOFmaker; //TOF-T0 maker object
116
117   Float_t fWeights[fNdetectors][5]; // weights: 0=tpc,1=tof
118   Float_t fProb[5],fWTofMism,fProbTofMism; // Bayesian Combined PID + mismatch weights and probability 
119
120   Float_t fZ,fMassTOF; //measured charge(Z) and mass/Z
121   TF1 *fBBdata; // Bethe Bloch function (needed to compute the charge of the particle)
122
123   ClassDef(AliFlowBayesianPID, 2); // example of analysis
124 };
125
126 #endif