]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSFindPrimaryVertex.C
Updated flags
[u/mrichter/AliRoot.git] / ITS / AliITSFindPrimaryVertex.C
CommitLineData
88cb7938 1#if !defined(__CINT__) || defined(__MAKECINT__)
2#include <TClassTable.h>
3#include <TFile.h>
4#include <TTree.h>
5#include <Riostream.h>
6#include <AliRun.h>
7#include <AliHeader.h>
8#include <AliGenEventHeader.h>
9#include <AliITSVertexerIons.h>
10#include <AliRunLoader.h>
fe4280bf 11#include <AliITSVertexerIons.h>
88cb7938 12#include <AliITSLoader.h>
fe4280bf 13#include <unistd.h>
af8e1c2d 14
88cb7938 15#endif
af8e1c2d 16
88cb7938 17void AliITSFindPrimaryVertex(Int_t evNumber1=0,Int_t NumbofEv=1, const char *filename="galice.root") {
18
19 Int_t evNumber2 = evNumber1+NumbofEv;
af8e1c2d 20
21 if (gClassTable->GetID("AliRun") < 0) {
88cb7938 22 gROOT->Macro("loadlibs.C");
af8e1c2d 23 } else {
88cb7938 24 if(gAlice){
25 delete gAlice->GetRunLoader();
26 delete gAlice;
27 gAlice=0;
28 }
af8e1c2d 29 }
af8e1c2d 30
88cb7938 31 AliRunLoader* rl = AliRunLoader::Open("galice.root");
32 if (rl == 0x0){
33 ::Error("AliITSFindPrimaryVertex.C","Can not open session RL=NULL");
34 return;
35 }
fe4280bf 36
88cb7938 37 // Open output file for vertices (default name: ITS.Vertex.root
38 // and Create vertexer
fe4280bf 39
88cb7938 40 AliITSVertexerIons *vertexer = new AliITSVertexerIons("default");
fe4280bf 41 //vertexer->SetDebug(1);
42
2e7b4767 43 AliESDVertex *V;
88cb7938 44 // Loop over events
fe4280bf 45
88cb7938 46 for (int nev=evNumber1; nev< evNumber2; nev++) {
47 cout<<"=============================================================\n";
48 cout<<" Processing event "<<nev<<endl;
49 cout<<"=============================================================\n";
50 rl->GetEvent(nev);
88cb7938 51 AliHeader *header = rl->GetHeader();
52 AliGenEventHeader* genEventHeader = header->GenEventHeader();
53 TArrayF primaryVertex(3);
54 genEventHeader->PrimaryVertex(primaryVertex);
fe4280bf 55
56 AliGenHijingEventHeader* hijingHeader = (AliGenHijingEventHeader*) genEventHeader;
57 Float_t b = hijingHeader->ImpactParameter();
58 cout << "Impact parameter = " << b << " fm" << endl;
59
88cb7938 60 TStopwatch timer;
61 timer.Start();
af8e1c2d 62
88cb7938 63 V=vertexer->FindVertexForCurrentEvent(nev);
fe4280bf 64
65 TVector3 vtrue(primaryVertex[0],primaryVertex[1],primaryVertex[2]);
66 TVector3 vfound(V->GetXv(),V->GetYv(),V->GetZv());
67 TVector3 dif=vtrue-vfound;
68 cout << "True vertex coordinates (cm) = " << vtrue.X() << " " << vtrue.Y() << " " << vtrue.Z() << endl;
69 cout << "Found vertex coordinates (cm) = " << vfound.X() << " " << vfound.Y() << " " << vfound.Z() << endl; cout << "Difference true - found (cm) = " << dif.Mag() << " " << dif.X() << " " << dif.Y() << " " << dif.Z() << endl;
70
88cb7938 71 if(V){
72 Double_t pos[3];
73 for(Int_t kk=0;kk<3;kk++)pos[kk]=(Double_t)primaryVertex[kk];
74 V->SetTruePos(pos);
75 }
76 timer.Stop();
77 timer.Print();
fe4280bf 78
88cb7938 79 vertexer->WriteCurrentVertex();
af8e1c2d 80 }
81
88cb7938 82
af8e1c2d 83}
84