Tests and example macros working with ESD (Yu.Belikov)
[u/mrichter/AliRoot.git] / ITS / AliCascadeFindVertices.C
CommitLineData
566abf75 1#if !defined(__CINT__) || defined(__MAKECINT__)
ddae8318 2 #include <Riostream.h>
ca28c5f5 3 #include "AliCascadeVertexer.h"
4 #include "TFile.h"
a62f4fcc 5 #include "TKey.h"
ca28c5f5 6 #include "TStopwatch.h"
566abf75 7
8 #include "AliRun.h"
a62f4fcc 9 #include "AliMagF.h"
10 #include "AliESD.h"
11 #include "AliKalmanTrack.h"
566abf75 12 #include "AliRunLoader.h"
ca28c5f5 13#endif
14
566abf75 15Int_t AliCascadeFindVertices(Int_t nev=5) {
ca28c5f5 16 cerr<<"Looking for cascade vertices...\n";
17
566abf75 18 if (gAlice) {
19 delete gAlice->GetRunLoader();
20 delete gAlice;
21 gAlice=0;
ca28c5f5 22 }
566abf75 23 AliRunLoader* rl = AliRunLoader::Open("galice.root");
24 if (rl == 0x0) {
25 cerr<<"AliCascadeFindVertices.C : Can not open session RL=NULL"<< endl;
26 return 1;
ca28c5f5 27 }
a62f4fcc 28
29 if (rl->LoadgAlice()) {
30 cerr<<"AliV0FindVertices.C : LoadgAlice returned error"<<endl;
31 delete rl;
32 return 3;
566abf75 33 }
566abf75 34
a62f4fcc 35 AliKalmanTrack::SetConvConst(
36 1000/0.299792458/rl->GetAliRun()->Field()->SolenoidField()
37 );
38
04b2a5f1 39 Double_t cuts[]={33., // max. allowed chi2
40 0.05, // min. allowed V0 impact parameter
41 0.008, // window around the Lambda mass
42 0.035, // min. allowed bachelor's impact parameter
43 0.10, // max. allowed DCA between a V0 and a track
a62f4fcc 44 0.9985,// max. allowed cosine of the cascade pointing angle
04b2a5f1 45 0.9, // min. radius of the fiducial volume
46 2.9 // max. radius of the fiducial volume
ca28c5f5 47 };
48 TStopwatch timer;
49 AliCascadeVertexer *vertexer=new AliCascadeVertexer(cuts);
a62f4fcc 50
566abf75 51 Int_t rc=0;
52 if (nev>rl->GetNumberOfEvents()) nev=rl->GetNumberOfEvents();
566abf75 53
a62f4fcc 54 TFile *casf=TFile::Open("AliESDcas.root","RECREATE");
55 if ((!casf)||(!casf->IsOpen())) {
56 cerr<<"Can't AliESDcas.root !\n"; return 1;
57 }
58 TFile *v0f=TFile::Open("AliESDv0.root");
59 if ((!v0f)||(!v0f->IsOpen())) {
60 cerr<<"Can't AliESDv0.root !\n"; return 1;
61 }
62
63 TKey *key=0;
64 TIter next(v0f->GetListOfKeys());
65 for (Int_t i=0; i<nev; i++) {
66 v0f->cd();
67 if ((key=(TKey*)next())==0) break;
68 cerr<<"Processing event number: "<<i<<endl;
69 AliESD *event=(AliESD*)key->ReadObj();
566abf75 70
a62f4fcc 71 rc=vertexer->V0sTracks2CascadeVertices(event);
566abf75 72
a62f4fcc 73 if (rc==0) {
74 Char_t ename[100];
75 sprintf(ename,"%d",i);
76 casf->cd();
77 if (!event->Write(ename)) rc++;
78 }
79 if (rc) {
80 cerr<<"Something bad happened...\n";
81 }
82 delete event;
566abf75 83 }
ca28c5f5 84 delete vertexer;
85 timer.Stop(); timer.Print();
86
a62f4fcc 87 v0f->Close();
88 casf->Close();
89
566abf75 90 delete rl;
ca28c5f5 91
92 return rc;
93}