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 ****************************************************************************/
10 #if !defined(__CINT__) || defined(__MAKECINT__)
11 #include <Riostream.h>
16 #include "AliHeader.h"
17 #include "AliRunLoader.h"
18 #include "AliITSLoader.h"
23 #include "TObjArray.h"
28 #include "TParticle.h"
29 #include "TStopwatch.h"
34 #include "AliCascadeVertex.h"
38 Int_t nlab,plab; // V0's daughter labels
39 Int_t blab; // Bachelor label
44 Int_t good_cascades(GoodCascade *gt, Int_t max);
46 extern AliRun *gAlice;
48 Int_t AliCascadeComparison(Int_t code=3312) {
49 //code= 3312; //kXiMinus
50 //code=-3312; //kXiPlusBar
51 //code= 3334; //kOmegaMinus
52 //code=-3334; //kOmegaPlusBar
53 cerr<<"Doing comparison...\n";
56 /*** Check if the file with the "good" cascades exists ***/
59 ifstream in("good_cascades");
61 cerr<<"Reading good cascades...\n";
62 while (in>>gc[ngood].nlab>>gc[ngood].plab>>
63 gc[ngood].blab>>gc[ngood].code>>
64 gc[ngood].px>>gc[ngood].py>>gc[ngood].pz>>
65 gc[ngood].x >>gc[ngood].y >>gc[ngood].z) {
69 cerr<<"Too many good cascades !\n";
73 if (!in.eof()) cerr<<"Read error (good_cascades) !\n";
75 /*** generate a file with the "good" cascades ***/
76 cerr<<"Marking good cascades (this will take a while)...\n";
77 ngood=good_cascades(gc,100);
78 ofstream out("good_cascades");
80 for (Int_t ngd=0; ngd<ngood; ngd++)
81 out<<gc[ngd].nlab<<' '<<gc[ngd].plab<<' '<<
82 gc[ngd].blab<<' '<<gc[ngd].code<<' '<<
83 gc[ngd].px<<' '<<gc[ngd].py<<' '<<gc[ngd].pz<<' '<<
84 gc[ngd].x <<' '<<gc[ngd].y <<' '<<gc[ngd].z <<endl;
85 } else cerr<<"Can not open file (good_cascades) !\n";
90 { /*** Load reconstructed vertices ***/
91 TFile *ef=TFile::Open("AliESDcas.root");
92 if ((!ef)||(!ef->IsOpen())) {
93 cerr<<"AliCascadeComparison.C: Can't open AliESDcas.root !\n";
97 TIter next(ef->GetListOfKeys());
98 if ((key=(TKey*)next())!=0) event=(AliESD*)key->ReadObj();
101 Int_t nentr=event->GetNumberOfCascades();
104 const Double_t cascadeWindow=0.05, cascadeWidth=0.015;
105 Double_t ptncut=0.12, ptpcut=0.33, kine0cut=0.003;
106 Double_t ptbcut=0.11, kinecut=0.002;
107 Double_t cascadeMass=1.32131;
112 ptncut=0.33; ptpcut=0.12;
117 ptbcut=0.22; kinecut=0.006;
122 ptncut=0.33; ptpcut=0.12;
123 ptbcut=0.22; kinecut=0.006;
125 default: cerr<<"Invalid PDG code !\n"; return 1;
128 /*** create some histograms ***/
129 TH1F *hp=new TH1F("hp","Angular Resolution",30,-30.,30.); //phi resolution
130 hp->SetXTitle("(mrad)"); hp->SetFillColor(2);
131 TH1F *hl=new TH1F("hl","Lambda Resolution",30,-30,30);
132 hl->SetXTitle("(mrad)"); hl->SetFillColor(1); hl->SetFillStyle(3013);
133 TH1F *hpt=new TH1F("hpt","Relative Pt Resolution",30,-10.,10.);
134 hpt->SetXTitle("(%)"); hpt->SetFillColor(2);
136 TH1F *hx=new TH1F("hx","Position Resolution (X,Y)",30,-3.,3.); //x res.
137 hx->SetXTitle("(mm)"); hx->SetFillColor(6);
138 TH1F *hy=new TH1F("hy","Position Resolution (Y)",30,-3.,3.); //y res
139 hy->SetXTitle("(mm)"); hy->SetFillColor(1); hy->SetFillStyle(3013);
140 TH1F *hz=new TH1F("hz","Position Resolution (Z)",30,-3.,3.); //z res.
141 hz->SetXTitle("(mm)"); hz->SetFillColor(6);
143 Double_t pmin=0.2, pmax=4.2; Int_t nchan=20;
144 TH1F *hgood=new TH1F("hgood","Good Cascades",nchan,pmin,pmax);
145 TH1F *hfound=new TH1F("hfound","Found Cascades",nchan,pmin,pmax);
146 TH1F *hfake=new TH1F("hfake","Fake Cascades",nchan,pmin,pmax);
147 TH1F *hg=new TH1F("hg","Efficiency for Good Cascades",nchan,pmin,pmax);
148 hg->SetLineColor(4); hg->SetLineWidth(2);
149 TH1F *hf=new TH1F("hf","Probability of Fake Cascades",nchan,pmin,pmax);
150 hf->SetFillColor(1); hf->SetFillStyle(3013); hf->SetLineWidth(2);
152 Double_t mmin=cascadeMass-cascadeWindow, mmax=cascadeMass+cascadeWindow;
153 TH1F *cs =new TH1F("cs","Cascade Effective Mass",40, mmin, mmax);
154 cs->SetXTitle("(GeV)");
155 cs->SetLineColor(4); cs->SetLineWidth(4);
156 TH1F *csf =new TH1F("csf","Fake Cascade Effective Mass",40, mmin, mmax);
157 csf->SetXTitle("(GeV)"); csf->SetFillColor(6);
159 Double_t pxg=0.,pyg=0.,ptg=0.;
160 Int_t nlab=-1, plab=-1, blab=-1;
162 for (i=0; i<nentr; i++) {
163 AliESDcascade *cascade=event->GetCascade(i);
165 Int_t nidx=TMath::Abs(cascade->GetNindex());
166 Int_t pidx=TMath::Abs(cascade->GetPindex());
167 Int_t bidx=TMath::Abs(cascade->GetBindex());
169 AliESDtrack *ntrack=event->GetTrack(nidx);
170 AliESDtrack *ptrack=event->GetTrack(pidx);
171 AliESDtrack *btrack=event->GetTrack(bidx);
173 nlab=TMath::Abs(ntrack->GetLabel());
174 plab=TMath::Abs(ptrack->GetLabel());
175 blab=TMath::Abs(btrack->GetLabel());
177 /** Kinematical cuts **/
178 Double_t pxn,pyn,pzn; cascade->GetNPxPyPz(pxn,pyn,pzn);
179 Double_t ptn=TMath::Sqrt(pxn*pxn + pyn*pyn);
180 if (ptn < ptncut) continue;
181 Double_t pxp,pyp,pzp; cascade->GetPPxPyPz(pxp,pyp,pzp);
182 Double_t ptp=TMath::Sqrt(pxp*pxp + pyp*pyp);
183 if (ptp < ptpcut) continue;
184 Double_t pxb,pyb,pzb; cascade->GetBPxPyPz(pxb,pyb,pzb);
185 Double_t ptb=TMath::Sqrt(pxb*pxb + pyb*pyb);
186 if (ptb < ptbcut) continue;
188 Double_t kine=cascade->ChangeMassHypothesis(kine0,code);
189 if (TMath::Abs(kine0)>kine0cut) continue;
190 //if (TMath::Abs(kine)>kinecut) continue;
192 Double_t mass=cascade->GetEffMass();
196 if (TMath::Abs(mass-cascadeMass)>cascadeWidth) continue;
199 for (j=0; j<ngood; j++) {
200 if (gc[j].code != cascade->GetPdgCode()) continue;
201 if (gc[j].nlab == nlab)
202 if (gc[j].plab == plab)
203 if (gc[j].blab == blab) break;
206 Double_t px,py,pz; cascade->GetPxPyPz(px,py,pz);
207 Double_t pt=TMath::Sqrt(px*px+py*py);
211 cerr<<"Fake cascade: ("<<nlab<<","<<plab<<","<<blab<<")\n";
216 pxg=gc[j].px; pyg=gc[j].py; ptg=TMath::Sqrt(pxg*pxg+pyg*pyg);
217 Double_t phig=TMath::ATan2(pyg,pxg), phi=TMath::ATan2(py,px);
218 Double_t lamg=TMath::ATan2(gc[j].pz,ptg), lam=TMath::ATan2(pz,pt);
219 hp->Fill((phi - phig)*1000.);
220 hl->Fill((lam - lamg)*1000.);
221 hpt->Fill((1/pt - 1/ptg)/(1/ptg)*100.);
223 Double_t x,y,z; cascade->GetXYZ(x,y,z);
224 hx->Fill((x-gc[j].x)*10);
225 hy->Fill((y-gc[j].y)*10);
226 hz->Fill((z-gc[j].z)*10);
232 for (i=0; i<ngood; i++) {
233 if (gc[i].code != code) continue;
234 pxg=gc[i].px; pyg=gc[i].py; ptg=TMath::Sqrt(pxg*pxg+pyg*pyg);
236 nlab=gc[i].nlab; plab=gc[i].plab; blab=gc[i].blab;
237 if (nlab < 0) continue;
238 cerr<<"Cascade ("<<nlab<<','<<plab<<","<<blab<<") has not been found !\n";
243 Stat_t ng=hgood->GetEntries();
244 Stat_t nf=hfound->GetEntries();
246 cerr<<"Number of found cascades: "<<nentr<<" ("<<nf<<" in the peak)\n";
247 cerr<<"Number of good cascades: "<<ng<<endl;
250 cerr<<"Integral efficiency is about "<<nf/ng*100.<<" %\n";
252 gStyle->SetOptStat(111110);
253 gStyle->SetOptFit(1);
255 TCanvas *c1=new TCanvas("c1","",0,0,580,610);
259 gPad->SetFillColor(42); gPad->SetFrameFillColor(10);
262 hl->Draw("same"); c1->cd();
265 gPad->SetFillColor(42); gPad->SetFrameFillColor(10);
266 //hpt->Fit("gaus"); c1->cd();
267 hpt->Draw(); c1->cd();
270 gPad->SetFillColor(42); gPad->SetFrameFillColor(10);
273 hy->Draw("same"); c1->cd();
276 gPad->SetFillColor(42); gPad->SetFrameFillColor(10);
281 TCanvas *c2=new TCanvas("c2","",600,0,580,610);
285 gPad->SetFillColor(42); gPad->SetFrameFillColor(10);
286 hfound->Sumw2(); hgood->Sumw2(); hfake->Sumw2();
287 hg->Divide(hfound,hgood,1,1.,"b");
288 hf->Divide(hfake,hgood,1,1.,"b");
290 hg->SetYTitle("Cascade reconstruction efficiency");
291 hg->SetXTitle("Pt (GeV/c)");
294 TLine *line1 = new TLine(pmin,1.0,pmax,1.0); line1->SetLineStyle(4);
296 TLine *line2 = new TLine(pmin,0.9,pmax,0.9); line2->SetLineStyle(4);
300 hf->SetFillStyle(3013);
303 hf->Draw("histsame");
304 TText *text = new TText(0.461176,0.248448,"Fake cascades");
305 text->SetTextSize(0.05);
307 text = new TText(0.453919,1.11408,"Good cascades");
308 text->SetTextSize(0.05);
313 gPad->SetFillColor(42); gPad->SetFrameFillColor(10);
314 //cs->Fit("gaus","","",cascadeMass-cascadeWidth,cascadeMass+cascadeWidth);
317 Double_t max=cs->GetMaximum();
319 new TLine(cascadeMass-cascadeWidth,0.,cascadeMass-cascadeWidth,max);
322 new TLine(cascadeMass+cascadeWidth,0.,cascadeMass+cascadeWidth,max);
325 timer.Stop(); timer.Print();
331 Int_t good_cascades(GoodCascade *gc, Int_t max) {
333 /*** Get information about the cuts ***/
334 Double_t r2min=0.9*0.9;
335 Double_t r2max=2.9*2.9;
337 /*** Get labels of the "good" tracks ***/
338 Double_t dd; Int_t id, label[15000], ngt=0;
339 ifstream in("good_tracks_its");
341 cerr<<"Can't open the file good_tracks_its \n";
344 while (in>>label[ngt]>>id>>dd>>dd>>dd>>dd>>dd>>dd) {
347 cerr<<"Too many good ITS tracks !\n";
352 cerr<<"Read error (good_tracks_its) !\n";
356 /*** Get an access to the kinematics ***/
358 delete gAlice->GetRunLoader();
362 AliRunLoader *rl = AliRunLoader::Open("galice.root");
364 cerr<<"AliCascadeComparison.C, good_cascades :Can't start session !\n";
370 rl->LoadKinematics();
371 Int_t np = rl->GetHeader()->GetNtrack();
375 TParticle *cp=gAlice->GetMCApp()->Particle(np);
377 /*** only these cascades are "good" ***/
378 Int_t code=cp->GetPdgCode();
379 if (code!=kXiMinus) if (code!=kXiPlusBar)
380 if (code!=kOmegaMinus) if (code!=kOmegaPlusBar) continue;
382 /*** daughter tracks must be "good" ***/
383 Int_t v0lab=cp->GetFirstDaughter(), blab=cp->GetLastDaughter();
384 if (v0lab==blab) continue;
385 if (v0lab<0) continue;
386 if (blab<0) continue;
388 TParticle *p0=gAlice->GetMCApp()->Particle(v0lab);
389 TParticle *bp=gAlice->GetMCApp()->Particle(blab);
390 if ((p0->GetPdgCode()!=kLambda0) && (p0->GetPdgCode()!=kLambda0Bar)) {
391 TParticle *p=p0; p0=bp; bp=p;
392 Int_t i=v0lab; v0lab=blab; blab=i;
393 if ((p0->GetPdgCode()!=kLambda0) && (p0->GetPdgCode()!=kLambda0Bar))
397 /** is the bachelor "good" ? **/
399 for (i=0; i<ngt; i++) if (label[i]==blab) break;
400 if (i==ngt) continue;
402 /** is the V0 "good" ? **/
403 Int_t plab=p0->GetFirstDaughter(), nlab=p0->GetLastDaughter();
404 if (nlab==plab) continue;
405 if (nlab<0) continue;
406 if (plab<0) continue;
408 for (i=0; i<ngt; i++) if (label[i]==nlab) break;
409 if (i==ngt) continue;
410 for (i=0; i<ngt; i++) if (label[i]==plab) break;
411 if (i==ngt) continue;
413 /*** fiducial volume ***/
414 Double_t x=bp->Vx(), y=bp->Vy(), r2=x*x+y*y; //bachelor
415 if (r2<r2min) continue;
416 if (r2>r2max) continue;
417 TParticle *pp=gAlice->GetMCApp()->Particle(plab);
418 x=pp->Vx(); y=pp->Vy(); r2=x*x+y*y; //V0
419 if (r2<r2min) continue;
420 if (r2>r2max) continue;
422 if (gAlice->GetMCApp()->Particle(plab)->GetPDG()->Charge() < 0.) {
423 i=plab; plab=nlab; nlab=i;
427 gc[nc].plab=plab; gc[nc].nlab=nlab; gc[nc].blab=blab;
428 gc[nc].px=cp->Px(); gc[nc].py=cp->Py(); gc[nc].pz=cp->Pz();
429 gc[nc].x=bp->Vx(); gc[nc].y=bp->Vy(); gc[nc].z=bp->Vz();