X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=ITS%2FAliV0Comparison.C;h=392463bcf2f5714d1e8ff78f94e52eb4af788934;hb=7b54ea5c7f4a049ae41d5026aba55d64b07bf6cf;hp=da772af851ab091ad3fa9d1d8bc898014ad78912;hpb=548b1270145e59901dd49b6ab6e195b2fcee0949;p=u%2Fmrichter%2FAliRoot.git diff --git a/ITS/AliV0Comparison.C b/ITS/AliV0Comparison.C index da772af851a..392463bcf2f 100644 --- a/ITS/AliV0Comparison.C +++ b/ITS/AliV0Comparison.C @@ -7,36 +7,44 @@ * Origin: I.Belikov, IReS, Strasbourg, Jouri.Belikov@cern.ch * ****************************************************************************/ -#ifndef __CINT__ - #include "Riostream.h" - #include - - #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 + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + + #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="."); + +extern AliRun *gAlice; +extern TBenchmark *gBenchmark; +extern TROOT *gROOT; + +static Int_t allgood=0; +static Int_t allfound=0; + +Int_t AliV0Comparison(Int_t code=310, const Char_t *dir=".") { + //Lambda=3122, LambdaBar=-3122 + gBenchmark->Start("AliV0Comparison"); + + ::Info("AliV0Comparison.C","Doing comparison..."); -Int_t AliV0Comparison(Int_t code=310) { //Lambda=3122, LambdaBar=-3122 - cerr<<"Doing comparison...\n"; const Double_t V0window=0.05; Double_t ptncut=0.13, ptpcut=0.13, kinecut=0.03; @@ -53,195 +61,272 @@ Int_t AliV0Comparison(Int_t code=310) { //Lambda=3122, LambdaBar=-3122 default: cerr<<"Invalid PDG code !\n"; return 1; } - 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("TreeV0"); - TBranch *branch=vTree->GetBranch("vertices"); - Int_t nentr=(Int_t)vTree->GetEntries(); - for (Int_t i=0; iSetAddress(&iovertex); - vTree->GetEvent(i); - varray.AddLast(iovertex); - } - - /*** 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<Close(); - - - 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->SetLineColor(4); v0s->SetLineWidth(4); - TH1F *v0sf =new TH1F("v0sf","Fake V0s Effective Mass",40, mmin, mmax); + 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; iGetNlabel()); - plab=TMath::Abs(vertex->GetPlabel()); - - /** 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); - - Int_t j; - for (j=0; jGetPdgCode()) continue; - if (gv[j].nlab == nlab) - if (gv[j].plab == 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); - cerr<<"Fake vertex: ("<Fill(mass,-1); - - 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.); - - 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); - - hfound->Fill(ptg); - gv[j].nlab=-1; + Char_t fname[100]; + sprintf(fname,"%s/GoodV0s.root",dir); + 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; } - for (i=0; iFill(ptg); - nlab=gv[i].nlab; plab=gv[i].plab; - if (nlab < 0) continue; - cerr<<"Vertex ("<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); - varray.Delete(); + 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; + } + } + AliESD* event = new AliESD; + TTree* esdTree = (TTree*) ef->Get("esdTree"); + if (!esdTree) { + ::Error("AliV0Comparison.C", "no ESD tree found"); + return 6; + } + esdTree->SetBranchAddress("ESD", &event); - Stat_t ng=hgood->GetEntries(); - Stat_t nf=hfound->GetEntries(); - cerr<<"Number of found vertices: "<GetEvent(e)) { + cout<GetNumberOfV0s(); + allfound+=nentr; - if (ng!=0) - cerr<<"Integral efficiency is about "<GetEvent(e++)==0) { + cerr<<"No reconstructable V0s !\n"; + continue; + } + + Int_t ngood=prefs->GetEntriesFast(),ng=0; + + Double_t pxg=0.,pyg=0.,pzg=0.,ptg=0.; + Int_t nlab=-1, plab=-1; + Int_t i; + for (i=0; iGetV0(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; jUncheckedAt(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: ("<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); + + } + for (i=0; iUncheckedAt(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 ("<Clear(); + nrefs->Clear(); + + } //**** End of the loop over events + + delete event; + ef->Close(); + + delete v0Tree; + refFile->Close(); + + Stat_t ng=hgood->GetEntries(), nf=hfound->GetEntries(); + if (ng!=0) cout<<"Integral efficiency is about "<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()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()Draw(); else hpt->Fit("gaus"); + c1->cd(); c1->cd(3); gPad->SetFillColor(42); gPad->SetFrameFillColor(10); - //hx->Fit("gaus"); - hx->Draw(); + if (hx->GetEntries()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()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); @@ -273,8 +358,8 @@ Int_t AliV0Comparison(Int_t code=310) { //Lambda=3122, LambdaBar=-3122 c2->cd(2); gPad->SetFillColor(42); gPad->SetFrameFillColor(10); - //v0s->Fit("gaus","","",V0mass-V0width,V0mass+V0width); - v0s->Draw(); + if (v0s->GetEntries()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); @@ -282,88 +367,155 @@ Int_t AliV0Comparison(Int_t code=310) { //Lambda=3122, LambdaBar=-3122 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(); + - 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); + Int_t nev=rl->GetNumberOfEvents(); + ::Info("GoodV0s","Number of events : %d\n",nev); + + 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<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; iParticle(nlab); - Double_t x=p->Vx(), y=p->Vy(), z=p->Vz(), r2=x*x+y*y; - if (r2r2max) 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; eGetEvent(e); v0File->cd(); + + Int_t np = rl->GetHeader()->GetNtrack(); + cout<<"Event "<GetEvent(e); + Int_t nk=itsRefs->GetEntriesFast(); + + AliStack *stack=rl->Stack(); + + AliTrackReference *nref=0, *pref=0; + + Int_t nv=0; + while (np--) { + //cerr<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; iUncheckedAt(i); + if (nref->Label()==nlab) break; + } + if (i==nk) continue; + for (i=0; iUncheckedAt(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 (r2r2max) 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(); + + v0Tree.Fill(); + nrefs->Clear(); prefs->Clear(); + + } //**** end of the loop over generated events - file->Close(); + v0Tree.Write(); + v0File->Close(); - return nv; + delete itsTree; + itsFile->Close(); + + delete rl; + return 0; }