]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliCascadeFindVertices.C
Defining properly momentum components in AliMUONHit constructors (thanks Artur)
[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 "AliKalmanTrack.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    AliKalmanTrack::SetConvConst(
36       1000/0.299792458/rl->GetAliRun()->Field()->SolenoidField()
37    );
38        
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
44                     0.9985,// max. allowed cosine of the cascade pointing angle
45                     0.9,    // min. radius of the fiducial volume
46                     2.9     // max. radius of the fiducial volume
47                    };
48    TStopwatch timer;
49    AliCascadeVertexer *vertexer=new AliCascadeVertexer(cuts);
50
51    Int_t rc=0;
52    if (nev>rl->GetNumberOfEvents()) nev=rl->GetNumberOfEvents();
53
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();
70
71      rc=vertexer->V0sTracks2CascadeVertices(event);
72
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;
83    }
84    delete vertexer;
85    timer.Stop(); timer.Print();
86     
87    v0f->Close();
88    casf->Close();
89
90    delete rl;
91
92    return rc;
93 }