]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSFindPrimaryVertex.C
New primary vertex classes and macros (from A. Dainese and M. Masera)
[u/mrichter/AliRoot.git] / ITS / AliITSFindPrimaryVertex.C
1 #include "iostream.h"
2 #include "TMath.h"
3
4 void AliITSFindPrimaryVertex(Int_t evNumber1=0,Int_t evNumber2=0, const char *filename="galice.root") {
5
6   
7   ///////////////// Dynamically link some shared libs /////////////////////
8   
9   if (gClassTable->GetID("AliRun") < 0) {
10     gROOT->LoadMacro("loadlibs.C");
11     loadlibs();
12   } else {
13     delete gAlice;
14     gAlice=0;
15   }
16
17 // Connect the Root Galice file containing Geometry, Kine and Hits
18    TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(filename);
19    if (!file) file = new TFile(filename);
20
21
22 // Get AliRun object from file 
23    if (!gAlice) {
24       gAlice = (AliRun*)file->Get("gAlice");
25       if (gAlice) {
26         printf("AliRun object found on file\n");
27       }
28       else {
29         printf("AliRun object not found - nothing done\n");
30         return;
31       }
32    }
33
34    // Open output file for vertices and Create vertexer
35    TFile *filou = new TFile("vertices.root","recreate");
36    AliITSVertexerIons *vertexer = new AliITSVertexerIons(file,filou);
37    AliITSVertex *V;
38 //   Loop over events 
39 //
40    Int_t Nh=0;
41    Int_t Nh1=0;
42    for (int nev=0; nev<= evNumber2; nev++) {
43      gAlice->SetEvent(nev);
44          Int_t nparticles = gAlice->GetEvent(nev);
45      cout << "nev         " << nev <<endl;
46      cout << "nparticles  " << nparticles <<endl;
47      if (nev < evNumber1) continue;
48      if (nparticles <= 0) return;
49   
50   
51      TStopwatch timer;
52      timer.Start();
53
54      V=vertexer->FindVertexForCurrentEvent(i);
55
56      timer.Stop();
57      timer.Print();
58
59      cout << endl << "Xv = " << V->GetXv() << " cm" << endl;
60      cout << "X resolution = " << V->GetXRes()*10000 << " microns"  << endl;
61      cout << "Signal/Noise for X = " << V->GetXSNR() << endl;
62      cout << endl << "Yv = " << V->GetYv() << " cm"  << endl;
63      cout << "Y resolution = " << V->GetYRes()*10000 << " microns"  << endl;
64      cout << "Signal/Noise for Y = " << V->GetYSNR() << endl;
65      cout << endl << "Zv = " << V->GetZv() << " cm" << endl;
66      cout << "Z Resolution = " << V->GetZRes()*10000 << " microns" << endl;
67      cout << "Signal/Noise for Z = " << V->GetZSNR() <<endl;
68                  
69      vertexer->WriteCurrentVertex(); 
70   } 
71   
72   file->Close(); 
73   filou->Close();
74 }
75