13 #include "TParticle.h"
14 #include "TStopwatch.h"
18 #include "AliV0vertex.h"
27 Int_t good_vertices(GoodVertex *gt, Int_t max);
29 Int_t AliV0Comparison(Int_t code=310) { //Lambda=3122, LambdaBar=-3122
30 cerr<<"Doing comparison...\n";
32 const Double_t V0window=0.05, V0width=0.015;
35 case kK0Short: V0mass=0.497672; break;
36 case kLambda0: V0mass=1.115683; break;
37 case kLambda0Bar: V0mass=1.115683; break;
38 default: cerr<<"Invalid PDG code !\n"; return 1;
43 /*** Load reconstructed vertices ***/
44 TFile *vf=TFile::Open("AliV0vertices.root");
45 if (!vf->IsOpen()) {cerr<<"Can't open AliV0vertices.root !\n"; return 2;}
46 TObjArray varray(1000);
47 TTree *vTree=(TTree*)vf->Get("TreeV");
48 TBranch *branch=vTree->GetBranch("vertices");
49 Int_t nentr=(Int_t)vTree->GetEntries();
50 for (Int_t i=0; i<nentr; i++) {
51 AliV0vertex *iovertex=new AliV0vertex; branch->SetAddress(&iovertex);
53 varray.AddLast(iovertex);
56 /*** Check if the file with the "good" vertices exists ***/
59 ifstream in("good_vertices");
61 cerr<<"Reading good vertices...\n";
62 while (in>>gv[ngood].nlab>>gv[ngood].plab>>gv[ngood].code>>
63 gv[ngood].px>>gv[ngood].py>>gv[ngood].pz>>
64 gv[ngood].x >>gv[ngood].y >>gv[ngood].z) {
68 cerr<<"Too many good vertices !\n";
72 if (!in.eof()) cerr<<"Read error (good_vertices) !\n";
74 /*** generate a file with the "good" vertices ***/
75 cerr<<"Marking good vertices (this will take a while)...\n";
76 ngood=good_vertices(gv,1000);
77 ofstream out("good_vertices");
79 for (Int_t ngd=0; ngd<ngood; ngd++)
80 out<<gv[ngd].nlab<<' '<<gv[ngd].plab<<' '<<gv[ngd].code<<' '<<
81 gv[ngd].px<<' '<<gv[ngd].py<<' '<<gv[ngd].pz<<' '<<
82 gv[ngd].x <<' '<<gv[ngd].y <<' '<<gv[ngd].z <<endl;
83 } else cerr<<"Can not open file (good_vertices) !\n";
90 TH1F *hp=new TH1F("hp","Angular Resolution",30,-30.,30.); //phi resolution
91 hp->SetXTitle("(mrad)"); hp->SetFillColor(2);
92 TH1F *hl=new TH1F("hl","Lambda Resolution",30,-30,30);
93 hl->SetXTitle("(mrad)"); hl->SetFillColor(1); hl->SetFillStyle(3013);
94 TH1F *hpt=new TH1F("hpt","Relative Pt Resolution",30,-10.,10.);
95 hpt->SetXTitle("(%)"); hpt->SetFillColor(2);
97 TH1F *hx=new TH1F("hx","Position Resolution (X,Y)",30,-3.,3.); //x res.
98 hx->SetXTitle("(mm)"); hx->SetFillColor(6);
99 TH1F *hy=new TH1F("hy","Position Resolution (Y)",30,-3.,3.); //y res
100 hy->SetXTitle("(mm)"); hy->SetFillColor(1); hy->SetFillStyle(3013);
101 TH1F *hz=new TH1F("hz","Position Resolution (Z)",30,-3.,3.); //z res.
102 hz->SetXTitle("(mm)"); hz->SetFillColor(6);
105 Double_t pmin=0.2, pmax=4.2; Int_t nchan=20;
106 TH1F *hgood=new TH1F("hgood","Good Vertices",nchan,pmin,pmax);
107 TH1F *hfound=new TH1F("hfound","Found Vertices",nchan,pmin,pmax);
108 TH1F *hfake=new TH1F("hfake","Fake Vertices",nchan,pmin,pmax);
109 TH1F *hg=new TH1F("hg","Efficiency for Good Vertices",nchan,pmin,pmax);
110 hg->SetLineColor(4); hg->SetLineWidth(2);
111 TH1F *hf=new TH1F("hf","Probability of Fake Vertices",nchan,pmin,pmax);
112 hf->SetFillColor(1); hf->SetFillStyle(3013); hf->SetLineWidth(2);
114 Double_t mmin=V0mass-V0window, mmax=V0mass+V0window;
115 TH1F *v0s =new TH1F("v0s","V0s Effective Mass",40, mmin, mmax);
116 v0s->SetXTitle("(GeV/c)"); v0s->SetFillColor(6);
119 Double_t pxg=0.,pyg=0.,ptg=0.;
120 Int_t nlab=-1, plab=-1;
122 for (i=0; i<nentr; i++) {
123 AliV0vertex *vertex=(AliV0vertex*)varray.UncheckedAt(i);
124 nlab=TMath::Abs(vertex->GetNlabel());
125 plab=TMath::Abs(vertex->GetPlabel());
127 vertex->ChangeMassHypothesis(code);
129 Double_t mass=vertex->GetEffMass();
133 for (j=0; j<ngood; j++) {
134 if (gv[j].code != vertex->GetPdgCode()) continue;
135 if (gv[j].nlab == nlab)
136 if (gv[j].plab == plab) break;
139 if (TMath::Abs(mass-V0mass)>V0width) continue;
141 Double_t px,py,pz; vertex->GetPxPyPz(px,py,pz);
142 Double_t pt=TMath::Sqrt(px*px+py*py);
146 cerr<<"Fake vertex: ("<<nlab<<","<<plab<<")\n";
150 pxg=gv[j].px; pyg=gv[j].py; ptg=TMath::Sqrt(pxg*pxg+pyg*pyg);
151 Double_t phig=TMath::ATan2(pyg,pxg), phi=TMath::ATan2(py,px);
152 Double_t lamg=TMath::ATan2(gv[j].pz,ptg), lam=TMath::ATan2(pz,pt);
153 hp->Fill((phi - phig)*1000.);
154 hl->Fill((lam - lamg)*1000.);
155 hpt->Fill((1/pt - 1/ptg)/(1/ptg)*100.);
157 Double_t x,y,z; vertex->GetXYZ(x,y,z);
158 hx->Fill((x-gv[j].x)*10);
159 hy->Fill((y-gv[j].y)*10);
160 hz->Fill((z-gv[j].z)*10);
166 for (i=0; i<ngood; i++) {
167 if (gv[i].code != code) continue;
168 pxg=gv[i].px; pyg=gv[i].py; ptg=TMath::Sqrt(pxg*pxg+pyg*pyg);
170 nlab=gv[i].nlab; plab=gv[i].plab;
171 if (nlab < 0) continue;
172 cerr<<"Vertex ("<<nlab<<','<<plab<<") has not been found !\n";
177 Stat_t ng=hgood->GetEntries();
178 Stat_t nf=hfound->GetEntries();
180 cerr<<"Number of found vertices: "<<nentr<<" ("<<nf<<" in the peak)\n";
181 cerr<<"Number of good vertices: "<<ng<<endl;
184 cerr<<"Integral efficiency is about "<<nf/ng*100.<<" %\n";
186 gStyle->SetOptStat(111110);
187 gStyle->SetOptFit(1);
189 TCanvas *c1=new TCanvas("c1","",0,0,580,610);
193 gPad->SetFillColor(42); gPad->SetFrameFillColor(10);
196 hl->Draw("same"); c1->cd();
199 gPad->SetFillColor(42); gPad->SetFrameFillColor(10);
200 //hpt->Fit("gaus"); c1->cd();
201 hpt->Draw(); c1->cd();
204 gPad->SetFillColor(42); gPad->SetFrameFillColor(10);
207 hy->Draw("same"); c1->cd();
210 gPad->SetFillColor(42); gPad->SetFrameFillColor(10);
215 TCanvas *c2=new TCanvas("c2","",600,0,580,610);
219 gPad->SetFillColor(42); gPad->SetFrameFillColor(10);
220 hfound->Sumw2(); hgood->Sumw2(); hfake->Sumw2();
221 hg->Divide(hfound,hgood,1,1.,"b");
222 hf->Divide(hfake,hgood,1,1.,"b");
224 hg->SetYTitle("V0 reconstruction efficiency");
225 hg->SetXTitle("Pt (GeV/c)");
228 TLine *line1 = new TLine(pmin,1.0,pmax,1.0); line1->SetLineStyle(4);
230 TLine *line2 = new TLine(pmin,0.9,pmax,0.9); line2->SetLineStyle(4);
234 hf->SetFillStyle(3013);
237 hf->Draw("histsame");
238 TText *text = new TText(0.461176,0.248448,"Fake vertices");
239 text->SetTextSize(0.05);
241 text = new TText(0.453919,1.11408,"Good vertices");
242 text->SetTextSize(0.05);
247 gPad->SetFillColor(42); gPad->SetFrameFillColor(10);
248 v0s->SetXTitle("(GeV/c)");
249 v0s->Fit("gaus","","",V0mass-V0width,V0mass+V0width);
250 Double_t max=v0s->GetMaximum();
251 TLine *line3 = new TLine(V0mass-V0width,0.,V0mass-V0width,max);
253 TLine *line4 = new TLine(V0mass+V0width,0.,V0mass+V0width,max);
256 timer.Stop(); timer.Print();
261 Int_t good_vertices(GoodVertex *gv, Int_t max) {
263 /*** Get information about the cuts ***/
264 Double_t r2min=0.9*0.9;
265 Double_t r2max=2.9*2.9;
267 /*** Get labels of the "good" tracks ***/
268 Double_t dd; Int_t id, label[15000], ngt=0;
269 ifstream in("good_tracks_its");
271 cerr<<"Can't open the file good_tracks_its \n";
274 while (in>>label[ngt]>>id>>dd>>dd>>dd>>dd>>dd>>dd) {
277 cerr<<"Too many good ITS tracks !\n";
282 cerr<<"Read error (good_tracks_its) !\n";
286 /*** Get an access to the kinematics ***/
287 if (gAlice) {delete gAlice; gAlice=0;}
289 TFile *file=TFile::Open("galice.root");
290 if (!file->IsOpen()) {cerr<<"Can't open galice.root !\n"; exit(4);}
291 if (!(gAlice=(AliRun*)file->Get("gAlice"))) {
292 cerr<<"gAlice has not been found on galice.root !\n";
296 Int_t np=gAlice->GetEvent(0);
299 TParticle *p0=gAlice->Particle(np);
301 /*** only these V0s are "good" ***/
302 Int_t code=p0->GetPdgCode();
305 if (code!=kLambda0Bar) continue;
307 /*** daughter tracks should be "good" ***/
308 Int_t plab=p0->GetFirstDaughter(), nlab=p0->GetLastDaughter();
309 if (nlab==plab) continue;
310 if (nlab<0) continue;
311 if (plab<0) continue;
313 for (i=0; i<ngt; i++) if (label[i]==nlab) break;
314 if (i==ngt) continue;
315 for (i=0; i<ngt; i++) if (label[i]==plab) break;
316 if (i==ngt) continue;
318 /*** fiducial volume ***/
319 TParticle *p=gAlice->Particle(nlab);
320 Double_t x=p->Vx(), y=p->Vy(), z=p->Vz(), r2=x*x+y*y;
321 if (r2<r2min) continue;
322 if (r2>r2max) continue;
325 gv[nv].plab=plab; gv[nv].nlab=nlab;
326 gv[nv].px=p0->Px(); gv[nv].py=p0->Py(); gv[nv].pz=p0->Pz();
327 gv[nv].x=x; gv[nv].y=y; gv[nv].z=z;
331 delete gAlice; gAlice=0;