7 Int_t good_tracks(GoodTrack *gt, Int_t max);
9 Int_t AliTPCComparison() {
10 cerr<<"Doing comparison...\n";
12 TFile *cf=TFile::Open("AliTPCclusters.root");
13 if (!cf->IsOpen()) {cerr<<"Can't open AliTPCclusters.root !\n"; return 1;}
14 AliTPCParam *digp= (AliTPCParam*)cf->Get("75x40_100x60");
15 if (!digp) { cerr<<"TPC parameters have not been found !\n"; return 2; }
18 AliTPCClustersArray *ca=new AliTPCClustersArray;
20 ca->SetClusterType("AliTPCcluster");
21 ca->ConnectTree("Segment Tree");
22 Int_t nentr=Int_t(ca->GetTree()->GetEntries());
23 for (Int_t i=0; i<nentr; i++) {
24 AliSegmentID *s=ca->LoadEntry(i);
28 TFile *tf=TFile::Open("AliTPCtracks.root");
29 if (!tf->IsOpen()) {cerr<<"Can't open AliTPCtracks.root !\n"; return 3;}
30 TObjArray tarray(2000);
31 TTree *tracktree=(TTree*)tf->Get("TreeT");
32 TBranch *tbranch=tracktree->GetBranch("tracks");
33 Int_t nentr=tracktree->GetEntries();
34 for (i=0; i<nentr; i++) {
35 AliTPCtrack *iotrack=new AliTPCtrack;
36 tbranch->SetAddress(&iotrack);
37 tracktree->GetEvent(i);
38 iotrack->CookLabel(ca);
39 tarray.AddLast(iotrack);
46 /////////////////////////////////////////////////////////////////////////
49 ifstream in("good_tracks");
51 cerr<<"Reading good tracks...\n";
52 while (in>>gt[ngood].lab>>gt[ngood].code
53 >>gt[ngood].px >>gt[ngood].py>>gt[ngood].pz
54 >>gt[ngood].x >>gt[ngood].y >>gt[ngood].z) {
58 cerr<<"Too many good tracks !\n";
62 if (!in.eof()) cerr<<"Read error (good_tracks) !\n";
64 cerr<<"Marking good tracks (this will take a while)...\n";
65 ngood=good_tracks(gt,7000);
66 ofstream out("good_tracks");
68 for (Int_t ngd=0; ngd<ngood; ngd++)
69 out<<gt[ngd].lab<<' '<<gt[ngd].code<<' '
70 <<gt[ngd].px <<' '<<gt[ngd].py<<' '<<gt[ngd].pz<<' '
71 <<gt[ngd].x <<' '<<gt[ngd].y <<' '<<gt[ngd].z <<endl;
72 } else cerr<<"Can not open file (good_tracks) !\n";
75 cerr<<"Number of good tracks : "<<ngood<<endl;
77 cerr<<"Doing comparison...\n";
78 TH1F *hp=new TH1F("hp","PHI resolution",50,-20.,20.); hp->SetFillColor(4);
79 TH1F *hl=new TH1F("hl","LAMBDA resolution",50,-20,20);hl->SetFillColor(4);
80 TH1F *hpt=new TH1F("hpt","Relative Pt resolution",30,-10.,10.);
82 TH1F *hmpt=new TH1F("hmpt","Relative Pt resolution (pt>4GeV/c)",30,-60,60);
83 hmpt->SetFillColor(6);
85 TH1F *hgood=new TH1F("hgood","Good tracks",20,0,7);
86 TH1F *hfound=new TH1F("hfound","Found tracks",20,0,7);
87 TH1F *hfake=new TH1F("hfake","Fake tracks",20,0,7);
88 TH1F *hg=new TH1F("hg","",20,0,7); //efficiency for good tracks
89 hg->SetLineColor(4); hg->SetLineWidth(2);
90 TH1F *hf=new TH1F("hf","Efficiency for fake tracks",20,0,7);
91 hf->SetFillColor(1); hf->SetFillStyle(3013); hf->SetLineWidth(2);
93 TH1F *he =new TH1F("he","dE/dX for pions with 0.4<p<0.5 GeV/c",50,0.,100.);
94 TH2F *hep=new TH2F("hep","dE/dX vs momentum",50,0.,2.,50,0.,200.);
97 Int_t lab=gt[ngood].lab,tlab;
99 TMath::Sqrt(gt[ngood].px*gt[ngood].px + gt[ngood].py*gt[ngood].py);
105 for (i=0; i<nentr; i++) {
106 track=(AliTPCtrack*)tarray->UncheckedAt(i);
107 tlab=track->GetLabel();
108 if (lab==TMath::Abs(tlab)) break;
111 cerr<<"Track "<<lab<<" was not found !\n";
114 Double_t xk=gt[ngood].x;//digp->GetPadRowRadii(0,0);
115 track->PropagateTo(xk);
117 if (lab==tlab) hfound->Fill(ptg);
118 else { hfake->Fill(ptg); cerr<<lab<<" fake\n";}
120 Double_t px,py,pz,pt=fabs(track->GetPt());track->GetPxPyPz(px,py,pz);
122 if (TMath::Abs(gt[ngood].code)==11 && ptg>4.) {
123 hmpt->Fill((1/pt - 1/ptg)/(1/ptg)*100.);
125 Float_t phig=TMath::ATan2(gt[ngood].py,gt[ngood].px);
126 Float_t phi =TMath::ATan2(py,px );
127 hp->Fill((phi - phig)*1000.);
129 Float_t lamg=TMath::ATan2(gt[ngood].pz,ptg);
130 Float_t lam =TMath::ATan2(pz ,pt );
131 hl->Fill((lam - lamg)*1000.);
133 hpt->Fill((1/pt - 1/ptg)/(1/ptg)*100.);
136 Float_t mom=track->GetP();
137 Float_t dedx=track->GetdEdx();
138 hep->Fill(mom,dedx,1.);
139 if (TMath::Abs(gt[ngood].code)==211)
140 if (mom>0.4 && mom<0.5) {
146 Stat_t ng=hgood->GetEntries(); cerr<<"Good tracks "<<ng<<endl;
147 Stat_t nf=hfound->GetEntries();
149 cerr<<"Integral efficiency is about "<<nf/ng*100.<<" %\n";
151 gStyle->SetOptStat(111110);
152 gStyle->SetOptFit(1);
154 TCanvas *c1=new TCanvas("c1","",0,0,700,850);
156 TPad *p1=new TPad("p1","",0,0.3,.5,.6); p1->Draw();
157 p1->cd(); p1->SetFillColor(42); p1->SetFrameFillColor(10);
158 hp->SetFillColor(4); hp->SetXTitle("(mrad)"); hp->Fit("gaus"); c1->cd();
160 TPad *p2=new TPad("p2","",0.5,.3,1,.6); p2->Draw();
161 p2->cd(); p2->SetFillColor(42); p2->SetFrameFillColor(10);
162 hl->SetXTitle("(mrad)"); hl->Fit("gaus"); c1->cd();
164 TPad *p3=new TPad("p3","",0,0,0.5,0.3); p3->Draw();
165 p3->cd(); p3->SetFillColor(42); p3->SetFrameFillColor(10);
166 hpt->SetXTitle("(%)"); hpt->Fit("gaus"); c1->cd();
168 TPad *p4=new TPad("p4","",0.5,0,1,0.3); p4->Draw();
169 p4->cd(); p4->SetFillColor(42); p4->SetFrameFillColor(10);
170 hmpt->SetXTitle("(%)"); hmpt->Fit("gaus"); c1->cd();
172 TPad *p5=new TPad("p5","",0,0.6,1,1); p5->Draw(); p5->cd();
173 p5->SetFillColor(41); p5->SetFrameFillColor(10);
174 hfound->Sumw2(); hgood->Sumw2(); hfake->Sumw2();
175 hg->Divide(hfound,hgood,1,1.,"b");
176 hf->Divide(hfake,hgood,1,1.,"b");
178 hg->SetYTitle("Tracking efficiency");
179 hg->SetXTitle("Pt (GeV/c)");
182 TLine *line1 = new TLine(0,1.0,7,1.0); line1->SetLineStyle(4);
184 TLine *line2 = new TLine(0,0.9,7,0.9); line2->SetLineStyle(4);
188 hf->SetFillStyle(3013);
191 hf->Draw("histsame");
192 TText *text = new TText(0.461176,0.248448,"Fake tracks");
193 text->SetTextSize(0.05);
195 text = new TText(0.453919,1.11408,"Good tracks");
196 text->SetTextSize(0.05);
201 TCanvas *c2=new TCanvas("c2","",320,32,530,590);
203 TPad *p6=new TPad("p6","",0.,0.,1.,.5); p6->Draw();
204 p6->cd(); p6->SetFillColor(42); p6->SetFrameFillColor(10);
205 he->SetFillColor(2); he->SetFillStyle(3005);
206 he->SetXTitle("Arbitrary Units");
207 he->Fit("gaus"); c2->cd();
209 TPad *p7=new TPad("p7","",0.,0.5,1.,1.); p7->Draw();
210 p7->cd(); p7->SetFillColor(42); p7->SetFrameFillColor(10);
211 hep->SetXTitle("p (Gev/c)"); hep->SetYTitle("dE/dX (Arb. Units)");
212 hep->Draw(); c1->cd();
218 Int_t good_tracks(GoodTrack *gt, Int_t max) {
221 TFile *file=TFile::Open("rfio:galice.root");
222 if (!file->IsOpen()) {cerr<<"Can't open galice.root !\n"; exit(4);}
224 if (!(gAlice=(AliRun*)file->Get("gAlice"))) {
225 cerr<<"gAlice have not been found on galice.root !\n";
231 AliTPC *TPC=(AliTPC*)gAlice->GetDetector("TPC");
232 Int_t ver = TPC->IsVersion();
233 cerr<<"TPC version "<<ver<<" has been found !\n";
235 AliTPCParam *digp=(AliTPCParam*)file->Get("75x40_100x60");
236 if (!digp) { cerr<<"TPC parameters have not been found !\n"; exit(6); }
239 Int_t nrow_up=digp->GetNRowUp();
240 Int_t nrows=digp->GetNRowLow()+nrow_up;
241 Int_t zero=digp->GetZeroSup();
242 Int_t gap=Int_t(0.125*nrows);
243 Int_t good_number=Int_t(0.4*nrows);
245 TClonesArray *particles=gAlice->Particles();
246 Int_t np=particles->GetEntriesFast();
247 Int_t *good=new Int_t[np];
248 for (Int_t ii=0; ii<np; ii++) good[ii]=0;
253 TFile *cf=TFile::Open("AliTPCclusters.root");
254 if (!cf->IsOpen()){cerr<<"Can't open AliTPCclusters.root !\n";exit(5);}
255 AliTPCClustersArray *ca=new AliTPCClustersArray;
257 ca->SetClusterType("AliTPCcluster");
258 ca->ConnectTree("Segment Tree");
259 Int_t nrows=Int_t(ca->GetTree()->GetEntries());
260 for (Int_t n=0; n<nrows; n++) {
261 AliSegmentID *s=ca->LoadEntry(n);
263 digp->AdjustSectorRow(s->GetID(),sec,row);
264 AliTPCClustersRow &clrow = *ca->GetRow(sec,row);
265 Int_t ncl=clrow.GetArray()->GetEntriesFast();
267 AliTPCcluster *c=(AliTPCcluster*)clrow[ncl];
268 Int_t lab=c->GetLabel(0);
269 if (lab<0) continue; //noise cluster
271 if (sec>=digp->GetNInnerSector())
272 if (row==nrow_up-1 ) good[lab]|=0x1000;
273 if (sec>=digp->GetNInnerSector())
274 if (row==nrow_up-1-gap) good[lab]|=0x800;
277 ca->ClearRow(sec,row);
283 TTree *TD=(TTree*)gDirectory->Get("TreeD_75x40_100x60");
284 AliSimDigits da, *digits=&da;
285 TD->GetBranch("Segment")->SetAddress(&digits);
286 Int_t *count = new Int_t[np];
288 for (i=0; i<np; i++) count[i]=0;
289 Int_t sectors_by_rows=(Int_t)TD->GetEntries();
290 for (i=0; i<sectors_by_rows; i++) {
291 if (!TD->GetEvent(i)) continue;
293 digp->AdjustSectorRow(digits->GetID(),sec,row);
294 cerr<<sec<<' '<<row<<" \r";
296 while (digits->Next()) {
297 Int_t it=digits->CurrentRow(), ip=digits->CurrentColumn();
298 Short_t dig = digits->GetDigit(it,ip);
299 Int_t idx0=digits->GetTrackID(it,ip,0);
300 Int_t idx1=digits->GetTrackID(it,ip,1);
301 Int_t idx2=digits->GetTrackID(it,ip,2);
302 if (idx0>=0 && dig>=zero) count[idx0]+=1;
303 if (idx1>=0 && dig>=zero) count[idx1]+=1;
304 if (idx2>=0 && dig>=zero) count[idx2]+=1;
306 for (Int_t j=0; j<np; j++) {
308 if (sec>=digp->GetNInnerSector())
309 if (row==nrow_up-1 ) good[j]|=0x1000;
310 if (sec>=digp->GetNInnerSector())
311 if (row==nrow_up-1-gap) good[j]|=0x800;
320 cerr<<"Invalid TPC version !\n";
325 TTree *TH=gAlice->TreeH();
326 TClonesArray *hits=TPC->Hits();
327 Int_t npart=TH->GetEntries();
332 Int_t nhits=hits->GetEntriesFast();
333 if (nhits==0) continue;
336 for (j=0; j<nhits-1; j++) {
337 hit=(AliTPChit*)hits->UncheckedAt(j);
338 if (hit->fQ==0.) break;
340 if (j==nhits-1) continue;
341 AliTPChit *hit1=(AliTPChit*)hits->UncheckedAt(j+1);
342 if (hit1->fQ != 0.) continue;
343 Int_t i=hit->Track();
344 TParticle *p = (TParticle*)particles->UncheckedAt(i);
345 if (p->GetFirstMother()>=0) continue; //secondary particle
346 if (good[i] < 0x1000+0x800+2+good_number) continue;
347 if (p->Pt()<0.100) continue;
348 if (TMath::Abs(p->Pz()/p->Pt())>0.999) continue;
351 gt[nt].code=p->GetPdgCode();
352 //**** px py pz - in global coordinate system, x y z - in local !
353 gt[nt].px=hit->X(); gt[nt].py=hit->Y(); gt[nt].pz=hit->Z();
354 Float_t cs,sn; digp->AdjustCosSin(hit1->fSector,cs,sn);
355 gt[nt].x = hit1->X()*cs + hit1->Y()*sn;
356 gt[nt].y =-hit1->X()*sn + hit1->Y()*cs;
357 gt[nt].z = hit1->Z();
361 if (nt==max) {cerr<<"Too many good tracks !\n"; break;}
365 delete gAlice; gAlice=0;