reading RAW without data
[u/mrichter/AliRoot.git] / HBTAN / AliHBTWeightsPID.cxx
1 /* $Id $ */
2
3 //-----------------------------------------------------------
4 //This class introduces the weights calculated according 
5 //with functions of efficiency of identification (TPC+TOF) 
6 //(calculated by B.V. Batyunia).
7 //Author: Ludmila Malinina, JINR (malinina@sunhe.jinr.ru)
8 //-----------------------------------------------------------
9
10 #include "AliHBTWeightsPID.h"
11 #include "AliHBTPair.h"
12 #include <TRandom.h>
13 #include <TMath.h>
14 #include <TH1.h>
15 #include <TF1.h>
16
17 ClassImp(AliHBTWeightsPID)  
18  
19 AliHBTWeightsPID* AliHBTWeightsPID::fgWeightsPID=NULL; 
20
21 AliHBTWeightsPID::AliHBTWeightsPID()
22 {
23   //ctor
24   //initial parameters of model
25
26   fPtK   = new TH1F("fPtK"," pt of K+- ",40,0,4);
27   fPtKefftpc   = new TH1F("fPtEfficKpos"," pt of K+ after efficiency cut ",40,0,4);
28   fPtKefftpcboth   = new TH1F("fPtEfficKneg"," pt of K- after efficiency cut ",40,0,4);
29
30   // efficiency functions (from pt) for K+- in the TPC
31   fEffic1pol = new TF1("fEffic1pol4","pol4",100.,480.); 
32   // for -0.9 < eta < -0.7
33   // for  0.7 < eta <  0.9
34   fEffic1pol->SetParameter(0,-0.266362);
35   fEffic1pol->SetParameter(1,0.00565461);
36   fEffic1pol->SetParameter(2,-4.06686e-05);
37   fEffic1pol->SetParameter(3,1.39387e-07);
38   fEffic1pol->SetParameter(4,-1.59674e-10);
39
40   fEffic2pol = new TF1("fEffic2pol4","pol4",100.,540.); 
41
42   fEffic2pol->SetParameter(0,-0.324881);
43   fEffic2pol->SetParameter(1,0.00565381);
44   fEffic2pol->SetParameter(2,-3.23633e-05);
45   fEffic2pol->SetParameter(3,9.72523e-08);
46   fEffic2pol->SetParameter(4,-1.01013e-10);
47                                                                                
48   fEffic3pol = new TF1("fEffic3pol4","pol4",100.,585.); 
49   // for -0.5 < eta < -0.3
50   // for  0.3 < eta <  0.5
51   fEffic3pol->SetParameter(0,-0.306572);
52   fEffic3pol->SetParameter(1,0.00557472);
53   fEffic3pol->SetParameter(2,-3.33752e-05);
54   fEffic3pol->SetParameter(3,9.83241e-08);
55   fEffic3pol->SetParameter(4,-9.5827e-11);
56   fEffic4pol = new TF1("fEffic4pol4","pol4",100.,600.);
57   // for -0.3 < eta < 0.3
58   fEffic4pol->SetParameter(0,-0.168648);
59   fEffic4pol->SetParameter(1,0.00252021);
60   fEffic4pol->SetParameter(2,-1.09113e-05);
61   fEffic4pol->SetParameter(3,3.34871e-08);
62   fEffic4pol->SetParameter(4,-3.31691e-11);
63
64   // efficiency functions (from pt) for K+- in the TOF
65   fEffic1polTOF = new TF1("fEffic1pol4TOF","pol4",0.2,2.0); 
66   // for -0.9 < eta < -0.7
67   // for  0.7 < eta <  0.9
68   fEffic1polTOF->SetParameter(0,-0.165885);
69   fEffic1polTOF->SetParameter(1,0.717459);
70   fEffic1polTOF->SetParameter(2,-0.457131);
71   fEffic1polTOF->SetParameter(3,0.284753);
72   fEffic1polTOF->SetParameter(4,-0.105215);
73                                                                                
74   fEffic2polTOF = new TF1("fEffic2pol4TOF","pol4",0.2,2.4); 
75   // for -0.7 < eta < -0.5
76   // for  0.5 < eta <  0.7
77
78   fEffic2polTOF->SetParameter(0,-0.165947);
79   fEffic2polTOF->SetParameter(1,0.702475);
80   fEffic2polTOF->SetParameter(2,-0.300313);
81   fEffic2polTOF->SetParameter(3,0.127047);
82   fEffic2polTOF->SetParameter(4,-0.0489395);
83                                                                                
84
85   fEffic3polTOF = new TF1("fEffic3pol4TOF","pol4",0.2,2.4); 
86   // for -0.5 < eta < -0.3
87   // for  0.3 < eta <  0.5
88   fEffic3polTOF->SetParameter(0,-0.339516);
89   fEffic3polTOF->SetParameter(1,1.56942);
90   fEffic3polTOF->SetParameter(2,-1.43132);
91   fEffic3polTOF->SetParameter(3,0.727148);
92   fEffic3polTOF->SetParameter(4,-0.158444);
93   fEffic4polTOF = new TF1("fEffic4pol4TOF","pol4",0.2,2.6);
94   // for -0.3 < eta < 0.3
95   fEffic4polTOF->SetParameter(0,-0.243435);
96   fEffic4polTOF->SetParameter(1,1.00928);
97   fEffic4polTOF->SetParameter(2,-0.594597);
98   fEffic4polTOF->SetParameter(3,0.212601);
99   fEffic4polTOF->SetParameter(4,-0.0453419);
100
101 }                                            
102
103 AliHBTWeightsPID* AliHBTWeightsPID::Instance()
104 {
105   //Creates an instance of the class 
106   //or returns pointer to already existing one
107   if (fgWeightsPID) {
108     return fgWeightsPID;
109   } else {
110     fgWeightsPID = new AliHBTWeightsPID();
111     return fgWeightsPID;
112   }
113 }
114
115
116 Double_t AliHBTWeightsPID::GetWeightPID(const AliHBTPair* trackpair)
117 {
118   //Calculates the weight of "trackpair"
119   AliVAODParticle *track1 = trackpair->Particle1();
120   AliVAODParticle *track2 = trackpair->Particle2();
121     
122   Double_t pt1=track1->Pt();
123   Double_t eta1=track1->Eta();
124
125   fPtK->Fill(pt1); 
126
127   if(TMath::Abs(eta1) > 0.7 && TMath::Abs(eta1) < 0.9 && pt1 < 0.48) {
128     fEfficTPC1 = fEffic1pol->Eval(pt1*1000.);
129   }else if(TMath::Abs(eta1) > 0.5 && TMath::Abs(eta1) < 0.7 && pt1 < 0.54) {
130     fEfficTPC1 = fEffic2pol->Eval(pt1*1000.);
131   }else if(TMath::Abs(eta1) > 0.3 && TMath::Abs(eta1) < 0.5 && pt1 < 0.585) {
132     fEfficTPC1 = fEffic3pol->Eval(pt1*1000.);
133   }else if(eta1 > -0.3 && eta1 < 0.3 && pt1 < 0.6) {
134     fEfficTPC1 = fEffic4pol->Eval(pt1*1000.);
135   }
136   
137   // TOF efficiency
138   
139   if(pt1 > 0.2) {
140     if(TMath::Abs(eta1) > 0.7 && TMath::Abs(eta1) < 0.9 && pt1 < 2.0) {
141       fEfficTOF1 = fEffic1polTOF->Eval(pt1);
142     }else if(TMath::Abs(eta1) > 0.5 && TMath::Abs(eta1) < 0.7 && pt1 < 2.4) {
143       fEfficTOF1 = fEffic2polTOF->Eval(pt1);
144     }else if(TMath::Abs(eta1) > 0.3 && TMath::Abs(eta1) < 0.5 && pt1 < 2.4) {
145       fEfficTOF1 = fEffic3polTOF->Eval(pt1);
146     }else if(eta1 > -0.3 && eta1 < 0.3 && pt1 < 2.6) {
147       fEfficTOF1 = fEffic4polTOF->Eval(pt1);
148     }
149   }
150   
151   Double_t rndmtpc=gRandom->Rndm();
152   Double_t rndmtof=gRandom->Rndm();
153   Double_t weightPID1=1.;
154   if(fEfficTPC1 < rndmtpc && fEfficTOF1 < rndmtof) { weightPID1=0.;}
155   fPtKefftpc->Fill(pt1,weightPID1); 
156   
157   
158   Double_t pt2=track2->Pt();
159   Double_t eta2=track2->Eta();
160   
161   // TPC efficiency
162
163   if(TMath::Abs(eta2) > 0.7 && TMath::Abs(eta2) < 0.9 && pt2 < 0.48) {
164     fEfficTPC1 = fEffic1pol->Eval(pt2*1000.);
165   }else if(TMath::Abs(eta2) > 0.5 && TMath::Abs(eta2) < 0.7 && pt2 < 0.54) {
166     fEfficTPC1 = fEffic2pol->Eval(pt2*1000.);
167   }else if(TMath::Abs(eta2) > 0.3 && TMath::Abs(eta2) < 0.5 && pt2 < 0.585) {
168     fEfficTPC1 = fEffic3pol->Eval(pt2*1000.);
169   }else if(eta2 > -0.3 && eta2 < 0.3 && pt2 < 0.6) {
170     fEfficTPC1 = fEffic4pol->Eval(pt2*1000.);
171   }
172   
173   // TOF efficiency
174   
175   if(pt2 > 0.2) {
176     if(TMath::Abs(eta2) > 0.7 && TMath::Abs(eta2) < 0.9 && pt2 < 2.0) {
177       fEfficTOF1 = fEffic1polTOF->Eval(pt2);
178     }else if(TMath::Abs(eta2) > 0.5 && TMath::Abs(eta2) < 0.7 && pt2 < 2.4) {
179       fEfficTOF1 = fEffic2polTOF->Eval(pt2);
180     }else if(TMath::Abs(eta2) > 0.3 && TMath::Abs(eta2) < 0.5 && pt2 < 2.4) {
181       fEfficTOF1 = fEffic3polTOF->Eval(pt2);
182     }else if(eta2 > -0.3 && eta2 < 0.3 && pt2 < 2.6) {
183       fEfficTOF1 = fEffic4polTOF->Eval(pt2);
184     }
185   }
186   
187   rndmtpc=gRandom->Rndm();
188   rndmtof=gRandom->Rndm();
189   
190   Double_t weightPID2=1.;
191   if(fEfficTPC1 < rndmtpc && fEfficTOF1 < rndmtof) { weightPID2=0.;}
192   
193   Double_t weightPID=weightPID1*weightPID2;
194   fPtKefftpcboth->Fill(pt1,weightPID); 
195   
196   return weightPID;
197 }