]> git.uio.no Git - u/mrichter/AliRoot.git/blob - START/readVertex.C
Digits and reconstruction with TObject
[u/mrichter/AliRoot.git] / START / readVertex.C
1 void readVertex(Int_t evNumber=1) 
2 {
3  
4   // Dynamically link some shared libs
5   if (gClassTable->GetID("AliRun") < 0) {
6     gROOT->LoadMacro("loadlibs.C");
7     loadlibs();
8   }
9   
10   // Connect the Root Galice file containing Geometry, Kine and Hits
11
12   TFile *file =  (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
13   if (!file) file = new TFile("production.root","UPDATE");
14   
15   // Get AliRun object from file or create it if not on file
16   if (!gAlice) {
17     gAlice = (AliRun*)file->Get("gAlice");
18     if (gAlice) printf("AliRun object found on file\n");
19     if (!gAlice) gAlice = new AliRun("gAlice","Alice test program");
20   }
21   char nameTD[8],nameTR[8];
22
23   TH1F *hVertex = new TH1F("hVertex","Z position of vertex",100,-350,350);
24   TH1F *hRealVertex = new TH1F("hRealVertex","Z position of vertex",100,-350,350);
25   
26   digits = new AliSTARTdigit();
27   vertex = new AliSTARTvertex();
28  // Event ------------------------- LOOP  
29   for (Int_t j=0; j<evNumber; j++){
30     
31     sprintf(nameTR,"START_R_%d",j);
32     printf("%s\n",nameTR);
33     TObject *tr = (TObject*)gDirectory->Get(nameTR);
34     cout<<" tr "<<tr<<endl;
35     vertex->Read(nameTR);
36     
37     hVertex->Fill(vertex->GetVertex());
38     printf(" Z position %f\n",vertex->GetVertex());
39     gAlice->GetEvent(j);
40     AliHeader *header = gAlice->GetHeader();
41     AliGenEventHeader* genHeader = header->GenEventHeader();
42     TArrayF *o = new TArrayF(3); 
43     genHeader->PrimaryVertex(*o);
44     cout<<" o "<<o<<endl;
45     Float_t zRealVertex=o->At(2);
46     cout<<" zRealVertex "<<zRealVertex<<endl;
47     hRealVertex->Fill(zRealVertex);
48        
49   }
50     Hfile = new TFile("figs.root","UPDATE","Histograms for START Vertex");
51    printf("Writting histograms to root file \n");
52    Hfile->cd();
53
54  //Create a canvas, set the view range, show histograms
55    
56   gStyle->SetOptStat(111111);
57   hVertex->SetXTitle("vertex position, mm");
58   hVertex->SetYTitle("number of events");
59   hVertex->Write();
60   hRealVertex->SetXTitle("vertex position, mm");
61   hRealVertex->SetYTitle("number of events");
62   hRealVertex->Write();
63
64 } // end of macro
65
66
67
68