]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGPP/TPC/AliComparisonDraw.cxx
Correcly handle centrality bins (Diego)
[u/mrichter/AliRoot.git] / PWGPP / TPC / AliComparisonDraw.cxx
1
2
3 //
4 // Comparison draw
5 // Compare the MC information with the reconstructed 
6 //
7
8 /*
9   after running analysis, read the file, and get component
10   gSystem->Load("libPWGPP.so");
11   TFile f("Output.root");
12   AliComparisonDraw * comp = (AliComparisonDraw*)f.Get("AliComparisonDraw");
13   TF1 fl("fl","((min(250./(abs(x+0.000001)),250)-90))",0,2);  // length function
14   TF1 fl2("fl2","[0]/((min(250./(abs(x+0.000001)),250)-90))^[1]",0,2);
15   fl2.SetParameter(1,1);
16   fl2.SetParameter(0,1);
17
18 */
19
20
21
22
23 #include "TFile.h"
24 #include "TH3F.h"
25 #include "TH2F.h"
26 #include "TF1.h"
27 #include "TProfile.h"
28 #include "TProfile2D.h"
29 #include "TGraph2D.h"
30 #include "TCanvas.h"
31 #include "TGraph.h"
32 //
33 // 
34 #include "AliESDEvent.h"   // new container
35 #include "AliESD.h"
36 #include "AliESDfriend.h"
37 #include "AliESDfriendTrack.h"
38 //
39 #include "AliMathBase.h"
40 #include "AliTreeDraw.h" 
41
42 #include "AliMCInfo.h" 
43 #include "AliESDRecInfo.h" 
44 #include "AliComparisonDraw.h" 
45
46
47 ClassImp(AliComparisonDraw)
48
49 Bool_t    AliComparisonDraw::fgBDraw=kFALSE;         //option draw temporary results
50
51 AliComparisonDraw::AliComparisonDraw():
52   TNamed("ComparisonDraw","ComparisonDraw"),
53   fEffTPCPt(0),      // TPC efficiency as function of Pt (tan+-1)
54   fEffTPCPtMC(0),    // MC -TPC efficiency as function of Pt (tan+-1)
55   fEffTPCPtF(0),     // efficiency for findable tracks
56   //
57   fEffTPCTan(0),   // TPC efficiency as function of Tan (pt>0.15
58   fEffTPCTanMC(0), // MC -TPC efficiency as function of Tan (pt>0.15)
59   fEffTPCTanF(0),  // efficiency for findable tracks Tan (pt>0.15)
60   //
61   fEffTPCPtTan(0),    // TPC efficiency as function of Pt and tan
62   fEffTPCPtTanMC(0),  // MC -TPC efficiency as function of Pt and tan
63   fEffTPCPtTanF(0),  // TPC efficiency as function of Pt and tan
64   //
65   // dEdx resolution
66   //
67   fTPCSignalNormTan(0), // tpc signal normalized to the mean signal - MC
68   fTPCSignalNormSPhi(0),   // tpc signal normalized to the mean signal - MC
69   fTPCSignalNormTPhi(0),   // tpc signal normalized to the mean signal - MC
70   //
71   fTPCSignalNormTanSPhi(0),   // tpc signal normalized to the mean signal - MC
72   fTPCSignalNormTanTPhi(0),   // tpc signal normalized to the mean signal - MC
73   fTPCSignalNormTanSPt(0),   // tpc signal normalized to the mean signal - MC
74   //
75   //
76   fPtResolLPT(0),        // pt resolution - low pt
77   fPtResolHPT(0),        // pt resolution - high pt 
78   fPtPullLPT(0),         // pt resolution - low pt
79   fPtPullHPT(0),         // pt resolution - high pt 
80   //
81   // Resolution constrained param
82   //
83   fCPhiResolTan(0),   // angular resolution -  constrained
84   fCTanResolTan(0),   // angular resolution -  constrained
85   fCPtResolTan(0),    // pt resolution      -  constrained
86   fCPhiPullTan(0),   // angular resolution -  constrained
87   fCTanPullTan(0),   // angular resolution -  constrained
88   fCPtPullTan(0),    // pt resolution      -  constrained
89   //
90   // DCA resolution
91   //
92   fD0TanSPtB1(0),   // distance to vertex y  
93   fD1TanSPtB1(0),   // distance to vertex z  
94   fD0TanSPtL1(0),   // distance to vertex y  
95   fD1TanSPtL1(0)   // distance to vertex z  
96 {
97   InitHisto();
98 }
99
100 AliComparisonDraw::AliComparisonDraw(const AliComparisonDraw& draw):
101   TNamed(draw.GetName(),draw.GetTitle()),
102   fEffTPCPt(draw.fEffTPCPt),      // TPC efficiency as function of Pt (tan+-1)
103   fEffTPCPtMC(draw.fEffTPCPtMC),    // MC -TPC efficiency as function of Pt (tan+-1)
104   fEffTPCPtF(draw.fEffTPCPtF),     // efficiency for findable tracks
105   //
106   fEffTPCTan(draw.fEffTPCTan),   // TPC efficiency as function of Tan (pt>0.15
107   fEffTPCTanMC(draw.fEffTPCTanMC), // MC -TPC efficiency as function of Tan (pt>0.15)
108   fEffTPCTanF(draw.fEffTPCTanF),  // efficiency for findable tracks Tan (pt>0.15)
109   //
110   fEffTPCPtTan(draw.fEffTPCPtTan),    // TPC efficiency as function of Pt and tan
111   fEffTPCPtTanMC(draw.fEffTPCPtTanMC),  // MC -TPC efficiency as function of Pt and tan
112   fEffTPCPtTanF(draw.fEffTPCPtTanF),  // TPC efficiency as function of Pt and tan
113   //
114   // dEdx resolution
115   //
116   fTPCSignalNormTan(draw.fTPCSignalNormTan), // tpc signal normalized to the mean signal - MC
117   fTPCSignalNormSPhi(draw.fTPCSignalNormSPhi),   // tpc signal normalized to the mean signal - MC
118   fTPCSignalNormTPhi(draw.fTPCSignalNormTPhi),   // tpc signal normalized to the mean signal - MC
119   //
120   fTPCSignalNormTanSPhi(draw.fTPCSignalNormTanSPhi),   // tpc signal normalized to the mean signal - MC
121   fTPCSignalNormTanTPhi(draw.fTPCSignalNormTanTPhi),   // tpc signal normalized to the mean signal - MC
122   fTPCSignalNormTanSPt(draw.fTPCSignalNormTanSPt),   // tpc signal normalized to the mean signal - MC
123   //
124   //
125   fPtResolLPT(draw.fPtResolLPT),        // pt resolution - low pt
126   fPtResolHPT(draw.fPtResolHPT),        // pt resolution - high pt 
127   fPtPullLPT(draw.fPtPullLPT),         // pt resolution - low pt
128   fPtPullHPT(draw.fPtPullHPT),         // pt resolution - high pt 
129   //
130   // Resolution constrained param
131   //
132   fCPhiResolTan(draw.fCPhiResolTan),   // angular resolution -  constrained
133   fCTanResolTan(draw.fCTanResolTan),   // angular resolution -  constrained
134   fCPtResolTan(draw.fCPtResolTan),    // pt resolution      -  constrained
135   fCPhiPullTan(draw.fCPhiPullTan),   // angular resolution -  constrained
136   fCTanPullTan(draw.fCTanPullTan),   // angular resolution -  constrained
137   fCPtPullTan(draw.fCPtPullTan),    // pt resolution      -  constrained
138   //
139   // DCA resolution
140   //
141   fD0TanSPtB1(draw.fD0TanSPtB1),   // distance to vertex y  
142   fD1TanSPtB1(draw.fD1TanSPtB1),   // distance to vertex z  
143   fD0TanSPtL1(draw.fD0TanSPtL1),   // distance to vertex y  
144   fD1TanSPtL1(draw.fD1TanSPtL1)   // distance to vertex z  
145 {
146   //
147   // copy constructor
148   //
149 }
150
151 AliComparisonDraw& AliComparisonDraw::operator=(const AliComparisonDraw& info){
152   //
153   // assignment operator
154   //
155   delete this;
156   new (this) AliComparisonDraw(info);
157   return *this;  
158 }
159
160
161
162
163 AliComparisonDraw::~AliComparisonDraw(){
164   //
165   //
166   //
167   delete  fEffTPCPt;      // TPC efficiency as function of Pt (tan+-1)
168   delete  fEffTPCPtMC;    // MC -TPC efficiency as function of Pt (tan+-1)
169   delete  fEffTPCPtF;     // efficiency for findable tracks
170   //
171   delete  fEffTPCTan;   // TPC efficiency as function of Tan (pt>0.15
172   delete  fEffTPCTanMC; // MC -TPC efficiency as function of Tan (pt>0.15)
173   delete  fEffTPCTanF;  // efficiency for findable tracks Tan (pt>0.15)
174   //
175   delete  fEffTPCPtTan;    // TPC efficiency as function of Pt and tan
176   delete  fEffTPCPtTanMC;  // MC -TPC efficiency as function of Pt and tan
177   delete  fEffTPCPtTanF;  // TPC efficiency as function of Pt and tan
178   //
179   // dEdx resolution
180   //
181   delete  fTPCSignalNormTan; // tpc signal normalized to the mean signal - MC
182   delete  fTPCSignalNormSPhi;   // tpc signal normalized to the mean signal - MC
183   delete  fTPCSignalNormTPhi;   // tpc signal normalized to the mean signal - MC
184   //
185   delete  fTPCSignalNormTanSPhi;   // tpc signal normalized to the mean signal - MC
186   delete  fTPCSignalNormTanTPhi;   // tpc signal normalized to the mean signal - MC
187   delete  fTPCSignalNormTanSPt;   // tpc signal normalized to the mean signal - MC
188   //
189   //
190   delete  fPtResolLPT;        // pt resolution - low pt
191   delete  fPtResolHPT;        // pt resolution - high pt 
192   delete  fPtPullLPT;         // pt resolution - low pt
193   delete  fPtPullHPT;         // pt resolution - high pt 
194   //
195   // Resolution constrained param
196   //
197   delete fCPhiResolTan;   // angular resolution -  constrained
198   delete fCTanResolTan;   // angular resolution -  constrained
199   delete fCPtResolTan;    // pt resolution      -  constrained
200   delete fCPhiPullTan;   // angular resolution -  constrained
201   delete fCTanPullTan;   // angular resolution -  constrained
202   delete fCPtPullTan;    // pt resolution      -  constrained
203   //
204   // DCA resolution
205   //
206   delete fD0TanSPtB1;   // distance to vertex y  
207   delete fD1TanSPtB1;   // distance to vertex z  
208   delete fD0TanSPtL1;   // distance to vertex y  
209   delete fD1TanSPtL1;   // distance to vertex z  
210  
211 }
212
213
214
215
216 void AliComparisonDraw::InitHisto(){
217   //
218   //
219   // EFFICIENCY
220   //  
221   // Efficiency as function of pt
222   fEffTPCPt = new TProfile("Eff_pt","Eff_Pt",50,0.1,3);            // physical
223   fEffTPCPtMC = new TProfile("MC_Eff_pt","MC_Eff_Pt",50,0.1,3);    // MC - particles make more than 50 rowdigits
224   fEffTPCPtF = new TProfile("F_Eff_pt","F_Eff_Pt",50,0.1,3);     // tracking - under condition more than 50 rdigits
225
226   // Efficiency as function of pt
227   fEffTPCTan = new TProfile("Eff_tan","Eff_tan",50,-2.5,2.5);            // physical
228   fEffTPCTanMC = new TProfile("MC_Eff_tan","MC_Eff_tan",50,-2.5,2.5);    // MC - particles make more than 50 rowdigits
229   fEffTPCTanF = new TProfile("F_Eff_tan","F_Eff_tan",50,-2.5,2.5);     // tracking - under condition more than 50 rdigits
230
231   fEffTPCPtTan = new TProfile2D("Eff_pt","Eff_Pt",10,0.1,3,20,-2.,2.);
232   fEffTPCPtTanMC = new TProfile2D("MC_Eff_pt","MC Eff Pt",10,0.1,3,20, -2.,2.);
233   fEffTPCPtTanF = new TProfile2D("MC_Eff_pt","MC Eff Pt",10,0.1,3,20, -2.,2.);
234   
235   //
236   // TPC dEdx
237   //
238   fTPCSignalNormTan = new TH2F("CdEdxTan","CdEdxTan",50, -2,2,  40,30,70); // tpc signal normalized to the MC
239   fTPCSignalNormSPhi   = new TH2F("CdEdxSPhi","CdEdxSPhi",10,0.0,1,40,30,70); // tpc signal normalized to the MC
240   fTPCSignalNormTPhi   = new TH2F("CdEdxTPhi","CdEdxTPhi",10,0.0,2,40,30,70); // tpc signal normalized to the MC
241
242   fTPCSignalNormTanSPhi= new TH3F("CdEdxTanSPhi","CdEdxTanSPhi",20, -2,2, 10,0.0 ,1,  40,30,70);   // tpc signal normalized to the mean signal - MC
243   fTPCSignalNormTanTPhi= new TH3F("CdEdxTanTPhi","CdEdxTanTPhi",20, -2,2, 10,0.0 ,1,  40,30,70);   // tpc signal normalized to the mean signal - MC
244   fTPCSignalNormTanSPt= new TH3F("CdEdxTanSPt","CdEdxTanSPt",20, -2,2, 10,0.3 ,3,  40,30,70);   // tpc signal normalized to the mean signal - MC
245
246
247
248   //
249   // RESOLUTION
250   //
251   fCPtResolTan = new TH2F("C Pt resol","C pt resol",50, -2,2,200,-0.2,0.2);
252   fCPtPullTan = new TH2F("C Pt pull","C pt pull",50, -2,2,200,-5,5);
253   //
254   fCPhiResolTan = new TH2F("CPhiResolTan","CPhiResolTan",50, -2,2,200,-0.025,0.025);   
255   // angular resolution -  constrained
256   fCTanResolTan = new TH2F("CTanResolTan","CTanResolTan",50, -2,2,200,-0.025,0.025);
257   // angular resolution -  constrained
258   fCPtResolTan=new TH2F("CPtResol","CPtResol",50, -2,2,200,-0.2,0.2);;    
259   // pt resolution      -  constrained
260   fCPhiPullTan = new TH2F("CPhiPullTan","CPhiPullTan",50, -2,2,200,-5,5);   
261   // angular resolution -  constrained
262   fCTanPullTan = new TH2F("CTanPullTan","CTanPullTan",50, -2,2,200,-5,5);
263   // angular resolution -  constrained
264   fCPtPullTan=new TH2F("CPtPull","CPtPull",50, -2,2,200,-5,5);    
265   // pt resolution      -  constrained
266   //
267   fPtResolLPT = new TH2F("Pt resol","pt resol",10, 0.1,3,200,-0.2,0.2);
268   fPtResolHPT = new TH2F("Pt resol","pt resol",10, 2,100,200,-0.3,0.3);  
269   fPtPullLPT = new TH2F("Pt pool","pt pool",10, 0.1,3,200,-6,6);
270   fPtPullHPT = new TH2F("Pt pool","pt pool",10, 2,100,200,-6,6);  
271   //
272   fD0TanSPtB1 = new TH3F("DCAyTanSPt","DCAyTanSPt",20,1,2, 10,0.3,2, 100,-4,4);
273   fD1TanSPtB1 = new TH3F("DCAzTanSPt","DCAzTanSPt",20,1,2, 10,0.3,2, 100,-4,4);
274   fD0TanSPtL1 = new TH3F("DCAyTanSPt","DCAyTanSPt",20,0,1, 10,0.3,2, 100,-0.1,0.1);
275   fD1TanSPtL1 = new TH3F("DCAzTanSPt","DCAzTanSPt",20,0,1, 10,0.3,2, 100, -0.1,0.1);
276
277
278
279 }
280
281 void AliComparisonDraw::ProcessEff(AliMCInfo* infoMC, AliESDRecInfo *infoRC){
282   //
283   // make efficiencies histograms
284   //
285   Float_t kptcut = 0.15;
286   Float_t ktancut=1.;
287   Int_t   kmincl =50;
288   Float_t mcpt = infoMC->GetParticle().Pt();
289   Float_t tantheta = TMath::Tan(infoMC->GetParticle().Theta()-TMath::Pi()*0.5);
290   Bool_t isPrim = infoMC->GetParticle().R()<0.1 && TMath::Abs(infoMC->GetParticle().Vz())<10;
291   //z diamond and 
292   
293   if (!isPrim) return;
294
295   //pt
296   if (TMath::Abs(tantheta)<ktancut){
297     fEffTPCPt->Fill(mcpt, infoRC->GetStatus(1)==3);
298     fEffTPCPtMC->Fill(mcpt, infoMC->GetRowsWithDigits()>kmincl);
299     if (infoMC->GetRowsWithDigits()>kmincl){
300       fEffTPCPtF->Fill(mcpt, infoRC->GetStatus(1)==3);
301     }
302   }
303
304   //theta
305   if (TMath::Abs(mcpt)>kptcut){
306     fEffTPCTan->Fill(tantheta, infoRC->GetStatus(1)==3);
307     fEffTPCTanMC->Fill(tantheta, infoMC->GetRowsWithDigits()>kmincl);
308     if (infoMC->GetRowsWithDigits()>kmincl){
309       fEffTPCTanF->Fill(tantheta, infoRC->GetStatus(1)==3);
310     }
311   }
312   // 
313   // pt-theta
314   //
315   fEffTPCPtTan->Fill(mcpt,tantheta,infoRC->GetStatus(1)==3);
316   fEffTPCPtTanMC->Fill(mcpt,tantheta,infoMC->GetRowsWithDigits()>50); 
317   if (infoMC->GetRowsWithDigits()>kmincl){
318     fEffTPCPtTanF->Fill(mcpt,tantheta,infoRC->GetStatus(1)==3); 
319   }
320 }
321
322
323 void AliComparisonDraw::ProcessResolConstrained(AliMCInfo* infoMC, AliESDRecInfo *infoRC){
324   //
325   //
326   //
327   Float_t mcpt = infoMC->GetParticle().Pt();
328   Float_t tantheta = TMath::Tan(infoMC->GetParticle().Theta()-TMath::Pi()*0.5);
329   Bool_t isPrim = infoMC->GetParticle().R()<0.1 && TMath::Abs(infoMC->GetParticle().Vz())<10;
330   //z diamond and 
331   
332   if (!isPrim) return;
333   if (infoRC->GetStatus(1)!=3) return;
334   if (!infoRC->GetESDtrack()) return;  
335   if (infoRC->GetESDtrack()->GetTPCNcls()<10) return;
336   if (!infoRC->GetESDtrack()->GetConstrainedParam()) return;
337   
338   //
339   // constrained parameters resolution
340   //
341   const AliExternalTrackParam * cparam = infoRC->GetESDtrack()->GetConstrainedParam();
342   Float_t deltaCPt= (mcpt-cparam->Pt())/mcpt;  
343   Float_t pullCPt= (1/mcpt-cparam->OneOverPt())/
344     TMath::Sqrt(cparam->GetSigma1Pt2());          
345   Float_t deltaPhi = TMath::ATan2(cparam->Py(),cparam->Px())-
346     TMath::ATan2(infoMC->GetParticle().Py(),infoMC->GetParticle().Px());
347   Float_t pullPhi = deltaPhi/TMath::Sqrt(cparam->GetSigmaSnp2()); 
348
349   Float_t deltaTan = TMath::ATan2(cparam->Pz(),cparam->Pt())-
350     TMath::ATan2(infoMC->GetParticle().Pz(),infoMC->GetParticle().Pt());
351   Float_t pullTan = deltaPhi/TMath::Sqrt(cparam->GetSigmaSnp2()); 
352
353   fCPtResolTan->Fill(tantheta,deltaCPt);
354   fCPtPullTan->Fill(tantheta,pullCPt);
355   fCPhiResolTan->Fill(tantheta,deltaPhi);
356   fCPhiPullTan->Fill(tantheta,pullPhi);
357   fCTanResolTan->Fill(tantheta,deltaTan);
358   fCTanPullTan->Fill(tantheta,pullTan);
359
360 }
361
362
363
364 void  AliComparisonDraw::ProcessTPCdedx(AliMCInfo* infoMC, AliESDRecInfo *infoRC){
365   //
366   //
367   //
368   Float_t mcpt = infoMC->GetParticle().Pt();
369   Float_t tantheta = TMath::Tan(infoMC->GetParticle().Theta()-TMath::Pi()*0.5);
370   Bool_t isPrim = infoMC->GetParticle().R()<0.1 && TMath::Abs(infoMC->GetParticle().Vz())<10;
371   //z diamond and 
372   
373   if (!isPrim) return;
374   if (infoRC->GetStatus(1)!=3) return;
375   if (!infoRC->GetESDtrack()) return;  
376   if (infoRC->GetESDtrack()->GetTPCNcls()<10) return;
377   if (!infoRC->GetESDtrack()->GetConstrainedParam()) return;
378   Float_t mprim = infoMC->GetPrim();
379   if (mprim>1.4) return;
380   if (mprim<0.5) return;
381   if (infoRC->GetESDtrack()->GetTPCsignalN()<50) return;
382   //
383   Float_t ratio = infoRC->GetESDtrack()->GetTPCsignal()/infoMC->GetPrim();
384   Float_t sphi =  infoRC->GetESDtrack()->GetInnerParam()->GetSnp();
385   Float_t tphi =  sphi/TMath::Sqrt((1.-sphi)*(1.+sphi));
386
387
388   if (TMath::Abs(infoMC->GetParticle().GetPdgCode())!=211) return;
389   if (mcpt>0.5){
390     fTPCSignalNormTan->Fill(tantheta,ratio);    //only subset
391   }
392   if (TMath::Abs(tantheta)<0.5){
393     fTPCSignalNormSPhi->Fill(sphi,ratio);        // only subset
394     fTPCSignalNormTPhi->Fill(tphi,ratio);        // only subset
395   }
396   fTPCSignalNormTanSPhi->Fill(tantheta,sphi,ratio);    
397   fTPCSignalNormTanTPhi->Fill(tantheta,tphi,ratio);    
398   fTPCSignalNormTanSPt->Fill(tantheta,TMath::Sqrt(mcpt),ratio);    
399 }
400
401 void      AliComparisonDraw::ProcessDCA(AliMCInfo* infoMC, AliESDRecInfo *infoRC){
402   //
403   //
404   //
405   Float_t mcpt = infoMC->GetParticle().Pt();
406   Float_t tantheta = TMath::Tan(infoMC->GetParticle().Theta()-TMath::Pi()*0.5);
407   Bool_t isPrim = infoMC->GetParticle().R()<0.1 && TMath::Abs(infoMC->GetParticle().Vz())<10;
408   //z diamond and 
409   if (!isPrim) return;
410   if (infoRC->GetStatus(1)!=3) return;
411   if (!infoRC->GetESDtrack()) return;  
412   if (infoRC->GetESDtrack()->GetTPCNcls()<10) return;
413   if (!infoRC->GetESDtrack()->GetConstrainedParam()) return;
414   Float_t spt = TMath::Sqrt(mcpt);
415   Float_t dca[2],cov[3];
416   infoRC->GetESDtrack()->GetImpactParameters(dca,cov);
417   Int_t clusterITS[100];
418   if (infoRC->GetESDtrack()->GetITSclusters(clusterITS)==0){
419     fD0TanSPtB1->Fill(tantheta,spt,dca[0]);
420     fD1TanSPtB1->Fill(tantheta,spt,dca[1]);
421   }
422   fD0TanSPtL1->Fill(tantheta,spt,dca[0]);
423   fD1TanSPtL1->Fill(tantheta,spt,dca[1]);  
424 }
425
426
427
428
429 void AliComparisonDraw::Process(AliMCInfo* infoMC, AliESDRecInfo *infoRC){
430   //
431   // 
432   //
433   ProcessEff(infoMC,infoRC);
434   ProcessResolConstrained(infoMC,infoRC);
435   ProcessTPCdedx(infoMC, infoRC);
436   ProcessDCA(infoMC, infoRC);
437
438   Float_t mcpt = infoMC->GetParticle().Pt();
439   Bool_t isPrim = infoMC->GetParticle().R()<0.1 && TMath::Abs(infoMC->GetParticle().Vz())<10;
440   //z diamond and 
441   
442   if (!isPrim) return;
443   //
444   //
445   if (infoRC->GetStatus(1)==0) return;
446   if (!infoRC->GetESDtrack()) return;  
447   if (infoRC->GetESDtrack()->GetTPCNcls()<10) return;
448   //  printf("Pt\t%f\t%f\n",mcpt, infoRC->GetESDtrack()->Pt());
449   
450   Float_t deltaPt= (mcpt-infoRC->GetESDtrack()->Pt())/mcpt;  
451   Float_t poolPt= (1/mcpt-infoRC->GetESDtrack()->OneOverPt())/
452     TMath::Sqrt(infoRC->GetESDtrack()->GetSigma1Pt2());  
453
454   fPtResolLPT->Fill(mcpt,deltaPt);
455   fPtResolHPT->Fill(mcpt,deltaPt);
456   fPtPullLPT->Fill(mcpt,poolPt);
457   fPtPullHPT->Fill(mcpt,poolPt);  
458 }
459
460
461
462 TH1F* AliComparisonDraw::MakeResol(TH2F * his, Int_t integ, Bool_t type){
463   TH1F *hisr, *hism;
464   if (!gPad) new TCanvas;
465   hisr = AliTreeDraw::CreateResHistoI(his,&hism,integ);
466   if (type) return hism;
467   else 
468     return hisr;
469 }
470
471
472 TGraph2D * AliComparisonDraw::MakeStat2D(TH3 * his, Int_t delta0, Int_t delta1, Int_t type){
473   //
474   //
475   //
476   // delta - number of bins to integrate
477   // type - 0 - mean value
478
479   TAxis * xaxis  = his->GetXaxis();
480   TAxis * yaxis  = his->GetYaxis();
481   //  TAxis * zaxis  = his->GetZaxis();
482   Int_t   nbinx  = xaxis->GetNbins();
483   Int_t   nbiny  = yaxis->GetNbins();
484   char name[1000];
485   Int_t icount=0;
486   TGraph2D  *graph = new TGraph2D(nbinx*nbiny);
487   TF1 f1("f1","gaus");
488   for (Int_t ix=0; ix<nbinx;ix++)
489     for (Int_t iy=0; iy<nbiny;iy++){
490       Float_t xcenter = xaxis->GetBinCenter(ix); 
491       Float_t ycenter = yaxis->GetBinCenter(iy); 
492       snprintf(name,1000,"%s_%d_%d",his->GetName(), ix,iy);
493       TH1 *projection = his->ProjectionZ(name,ix-delta0,ix+delta0,iy-delta1,iy+delta1);
494       Float_t stat= 0;
495       if (type==0) stat = projection->GetMean();
496       if (type==1) stat = projection->GetRMS();
497       if (type==2 || type==3){
498         TVectorD vec(3);
499         AliMathBase::LTM((TH1F*)projection,&vec,0.7);
500         if (type==2) stat= vec[1];
501         if (type==3) stat= vec[0];      
502       }
503       if (type==4|| type==5){
504         projection->Fit(&f1);
505         if (type==4) stat= f1.GetParameter(1);
506         if (type==5) stat= f1.GetParameter(2);
507       }
508       //printf("%d\t%f\t%f\t%f\n", icount,xcenter, ycenter, stat);
509       graph->SetPoint(icount,xcenter, ycenter, stat);
510       icount++;
511     }
512   return graph;
513 }
514
515 TGraph * AliComparisonDraw::MakeStat1D(TH3 * his, Int_t delta1, Int_t type){
516   //
517   //
518   //
519   // delta - number of bins to integrate
520   // type - 0 - mean value
521
522   TAxis * xaxis  = his->GetXaxis();
523   TAxis * yaxis  = his->GetYaxis();
524   //  TAxis * zaxis  = his->GetZaxis();
525   Int_t   nbinx  = xaxis->GetNbins();
526   Int_t   nbiny  = yaxis->GetNbins();
527   char name[1000];
528   Int_t icount=0;
529   TGraph  *graph = new TGraph(nbinx);
530   TF1 f1("f1","gaus");
531   for (Int_t ix=0; ix<nbinx;ix++){
532     Float_t xcenter = xaxis->GetBinCenter(ix); 
533     //    Float_t ycenter = yaxis->GetBinCenter(iy); 
534     snprintf(name,1000,"%s_%d",his->GetName(), ix);
535     TH1 *projection = his->ProjectionZ(name,ix-delta1,ix+delta1,0,nbiny);
536     Float_t stat= 0;
537     if (type==0) stat = projection->GetMean();
538     if (type==1) stat = projection->GetRMS();
539     if (type==2 || type==3){
540       TVectorD vec(3);
541         AliMathBase::LTM((TH1F*)projection,&vec,0.7);
542         if (type==2) stat= vec[1];
543         if (type==3) stat= vec[0];      
544     }
545     if (type==4|| type==5){
546       projection->Fit(&f1);
547       if (type==4) stat= f1.GetParameter(1);
548       if (type==5) stat= f1.GetParameter(2);
549     }
550       //printf("%d\t%f\t%f\t%f\n", icount,xcenter, ycenter, stat);
551     graph->SetPoint(icount,xcenter, stat);
552     icount++;
553   }
554   return graph;
555 }
556
557 //
558 // Make derived plots
559 //
560
561 void AliComparisonDraw::MakePlots(){
562   //
563   //
564   //
565   AliComparisonDraw * comp=this;
566
567   TFile *fp = new TFile("picutures.root","recreate");
568   TH1F *hiss=0;
569   //TH1F *hism=0;
570   TGraph2D * gr=0, gr2=0;
571   TGraph * gr0 = 0;
572   TCanvas * c = new TCanvas("Phi resol Tan","Phi resol Tan");
573   //
574   //
575   //
576   hiss = comp->MakeResol(comp->fCPtResolTan,1,0);
577   hiss->SetXTitle("Tan(#theta)");
578   hiss->SetYTitle("#sigmap_{t}/p_{t}");
579   hiss->Draw(); 
580   hiss->Write("CptResolTan");
581   //
582   //
583   hiss = comp->MakeResol(comp->fCPhiResolTan,1,0);
584   c->cd();
585   hiss->SetXTitle("Tan(#theta)");
586   hiss->SetYTitle("#sigma#phi (rad)");
587   hiss->Draw();
588   fp->cd();
589   hiss->Write("PhiResolTan");
590   //
591   hiss = comp->MakeResol(comp->fCTanResolTan,1,0);
592   c->cd();
593   hiss->SetXTitle("Tan(#theta)");
594   hiss->SetYTitle("#sigma#theta (rad)");
595   hiss->Draw();
596   fp->cd();
597   hiss->Write("ThetaResolTan");
598   //
599   //
600   hiss = comp->MakeResol(comp->fCTanResolTan,1,0);
601   c->cd();
602   hiss->SetXTitle("Tan(#theta)");
603   hiss->SetYTitle("#sigmap_{t}/p_{t} ");
604   hiss->Draw();
605   fp->cd();
606   //
607   //
608   //
609   hiss = comp->MakeResol(comp->fTPCSignalNormTan,4,0);
610   hiss->SetXTitle("Tan(#theta)");
611   hiss->SetYTitle("#sigma_{dEdx}");
612   hiss->Draw();
613   fp->cd();
614   hiss->Write("TPCdEdxResolTan");
615   //
616   //
617   //
618   hiss = comp->MakeResol(comp->fTPCSignalNormTan,4,1); 
619   hiss->SetXTitle("Tan(#theta)");
620   hiss->SetYTitle("<dEdx>");
621   hiss->Draw(); 
622   hiss->Write("TPCdEdxMeanTan");
623   //
624   //
625   gr = comp->MakeStat2D(comp->fTPCSignalNormTanSPt,3,1,4);
626   gr->GetXaxis()->SetTitle("Tan(#theta)");
627   gr->GetYaxis()->SetTitle("#sqrt{p_{t}(GeV)}");
628   gr->GetZaxis()->SetTitle("<dEdx>");
629   gr->Draw("colz"); 
630   gr->GetHistogram()->Write("TPCdEdxMeanTanPt");
631   //
632   //
633   gr = comp->MakeStat2D(comp->fTPCSignalNormTanSPt,3,1,5);
634   gr->GetXaxis()->SetTitle("Tan(#theta)");
635   gr->GetYaxis()->SetTitle("#sqrt{p_{t}(GeV)}");
636   gr->GetZaxis()->SetTitle("#sigma_{dEdx}");
637   gr->Draw("colz"); 
638   gr->GetHistogram()->Write("TPCdEdxMeanTanPt");
639   //
640   //
641   //
642   comp->fEffTPCTanF->SetXTitle("Tan(#theta)");
643   comp->fEffTPCTanF->SetYTitle("eff_{findable}");
644   comp->fEffTPCTanF->Draw();
645   comp->fEffTPCTanF->Write("EffTanFindable");
646   //
647   //
648   comp->fEffTPCTan->SetXTitle("Tan(#theta)");
649   comp->fEffTPCTan->SetYTitle("eff_{all}");
650   comp->fEffTPCTan->Draw();
651   comp->fEffTPCTan->Write("EffTanAll");
652   //
653   //DCA resolution
654   //
655   gr0 = comp->MakeStat1D(comp->fD0TanSPtB1,2,5);
656   gr0->GetXaxis()->SetTitle("Tan(#theta)");
657   gr0->GetYaxis()->SetTitle("#sigmaDCA (cm)");
658   gPad->Clear();
659   gr0->Draw("al*");
660   gr->GetHistogram()->Write("DCAResolTan");
661   //
662   //
663   //
664   gr = comp->MakeStat2D(comp->fD0TanSPtB1,4,2,5); 
665   gr0->GetXaxis()->SetTitle("Tan(#theta)");
666   gr0->GetYaxis()->SetTitle("#sigmaDCA (cm)");
667   gPad->Clear();
668   gr0->Draw("al*");
669   gr->GetHistogram()->Write("DCAResolSPTTan");
670
671   fp->Close();
672
673
674 }
675
676
677