* Origin: I.Belikov, IReS, Strasbourg, Jouri.Belikov@cern.ch *
****************************************************************************/
-#ifndef __CINT__
- #include <iostream.h>
- #include <fstream.h>
-
- #include "TH1.h"
- #include "TFile.h"
- #include "TTree.h"
- #include "TObjArray.h"
- #include "TStyle.h"
- #include "TCanvas.h"
- #include "TLine.h"
- #include "TText.h"
- #include "TParticle.h"
- #include "TStopwatch.h"
-
+#if !defined(__CINT__) || defined(__MAKECINT__)
+ #include <TMath.h>
+ #include <TError.h>
+ #include <Riostream.h>
+ #include <TH1F.h>
+ #include <TTree.h>
+ #include <TParticle.h>
+ #include <TCanvas.h>
+ #include <TLine.h>
+ #include <TText.h>
+ #include <TBenchmark.h>
+ #include <TStyle.h>
+ #include <TKey.h>
+ #include <TROOT.h>
+
+ #include "AliStack.h"
+ #include "AliHeader.h"
+ #include "AliTrackReference.h"
+ #include "AliRunLoader.h"
#include "AliRun.h"
- #include "AliPDG.h"
- #include "AliV0vertex.h"
+ #include "AliESD.h"
#endif
-struct GoodVertex {
- Int_t nlab,plab;
- Int_t code;
- Float_t px,py,pz;
- Float_t x,y,z;
-};
-Int_t good_vertices(GoodVertex *gt, Int_t max);
+Int_t GoodV0s(const Char_t *dir=".");
-Int_t AliV0Comparison(Int_t code=310) { //Lambda=3122, LambdaBar=-3122
- cerr<<"Doing comparison...\n";
+extern AliRun *gAlice;
+extern TBenchmark *gBenchmark;
+extern TROOT *gROOT;
- const Double_t V0window=0.05, V0width=0.015;
- Double_t V0mass=0.5;
- switch (code) {
- case kK0Short: V0mass=0.497672; break;
- case kLambda0: V0mass=1.115683; break;
- case kLambda0Bar: V0mass=1.115683; break;
- default: cerr<<"Invalid PDG code !\n"; return 1;
- }
+static Int_t allgood=0;
+static Int_t allfound=0;
- TStopwatch timer;
-
- /*** Load reconstructed vertices ***/
- TFile *vf=TFile::Open("AliV0vertices.root");
- if (!vf->IsOpen()) {cerr<<"Can't open AliV0vertices.root !\n"; return 2;}
- TObjArray varray(1000);
- TTree *vTree=(TTree*)vf->Get("TreeV");
- TBranch *branch=vTree->GetBranch("vertices");
- Int_t nentr=(Int_t)vTree->GetEntries();
- for (Int_t i=0; i<nentr; i++) {
- AliV0vertex *iovertex=new AliV0vertex; branch->SetAddress(&iovertex);
- vTree->GetEvent(i);
- varray.AddLast(iovertex);
- }
+Int_t AliV0Comparison(Int_t code=310, const Char_t *dir=".") {
+ //Lambda=3122, LambdaBar=-3122
+ gBenchmark->Start("AliV0Comparison");
- /*** Check if the file with the "good" vertices exists ***/
- GoodVertex gv[1000];
- Int_t ngood=0;
- ifstream in("good_vertices");
- if (in) {
- cerr<<"Reading good vertices...\n";
- while (in>>gv[ngood].nlab>>gv[ngood].plab>>gv[ngood].code>>
- gv[ngood].px>>gv[ngood].py>>gv[ngood].pz>>
- gv[ngood].x >>gv[ngood].y >>gv[ngood].z) {
- ngood++;
- cerr<<ngood<<'\r';
- if (ngood==1000) {
- cerr<<"Too many good vertices !\n";
- break;
- }
- }
- if (!in.eof()) cerr<<"Read error (good_vertices) !\n";
- } else {
- /*** generate a file with the "good" vertices ***/
- cerr<<"Marking good vertices (this will take a while)...\n";
- ngood=good_vertices(gv,1000);
- ofstream out("good_vertices");
- if (out) {
- for (Int_t ngd=0; ngd<ngood; ngd++)
- out<<gv[ngd].nlab<<' '<<gv[ngd].plab<<' '<<gv[ngd].code<<' '<<
- gv[ngd].px<<' '<<gv[ngd].py<<' '<<gv[ngd].pz<<' '<<
- gv[ngd].x <<' '<<gv[ngd].y <<' '<<gv[ngd].z <<endl;
- } else cerr<<"Can not open file (good_vertices) !\n";
- out.close();
- }
+ ::Info("AliV0Comparison.C","Doing comparison...");
- vf->Close();
+ const Double_t V0window=0.05;
+ Double_t ptncut=0.13, ptpcut=0.13, kinecut=0.03;
+ Double_t V0mass=0.497672, V0width=0.020;
+ switch (code) {
+ case kK0Short:
+ break;
+ case kLambda0:
+ V0mass=1.115683; V0width=0.015; ptpcut=0.50; kinecut=0.002;
+ break;
+ case kLambda0Bar:
+ V0mass=1.115683; V0width=0.015; ptncut=0.50; kinecut=0.002;
+ break;
+ default: cerr<<"Invalid PDG code !\n"; return 1;
+ }
- TH1F *hp=new TH1F("hp","Angular Resolution",30,-30.,30.); //phi resolution
+ TH1F *hp=(TH1F*)gROOT->FindObject("hp");
+ if (!hp) hp=new TH1F("hp","PHI Resolution",30,-30.,30.);
hp->SetXTitle("(mrad)"); hp->SetFillColor(2);
- TH1F *hl=new TH1F("hl","Lambda Resolution",30,-30,30);
- hl->SetXTitle("(mrad)"); hl->SetFillColor(1); hl->SetFillStyle(3013);
- TH1F *hpt=new TH1F("hpt","Relative Pt Resolution",30,-10.,10.);
+
+ TH1F *hl=(TH1F*)gROOT->FindObject("hl");
+ if (!hl) hl=new TH1F("hl","LAMBDA Resolution",30,-30,30);
+ hl->SetXTitle("(mrad)"); hl->SetFillColor(1); hl->SetFillStyle(3013);
+
+ TH1F *hpt=(TH1F*)gROOT->FindObject("hpt");
+ if (!hpt) hpt=new TH1F("hpt","Relative Pt Resolution",30,-10.,10.);
hpt->SetXTitle("(%)"); hpt->SetFillColor(2);
- TH1F *hx=new TH1F("hx","Position Resolution (X,Y)",30,-3.,3.); //x res.
+ TH1F *hx=(TH1F*)gROOT->FindObject("hx");
+ if (!hx) hx=new TH1F("hx","Position Resolution (X)",30,-3.,3.);
hx->SetXTitle("(mm)"); hx->SetFillColor(6);
- TH1F *hy=new TH1F("hy","Position Resolution (Y)",30,-3.,3.); //y res
+
+ TH1F *hy=(TH1F*)gROOT->FindObject("hy");
+ if (!hy) hy=new TH1F("hy","Position Resolution (Y)",30,-3.,3.);
hy->SetXTitle("(mm)"); hy->SetFillColor(1); hy->SetFillStyle(3013);
- TH1F *hz=new TH1F("hz","Position Resolution (Z)",30,-3.,3.); //z res.
+
+ TH1F *hz=(TH1F*)gROOT->FindObject("hz");
+ if (!hz) hz=new TH1F("hz","Position Resolution (Z)",30,-3.,3.);
hz->SetXTitle("(mm)"); hz->SetFillColor(6);
Double_t pmin=0.2, pmax=4.2; Int_t nchan=20;
- TH1F *hgood=new TH1F("hgood","Good Vertices",nchan,pmin,pmax);
- TH1F *hfound=new TH1F("hfound","Found Vertices",nchan,pmin,pmax);
- TH1F *hfake=new TH1F("hfake","Fake Vertices",nchan,pmin,pmax);
- TH1F *hg=new TH1F("hg","Efficiency for Good Vertices",nchan,pmin,pmax);
+ TH1F *hgood=(TH1F*)gROOT->FindObject("hgood");
+ if (!hgood) hgood=new TH1F("hgood","Good Vertices",nchan,pmin,pmax);
+
+ TH1F *hfound=(TH1F*)gROOT->FindObject("hfound");
+ if (!hfound) hfound=new TH1F("hfound","Found Vertices",nchan,pmin,pmax);
+
+ TH1F *hfake=(TH1F*)gROOT->FindObject("hfake");
+ if (!hfake) hfake=new TH1F("hfake","Fake Vertices",nchan,pmin,pmax);
+
+ TH1F *hg=(TH1F*)gROOT->FindObject("hg");
+ if (!hg) hg=new TH1F("hg","Efficiency for Good Vertices",nchan,pmin,pmax);
hg->SetLineColor(4); hg->SetLineWidth(2);
- TH1F *hf=new TH1F("hf","Probability of Fake Vertices",nchan,pmin,pmax);
+
+ TH1F *hf=(TH1F*)gROOT->FindObject("hf");
+ if (!hf) hf=new TH1F("hf","Probability of Fake Vertices",nchan,pmin,pmax);
hf->SetFillColor(1); hf->SetFillStyle(3013); hf->SetLineWidth(2);
+
Double_t mmin=V0mass-V0window, mmax=V0mass+V0window;
- TH1F *v0s =new TH1F("v0s","V0s Effective Mass",40, mmin, mmax);
- v0s->SetXTitle("(GeV)"); v0s->SetFillColor(6);
+ TH1F *v0s=(TH1F*)gROOT->FindObject("v0s");
+ if (!v0s) v0s=new TH1F("v0s","V0s Effective Mass",40, mmin, mmax);
+ v0s->SetXTitle("(GeV)"); v0s->SetLineColor(4); v0s->SetLineWidth(4);
+
+ TH1F *v0sf=(TH1F*)gROOT->FindObject("v0sf");
+ if (!v0sf) v0sf=new TH1F("v0sf","Fake V0s Effective Mass",40, mmin, mmax);
+ v0sf->SetXTitle("(GeV)"); v0sf->SetFillColor(6);
- Double_t pxg=0.,pyg=0.,ptg=0.;
- Int_t nlab=-1, plab=-1;
- Int_t i;
- for (i=0; i<nentr; i++) {
- AliV0vertex *vertex=(AliV0vertex*)varray.UncheckedAt(i);
- nlab=TMath::Abs(vertex->GetNlabel());
- plab=TMath::Abs(vertex->GetPlabel());
+ Char_t fname[100];
+ sprintf(fname,"%s/GoodV0s.root",dir);
- vertex->ChangeMassHypothesis(code);
+ TFile *refFile=TFile::Open(fname,"old");
+ if (!refFile || !refFile->IsOpen()) {
+ ::Info("AliV0Comparison.C","Marking good V0s (will take a while)...");
+ if (GoodV0s(dir)) {
+ ::Error("AliV0Comparison.C","Can't generate the reference file !");
+ return 1;
+ }
+ }
+ refFile=TFile::Open(fname,"old");
+ if (!refFile || !refFile->IsOpen()) {
+ ::Error("AliV0Comparison.C","Can't open the reference file !");
+ return 1;
+ }
+
+ TTree *v0Tree=(TTree*)refFile->Get("v0Tree");
+ if (!v0Tree) {
+ ::Error("AliV0Comparison.C","Can't get the reference tree !");
+ return 2;
+ }
+ TBranch *pbranch=v0Tree->GetBranch("positive");
+ if (!pbranch) {
+ ::Error("AliV0Comparison.C","Can't get the positive daughter branch !");
+ return 3;
+ }
+ TClonesArray dummy("AliTrackReference",1000), *prefs=&dummy;
+ pbranch->SetAddress(&prefs);
- Double_t mass=vertex->GetEffMass();
- v0s->Fill(mass);
+ TBranch *nbranch=v0Tree->GetBranch("negative");
+ if (!nbranch) {
+ ::Error("AliV0Comparison.C","Can't get the negative daughter branch !");
+ return 4;
+ }
+ TClonesArray dumm("AliTrackReference",1000), *nrefs=&dumm;
+ nbranch->SetAddress(&nrefs);
+
+
+ sprintf(fname,"%s/AliESDs.root",dir);
+ TFile *ef=TFile::Open(fname);
+ if ((!ef)||(!ef->IsOpen())) {
+ sprintf(fname,"%s/AliESDv0.root",dir);
+ ef=TFile::Open(fname);
+ if ((!ef)||(!ef->IsOpen())) {
+ ::Error("AliV0Comparison.C","Can't open AliESDv0.root !");
+ return 5;
+ }
+ }
+ TKey *key=0;
+ TIter next(ef->GetListOfKeys());
- Int_t j;
- for (j=0; j<ngood; j++) {
- if (gv[j].code != vertex->GetPdgCode()) continue;
- if (gv[j].nlab == nlab)
- if (gv[j].plab == plab) break;
- }
- if (TMath::Abs(mass-V0mass)>V0width) continue;
+ //******* Loop over events *********
+ Int_t e=0;
+ while ((key=(TKey*)next())!=0) {
+ cout<<endl<<endl<<"********* Processing event number: "<<e<<"*******\n";
+
+ AliESD *event=(AliESD*)key->ReadObj();
- Double_t px,py,pz; vertex->GetPxPyPz(px,py,pz);
- Double_t pt=TMath::Sqrt(px*px+py*py);
+ Int_t nentr=event->GetNumberOfV0s();
+ allfound+=nentr;
- if (j==ngood) {
- hfake->Fill(pt);
- cerr<<"Fake vertex: ("<<nlab<<","<<plab<<")\n";
- continue;
- }
+ if (v0Tree->GetEvent(e++)==0) {
+ cerr<<"No reconstructable V0s !\n";
+ continue;
+ }
- pxg=gv[j].px; pyg=gv[j].py; ptg=TMath::Sqrt(pxg*pxg+pyg*pyg);
- Double_t phig=TMath::ATan2(pyg,pxg), phi=TMath::ATan2(py,px);
- Double_t lamg=TMath::ATan2(gv[j].pz,ptg), lam=TMath::ATan2(pz,pt);
- hp->Fill((phi - phig)*1000.);
- hl->Fill((lam - lamg)*1000.);
- hpt->Fill((1/pt - 1/ptg)/(1/ptg)*100.);
+ Int_t ngood=prefs->GetEntriesFast(),ng=0;
- Double_t x,y,z; vertex->GetXYZ(x,y,z);
- hx->Fill((x-gv[j].x)*10);
- hy->Fill((y-gv[j].y)*10);
- hz->Fill((z-gv[j].z)*10);
+ Double_t pxg=0.,pyg=0.,pzg=0.,ptg=0.;
+ Int_t nlab=-1, plab=-1;
+ Int_t i;
+ for (i=0; i<nentr; i++) {
+ AliESDv0 *vertex=event->GetV0(i);
+
+ Int_t nidx=TMath::Abs(vertex->GetNindex());
+ Int_t pidx=TMath::Abs(vertex->GetPindex());
+
+ AliESDtrack *ntrack=event->GetTrack(nidx);
+ AliESDtrack *ptrack=event->GetTrack(pidx);
+
+ nlab=TMath::Abs(ntrack->GetLabel());
+ plab=TMath::Abs(ptrack->GetLabel());
+
+ /** Kinematical cuts **/
+ Double_t pxn,pyn,pzn; vertex->GetNPxPyPz(pxn,pyn,pzn);
+ Double_t ptn=TMath::Sqrt(pxn*pxn + pyn*pyn);
+ if (ptn < ptncut) continue;
+ Double_t pxp,pyp,pzp; vertex->GetPPxPyPz(pxp,pyp,pzp);
+ Double_t ptp=TMath::Sqrt(pxp*pxp + pyp*pyp);
+ if (ptp < ptpcut) continue;
+ Double_t kine=vertex->ChangeMassHypothesis(code);
+ //if (TMath::Abs(kine)>kinecut) continue;
+
+ Double_t mass=vertex->GetEffMass();
+ v0s->Fill(mass);
+ v0sf->Fill(mass);
+
+ AliTrackReference *nref=0, *pref=0;
+ Int_t j;
+ for (j=0; j<ngood; j++) {
+ nref=(AliTrackReference*)nrefs->UncheckedAt(j);
+ pref=(AliTrackReference*)prefs->UncheckedAt(j);
+ if (nref->Label() == nlab)
+ if (pref->Label() == plab) break;
+ }
+
+ if (TMath::Abs(mass-V0mass)>V0width) continue;
+
+ Double_t px,py,pz; vertex->GetPxPyPz(px,py,pz);
+ Double_t pt=TMath::Sqrt(px*px+py*py);
+
+ if (j==ngood) {
+ hfake->Fill(pt);
+ cout<<"Fake vertex: ("<<nlab<<","<<plab<<")\n";
+ continue;
+ }
+ v0sf->Fill(mass,-1);
+
+ pxg=nref->Px()+pref->Px(); pyg=nref->Py()+pref->Py();
+ pzg=nref->Pz()+pref->Pz();
+ ptg=TMath::Sqrt(pxg*pxg+pyg*pyg);
+ Double_t phig=TMath::ATan2(pyg,pxg), phi=TMath::ATan2(py,px);
+ Double_t lamg=TMath::ATan2(pzg,ptg), lam=TMath::ATan2(pz,pt);
+ hp->Fill((phi - phig)*1000.);
+ hl->Fill((lam - lamg)*1000.);
+ hpt->Fill((1/pt - 1/ptg)/(1/ptg)*100.);
+
+ Double_t x,y,z; vertex->GetXYZ(x,y,z);
+ hx->Fill((x - nref->X())*10);
+ hy->Fill((y - nref->Y())*10);
+ hz->Fill((z - nref->Z())*10);
+
+ hfound->Fill(ptg);
+ nref->SetLabel(-1);
- hfound->Fill(ptg);
- gv[j].nlab=-1;
+ }
+ for (i=0; i<ngood; i++) {
+ AliTrackReference *nref=(AliTrackReference*)nrefs->UncheckedAt(i);
+ AliTrackReference *pref=(AliTrackReference*)prefs->UncheckedAt(i);
+ Int_t pdg=(Int_t)nref->GetLength();//this is the mother's PDG !
+ if (code!=pdg) continue;
+ ng++;
+ pxg=nref->Px()+pref->Px(); pyg=nref->Py()+pref->Py();
+ ptg=TMath::Sqrt(pxg*pxg+pyg*pyg);
+ hgood->Fill(ptg);
+ nlab=nref->Label(); plab=pref->Label();
+ if (nlab < 0) continue;
+ cout<<"Vertex ("<<nlab<<','<<plab<<") has not been found !\n";
+ }
+ allgood+=ng;
- }
- for (i=0; i<ngood; i++) {
- if (gv[i].code != code) continue;
- pxg=gv[i].px; pyg=gv[i].py; ptg=TMath::Sqrt(pxg*pxg+pyg*pyg);
- hgood->Fill(ptg);
- nlab=gv[i].nlab; plab=gv[i].plab;
- if (nlab < 0) continue;
- cerr<<"Vertex ("<<nlab<<','<<plab<<") has not been found !\n";
- }
+ cout<<"Number of found V0s : "<<nentr<<endl;
+ cout<<"Number of \"good\" V0s : "<<ng<<endl;
- varray.Delete();
+ prefs->Clear();
+ nrefs->Clear();
+ delete event;
- Stat_t ng=hgood->GetEntries();
- Stat_t nf=hfound->GetEntries();
+ } //**** End of the loop over events
- cerr<<"Number of found vertices: "<<nentr<<" ("<<nf<<" in the peak)\n";
- cerr<<"Number of good vertices: "<<ng<<endl;
+ ef->Close();
+
+ delete v0Tree;
+ refFile->Close();
- if (ng!=0)
- cerr<<"Integral efficiency is about "<<nf/ng*100.<<" %\n";
+ Stat_t ng=hgood->GetEntries(), nf=hfound->GetEntries();
+ if (ng!=0) cout<<"Integral efficiency is about "<<nf/ng*100.<<" %\n";
+ cout<<"Total number of found V0s: "<<allfound<<" ("<<nf<<" in the peak)\n";
+ cout<<"Total number of \"good\" V0s: "<<allgood<<endl;
gStyle->SetOptStat(111110);
gStyle->SetOptFit(1);
- TCanvas *c1=new TCanvas("c1","",0,0,580,610);
- c1->Divide(2,2);
+ TCanvas *c1=(TCanvas*)gROOT->FindObject("c1");
+ if (!c1) {
+ c1=new TCanvas("c1","",0,0,580,610);
+ c1->Divide(2,2);
+ }
+
+ Int_t minc=33;
c1->cd(1);
gPad->SetFillColor(42); gPad->SetFrameFillColor(10);
- //hp->Fit("gaus");
- hp->Draw();
+ if (hp->GetEntries()<minc) hp->Draw(); else hp->Fit("gaus");
hl->Draw("same"); c1->cd();
c1->cd(2);
gPad->SetFillColor(42); gPad->SetFrameFillColor(10);
- //hpt->Fit("gaus"); c1->cd();
- hpt->Draw(); c1->cd();
+ if (hpt->GetEntries()<minc) hpt->Draw(); else hpt->Fit("gaus");
+ c1->cd();
c1->cd(3);
gPad->SetFillColor(42); gPad->SetFrameFillColor(10);
- //hx->Fit("gaus");
- hx->Draw();
+ if (hx->GetEntries()<minc) hx->Draw(); else hx->Fit("gaus");
hy->Draw("same"); c1->cd();
c1->cd(4);
gPad->SetFillColor(42); gPad->SetFrameFillColor(10);
- //hz->Fit("gaus");
- hz->Draw();
+ if (hz->GetEntries()<minc) hz->Draw(); else hz->Fit("gaus");
+ c1->Update();
- TCanvas *c2=new TCanvas("c2","",600,0,580,610);
- c2->Divide(1,2);
+ TCanvas *c2=(TCanvas*)gROOT->FindObject("c2");
+ if (!c2) {
+ c2=new TCanvas("c2","",600,0,580,610);
+ c2->Divide(1,2);
+ }
c2->cd(1);
gPad->SetFillColor(42); gPad->SetFrameFillColor(10);
c2->cd(2);
gPad->SetFillColor(42); gPad->SetFrameFillColor(10);
- v0s->SetXTitle("(GeV/c)");
- v0s->Fit("gaus","","",V0mass-V0width,V0mass+V0width);
+ if (v0s->GetEntries()<minc) v0s->Draw();
+ else v0s->Fit("gaus","","",V0mass-V0width,V0mass+V0width);
+ v0sf->Draw("same");
Double_t max=v0s->GetMaximum();
TLine *line3 = new TLine(V0mass-V0width,0.,V0mass-V0width,max);
line3->Draw("same");
TLine *line4 = new TLine(V0mass+V0width,0.,V0mass+V0width,max);
line4->Draw("same");
- timer.Stop(); timer.Print();
+ c2->Update();
+
+ TFile fc("AliV0Comparison.root","RECREATE");
+ c1->Write();
+ c2->Write();
+ fc.Close();
+
+ gBenchmark->Stop("AliV0Comparison");
+ gBenchmark->Show("AliV0Comparison");
return 0;
}
-Int_t good_vertices(GoodVertex *gv, Int_t max) {
- Int_t nv=0;
- /*** Get information about the cuts ***/
- Double_t r2min=0.9*0.9;
- Double_t r2max=2.9*2.9;
- /*** Get labels of the "good" tracks ***/
- Double_t dd; Int_t id, label[15000], ngt=0;
- ifstream in("good_tracks_its");
- if (!in) {
- cerr<<"Can't open the file good_tracks_its \n";
- return nv;
+Int_t GoodV0s(const Char_t *dir) {
+ if (gAlice) {
+ delete gAlice->GetRunLoader();
+ delete gAlice;//if everything was OK here it is already NULL
+ gAlice = 0x0;
}
- while (in>>label[ngt]>>id>>dd>>dd>>dd>>dd>>dd>>dd) {
- ngt++;
- if (ngt>=15000) {
- cerr<<"Too many good ITS tracks !\n";
- return nv;
- }
- }
- if (!in.eof()) {
- cerr<<"Read error (good_tracks_its) !\n";
- return nv;
+
+ Char_t fname[100];
+ sprintf(fname,"%s/galice.root",dir);
+
+ AliRunLoader *rl = AliRunLoader::Open(fname,"COMPARISON");
+ if (!rl) {
+ ::Error("GoodTracksITS","Can't start session !");
+ return 1;
}
- /*** Get an access to the kinematics ***/
- if (gAlice) {delete gAlice; gAlice=0;}
+ rl->LoadgAlice();
+ rl->LoadHeader();
+ rl->LoadKinematics();
+
+
+ Int_t nev=rl->GetNumberOfEvents();
+ ::Info("GoodV0s","Number of events : %d\n",nev);
- TFile *file=TFile::Open("galice.root");
- if (!file->IsOpen()) {cerr<<"Can't open galice.root !\n"; exit(4);}
- if (!(gAlice=(AliRun*)file->Get("gAlice"))) {
- cerr<<"gAlice has not been found on galice.root !\n";
- exit(5);
+ sprintf(fname,"%s/GoodTracksITS.root",dir);
+ TFile *itsFile=TFile::Open(fname);
+ if ((!itsFile)||(!itsFile->IsOpen())) {
+ ::Error("GoodV0s","Can't open the GoodTracksITS.root !");
+ delete rl;
+ return 5;
+ }
+ TClonesArray dum("AliTrackReference",1000), *itsRefs=&dum;
+ TTree *itsTree=(TTree*)itsFile->Get("itsTree");
+ if (!itsTree) {
+ ::Error("GoodV0s","Can't get the ITS reference tree !");
+ delete rl;
+ return 6;
+ }
+ TBranch *itsBranch=itsTree->GetBranch("ITS");
+ if (!itsBranch) {
+ ::Error("GoodV0s","Can't get the ITS reference branch !");
+ delete rl;
+ return 7;
}
+ itsBranch->SetAddress(&itsRefs);
- Int_t np=gAlice->GetEvent(0);
- while (np--) {
- cerr<<np<<'\r';
- TParticle *p0=gAlice->Particle(np);
-
- /*** only these V0s are "good" ***/
- Int_t code=p0->GetPdgCode();
- if (code!=kK0Short)
- if (code!=kLambda0)
- if (code!=kLambda0Bar) continue;
-
- /*** daughter tracks should be "good" ***/
- Int_t plab=p0->GetFirstDaughter(), nlab=p0->GetLastDaughter();
- if (nlab==plab) continue;
- if (nlab<0) continue;
- if (plab<0) continue;
- Int_t i;
- for (i=0; i<ngt; i++) if (label[i]==nlab) break;
- if (i==ngt) continue;
- for (i=0; i<ngt; i++) if (label[i]==plab) break;
- if (i==ngt) continue;
-
- /*** fiducial volume ***/
- TParticle *p=gAlice->Particle(nlab);
- Double_t x=p->Vx(), y=p->Vy(), z=p->Vz(), r2=x*x+y*y;
- if (r2<r2min) continue;
- if (r2>r2max) continue;
+
+ sprintf(fname,"%s/GoodV0s.root",dir);
+ TFile *v0File=TFile::Open(fname,"recreate");
+ TClonesArray dummy("AliTrackReference",1000), *nrefs=&dummy;
+ TClonesArray dumm("AliTrackReference",1000), *prefs=&dumm;
+ TTree v0Tree("v0Tree","Tree with info about the reconstructable V0s");
+ v0Tree.Branch("negative",&nrefs);
+ v0Tree.Branch("positive",&prefs);
+
+
+ /*** Some information about the cuts ***/
+ Double_t r2min=0.9*0.9;
+ Double_t r2max=2.9*2.9;
+
+
+
+ //******** Loop over generated events
+ for (Int_t e=0; e<nev; e++) {
+ rl->GetEvent(e); v0File->cd();
+
+ Int_t np = rl->GetHeader()->GetNtrack();
+ cout<<"Event "<<e<<" Number of particles: "<<np<<endl;
+
+ itsTree->GetEvent(e);
+ Int_t nk=itsRefs->GetEntriesFast();
+
+ AliStack *stack=rl->Stack();
+
+ AliTrackReference *nref=0, *pref=0;
+
+ Int_t nv=0;
+ while (np--) {
+ //cerr<<np<<'\r';
+ TParticle *p0=stack->Particle(np);
+
+ /*** only these V0s are "good" ***/
+ Int_t code=p0->GetPdgCode();
+ if (code!=kK0Short)
+ if (code!=kLambda0)
+ if (code!=kLambda0Bar) continue;
+
+ /*** daughter tracks should be "good" ***/
+ Int_t plab=p0->GetFirstDaughter(), nlab=p0->GetLastDaughter();
+ if (nlab==plab) continue;
+ if (nlab<0) continue;
+ if (plab<0) continue;
+ Int_t i;
+ if (stack->Particle(plab)->GetPDG()->Charge() < 0.) {
+ i=plab; plab=nlab; nlab=i;
+ }
+
+ for (i=0; i<nk; i++) {
+ nref=(AliTrackReference*)itsRefs->UncheckedAt(i);
+ if (nref->Label()==nlab) break;
+ }
+ if (i==nk) continue;
+ for (i=0; i<nk; i++) {
+ pref=(AliTrackReference*)itsRefs->UncheckedAt(i);
+ if (pref->Label()==plab) break;
+ }
+ if (i==nk) continue;
+
+ /*** fiducial volume ***/
+ TParticle *p=stack->Particle(nlab);
+ Double_t x=p->Vx(), y=p->Vy(), z=p->Vz(), r2=x*x+y*y;
+ if (r2<r2min) continue;
+ if (r2>r2max) continue;
- if (gAlice->Particle(plab)->GetPDG()->Charge() < 0.) {
- i=plab; plab=nlab; nlab=i;
+ Int_t pdg=p0->GetPdgCode();
+ nref->SetLength(pdg); //This will the V0's PDG !
+
+ new((*nrefs)[nv]) AliTrackReference(*nref);
+ new((*prefs)[nv]) AliTrackReference(*pref);
+
+ nv++;
}
-
- gv[nv].code=code;
- gv[nv].plab=plab; gv[nv].nlab=nlab;
- gv[nv].px=p0->Px(); gv[nv].py=p0->Py(); gv[nv].pz=p0->Pz();
- gv[nv].x=x; gv[nv].y=y; gv[nv].z=z;
- nv++;
- }
-
- delete gAlice; gAlice=0;
+ itsRefs->Clear();
- file->Close();
+ v0Tree.Fill();
+ nrefs->Clear(); prefs->Clear();
- return nv;
+ } //**** end of the loop over generated events
+
+ v0Tree.Write();
+ v0File->Close();
+
+ delete itsTree;
+ itsFile->Close();
+
+ delete rl;
+ return 0;
}