]> git.uio.no Git - u/mrichter/AliRoot.git/blob - T0/readVertex.C
No optimization with gcc 4.3.0
[u/mrichter/AliRoot.git] / T0 / 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,-100,100);
24   TH1F *hRealVertex = new TH1F("hRealVertex","Z position of vertex",
25                                100,-100,100);
26   
27   digits = new AliT0digit();
28   vertex = new AliT0vertex();
29  // Event ------------------------- LOOP  
30   for (Int_t j=0; j<evNumber; j++){
31     
32     sprintf(nameTR,"T0_R_%d",j);
33     printf("%s\n",nameTR);
34     TObject *tr = (TObject*)gDirectory->Get(nameTR);
35     cout<<" tr "<<tr<<endl;
36     vertex->Read(nameTR);
37     
38     hVertex->Fill(vertex->GetVertex());
39     printf(" Z position %f\n",vertex->GetVertex());
40     gAlice->GetEvent(j);
41     AliHeader *header = gAlice->GetHeader();
42     AliGenEventHeader* genHeader = header->GenEventHeader();
43     TArrayF *o = new TArrayF(3); 
44     genHeader->PrimaryVertex(*o);
45     cout<<" o "<<o<<endl;
46     Float_t zRealVertex=o->At(2);
47     cout<<" zRealVertex "<<zRealVertex<<endl;
48     hRealVertex->Fill(zRealVertex);
49        
50   }
51     Hfile = new TFile("figs.root","RECREATE","Histograms for T0 Vertex");
52    printf("Writting histograms to root file \n");
53    Hfile->cd();
54
55  //Create a canvas, set the view range, show histograms
56    
57   gStyle->SetOptStat(111111);
58   hVertex->SetXTitle("vertex position, mm");
59   hVertex->SetYTitle("number of events");
60   hVertex->Write();
61   hRealVertex->SetXTitle("vertex position, mm");
62   hRealVertex->SetYTitle("number of events");
63   hRealVertex->Write();
64
65 } // end of macro
66
67
68
69