7 #include "AliITSgeom.h"
8 #include "AliITStrackerV2.h"
9 #include "AliITStrackV2.h"
10 #include "AliITSclusterV2.h"
15 #include "TObjArray.h"
20 #include "TParticle.h"
29 Int_t good_tracks(GoodTrack *gt, Int_t max);
31 Int_t AliITSComparisonV2() {
32 cerr<<"Doing comparison...\n";
34 TFile *cf=TFile::Open("AliITSclustersV2.root");
35 if (!cf->IsOpen()) {cerr<<"Can't open AliITSclustersV2.root !\n"; return 1;}
36 AliITSgeom *geom=(AliITSgeom*)cf->Get("AliITSgeom");
37 if (!geom) { cerr<<"Can't get the ITS geometry !\n"; return 2; }
38 AliITStrackerV2 tracker(geom);
41 TFile *tf=TFile::Open("AliITStracksV2.root");
42 if (!tf->IsOpen()) {cerr<<"Can't open AliITStracksV2.root !\n"; return 3;}
43 TObjArray tarray(2000);
44 TTree *tracktree=(TTree*)tf->Get("TreeT");
45 TBranch *tbranch=tracktree->GetBranch("tracks");
46 Int_t nentr=(Int_t)tracktree->GetEntries(),i;
47 for (i=0; i<nentr; i++) {
48 AliITStrackV2 *iotrack=new AliITStrackV2;
49 tbranch->SetAddress(&iotrack);
50 tracktree->GetEvent(i);
52 Int_t tpcLabel=iotrack->GetLabel();
53 tracker.CookLabel(iotrack,0.);
54 Int_t itsLabel=iotrack->GetLabel();
55 if (itsLabel != tpcLabel) iotrack->SetLabel(-TMath::Abs(itsLabel));
56 if (tpcLabel < 0) iotrack->SetLabel(-TMath::Abs(itsLabel));
59 Int_t nc=iotrack->GetNumberOfClusters();
60 for (Int_t k=0; k<nc; k++) {
61 Int_t index=iotrack->GetClusterIndex(k);
62 AliITSclusterV2 *c=tracker.GetCluster(index);
63 cout<<c->GetLabel(0)<<' '<<c->GetLabel(1)<<' '<<c->GetLabel(2)<<endl;
67 tarray.AddLast(iotrack);
72 /////////////////////////////////////////////////////////////////////////
75 ifstream in("good_tracks_its");
77 cerr<<"Reading good tracks...\n";
78 while (in>>gt[ngood].lab>>gt[ngood].code>>
79 gt[ngood].px>>gt[ngood].py>>gt[ngood].pz>>
80 gt[ngood].x >>gt[ngood].y >>gt[ngood].z) {
84 cerr<<"Too many good tracks !\n";
88 if (!in.eof()) cerr<<"Read error (good_tracks_its) !\n";
90 cerr<<"Marking good tracks (this will take a while)...\n";
91 ngood=good_tracks(gt,15000);
92 ofstream out("good_tracks_its");
94 for (Int_t ngd=0; ngd<ngood; ngd++)
95 out<<gt[ngd].lab<<' '<<gt[ngd].code<<' '<<
96 gt[ngd].px<<' '<<gt[ngd].py<<' '<<gt[ngd].pz<<' '<<
97 gt[ngd].x <<' '<<gt[ngd].y <<' '<<gt[ngd].z <<endl;
98 } else cerr<<"Can not open file (good_tracks_its) !\n";
101 cerr<<"Number of good tracks : "<<ngood<<endl;
103 TH1F *hp=new TH1F("hp","PHI resolution",50,-20.,20.); hp->SetFillColor(4);
104 TH1F *hl=new TH1F("hl","LAMBDA resolution",50,-20,20);hl->SetFillColor(4);
105 TH1F *hpt=new TH1F("hpt","Relative Pt resolution",30,-10.,10.);
106 hpt->SetFillColor(2);
107 TH1F *hmpt=new TH1F("hmpt","Transverse impact parameter",30,-300,300);
108 hmpt->SetFillColor(6);
109 TH1F *hz=new TH1F("hz","Longitudinal impact parameter",30,-300,300);
110 //hmpt->SetFillColor(6);
112 TH1F *hgood=new TH1F("hgood","Good tracks",30,0.1,6.1);
113 TH1F *hfound=new TH1F("hfound","Found tracks",30,0.1,6.1);
114 TH1F *hfake=new TH1F("hfake","Fake tracks",30,0.1,6.1);
115 TH1F *hg=new TH1F("hg","",30,0.1,6.1); //efficiency for good tracks
116 hg->SetLineColor(4); hg->SetLineWidth(2);
117 TH1F *hf=new TH1F("hf","Efficiency for fake tracks",30,0.1,6.1);
118 hf->SetFillColor(1); hf->SetFillStyle(3013); hf->SetLineWidth(2);
120 TH1F *hptw=new TH1F("hptw","Weghted pt",30,0.1,6.1);
123 Int_t lab=gt[ngood].lab, tlab=-1;
124 Double_t pxg=gt[ngood].px, pyg=gt[ngood].py, pzg=gt[ngood].pz;
125 Double_t ptg=TMath::Sqrt(pxg*pxg+pyg*pyg);
129 AliITStrackV2 *track=0;
131 for (j=0; j<nentr; j++) {
132 track=(AliITStrackV2*)tarray.UncheckedAt(j);
133 tlab=track->GetLabel();
134 if (lab==TMath::Abs(tlab)) break;
137 cerr<<"Track "<<lab<<" was not found !\n";
140 track->Propagate(track->GetAlpha(),3.,0.1/65.19*1.848,0.1*1.848);
141 track->PropagateToVertex();
143 if (lab==tlab) hfound->Fill(ptg);
144 else { hfake->Fill(ptg); cerr<<lab<<" fake\n";}
146 Double_t xv,par[5]; track->GetExternalParameters(xv,par);
147 Float_t phi=TMath::ASin(par[2]) + track->GetAlpha();
148 if (phi<-TMath::Pi()) phi+=2*TMath::Pi();
149 if (phi>=TMath::Pi()) phi-=2*TMath::Pi();
150 Float_t lam=TMath::ATan(par[3]);
151 Float_t pt_1=TMath::Abs(par[4]);
153 Double_t phig=TMath::ATan2(pyg,pxg);
154 hp->Fill((phi - phig)*1000.);
156 Double_t lamg=TMath::ATan2(pzg,ptg);
157 hl->Fill((lam - lamg)*1000.);
159 Double_t d=10000*track->GetD();
162 hptw->Fill(ptg,TMath::Abs(d));
164 Double_t z=10000*track->GetZ();
167 //if (TMath::Abs(gt[ngood].code)==11 && ptg>4.)
168 hpt->Fill((pt_1 - 1/ptg)/(1/ptg)*100.);
172 Stat_t ng=hgood->GetEntries(); cerr<<"Good tracks "<<ng<<endl;
173 Stat_t nf=hfound->GetEntries();
175 cerr<<"Integral efficiency is about "<<nf/ng*100.<<" %\n";
177 gStyle->SetOptStat(111110);
178 gStyle->SetOptFit(1);
180 TCanvas *c1=new TCanvas("c1","",0,0,700,850);
182 TPad *p1=new TPad("p1","",0,0.3,.5,.6); p1->Draw();
183 p1->cd(); p1->SetFillColor(42); p1->SetFrameFillColor(10);
184 hp->SetFillColor(4); hp->SetXTitle("(mrad)"); hp->Fit("gaus"); c1->cd();
186 TPad *p2=new TPad("p2","",0.5,.3,1,.6); p2->Draw();
187 p2->cd(); p2->SetFillColor(42); p2->SetFrameFillColor(10);
188 hl->SetXTitle("(mrad)"); hl->Fit("gaus"); c1->cd();
190 TPad *p3=new TPad("p3","",0,0,0.5,0.3); p3->Draw();
191 p3->cd(); p3->SetFillColor(42); p3->SetFrameFillColor(10);
192 hpt->SetXTitle("(%)"); hpt->Fit("gaus"); c1->cd();
194 TPad *p4=new TPad("p4","",0.5,0,1,0.3); p4->Draw();
195 p4->cd(); p4->SetFillColor(42); p4->SetFrameFillColor(10);
196 hmpt->SetXTitle("(micron)"); hmpt->Fit("gaus"); hz->Draw("same"); c1->cd();
199 //hg->SetMaximum(333);
200 //hg->SetYTitle("Impact Parameter Resolution (micron)");
201 //hg->SetXTitle("Pt (GeV/c)");
202 //hg->GetXaxis()->SetRange(0,10);
203 //hg->Divide(hptw,hfound,1,1.);
204 //hg->DrawCopy(); c1->cd();
207 TPad *p5=new TPad("p5","",0,0.6,1,1); p5->Draw(); p5->cd();
208 p5->SetFillColor(41); p5->SetFrameFillColor(10);
209 hfound->Sumw2(); hgood->Sumw2(); hfake->Sumw2();
210 hg->Divide(hfound,hgood,1,1.,"b");
211 hf->Divide(hfake,hgood,1,1.,"b");
213 hg->SetYTitle("Tracking efficiency");
214 hg->SetXTitle("Pt (GeV/c)");
217 TLine *line1 = new TLine(0,1.0,7,1.0); line1->SetLineStyle(4);
219 TLine *line2 = new TLine(0,0.9,7,0.9); line2->SetLineStyle(4);
223 hf->SetFillStyle(3013);
226 hf->Draw("histsame");
227 TText *text = new TText(0.461176,0.248448,"Fake tracks");
228 text->SetTextSize(0.05);
230 text = new TText(0.453919,1.11408,"Good tracks");
231 text->SetTextSize(0.05);
237 Int_t good_tracks(GoodTrack *gt, Int_t max) {
238 if (gAlice) {delete gAlice; gAlice=0;}
240 TFile *file=TFile::Open("galice.root");
241 if (!file->IsOpen()) {cerr<<"Can't open galice.root !\n"; exit(4);}
242 if (!(gAlice=(AliRun*)file->Get("gAlice"))) {
243 cerr<<"gAlice have not been found on galice.root !\n";
247 Int_t np=gAlice->GetEvent(0);
249 Int_t *good=new Int_t[np];
251 for (k=0; k<np; k++) good[k]=0;
253 AliITS *ITS=(AliITS*)gAlice->GetDetector("ITS");
255 cerr<<"can't get ITS !\n"; exit(8);
257 AliITSgeom *geom=ITS->GetITSgeom();
259 cerr<<"cen't get ITS geometry !\n"; exit(9);
262 TFile *cf=TFile::Open("AliITSclustersV2.root");
264 cerr<<"Can't open AliITSclustersV2.root !\n"; exit(6);
266 TTree *cTree=(TTree*)cf->Get("cTree");
268 cerr<<"Can't get cTree !\n"; exit(7);
270 TBranch *branch=cTree->GetBranch("Clusters");
272 cerr<<"Can't get clusters branch !\n"; exit(8);
274 TClonesArray *clusters=new TClonesArray("AliITSclusterV2",10000);
275 branch->SetAddress(&clusters);
277 Int_t entr=(Int_t)cTree->GetEntries();
278 for (k=0; k<entr; k++) {
279 if (!cTree->GetEvent(k)) continue;
280 Int_t lay,lad,det; geom->GetModuleId(k-1,lay,lad,det);
281 if (lay<1 || lay>6) {
282 cerr<<"wrong layer !\n"; exit(10);
284 Int_t ncl=clusters->GetEntriesFast();
286 AliITSclusterV2 *pnt=(AliITSclusterV2*)clusters->UncheckedAt(ncl);
287 Int_t l0=pnt->GetLabel(0);
288 Int_t l1=pnt->GetLabel(1);
289 Int_t l2=pnt->GetLabel(2);
290 Int_t mask=1<<(lay-1);
291 if (l0>=0) good[l0]|=mask;
292 if (l1>=0) good[l1]|=mask;
293 if (l2>=0) good[l2]|=mask;
296 clusters->Delete(); delete clusters;
299 ifstream in("good_tracks_tpc");
301 cerr<<"can't get good_tracks_tpc !\n"; exit(11);
304 Double_t px,py,pz,x,y,z;
306 while (in>>lab>>code>>px>>py>>pz>>x>>y>>z) {
307 if (good[lab] != 0x3F) continue;
308 TParticle *p = (TParticle*)gAlice->Particle(lab);
310 gt[nt].code=p->GetPdgCode();
311 //**** px py pz - in global coordinate system
312 gt[nt].px=p->Px(); gt[nt].py=p->Py(); gt[nt].pz=p->Pz();
313 gt[nt].x=gt[nt].y=gt[nt].z=0.;
315 if (nt==max) {cerr<<"Too many good tracks !\n"; break;}
320 delete gAlice; gAlice=0;