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