]> git.uio.no Git - u/mrichter/AliRoot.git/blob - START/readVertex.C
Possibility to define the magnetic field in the reconstruction (Yu.Belikov)
[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("galice.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   
25   digits = new AliSTARTdigit();
26   vertex = new AliSTARTvertex();
27   TBranch *bd;
28   TBranch *bRec;
29
30  // Event ------------------------- LOOP  
31   for (j=0; j<evNumber; j++){
32     sprintf(nameTD,"TreeD%d",j);
33     printf("%s\n",nameTD);
34     TTree *TD = (TTree*)gDirectory->Get(nameTD);
35     bd = TD->GetBranch("START");
36     bd->SetAddress(&digits);
37     bd->GetEvent(0); 
38     printf(" Digits: %d \n ",digits->GetTime()); 
39     
40     
41     sprintf(nameTR,"TreeR%d",j);
42     printf("%s\n",nameTR);
43     TTree *TR = (TTree*)gDirectory->Get(nameTR);
44     bRec = TR->GetBranch("START");
45     bRec->SetAddress(&vertex);
46     bRec->GetEvent(0);
47     if(digits->GetTime()!=999999){
48       hVertex->Fill(vertex->GetVertex());
49       // printf(" Z position %f\n",vertex->GetVertex());
50     }
51   }
52     Hfile = new TFile("figs1.root","RECREATE","Histograms for START Vertex");
53    printf("Writting histograms to root file \n");
54    Hfile->cd();
55
56  //Create a canvas, set the view range, show histograms
57    
58   gStyle->SetOptStat(111111);
59   TCanvas *c1 = new TCanvas("c1","Alice START Time (vertex)",400,10,600,600);
60
61   hVertex->SetXTitle("vertex position, mm");
62   hVertex->SetYTitle("number of events");
63   hVertex->Write();
64
65 } // end of macro
66
67
68
69