]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSVertexerTracksTest.C
Moving AliITSVertex to AliESDVertex
[u/mrichter/AliRoot.git] / ITS / AliITSVertexerTracksTest.C
CommitLineData
314e387c 1#if !defined(__CINT__) || defined(__MAKECINT__)
2//-- --- standard headers-------------
3#include <Riostream.h>
4//--------Root headers ---------------
5#include <TSystem.h>
6#include <TFile.h>
7#include <TStopwatch.h>
8#include <TObject.h>
9#include <TTree.h>
10#include <TStopwatch.h>
11#include <TKey.h>
12//----- AliRoot headers ---------------
13#include "alles.h"
14#include "AliRun.h"
15#include "AliRunLoader.h"
16#include "AliMagF.h"
17#include "AliKalmanTrack.h"
2e7b4767 18#include "AliESDVertex.h"
314e387c 19#include "AliITSVertexer.h"
20#include "AliITSVertexerTracks.h"
21//-------------------------------------
22#endif
23void AliITSVertexerTracksTest(Int_t evFirst=0,Int_t evLast=0,Bool_t esd=kTRUE,
24 const Char_t *galiceName="galice.root",
25 const Char_t *inName="AliESDs.root",
26 const Char_t *outName="AliESDs.root") {
27 /*******************************************************************
28 * *
29 * Test macro for vertexing in pp using tracks. *
30 * If(esd) { *
31 * Input file must contain ESD events with tracks reco in ITS *
32 * if output file = input file, vertices will be stored in the *
33 * ESD events and these rewritten to the same file; otherwise *
34 * they will be written to a new file *
35 * } else { *
36 * input file must contain a tree with AliITStracksV2 and *
37 * can be written to the same file (output file = input file) *
38 * or to a new one *
39 * } *
40 * If file galice.root is present field will be read from it *
41 * otherwise it can be set here "by hand". *
42 * *
43 * Origin: A.Dainese, Padova andrea.dainese@pd.infn.it *
44 *******************************************************************/
45
46 TStopwatch timer;
47 timer.Start();
48
49 // Look for field value in galice.root
50 Double_t field = 0.4;
51 if(!gSystem->AccessPathName(galiceName,kFileExists)) {
52 AliRunLoader *rl = AliRunLoader::Open(galiceName);
53 rl->LoadgAlice();
54 AliMagF *fiel = (AliMagF*)gAlice->Field();
55 field=(Double_t)fiel->SolenoidField()/10.;
56 AliKalmanTrack::SetConvConst(100/0.299792458/field);
57 printf(" B = %3.1f read from gAlice and set\n",field);
58 } else {
59 printf(" File galice.root not found: default 0.4 T being used!\n");
60 }
61
62 // Open input and output files
63 TFile *inFile = TFile::Open(inName);
64 TFile *outFile = TFile::Open(outName,"update");
65
66 // Create vertexer
67 AliITSVertexerTracks *vertexer =
68 new AliITSVertexerTracks(inFile,outFile,field,evFirst,evLast);
69 // Find vertices
70 if(esd) {
71 vertexer->FindVerticesESD();
72 } else {
73 vertexer->FindVertices();
74 }
75
76 timer.Stop(); timer.Print();
77
78 delete vertexer;
79
80 inFile->Close();
81 outFile->Close();
82 delete inFile;
83 delete outFile;
84
85 return;
86}
87//----------------------------------------------------------------------------
88void VertexRecoInESDChain() {
89
90 TStopwatch timer;
91 timer.Start();
92
93 // Look for field value in galice.root
94 Double_t field = 0.4;
95 if(!gSystem->AccessPathName("galice.root",kFileExists)) {
96 AliRunLoader *rl = AliRunLoader::Open("galice.root");
97 rl->LoadgAlice();
98 AliMagF *fiel = (AliMagF*)gAlice->Field();
99 field=(Double_t)fiel->SolenoidField()/10.;
100 AliKalmanTrack::SetConvConst(100/0.299792458/field);
101 printf(" B = %3.1f read from gAlice and set\n",field);
102 } else {
103 printf(" File galice.root not found: default 0.4 T being used!\n");
104 }
105
106 // open file with ESD events (this would not be necessary in the chain...)
107 if(gSystem->AccessPathName("AliESDs.root",kFileExists))
108 { printf(" ESD file not found!\n"); return; }
109 TFile *esdFile = new TFile("AliESDs.root","update");
110
111 AliITSVertexerTracks *vertexer = new AliITSVertexerTracks();
112 vertexer->SetField(field);
113
114 Int_t n=0;
115 TKey *key=0;
116 TIter next(esdFile->GetListOfKeys());
117
118 //******* The loop over events
119 while ((key=(TKey*)next())!=0) {
120 printf("--- Processing event number : %d",n++);
121
122 AliESD *event=(AliESD*)key->ReadObj();
123
124 // find vertex and store it in the ESD (only pos and cov matrix)
125 vertexer->FindVertexForCurrentEvent(event);
126
127 // write event on file
128 event->Write();
129
130 }
131
132 timer.Stop(); timer.Print();
133
134 delete vertexer;
135 esdFile->Close();
136 delete esdFile;
137
138 return;
139}
140
141
142
143
144
145
146