//-------------------------------------------------------------------------
// Implementation of the cascade vertexer class
-//
+// Reads V0s and tracks, writes out cascade vertices
+// Fills the ESD with the cascades
// Origin: Christian Kuhn, IReS, Strasbourg, christian.kuhn@ires.in2p3.fr
//-------------------------------------------------------------------------
-#include <TFile.h>
-#include <TTree.h>
#include <TObjArray.h>
-#include <Riostream.h>
+#include <TTree.h>
+#include "AliESD.h"
+#include "AliESDv0.h"
#include "AliCascadeVertex.h"
#include "AliCascadeVertexer.h"
-#include "AliV0vertex.h"
#include "AliITStrackV2.h"
+#include "AliV0vertex.h"
ClassImp(AliCascadeVertexer)
-Int_t
-AliCascadeVertexer::V0sTracks2CascadeVertices(const TFile *inp, TFile *out) {
-
+Int_t AliCascadeVertexer::V0sTracks2CascadeVertices(AliESD *event) {
//--------------------------------------------------------------------
- //This function reconstructs cascade vertices
+ // This function reconstructs cascade vertices
+ // Adapted to the ESD by I.Belikov (Jouri.Belikov@cern.ch)
//--------------------------------------------------------------------
- TFile *in=(TFile*)inp;
- TDirectory *savedir=gDirectory;
- // Tree for vertices(V0's)
+ Int_t nV0=(Int_t)event->GetNumberOfV0s();
+ TObjArray vtcs(nV0);
+ Int_t i;
+ for (i=0; i<nV0; i++) {
+ const AliESDv0 *esdV0=event->GetV0(i);
+ vtcs.AddLast(new AliV0vertex(*esdV0));
+ }
+
+
+ Int_t ntr=(Int_t)event->GetNumberOfTracks();
+ TObjArray trks(ntr);
+ for (i=0; i<ntr; i++) {
+ AliESDtrack *esdtr=event->GetTrack(i);
+ UInt_t status=esdtr->GetStatus();
+ UInt_t flags=AliESDtrack::kITSin|AliESDtrack::kTPCin;
+
+ if ((status&AliESDtrack::kITSrefit)==0)
+ if ((status&flags)!=status) continue;
+
+ AliITStrackV2 *iotrack=new AliITStrackV2(*esdtr);
+ iotrack->SetLabel(i); // now it is the index in array of ESD tracks
+ if ((status&AliESDtrack::kITSrefit)==0) //correction for the beam pipe
+ if (!iotrack->PropagateTo(3.,0.0023,65.19)) continue;
+ if (!iotrack->PropagateTo(2.5,0.,0.)) continue;
+ trks.AddLast(iotrack);
+ }
+ ntr=trks.GetEntriesFast();
+
+ Double_t massLambda=1.11568;
+ Int_t ncasc=0;
+
+ // Looking for the cascades...
+ for (i=0; i<nV0; i++) {
+ AliV0vertex *v=(AliV0vertex*)vtcs.UncheckedAt(i);
+ v->ChangeMassHypothesis(kLambda0); // the v0 must be Lambda
+ if (TMath::Abs(v->GetEffMass()-massLambda)>fMassWin) continue;
+ if (v->GetD(0,0,0)<fDV0min) continue;
+ for (Int_t j=0; j<ntr; j++) {
+ AliITStrackV2 *b=(AliITStrackV2*)trks.UncheckedAt(j);
+
+ if (TMath::Abs(b->GetD())<fDBachMin) continue;
+ if (b->Get1Pt()<0.) continue; // bachelor's charge
+
+ AliV0vertex v0(*v), *pv0=&v0;
+ AliITStrackV2 bt(*b), *pbt=&bt;
+
+ Double_t dca=PropagateToDCA(pv0,pbt);
+ if (dca > fDCAmax) continue;
+
+ AliCascadeVertex cascade(*pv0,*pbt);
+ if (cascade.GetChi2() > fChi2max) continue;
+
+ Double_t x,y,z; cascade.GetXYZ(x,y,z);
+ Double_t r2=x*x + y*y;
+ if (r2 > fRmax*fRmax) continue; // condition on fiducial zone
+ if (r2 < fRmin*fRmin) continue;
+
+ {
+ Double_t x1,y1,z1; pv0->GetXYZ(x1,y1,z1);
+ if (r2 > (x1*x1+y1*y1)) continue;
+ if (z*z > z1*z1) continue;
+ }
+
+ Double_t px,py,pz; cascade.GetPxPyPz(px,py,pz);
+ Double_t p2=px*px+py*py+pz*pz;
+ Double_t cost=(x*px+y*py+z*pz)/TMath::Sqrt(p2*(r2+z*z));
+
+ if (cost<fCPAmax) continue; //condition on the cascade pointing angle
+ //cascade.ChangeMassHypothesis(); //default is Xi
+
+ event->AddCascade(&cascade);
+
+ ncasc++;
- TTree *vtxTree=(TTree*)gDirectory->Get("TreeV0");
- TBranch *branch=vtxTree->GetBranch("vertices");
- Int_t nentrV0=(Int_t)vtxTree->GetEntries();
+ }
+ }
+
+ // Looking for the anti-cascades...
+ for (i=0; i<nV0; i++) {
+ AliV0vertex *v=(AliV0vertex*)vtcs.UncheckedAt(i);
+ v->ChangeMassHypothesis(kLambda0Bar); //the v0 must be anti-Lambda
+ if (TMath::Abs(v->GetEffMass()-massLambda)>fMassWin) continue;
+ if (v->GetD(0,0,0)<fDV0min) continue;
+ for (Int_t j=0; j<ntr; j++) {
+ AliITStrackV2 *b=(AliITStrackV2*)trks.UncheckedAt(j);
+
+ if (TMath::Abs(b->GetD())<fDBachMin) continue;
+ if (b->Get1Pt()>0.) continue; // bachelor's charge
+
+ AliV0vertex v0(*v), *pv0=&v0;
+ AliITStrackV2 bt(*b), *pbt=&bt;
+
+ Double_t dca=PropagateToDCA(pv0,pbt);
+ if (dca > fDCAmax) continue;
+
+ AliCascadeVertex cascade(*pv0,*pbt);
+ if (cascade.GetChi2() > fChi2max) continue;
+
+ Double_t x,y,z; cascade.GetXYZ(x,y,z);
+ Double_t r2=x*x + y*y;
+ if (r2 > fRmax*fRmax) continue; // condition on fiducial zone
+ if (r2 < fRmin*fRmin) continue;
+
+ {
+ Double_t x1,y1,z1; pv0->GetXYZ(x1,y1,z1);
+ if (r2 > (x1*x1+y1*y1)) continue;
+ if (z*z > z1*z1) continue;
+ }
+
+ Double_t px,py,pz; cascade.GetPxPyPz(px,py,pz);
+ Double_t p2=px*px+py*py+pz*pz;
+ Double_t cost=(x*px+y*py+z*pz)/TMath::Sqrt(p2*(r2+z*z));
+
+ if (cost<fCPAmax) continue; //condition on the cascade pointing angle
+ //cascade.ChangeMassHypothesis(); //default is Xi
+
+ event->AddCascade(&cascade);
+
+ ncasc++;
+
+ }
+ }
+
+Info("V0sTracks2CascadeVertices","Number of reconstructed cascades: %d",ncasc);
+
+ trks.Delete();
+ vtcs.Delete();
+
+ return 0;
+}
+
+Int_t AliCascadeVertexer::
+V0sTracks2CascadeVertices(TTree *vTree,TTree *tTree, TTree *xTree) {
+ //--------------------------------------------------------------------
+ // This function reconstructs cascade vertices
+ //--------------------------------------------------------------------
+ Warning("V0sTracks2CascadeVertices(TTree*,TTree*,TTree*)",
+ "Will be removed soon ! Use V0sTracks2CascadeVertices(AliESD*) instead");
+
+ TBranch *branch=vTree->GetBranch("vertices");
+ if (!branch) {
+ Error("V0sTracks2CascadeVertices","Can't get the V0 branch !");
+ return 1;
+ }
+ Int_t nentrV0=(Int_t)vTree->GetEntries();
TObjArray vtxV0(nentrV0);
AliV0vertex *ioVertex=new AliV0vertex;
branch->SetAddress(&ioVertex);
- vtxTree->GetEvent(i);
+ vTree->GetEvent(i);
nV0++;
vtxV0.AddLast(ioVertex);
}
-
- in->cd();
-
- // Tree for tracks
-
- TTree *trkTree=(TTree*)in->Get("TreeT_ITS_0");
- branch=trkTree->GetBranch("tracks");
- Int_t nentr=(Int_t)trkTree->GetEntries();
+ branch=tTree->GetBranch("tracks");
+ if (!branch) {
+ Error("V0sTracks2CascadeVertices","Can't get the track branch !");
+ return 2;
+ }
+ Int_t nentr=(Int_t)tTree->GetEntries();
TObjArray trks(nentr);
AliITStrackV2 *iotrack=new AliITStrackV2;
branch->SetAddress(&iotrack);
- trkTree->GetEvent(i);
+ tTree->GetEvent(i);
- iotrack->PropagateTo(3.,0.0023,65.19); iotrack->PropagateTo(2.5,0.,0.);
+ if (!iotrack->PropagateTo(3.,0.0023,65.19)) continue;
+ if (!iotrack->PropagateTo(2.5,0.,0.)) continue;
ntrack++; trks.AddLast(iotrack);
}
- // create Tree for cascades
-
- out->cd();
-
- TTree cascTree("TreeCasc","Tree with cascades");
- AliCascadeVertex *ioCascade=0;
- cascTree.Branch("cascades","AliCascadeVertex",&ioCascade,32000,0);
+ AliCascadeVertex *ioCascade=0;
+ branch=xTree->GetBranch("cascades");
+ if (!branch) xTree->Branch("cascades","AliCascadeVertex",&ioCascade,32000,3);
+ else branch->SetAddress(&ioCascade);
// loop on all vertices
for (i=0; i<nV0; i++) {
- AliV0vertex *V0ver=(AliV0vertex *)vtxV0.UncheckedAt(i);
+ AliV0vertex *lV0ver=(AliV0vertex *)vtxV0.UncheckedAt(i);
- V0ver->ChangeMassHypothesis(kLambda0); //I.B.
+ lV0ver->ChangeMassHypothesis(kLambda0); //I.B.
- if (V0ver->GetEffMass()<massLambda-fMassWin || // condition of the V0 mass window (cut fMassWin)
- V0ver->GetEffMass()>massLambda+fMassWin) continue;
+ if (lV0ver->GetEffMass()<massLambda-fMassWin || // condition of the V0 mass window (cut fMassWin)
+ lV0ver->GetEffMass()>massLambda+fMassWin) continue;
- if (V0ver->GetD(0,0,0)<fDV0min) continue; // condition of minimum impact parameter of the V0 (cut fDV0min)
+ if (lV0ver->GetD(0,0,0)<fDV0min) continue; // condition of minimum impact parameter of the V0 (cut fDV0min)
// here why not cuting on pointing angle ???
// for each vertex in the good mass range, loop on all tracks (= bachelor candidates)
if (TMath::Abs(bachtrk->GetD())<fDBachMin) continue; // eliminate to small impact parameters
- if (V0ver->GetPdgCode()==kLambda0 && bachtrk->Get1Pt()<0.) continue; // condition on V0 label
- if (V0ver->GetPdgCode()==kLambda0Bar && bachtrk->Get1Pt()>0.) continue; // + good sign for bachelor
+ if (lV0ver->GetPdgCode()==kLambda0 && bachtrk->Get1Pt()<0.) continue; // condition on V0 label
+ if (lV0ver->GetPdgCode()==kLambda0Bar && bachtrk->Get1Pt()>0.) continue; // + good sign for bachelor
- AliV0vertex V0(*V0ver), *pV0=&V0;
+ AliV0vertex lV0(*lV0ver), *pV0=&lV0;
AliITStrackV2 bt(*bachtrk), *pbt=&bt;
// calculation of the distance of closest approach between the V0 and the bachelor
{
//I.B.
- Double_t x1,y1,z1; V0ver->GetXYZ(x1,y1,z1);
+ Double_t x1,y1,z1; lV0ver->GetXYZ(x1,y1,z1);
if (r2 > (x1*x1+y1*y1)) continue;
if (z*z > z1*z1) continue;
}
//cascade.ChangeMassHypothesis(); //default is Xi
- ioCascade=&cascade; cascTree.Fill();
+ ioCascade=&cascade; xTree->Fill();
ncasc++;
}
}
- cerr<<"Number of reconstructed cascades: "<<ncasc<<endl;
-
- cascTree.Write();
+Info("V0sTracks2CascadeVertices","Number of reconstructed cascades: %d",ncasc);
trks.Delete();
vtxV0.Delete();
- savedir->cd();
-
return 0;
}
x1=x1*cs1 + y1*sn1;
if (!t->PropagateTo(x1,0.,0.)) {
- cerr<<"AliV0vertexer::PropagateToDCA: propagation failed !\n";
+ Error("PropagateToDCA","Propagation failed !");
return 1.e+33;
}