]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCComparison.C
Removed compiler warning
[u/mrichter/AliRoot.git] / TPC / AliTPCComparison.C
CommitLineData
7f6ddf58 1/****************************************************************************
2 * Very important, delicate and rather obscure macro. *
3 * *
4 * Creates list of "trackable" tracks, *
7f6ddf58 5 * calculates efficiency, resolutions etc. *
bf018fe4 6 * There is a possibility to run this macro over several events. *
7f6ddf58 7 * *
024a7fe9 8 * Origin: I.Belikov, CERN, Jouri.Belikov@cern.ch *
7f6ddf58 9 * with several nice improvements by: M.Ivanov, GSI, m.ivanov@gsi.de *
10 ****************************************************************************/
11
c630aafd 12#if !defined(__CINT__) || defined(__MAKECINT__)
5102bab6 13 #include <TMath.h>
14 #include <TError.h>
15 #include <Riostream.h>
16 #include <TH1F.h>
17 #include <TH2F.h>
18 #include <TTree.h>
19 #include <TParticle.h>
20 #include <TPad.h>
21 #include <TCanvas.h>
22 #include <TLine.h>
23 #include <TText.h>
24 #include <TBenchmark.h>
25 #include <TStyle.h>
26 #include <TKey.h>
bf018fe4 27 #include <TROOT.h>
5102bab6 28
29 #include "AliStack.h"
30 #include "AliHeader.h"
31 #include "AliTrackReference.h"
88cb7938 32 #include "AliRunLoader.h"
33 #include "AliMagF.h"
c630aafd 34 #include "AliRun.h"
5102bab6 35 #include "AliESD.h"
36
37 #include "AliSimDigits.h"
38 #include "AliTPC.h"
39 #include "AliTPCParamSR.h"
40 #include "AliTPCClustersArray.h"
41 #include "AliTPCClustersRow.h"
bf018fe4 42 #include "AliTPCcluster.h"
5102bab6 43 #include "AliTPCLoader.h"
be9c5115 44#endif
45
f38c8ae5 46struct GoodTrackTPC {
cc80f89e 47 Int_t lab;
48 Int_t code;
49 Float_t px,py,pz;
50 Float_t x,y,z;
51};
cc80f89e 52
5102bab6 53Int_t good_tracks_tpc(GoodTrackTPC *gt, const Int_t max,
54const char* evfoldname=AliConfig::fgkDefaultEventFolderName);
88cb7938 55
c630aafd 56extern AliRun *gAlice;
5102bab6 57extern TBenchmark *gBenchmark;
bf018fe4 58extern TROOT *gROOT;
fbb58996 59
bf018fe4 60Int_t AliTPCComparison(const Char_t *dir=".") {
5102bab6 61 gBenchmark->Start("AliTPCComparison");
62
63 ::Info("AliTPCComparison.C","Doing comparison...");
c630aafd 64
65 if (gAlice) {
88cb7938 66 delete gAlice->GetRunLoader();
67 delete gAlice;//if everything was OK here it is already NULL
68 gAlice = 0x0;
69 }
70
bf018fe4 71 Char_t fname[100];
72 sprintf(fname,"%s/galice.root",dir);
73
74 AliRunLoader *rl = AliRunLoader::Open(fname,"COMPARISON");
c630aafd 75 if (!rl) {
5102bab6 76 ::Fatal("AliTPCComparison.C","Can't start session !");
c630aafd 77 }
7f6ddf58 78
7f6ddf58 79 /* Generate a list of "good" tracks */
5102bab6 80 const Int_t MAX=20000;
f38c8ae5 81 GoodTrackTPC gt[MAX];
cc80f89e 82 Int_t ngood=0;
bf018fe4 83 sprintf(fname,"%s/good_tracks_tpc",dir);
84 ifstream in(fname);
cc80f89e 85 if (in) {
5102bab6 86 ::Info("AliTPCComparison.C","Reading good tracks...");
7f6ddf58 87 while (in>>gt[ngood].lab>>gt[ngood].code>>
be9c5115 88 gt[ngood].px>>gt[ngood].py>>gt[ngood].pz>>
89 gt[ngood].x >>gt[ngood].y >>gt[ngood].z) {
7ac477db 90 ngood++;
7ac477db 91 if (ngood==MAX) {
5102bab6 92 ::Warning("AliTPCComparison.C","Too many good tracks !");
7ac477db 93 break;
94 }
cc80f89e 95 }
5102bab6 96 if (!in.eof())
97 ::Fatal("AliTPCComparison.C","Read error (good_tracks_tpc) !");
cc80f89e 98 } else {
5102bab6 99 ::Info
100 ("AliTPCComparison","Marking good tracks (this will take a while)...");
88cb7938 101 ngood=good_tracks_tpc(gt,MAX,"COMPARISON");
bf018fe4 102 ofstream out(fname);
cc80f89e 103 if (out) {
104 for (Int_t ngd=0; ngd<ngood; ngd++)
7f6ddf58 105 out<<gt[ngd].lab<<' '<<gt[ngd].code<<' '<<
be9c5115 106 gt[ngd].px<<' '<<gt[ngd].py<<' '<<gt[ngd].pz<<' '<<
107 gt[ngd].x <<' '<<gt[ngd].y <<' '<<gt[ngd].z <<endl;
5102bab6 108 } else
109 ::Fatal("AliTPCComparison.C","Can not open file (good_tracks_tpc) !");
cc80f89e 110 out.close();
111 }
7f6ddf58 112
bf018fe4 113 AliESD *event=0;
3cb3ee52 114 { /*Load tracks*/
bf018fe4 115 sprintf(fname,"%s/AliESDs.root",dir);
116 TFile *ef=TFile::Open(fname);
5102bab6 117 if ((!ef)||(!ef->IsOpen())) {
bf018fe4 118 sprintf(fname,"%s/AliESDtpc.root",dir);
119 ef=TFile::Open(fname);
120 if ((!ef)||(!ef->IsOpen()))
121 ::Fatal("AliTPCComparison.C","Can't open AliESDtpc.root !");
5102bab6 122 }
123 TKey *key=0;
124 TIter next(ef->GetListOfKeys());
bf018fe4 125 if ((key=(TKey*)next())!=0) event=(AliESD*)key->ReadObj();
5102bab6 126 ef->Close();
3cb3ee52 127 }
bf018fe4 128 Int_t nentr=event->GetNumberOfTracks();
129
130 TH1F *hp=(TH1F*)gROOT->FindObject("hp");
131 if (!hp) hp=new TH1F("hp","PHI resolution",50,-20.,20.);
132 hp->SetFillColor(4);
133
134 TH1F *hl=(TH1F*)gROOT->FindObject("hl");
135 if (!hl) hl=new TH1F("hl","LAMBDA resolution",50,-20,20);
136 hl->SetFillColor(4);
137
138 TH1F *hpt=(TH1F*)gROOT->FindObject("hpt");
139 if (!hpt) hpt=new TH1F("hpt","Relative Pt resolution",30,-10.,10.);
140 hpt->SetFillColor(2);
141
142 TH1F *hmpt=(TH1F*)gROOT->FindObject("hmpt");
143 if (!hmpt)
144 hmpt=new TH1F("hmpt","Relative Pt resolution (pt>4GeV/c)",30,-60,60);
cc80f89e 145 hmpt->SetFillColor(6);
8c555625 146
bf018fe4 147
148
149 TH1F *hgood=(TH1F*)gROOT->FindObject("hgood");
150 if (!hgood) hgood=new TH1F("hgood","Good tracks",30,0.2,6.1);
151
152 TH1F *hfound=(TH1F*)gROOT->FindObject("hfound");
153 if (!hfound) hfound=new TH1F("hfound","Found tracks",30,0.2,6.1);
154
155 TH1F *hfake=(TH1F*)gROOT->FindObject("hfake");
156 if (!hfake) hfake=new TH1F("hfake","Fake tracks",30,0.2,6.1);
157
158 TH1F *hg=(TH1F*)gROOT->FindObject("hg");
159 if (!hg) hg=new TH1F("hg","Efficiency for good tracks",30,0.2,6.1);
8c555625 160 hg->SetLineColor(4); hg->SetLineWidth(2);
bf018fe4 161
162 TH1F *hf=(TH1F*)gROOT->FindObject("hf");
163 if (!hf) hf=new TH1F("hf","Efficiency for fake tracks",30,0.2,6.1);
8c555625 164 hf->SetFillColor(1); hf->SetFillStyle(3013); hf->SetLineWidth(2);
165
bf018fe4 166 TH1F *he=(TH1F*)gROOT->FindObject("he");
167 if (!he)
168 he =new TH1F("he","dE/dX for pions with 0.4<p<0.5 GeV/c",50,0.,100.);
169
170 TH2F *hep=(TH2F*)gROOT->FindObject("hep");
171 if (!hep) hep=new TH2F("hep","dE/dX vs momentum",50,0.,2.,50,0.,400.);
be9c5115 172 hep->SetMarkerStyle(8);
173 hep->SetMarkerSize(0.4);
8c555625 174
7f6ddf58 175 //MI change
176 Int_t mingood=ngood;
177 Int_t track_notfound[MAX], itrack_notfound=0;
178 Int_t track_fake[MAX], itrack_fake=0;
179 Int_t track_multifound[MAX], track_multifound_n[MAX], itrack_multifound=0;
cf98c13f 180
bf018fe4 181 Int_t i;
cc80f89e 182 while (ngood--) {
cf98c13f 183 Int_t lab=gt[ngood].lab,tlab=-1;
cc80f89e 184 Float_t ptg=
185 TMath::Sqrt(gt[ngood].px*gt[ngood].px + gt[ngood].py*gt[ngood].py);
8c555625 186
7f6ddf58 187 if (ptg<1e-33) continue; // for those not crossing 0 pad row
b9de75e1 188
8c555625 189 hgood->Fill(ptg);
cc80f89e 190
bf018fe4 191 AliESDtrack *track=0;
7f6ddf58 192 for (i=0; i<nentr; i++) {
bf018fe4 193 track=event->GetTrack(i);
73042f01 194 tlab=track->GetLabel();
cc80f89e 195 if (lab==TMath::Abs(tlab)) break;
8c555625 196 }
7f6ddf58 197 if (i==nentr) {
cf98c13f 198 track_notfound[itrack_notfound++]=lab;
cc80f89e 199 continue;
200 }
cf98c13f 201
202 //MI change - addition
203 Int_t micount=0;
204 Int_t mi;
bf018fe4 205 AliESDtrack * mitrack;
7f6ddf58 206 for (mi=0; mi<nentr; mi++) {
bf018fe4 207 mitrack=event->GetTrack(mi);
cf98c13f 208 if (lab==TMath::Abs(mitrack->GetLabel())) micount++;
209 }
210 if (micount>1) {
cf98c13f 211 track_multifound[itrack_multifound]=lab;
212 track_multifound_n[itrack_multifound]=micount;
213 itrack_multifound++;
214 }
215
cc80f89e 216 if (lab==tlab) hfound->Fill(ptg);
cf98c13f 217 else {
218 track_fake[itrack_fake++]=lab;
219 hfake->Fill(ptg);
cf98c13f 220 }
cc80f89e 221
bf018fe4 222 Double_t pxpypz[3]; track->GetInnerPxPyPz(pxpypz);
223 Float_t phi=TMath::ATan2(pxpypz[1],pxpypz[0]);
be9c5115 224 if (phi<-TMath::Pi()) phi+=2*TMath::Pi();
225 if (phi>=TMath::Pi()) phi-=2*TMath::Pi();
bf018fe4 226 Double_t pt=TMath::Sqrt(pxpypz[0]*pxpypz[0]+pxpypz[1]*pxpypz[1]);
227 Float_t lam=TMath::ATan2(pxpypz[2],pt);
228 Float_t pt_1=1/pt;
cc80f89e 229
230 if (TMath::Abs(gt[ngood].code)==11 && ptg>4.) {
be9c5115 231 hmpt->Fill((pt_1 - 1/ptg)/(1/ptg)*100.);
cc80f89e 232 } else {
233 Float_t phig=TMath::ATan2(gt[ngood].py,gt[ngood].px);
cc80f89e 234 hp->Fill((phi - phig)*1000.);
3c0f9266 235
cc80f89e 236 Float_t lamg=TMath::ATan2(gt[ngood].pz,ptg);
cc80f89e 237 hl->Fill((lam - lamg)*1000.);
238
be9c5115 239 hpt->Fill((pt_1 - 1/ptg)/(1/ptg)*100.);
cc80f89e 240 }
73042f01 241
bf018fe4 242 Float_t mom=pt/TMath::Cos(lam);
243 Float_t dedx=track->GetTPCsignal();
cc80f89e 244 hep->Fill(mom,dedx,1.);
245 if (TMath::Abs(gt[ngood].code)==211)
246 if (mom>0.4 && mom<0.5) {
247 he->Fill(dedx,1.);
248 }
73042f01 249
cc80f89e 250 }
251
cf98c13f 252 cout<<"\nList of Not found tracks :\n";
cf98c13f 253 for ( i = 0; i< itrack_notfound; i++){
254 cout<<track_notfound[i]<<"\t";
255 if ((i%5)==4) cout<<"\n";
256 }
257 cout<<"\nList of fake tracks :\n";
258 for ( i = 0; i< itrack_fake; i++){
259 cout<<track_fake[i]<<"\t";
260 if ((i%5)==4) cout<<"\n";
261 }
262 cout<<"\nList of multiple found tracks :\n";
263 for ( i=0; i<itrack_multifound; i++) {
7f6ddf58 264 cout<<"id. "<<track_multifound[i]
265 <<" found - "<<track_multifound_n[i]<<"times\n";
cf98c13f 266 }
8c555625 267
7f6ddf58 268 Stat_t ng=hgood->GetEntries(), nf=hfound->GetEntries();
269 if (ng!=0) cerr<<"\n\nIntegral efficiency is about "<<nf/ng*100.<<" %\n";
270 cout<<"Total number of found tracks ="<<nentr<<endl;
271 cout<<"Total number of \"good\" tracks ="
272 <<mingood<<" (selected for comparison: "<<ng<<')'<<endl<<endl;
273
274
8c555625 275 gStyle->SetOptStat(111110);
276 gStyle->SetOptFit(1);
277
278 TCanvas *c1=new TCanvas("c1","",0,0,700,850);
279
280 TPad *p1=new TPad("p1","",0,0.3,.5,.6); p1->Draw();
281 p1->cd(); p1->SetFillColor(42); p1->SetFrameFillColor(10);
282 hp->SetFillColor(4); hp->SetXTitle("(mrad)"); hp->Fit("gaus"); c1->cd();
283
284 TPad *p2=new TPad("p2","",0.5,.3,1,.6); p2->Draw();
285 p2->cd(); p2->SetFillColor(42); p2->SetFrameFillColor(10);
286 hl->SetXTitle("(mrad)"); hl->Fit("gaus"); c1->cd();
287
288 TPad *p3=new TPad("p3","",0,0,0.5,0.3); p3->Draw();
289 p3->cd(); p3->SetFillColor(42); p3->SetFrameFillColor(10);
290 hpt->SetXTitle("(%)"); hpt->Fit("gaus"); c1->cd();
291
292 TPad *p4=new TPad("p4","",0.5,0,1,0.3); p4->Draw();
293 p4->cd(); p4->SetFillColor(42); p4->SetFrameFillColor(10);
cc80f89e 294 hmpt->SetXTitle("(%)"); hmpt->Fit("gaus"); c1->cd();
8c555625 295
296 TPad *p5=new TPad("p5","",0,0.6,1,1); p5->Draw(); p5->cd();
3c0f9266 297 p5->SetFillColor(41); p5->SetFrameFillColor(10);
8c555625 298 hfound->Sumw2(); hgood->Sumw2(); hfake->Sumw2();
299 hg->Divide(hfound,hgood,1,1.,"b");
300 hf->Divide(hfake,hgood,1,1.,"b");
301 hg->SetMaximum(1.4);
302 hg->SetYTitle("Tracking efficiency");
303 hg->SetXTitle("Pt (GeV/c)");
304 hg->Draw();
305
7f6ddf58 306 TLine *line1 = new TLine(0.1,1.0,6.1,1.0); line1->SetLineStyle(4);
8c555625 307 line1->Draw("same");
7f6ddf58 308 TLine *line2 = new TLine(0.1,0.9,6.1,0.9); line2->SetLineStyle(4);
8c555625 309 line2->Draw("same");
310
311 hf->SetFillColor(1);
312 hf->SetFillStyle(3013);
313 hf->SetLineColor(2);
314 hf->SetLineWidth(2);
315 hf->Draw("histsame");
316 TText *text = new TText(0.461176,0.248448,"Fake tracks");
317 text->SetTextSize(0.05);
318 text->Draw();
319 text = new TText(0.453919,1.11408,"Good tracks");
320 text->SetTextSize(0.05);
321 text->Draw();
3c0f9266 322
323
324
325 TCanvas *c2=new TCanvas("c2","",320,32,530,590);
326
327 TPad *p6=new TPad("p6","",0.,0.,1.,.5); p6->Draw();
328 p6->cd(); p6->SetFillColor(42); p6->SetFrameFillColor(10);
329 he->SetFillColor(2); he->SetFillStyle(3005);
330 he->SetXTitle("Arbitrary Units");
331 he->Fit("gaus"); c2->cd();
332
333 TPad *p7=new TPad("p7","",0.,0.5,1.,1.); p7->Draw();
334 p7->cd(); p7->SetFillColor(42); p7->SetFrameFillColor(10);
335 hep->SetXTitle("p (Gev/c)"); hep->SetYTitle("dE/dX (Arb. Units)");
336 hep->Draw(); c1->cd();
337
cf98c13f 338 gBenchmark->Stop("AliTPCComparison");
339 gBenchmark->Show("AliTPCComparison");
340
88cb7938 341 delete rl;
73042f01 342 return 0;
cc80f89e 343}
3c0f9266 344
cc80f89e 345
c630aafd 346Int_t
347good_tracks_tpc(GoodTrackTPC *gt, const Int_t max, const char* evfoldname) {
7f6ddf58 348 Int_t nt=0;
cc80f89e 349
c630aafd 350 AliRunLoader *rl = AliRunLoader::GetRunLoader(evfoldname);
351 if (rl == 0x0) {
88cb7938 352 ::Fatal("AliTPCComparison.C::good_tracks_tpc",
353 "Can not find Run Loader in Folder Named %s",
354 evfoldname);
c630aafd 355 }
356 AliTPCLoader *tpcl = (AliTPCLoader *)rl->GetLoader("TPCLoader");
357 if (tpcl == 0x0) {
5102bab6 358 ::Fatal("AliTPCHits2Digits.C","Can not find TPCLoader !");
c630aafd 359 }
88cb7938 360
361 rl->LoadgAlice();
362
363 AliTPC *TPC=(AliTPC*)rl->GetAliRun()->GetDetector("TPC");
73042f01 364 Int_t ver = TPC->IsVersion();
365 cerr<<"TPC version "<<ver<<" has been found !\n";
366
88cb7938 367 rl->CdGAFile();
368 AliTPCParamSR *digp=(AliTPCParamSR*)gDirectory->Get("75x40_100x60_150x60");
5102bab6 369 if (!digp) {
370 ::Fatal("AliTPCHits2Digits.C","TPC parameters have not been found !");
371 }
73042f01 372 TPC->SetParam(digp);
373
88cb7938 374 rl->LoadHeader();
375
376 Int_t np = rl->GetHeader()->GetNtrack();
377
024a7fe9 378
73042f01 379 Int_t nrow_up=digp->GetNRowUp();
380 Int_t nrows=digp->GetNRowLow()+nrow_up;
381 Int_t zero=digp->GetZeroSup();
7f6ddf58 382 Int_t gap=Int_t(0.125*nrows), shift=Int_t(0.5*gap);
cc80f89e 383 Int_t good_number=Int_t(0.4*nrows);
384
7f6ddf58 385 Int_t *good=new Int_t[np];
386 Int_t i;
387 for (i=0; i<np; i++) good[i]=0;
388
389
390 switch (ver) {
391 case 1:
392 {
88cb7938 393 tpcl->LoadRecPoints();
7f6ddf58 394 AliTPCClustersArray *pca=new AliTPCClustersArray, &ca=*pca;
395 ca.Setup(digp);
396 ca.SetClusterType("AliTPCcluster");
88cb7938 397 ca.ConnectTree(tpcl->TreeR());
7f6ddf58 398 Int_t nrows=Int_t(ca.GetTree()->GetEntries());
399 for (Int_t n=0; n<nrows; n++) {
400 AliSegmentID *s=ca.LoadEntry(n);
401 Int_t sec,row;
402 digp->AdjustSectorRow(s->GetID(),sec,row);
403 AliTPCClustersRow &clrow = *ca.GetRow(sec,row);
404 Int_t ncl=clrow.GetArray()->GetEntriesFast();
405 while (ncl--) {
406 AliTPCcluster *c=(AliTPCcluster*)clrow[ncl];
407 Int_t lab=c->GetLabel(0);
408 if (lab<0) continue; //noise cluster
409 lab=TMath::Abs(lab);
410
411 if (sec>=digp->GetNInnerSector())
412 if (row==nrow_up-1) good[lab]|=0x4000;
413 if (sec>=digp->GetNInnerSector())
414 if (row==nrow_up-1-gap) good[lab]|=0x1000;
415
416 if (sec>=digp->GetNInnerSector())
417 if (row==nrow_up-1-shift) good[lab]|=0x2000;
418 if (sec>=digp->GetNInnerSector())
419 if (row==nrow_up-1-gap-shift) good[lab]|=0x800;
420
421 good[lab]++;
422 }
423 ca.ClearRow(sec,row);
424 }
425 delete pca;
88cb7938 426 tpcl->UnloadRecPoints();
7f6ddf58 427 }
afc42102 428 break;
7f6ddf58 429 case 2:
430 {
88cb7938 431 tpcl->LoadDigits();
432 TTree *TD=tpcl->TreeD();
433
7f6ddf58 434 AliSimDigits da, *digits=&da;
435 TD->GetBranch("Segment")->SetAddress(&digits);
436
437 Int_t *count = new Int_t[np];
438 Int_t i;
439 for (i=0; i<np; i++) count[i]=0;
440
441 Int_t sectors_by_rows=(Int_t)TD->GetEntries();
442 for (i=0; i<sectors_by_rows; i++) {
443 if (!TD->GetEvent(i)) continue;
444 Int_t sec,row;
445 digp->AdjustSectorRow(digits->GetID(),sec,row);
446 cerr<<sec<<' '<<row<<" \r";
447 digits->First();
448 do { //Many thanks to J.Chudoba who noticed this
449 Int_t it=digits->CurrentRow(), ip=digits->CurrentColumn();
450 Short_t dig = digits->GetDigit(it,ip);
451 Int_t idx0=digits->GetTrackID(it,ip,0);
452 Int_t idx1=digits->GetTrackID(it,ip,1);
453 Int_t idx2=digits->GetTrackID(it,ip,2);
8ded1b7a 454 if (idx0>=0 && dig>=zero && idx0<np) count[idx0]+=1;
455 if (idx1>=0 && dig>=zero && idx1<np) count[idx1]+=1;
456 if (idx2>=0 && dig>=zero && idx2<np) count[idx2]+=1;
afc42102 457 } while (digits->Next());
7f6ddf58 458 for (Int_t j=0; j<np; j++) {
459 if (count[j]>1) {
460 if (sec>=digp->GetNInnerSector())
461 if (row==nrow_up-1 ) good[j]|=0x4000;
462 if (sec>=digp->GetNInnerSector())
463 if (row==nrow_up-1-gap) good[j]|=0x1000;
464
465 if (sec>=digp->GetNInnerSector())
466 if (row==nrow_up-1-shift) good[j]|=0x2000;
467 if (sec>=digp->GetNInnerSector())
468 if (row==nrow_up-1-gap-shift) good[j]|=0x800;
469 good[j]++;
470 }
471 count[j]=0;
472 }
473 }
474 delete[] count;
88cb7938 475 tpcl->UnloadDigits();
afc42102 476 }
7f6ddf58 477 break;
478 default:
5102bab6 479 ::Fatal("AliTPCComparison.C","Invalid TPC version !");
cc80f89e 480 }
7f6ddf58 481
88cb7938 482 rl->LoadKinematics();
483 AliStack* stack = rl->Stack();
7f6ddf58 484 /** select tracks which are "good" enough **/
485 for (i=0; i<np; i++) {
486 if ((good[i]&0x5000) != 0x5000)
487 if ((good[i]&0x2800) != 0x2800) continue;
488 if ((good[i]&0x7FF ) < good_number) continue;
489
88cb7938 490 TParticle *p = (TParticle*)stack->Particle(i);
491 if (p == 0x0)
492 {
493 cerr<<"Can not get particle "<<i<<endl;
494 continue;
495 }
7f6ddf58 496 if (p->Pt()<0.100) continue;
497 if (TMath::Abs(p->Pz()/p->Pt())>0.999) continue;
498
bf018fe4 499 Double_t vx=p->Vx(),vy=p->Vy();
500 if (TMath::Sqrt(vx*vx+vy*vy)>3.5) continue;
501
502 /*
7f6ddf58 503 Int_t j=p->GetFirstMother();
504 if (j>=0) {
88cb7938 505 TParticle *pp = (TParticle*)stack->Particle(j);
506 if (pp == 0x0)
507 {
508 cerr<<"Can not get particle "<<j<<endl;
509 continue;
510 }
bf018fe4 511 //if (pp->GetFirstMother()>=0) continue;//only one decay is allowed
512 // for cascade hyperons only
024a7fe9 513 Int_t jj=pp->GetFirstMother();
514 if (jj>=0) {
88cb7938 515 TParticle *ppp = (TParticle*)stack->Particle(jj);
024a7fe9 516 if (ppp->GetFirstMother()>=0) continue;//two decays are allowed
517 }
bf018fe4 518
7f6ddf58 519 }
bf018fe4 520 */
7f6ddf58 521
522 gt[nt].lab=i;
523 gt[nt].code=p->GetPdgCode();
524 gt[nt].px=0.; gt[nt].py=0.; gt[nt].pz=0.;
527abbe9 525 gt[nt].x=0.; gt[nt].y=0.; gt[nt].z=0.;
7f6ddf58 526 nt++;
527 if (nt==max) {cerr<<"Too many good tracks !\n"; break;}
528 cerr<<np-i<<" \r";
529 }
88cb7938 530 rl->UnloadKinematics();
7f6ddf58 531
532 /** check if there is also information at the entrance of the TPC **/
88cb7938 533
5102bab6 534 rl->LoadTrackRefs();
535 TTree *TR=rl->TreeTR();
536 TBranch *branch=TR->GetBranch("TPC");
537 if (branch==0) {
538 ::Fatal("AliTPCComparison.C::good_tracks_tpc","No track references !");
539 }
540 TClonesArray *references=new TClonesArray("AliTrackReference",1000);
541 branch->SetAddress(&references);
542 np=(Int_t)TR->GetEntries();
7f6ddf58 543 for (i=0; i<np; i++) {
5102bab6 544 references->Clear();
545 TR->GetEvent(i);
546 Int_t nref=references->GetEntriesFast();
547 if (nref==0) continue;
548 AliTrackReference *ref=(AliTrackReference*)references->UncheckedAt(0);
549
550 Int_t j, lab=ref->Label();
551 for (j=0; j<nt; j++) {if (gt[j].lab==lab) break;}
552 if (j==nt) continue;
553
554 // (px,py,pz) - in global coordinate system, (x,y,z) - in local !
555 gt[j].px=ref->Px(); gt[j].py=ref->Py(); gt[j].pz=ref->Pz();
556 gt[j].x = ref->LocalX();
557 gt[j].y = ref->LocalY();
558 gt[j].z = ref->Z();
7f6ddf58 559 }
560
5102bab6 561 delete references;
7f6ddf58 562 delete[] good;
88cb7938 563
564 tpcl->UnloadHits();
5102bab6 565 rl->UnloadTrackRefs();
88cb7938 566 rl->UnloadgAlice();
7f6ddf58 567
cf98c13f 568 gBenchmark->Stop("AliTPCComparison");
569 gBenchmark->Show("AliTPCComparison");
cc80f89e 570 return nt;
8c555625 571}