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