1 /****************************************************************************
2 * Very important, delicate and rather obscure macro. *
4 * Creates list of "findable" cascades, *
5 * calculates efficiency, resolutions etc. *
7 * Origin: Christian Kuhn, IReS, Strasbourg, christian.kuhn@ires.in2p3.fr *
8 ****************************************************************************/
17 #include "TObjArray.h"
22 #include "TParticle.h"
23 #include "TStopwatch.h"
27 #include "AliCascadeVertex.h"
31 Int_t nlab,plab; // V0's daughter labels
32 Int_t blab; // Bachelor label
37 Int_t good_cascades(GoodCascade *gt, Int_t max);
39 Int_t AliCascadeComparison(Int_t code=3312) {
40 //code= 3312; //kXiMinus
41 //code=-3312; //kXiPlusBar
42 //code= 3334; //kOmegaMinus
43 //code=-3334; //kOmegaPlusBar
45 cerr<<"Doing comparison...\n";
47 const Double_t cascadeWindow=0.05, cascadeWidth=0.015;
48 Double_t cascadeMass=0.5;
51 case kXiPlusBar: cascadeMass=1.32131; break;
53 case kOmegaPlusBar: cascadeMass=1.67245; break;
54 default: cerr<<"Invalid PDG code !\n"; return 1;
59 /*** Load reconstructed cascades ***/
60 TFile *cf=TFile::Open("AliCascadeVertices.root");
61 if (!cf->IsOpen()){cerr<<"Can't open AliCascadeVertices.root !\n";return 2;}
62 TObjArray carray(1000);
63 TTree *cTree=(TTree*)cf->Get("TreeCasc");
64 TBranch *branch=cTree->GetBranch("cascades");
65 Int_t nentr=(Int_t)cTree->GetEntries();
66 for (Int_t i=0; i<nentr; i++) {
67 AliCascadeVertex *iovertex=new AliCascadeVertex;
68 branch->SetAddress(&iovertex);
70 carray.AddLast(iovertex);
74 /*** Check if the file with the "good" cascades exists ***/
77 ifstream in("good_cascades");
79 cerr<<"Reading good cascades...\n";
80 while (in>>gc[ngood].nlab>>gc[ngood].plab>>
81 gc[ngood].blab>>gc[ngood].code>>
82 gc[ngood].px>>gc[ngood].py>>gc[ngood].pz>>
83 gc[ngood].x >>gc[ngood].y >>gc[ngood].z) {
87 cerr<<"Too many good cascades !\n";
91 if (!in.eof()) cerr<<"Read error (good_cascades) !\n";
93 /*** generate a file with the "good" cascades ***/
94 cerr<<"Marking good cascades (this will take a while)...\n";
95 ngood=good_cascades(gc,100);
96 ofstream out("good_cascades");
98 for (Int_t ngd=0; ngd<ngood; ngd++)
99 out<<gc[ngd].nlab<<' '<<gc[ngd].plab<<' '<<
100 gc[ngd].blab<<' '<<gc[ngd].code<<' '<<
101 gc[ngd].px<<' '<<gc[ngd].py<<' '<<gc[ngd].pz<<' '<<
102 gc[ngd].x <<' '<<gc[ngd].y <<' '<<gc[ngd].z <<endl;
103 } else cerr<<"Can not open file (good_cascades) !\n";
107 /*** create some histograms ***/
108 TH1F *hp=new TH1F("hp","Angular Resolution",30,-30.,30.); //phi resolution
109 hp->SetXTitle("(mrad)"); hp->SetFillColor(2);
110 TH1F *hl=new TH1F("hl","Lambda Resolution",30,-30,30);
111 hl->SetXTitle("(mrad)"); hl->SetFillColor(1); hl->SetFillStyle(3013);
112 TH1F *hpt=new TH1F("hpt","Relative Pt Resolution",30,-10.,10.);
113 hpt->SetXTitle("(%)"); hpt->SetFillColor(2);
115 TH1F *hx=new TH1F("hx","Position Resolution (X,Y)",30,-3.,3.); //x res.
116 hx->SetXTitle("(mm)"); hx->SetFillColor(6);
117 TH1F *hy=new TH1F("hy","Position Resolution (Y)",30,-3.,3.); //y res
118 hy->SetXTitle("(mm)"); hy->SetFillColor(1); hy->SetFillStyle(3013);
119 TH1F *hz=new TH1F("hz","Position Resolution (Z)",30,-3.,3.); //z res.
120 hz->SetXTitle("(mm)"); hz->SetFillColor(6);
122 Double_t pmin=0.2, pmax=4.2; Int_t nchan=20;
123 TH1F *hgood=new TH1F("hgood","Good Cascades",nchan,pmin,pmax);
124 TH1F *hfound=new TH1F("hfound","Found Cascades",nchan,pmin,pmax);
125 TH1F *hfake=new TH1F("hfake","Fake Cascades",nchan,pmin,pmax);
126 TH1F *hg=new TH1F("hg","Efficiency for Good Cascades",nchan,pmin,pmax);
127 hg->SetLineColor(4); hg->SetLineWidth(2);
128 TH1F *hf=new TH1F("hf","Probability of Fake Cascades",nchan,pmin,pmax);
129 hf->SetFillColor(1); hf->SetFillStyle(3013); hf->SetLineWidth(2);
131 Double_t mmin=cascadeMass-cascadeWindow, mmax=cascadeMass+cascadeWindow;
132 TH1F *cs =new TH1F("v0s","Cascade Effective Mass",40, mmin, mmax);
133 cs->SetXTitle("(GeV)"); cs->SetFillColor(6);
135 Double_t pxg=0.,pyg=0.,ptg=0.;
136 Int_t nlab=-1, plab=-1, blab=-1;
138 for (i=0; i<nentr; i++) {
139 AliCascadeVertex *cascade=(AliCascadeVertex*)carray.UncheckedAt(i);
140 cascade->GetV0labels(nlab,plab);
141 nlab=TMath::Abs(nlab); plab=TMath::Abs(plab);
142 blab=TMath::Abs(cascade->GetBachelorLabel());
144 cascade->ChangeMassHypothesis(code);
146 Double_t mass=cascade->GetEffMass();
149 if (TMath::Abs(mass-cascadeMass)>cascadeWidth) continue;
152 for (j=0; j<ngood; j++) {
153 if (gc[j].code != cascade->GetPdgCode()) continue;
154 if (gc[j].nlab == nlab)
155 if (gc[j].plab == plab)
156 if (gc[j].blab == blab) break;
159 Double_t px,py,pz; cascade->GetPxPyPz(px,py,pz);
160 Double_t pt=TMath::Sqrt(px*px+py*py);
164 cerr<<"Fake cascade: ("<<nlab<<","<<plab<<","<<blab<<")\n";
168 pxg=gc[j].px; pyg=gc[j].py; ptg=TMath::Sqrt(pxg*pxg+pyg*pyg);
169 Double_t phig=TMath::ATan2(pyg,pxg), phi=TMath::ATan2(py,px);
170 Double_t lamg=TMath::ATan2(gc[j].pz,ptg), lam=TMath::ATan2(pz,pt);
171 hp->Fill((phi - phig)*1000.);
172 hl->Fill((lam - lamg)*1000.);
173 hpt->Fill((1/pt - 1/ptg)/(1/ptg)*100.);
175 Double_t x,y,z; cascade->GetXYZ(x,y,z);
176 hx->Fill((x-gc[j].x)*10);
177 hy->Fill((y-gc[j].y)*10);
178 hz->Fill((z-gc[j].z)*10);
184 for (i=0; i<ngood; i++) {
185 if (gc[i].code != code) continue;
186 pxg=gc[i].px; pyg=gc[i].py; ptg=TMath::Sqrt(pxg*pxg+pyg*pyg);
188 nlab=gc[i].nlab; plab=gc[i].plab; blab=gc[i].blab;
189 if (nlab < 0) continue;
190 cerr<<"Cascade ("<<nlab<<','<<plab<<","<<blab<<") has not been found !\n";
195 Stat_t ng=hgood->GetEntries();
196 Stat_t nf=hfound->GetEntries();
198 cerr<<"Number of found cascades: "<<nentr<<" ("<<nf<<" in the peak)\n";
199 cerr<<"Number of good cascades: "<<ng<<endl;
202 cerr<<"Integral efficiency is about "<<nf/ng*100.<<" %\n";
204 gStyle->SetOptStat(111110);
205 gStyle->SetOptFit(1);
207 TCanvas *c1=new TCanvas("c1","",0,0,580,610);
211 gPad->SetFillColor(42); gPad->SetFrameFillColor(10);
214 hl->Draw("same"); c1->cd();
217 gPad->SetFillColor(42); gPad->SetFrameFillColor(10);
218 //hpt->Fit("gaus"); c1->cd();
219 hpt->Draw(); c1->cd();
222 gPad->SetFillColor(42); gPad->SetFrameFillColor(10);
225 hy->Draw("same"); c1->cd();
228 gPad->SetFillColor(42); gPad->SetFrameFillColor(10);
233 TCanvas *c2=new TCanvas("c2","",600,0,580,610);
237 gPad->SetFillColor(42); gPad->SetFrameFillColor(10);
238 hfound->Sumw2(); hgood->Sumw2(); hfake->Sumw2();
239 hg->Divide(hfound,hgood,1,1.,"b");
240 hf->Divide(hfake,hgood,1,1.,"b");
242 hg->SetYTitle("Cascade reconstruction efficiency");
243 hg->SetXTitle("Pt (GeV/c)");
246 TLine *line1 = new TLine(pmin,1.0,pmax,1.0); line1->SetLineStyle(4);
248 TLine *line2 = new TLine(pmin,0.9,pmax,0.9); line2->SetLineStyle(4);
252 hf->SetFillStyle(3013);
255 hf->Draw("histsame");
256 TText *text = new TText(0.461176,0.248448,"Fake cascades");
257 text->SetTextSize(0.05);
259 text = new TText(0.453919,1.11408,"Good cascades");
260 text->SetTextSize(0.05);
265 gPad->SetFillColor(42); gPad->SetFrameFillColor(10);
266 cs->SetXTitle("(GeV/c)");
267 cs->Fit("gaus","","",cascadeMass-cascadeWidth,cascadeMass+cascadeWidth);
268 Double_t max=cs->GetMaximum();
270 new TLine(cascadeMass-cascadeWidth,0.,cascadeMass-cascadeWidth,max);
273 new TLine(cascadeMass+cascadeWidth,0.,cascadeMass+cascadeWidth,max);
276 timer.Stop(); timer.Print();
283 Int_t good_cascades(GoodCascade *gc, Int_t max) {
285 /*** Get information about the cuts ***/
286 Double_t r2min=0.9*0.9;
287 Double_t r2max=2.9*2.9;
289 /*** Get labels of the "good" tracks ***/
290 Double_t dd; Int_t id, label[15000], ngt=0;
291 ifstream in("good_tracks_its");
293 cerr<<"Can't open the file good_tracks_its \n";
296 while (in>>label[ngt]>>id>>dd>>dd>>dd>>dd>>dd>>dd) {
299 cerr<<"Too many good ITS tracks !\n";
304 cerr<<"Read error (good_tracks_its) !\n";
308 /*** Get an access to the kinematics ***/
309 if (gAlice) {delete gAlice; gAlice=0;}
311 TFile *file=TFile::Open("galice.root");
312 if (!file->IsOpen()) {cerr<<"Can't open galice.root !\n"; exit(4);}
313 if (!(gAlice=(AliRun*)file->Get("gAlice"))) {
314 cerr<<"gAlice has not been found on galice.root !\n";
318 Int_t np=gAlice->GetEvent(0);
321 TParticle *cp=gAlice->Particle(np);
323 /*** only these cascades are "good" ***/
324 Int_t code=cp->GetPdgCode();
325 if (code!=kXiMinus) if (code!=kXiPlusBar)
326 if (code!=kOmegaMinus) if (code!=kOmegaPlusBar) continue;
328 /*** daughter tracks must be "good" ***/
329 Int_t v0lab=cp->GetFirstDaughter(), blab=cp->GetLastDaughter();
330 if (v0lab==blab) continue;
331 if (v0lab<0) continue;
332 if (blab<0) continue;
334 TParticle *p0=gAlice->Particle(v0lab);
335 TParticle *bp=gAlice->Particle(blab);
336 if ((p0->GetPdgCode()!=kLambda0) && (p0->GetPdgCode()!=kLambda0Bar)) {
337 TParticle *p=p0; p0=bp; bp=p;
338 Int_t i=v0lab; v0lab=blab; blab=i;
339 if ((p0->GetPdgCode()!=kLambda0) && (p0->GetPdgCode()!=kLambda0Bar))
343 /** is the bachelor "good" ? **/
345 for (i=0; i<ngt; i++) if (label[i]==blab) break;
346 if (i==ngt) continue;
348 /** is the V0 "good" ? **/
349 Int_t plab=p0->GetFirstDaughter(), nlab=p0->GetLastDaughter();
350 if (nlab==plab) continue;
351 if (nlab<0) continue;
352 if (plab<0) continue;
354 for (i=0; i<ngt; i++) if (label[i]==nlab) break;
355 if (i==ngt) continue;
356 for (i=0; i<ngt; i++) if (label[i]==plab) break;
357 if (i==ngt) continue;
359 /*** fiducial volume ***/
360 Double_t x=bp->Vx(), y=bp->Vy(), z=bp->Vz(), r2=x*x+y*y; //bachelor
361 if (r2<r2min) continue;
362 if (r2>r2max) continue;
363 TParticle *pp=gAlice->Particle(plab);
364 x=pp->Vx(); y=pp->Vy(); r2=x*x+y*y; //V0
365 if (r2<r2min) continue;
366 if (r2>r2max) continue;
368 if (gAlice->Particle(plab)->GetPDG()->Charge() < 0.) {
369 i=plab; plab=nlab; nlab=i;
373 gc[nc].plab=plab; gc[nc].nlab=nlab; gc[nc].blab=blab;
374 gc[nc].px=cp->Px(); gc[nc].py=cp->Py(); gc[nc].pz=cp->Pz();
375 gc[nc].x=x; gc[nc].y=y; gc[nc].z=z;