2 //#include "TParticle.h"
9 Int_t good_tracks(GoodTrack *gt, Int_t max);
11 Int_t AliTPCComparison() {
13 gBenchmark->Start("AliTPCComparison");
14 cerr<<"Doing comparison...\n";
16 TFile *cf=TFile::Open("AliTPCclusters.root");
17 if (!cf->IsOpen()) {cerr<<"Can't open AliTPCclusters.root !\n"; return 1;}
18 AliTPCParam *digp= (AliTPCParam*)cf->Get("75x40_100x60");
19 if (!digp) { cerr<<"TPC parameters have not been found !\n"; return 2; }
22 AliTPCClustersArray *ca=new AliTPCClustersArray;
24 ca->SetClusterType("AliTPCcluster");
25 ca->ConnectTree("Segment Tree");
26 Int_t nentr=Int_t(ca->GetTree()->GetEntries());
27 for (i=0; i<nentr; i++) {
33 TFile *tf=TFile::Open("AliTPCtracks.root");
34 if (!tf->IsOpen()) {cerr<<"Can't open AliTPCtracks.root !\n"; return 3;}
35 TObjArray tarray(2000);
36 TTree *tracktree=(TTree*)tf->Get("TreeT");
37 TBranch *tbranch=tracktree->GetBranch("tracks");
38 nentr=(Int_t)tracktree->GetEntries();
40 for (i=0; i<nentr; i++) {
41 AliTPCtrack *iotrack=new AliTPCtrack;
42 tbranch->SetAddress(&iotrack);
43 tracktree->GetEvent(i);
44 iotrack->CookLabel(ca);
45 tarray.AddLast(iotrack);
52 /////////////////////////////////////////////////////////////////////////
55 ifstream in("good_tracks");
57 cerr<<"Reading good tracks...\n";
58 while (in>>gt[ngood].lab>>gt[ngood].code>>gt[ngood].px>>gt[ngood].py>>gt[ngood].pz>>gt[ngood].x>>gt[ngood].y>>gt[ngood].z) {
62 cerr<<"Too many good tracks !\n";
66 if (!in.eof()) cerr<<"Read error (good_tracks) !\n";
68 cerr<<"Marking good tracks (this will take a while)...\n";
69 ngood=good_tracks(gt,15000);
70 ofstream out("good_tracks");
72 for (Int_t ngd=0; ngd<ngood; ngd++)
73 out<<gt[ngd].lab<<' '<<gt[ngd].code<<' '<<gt[ngd].px <<' '<<gt[ngd].py<<' '<<gt[ngd].pz<<' '<<gt[ngd].x <<' '<<gt[ngd].y <<' '<<gt[ngd].z <<endl;
74 } else cerr<<"Can not open file (good_tracks) !\n";
77 cerr<<"Number of good tracks : "<<ngood<<endl;
79 cerr<<"Doing comparison...\n";
80 TH1F *hp=new TH1F("hp","PHI resolution",50,-20.,20.); hp->SetFillColor(4);
81 TH1F *hl=new TH1F("hl","LAMBDA resolution",50,-20,20);hl->SetFillColor(4);
82 TH1F *hpt=new TH1F("hpt","Relative Pt resolution",30,-10.,10.);
84 TH1F *hmpt=new TH1F("hmpt","Relative Pt resolution (pt>4GeV/c)",30,-60,60);
85 hmpt->SetFillColor(6);
87 TH1F *hgood=new TH1F("hgood","Good tracks",20,0,7);
88 TH1F *hfound=new TH1F("hfound","Found tracks",20,0,7);
89 TH1F *hfake=new TH1F("hfake","Fake tracks",20,0,7);
90 TH1F *hg=new TH1F("hg","",20,0,7); //efficiency for good tracks
91 hg->SetLineColor(4); hg->SetLineWidth(2);
92 TH1F *hf=new TH1F("hf","Efficiency for fake tracks",20,0,7);
93 hf->SetFillColor(1); hf->SetFillStyle(3013); hf->SetLineWidth(2);
95 TH1F *he =new TH1F("he","dE/dX for pions with 0.4<p<0.5 GeV/c",50,0.,100.);
96 TH2F *hep=new TH2F("hep","dE/dX vs momentum",50,0.,2.,50,0.,200.);
98 Int_t mingood = ngood; //MI change
99 Int_t * track_notfound = new Int_t[ngood];
100 Int_t itrack_notfound =0;
101 Int_t * track_fake = new Int_t[ngood];
102 Int_t itrack_fake = 0;
103 Int_t * track_multifound = new Int_t[ngood];
104 Int_t * track_multifound_n = new Int_t[ngood];
105 Int_t itrack_multifound =0;
108 Int_t lab=gt[ngood].lab,tlab=-1;
110 TMath::Sqrt(gt[ngood].px*gt[ngood].px + gt[ngood].py*gt[ngood].py);
114 AliTPCtrack *track=0;
115 for (i=0; i<nentr; i++) {
116 track=(AliTPCtrack*)tarray.UncheckedAt(i);
117 tlab=track->GetLabel();
118 if (lab==TMath::Abs(tlab)) break;
121 // cerr<<"Track "<<lab<<" was not found !\n";
122 track_notfound[itrack_notfound++]=lab;
126 //MI change - addition
129 AliTPCtrack * mitrack;
130 for (mi=0; mi<nentr; mi++) {
131 mitrack=(AliTPCtrack*)tarray.UncheckedAt(mi);
132 if (lab==TMath::Abs(mitrack->GetLabel())) micount++;
135 //cout<<"Track no. "<<lab<<" found "<<micount<<" times\n";
136 track_multifound[itrack_multifound]=lab;
137 track_multifound_n[itrack_multifound]=micount;
143 Double_t xk=gt[ngood].x;//digp->GetPadRowRadii(0,0);
144 track->PropagateTo(xk);
146 if (lab==tlab) hfound->Fill(ptg);
148 track_fake[itrack_fake++]=lab;
150 //cerr<<lab<<" fake\n";
153 Double_t px,py,pz,pt=fabs(track->GetPt());track->GetPxPyPz(px,py,pz);
155 if (TMath::Abs(gt[ngood].code)==11 && ptg>4.) {
156 hmpt->Fill((1/pt - 1/ptg)/(1/ptg)*100.);
158 Float_t phig=TMath::ATan2(gt[ngood].py,gt[ngood].px);
159 Float_t phi =TMath::ATan2(py,px );
160 hp->Fill((phi - phig)*1000.);
162 Float_t lamg=TMath::ATan2(gt[ngood].pz,ptg);
163 Float_t lam =TMath::ATan2(pz ,pt );
164 hl->Fill((lam - lamg)*1000.);
166 hpt->Fill((1/pt - 1/ptg)/(1/ptg)*100.);
169 Float_t mom=track->GetP();
170 Float_t dedx=track->GetdEdx();
171 hep->Fill(mom,dedx,1.);
172 if (TMath::Abs(gt[ngood].code)==211)
173 if (mom>0.4 && mom<0.5) {
180 Stat_t ng=hgood->GetEntries(); cerr<<"Good tracks "<<ng<<endl;
181 Stat_t nf=hfound->GetEntries();
183 cerr<<"\n\n\nIntegral efficiency is about "<<nf/ng*100.<<" %\n";
185 //MI change - addition
186 cout<<"Total number of found tracks ="<<nentr<<"\n";
187 cout<<"Total number of \"good\" tracks ="<<mingood<<"\n";
190 cout<<"\nList of Not found tracks :\n";
192 for ( i = 0; i< itrack_notfound; i++){
193 cout<<track_notfound[i]<<"\t";
194 if ((i%5)==4) cout<<"\n";
196 cout<<"\nList of fake tracks :\n";
197 for ( i = 0; i< itrack_fake; i++){
198 cout<<track_fake[i]<<"\t";
199 if ((i%5)==4) cout<<"\n";
201 cout<<"\nList of multiple found tracks :\n";
202 for ( i=0; i<itrack_multifound; i++) {
203 cout<<"id. "<<track_multifound[i]<<" found - "<<track_multifound_n[i]<<"times\n";
208 gStyle->SetOptStat(111110);
209 gStyle->SetOptFit(1);
211 TCanvas *c1=new TCanvas("c1","",0,0,700,850);
213 TPad *p1=new TPad("p1","",0,0.3,.5,.6); p1->Draw();
214 p1->cd(); p1->SetFillColor(42); p1->SetFrameFillColor(10);
215 hp->SetFillColor(4); hp->SetXTitle("(mrad)"); hp->Fit("gaus"); c1->cd();
217 TPad *p2=new TPad("p2","",0.5,.3,1,.6); p2->Draw();
218 p2->cd(); p2->SetFillColor(42); p2->SetFrameFillColor(10);
219 hl->SetXTitle("(mrad)"); hl->Fit("gaus"); c1->cd();
221 TPad *p3=new TPad("p3","",0,0,0.5,0.3); p3->Draw();
222 p3->cd(); p3->SetFillColor(42); p3->SetFrameFillColor(10);
223 hpt->SetXTitle("(%)"); hpt->Fit("gaus"); c1->cd();
225 TPad *p4=new TPad("p4","",0.5,0,1,0.3); p4->Draw();
226 p4->cd(); p4->SetFillColor(42); p4->SetFrameFillColor(10);
227 hmpt->SetXTitle("(%)"); hmpt->Fit("gaus"); c1->cd();
229 TPad *p5=new TPad("p5","",0,0.6,1,1); p5->Draw(); p5->cd();
230 p5->SetFillColor(41); p5->SetFrameFillColor(10);
231 hfound->Sumw2(); hgood->Sumw2(); hfake->Sumw2();
232 hg->Divide(hfound,hgood,1,1.,"b");
233 hf->Divide(hfake,hgood,1,1.,"b");
235 hg->SetYTitle("Tracking efficiency");
236 hg->SetXTitle("Pt (GeV/c)");
239 TLine *line1 = new TLine(0,1.0,7,1.0); line1->SetLineStyle(4);
241 TLine *line2 = new TLine(0,0.9,7,0.9); line2->SetLineStyle(4);
245 hf->SetFillStyle(3013);
248 hf->Draw("histsame");
249 TText *text = new TText(0.461176,0.248448,"Fake tracks");
250 text->SetTextSize(0.05);
252 text = new TText(0.453919,1.11408,"Good tracks");
253 text->SetTextSize(0.05);
258 TCanvas *c2=new TCanvas("c2","",320,32,530,590);
260 TPad *p6=new TPad("p6","",0.,0.,1.,.5); p6->Draw();
261 p6->cd(); p6->SetFillColor(42); p6->SetFrameFillColor(10);
262 he->SetFillColor(2); he->SetFillStyle(3005);
263 he->SetXTitle("Arbitrary Units");
264 he->Fit("gaus"); c2->cd();
266 TPad *p7=new TPad("p7","",0.,0.5,1.,1.); p7->Draw();
267 p7->cd(); p7->SetFillColor(42); p7->SetFrameFillColor(10);
268 hep->SetXTitle("p (Gev/c)"); hep->SetYTitle("dE/dX (Arb. Units)");
269 hep->Draw(); c1->cd();
271 gBenchmark->Stop("AliTPCComparison");
272 gBenchmark->Show("AliTPCComparison");
279 Int_t good_tracks(GoodTrack *gt, Int_t max) {
282 TFile *file=TFile::Open("galice.root");
283 if (!file->IsOpen()) {cerr<<"Can't open galice.root !\n"; exit(4);}
285 if (!(gAlice=(AliRun*)file->Get("gAlice"))) {
286 cerr<<"gAlice have not been found on galice.root !\n";
292 AliTPC *TPC=(AliTPC*)gAlice->GetDetector("TPC");
293 Int_t ver = TPC->IsVersion();
294 cerr<<"TPC version "<<ver<<" has been found !\n";
296 AliTPCParam *digp=(AliTPCParam*)file->Get("75x40_100x60");
297 if (!digp) { cerr<<"TPC parameters have not been found !\n"; exit(6); }
300 Int_t nrow_up=digp->GetNRowUp();
301 Int_t nrows=digp->GetNRowLow()+nrow_up;
302 Int_t zero=digp->GetZeroSup();
303 Int_t gap=Int_t(0.125*nrows);
304 Int_t good_number=Int_t(0.4*nrows);
306 TObjArray *particles=gAlice->Particles(); //MI change
309 // Int_t np=particles->GetEntriesFast();
310 Int_t np=gAlice->GetNtrack(); //FCA correction
311 Int_t *good=new Int_t[np];
312 for (Int_t ii=0; ii<np; ii++) good[ii]=0;
315 //MI change to be possible compile macro
316 //definition out of the swith statemnet
317 Int_t sectors_by_rows=0;
319 AliSimDigits da, *digits=&da;
324 TFile *cf=TFile::Open("AliTPCclusters.root");
325 if (!cf->IsOpen()){cerr<<"Can't open AliTPCclusters.root !\n";exit(5);}
326 AliTPCClustersArray *ca=new AliTPCClustersArray;
328 ca->SetClusterType("AliTPCcluster");
329 ca->ConnectTree("Segment Tree");
330 Int_t nrows=Int_t(ca->GetTree()->GetEntries());
331 for (Int_t n=0; n<nrows; n++) {
332 AliSegmentID *s=ca->LoadEntry(n);
334 digp->AdjustSectorRow(s->GetID(),sec,row);
335 AliTPCClustersRow &clrow = *ca->GetRow(sec,row);
336 Int_t ncl=clrow.GetArray()->GetEntriesFast();
338 AliTPCcluster *c=(AliTPCcluster*)clrow[ncl];
339 Int_t lab=c->GetLabel(0);
340 if (lab<0) continue; //noise cluster
342 if (sec>=digp->GetNInnerSector())
343 if (row==nrow_up-1 ) good[lab]|=0x1000;
344 if (sec>=digp->GetNInnerSector())
345 if (row==nrow_up-1-gap) good[lab]|=0x800;
348 ca->ClearRow(sec,row);
354 TD=(TTree*)gDirectory->Get("TreeD_75x40_100x60");
355 TD->GetBranch("Segment")->SetAddress(&digits);
356 count = new Int_t[np];
358 for (i=0; i<np; i++) count[i]=0;
359 sectors_by_rows=(Int_t)TD->GetEntries();
360 for (i=0; i<sectors_by_rows; i++) {
361 if (!TD->GetEvent(i)) continue;
363 digp->AdjustSectorRow(digits->GetID(),sec,row);
364 cerr<<sec<<' '<<row<<" \r";
366 while (digits->Next()) {
367 Int_t it=digits->CurrentRow(), ip=digits->CurrentColumn();
368 Short_t dig = digits->GetDigit(it,ip);
369 Int_t idx0=digits->GetTrackID(it,ip,0);
370 Int_t idx1=digits->GetTrackID(it,ip,1);
371 Int_t idx2=digits->GetTrackID(it,ip,2);
372 if (idx0>=0 && dig>=zero) count[idx0]+=1;
373 if (idx1>=0 && dig>=zero) count[idx1]+=1;
374 if (idx2>=0 && dig>=zero) count[idx2]+=1;
376 for (Int_t j=0; j<np; j++) {
378 if (sec>=digp->GetNInnerSector())
379 if (row==nrow_up-1 ) good[j]|=0x1000;
380 if (sec>=digp->GetNInnerSector())
381 if (row==nrow_up-1-gap) good[j]|=0x800;
390 cerr<<"Invalid TPC version !\n";
395 TTree *TH=gAlice->TreeH();
396 // TClonesArray *hits=TPC->Hits();
397 Int_t npart=(Int_t)TH->GetEntries();
404 AliTPChit * hit = (AliTPChit*) TPC->FirstHit(-1);
406 if (hit->fQ==0.) break;
407 hit = (AliTPChit*) TPC->NextHit();
410 hit0 = new AliTPChit(*hit); //Make copy of hit
414 AliTPChit *hit1=(AliTPChit*)TPC->NextHit();
415 if (hit1==0) continue;
416 /* Int_t nhits=hits->GetEntriesFast();
417 if (nhits==0) continue;
420 for (j=0; j<nhits-1; j++) {
421 hit=(AliTPChit*)hits->UncheckedAt(j);
422 if (hit->fQ==0.) break;
424 if (j==nhits-1) continue;
425 AliTPChit *hit1=(AliTPChit*)hits->UncheckedAt(j+1);
427 if (hit1->fQ != 0.) continue;
428 Int_t i=hit->Track();
429 // TParticle *p = (TParticle*)particles->UncheckedAt(i);
430 TParticle *p = (TParticle*)gAlice->Particle(i);
432 if (p->GetFirstMother()>=0) continue; //secondary particle
433 if (good[i] < 0x1000+0x800+2+good_number) continue;
434 if (p->Pt()<0.100) continue;
435 if (TMath::Abs(p->Pz()/p->Pt())>0.999) continue;
438 gt[nt].code=p->GetPdgCode();
439 //**** px py pz - in global coordinate system, x y z - in local !
440 gt[nt].px=hit->X(); gt[nt].py=hit->Y(); gt[nt].pz=hit->Z();
441 Float_t cs,sn; digp->AdjustCosSin(hit1->fSector,cs,sn);
442 gt[nt].x = hit1->X()*cs + hit1->Y()*sn;
443 gt[nt].y =-hit1->X()*sn + hit1->Y()*cs;
444 gt[nt].z = hit1->Z();
446 if (hit0) delete hit0;
448 if (nt==max) {cerr<<"Too many good tracks !\n"; break;}
452 //delete gAlice; gAlice=0;
455 gBenchmark->Stop("AliTPCComparison");
456 gBenchmark->Show("AliTPCComparison");