ROOT logo
void readVertex(Int_t evNumber=1) 
{
 
  // Dynamically link some shared libs
  if (gClassTable->GetID("AliRun") < 0) {
    gROOT->LoadMacro("loadlibs.C");
    loadlibs();
  }
  
  // Connect the Root Galice file containing Geometry, Kine and Hits

  TFile *file =  (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
  if (!file) file = new TFile("production.root","UPDATE");
  
  // Get AliRun object from file or create it if not on file
  if (!gAlice) {
    gAlice = (AliRun*)file->Get("gAlice");
    if (gAlice) printf("AliRun object found on file\n");
    if (!gAlice) gAlice = new AliRun("gAlice","Alice test program");
  }
  char nameTD[8],nameTR[8];

  TH1F *hVertex = new TH1F("hVertex","Z position of vertex",100,-100,100);
  TH1F *hRealVertex = new TH1F("hRealVertex","Z position of vertex",
			       100,-100,100);
  
  digits = new AliT0digit();
  vertex = new AliT0vertex();
 // Event ------------------------- LOOP  
  for (Int_t j=0; j<evNumber; j++){
    
    sprintf(nameTR,"T0_R_%d",j);
    printf("%s\n",nameTR);
    TObject *tr = (TObject*)gDirectory->Get(nameTR);
    cout<<" tr "<<tr<<endl;
    vertex->Read(nameTR);
    
    hVertex->Fill(vertex->GetVertex());
    printf(" Z position %f\n",vertex->GetVertex());
    gAlice->GetEvent(j);
    AliHeader *header = gAlice->GetHeader();
    AliGenEventHeader* genHeader = header->GenEventHeader();
    TArrayF *o = new TArrayF(3); 
    genHeader->PrimaryVertex(*o);
    cout<<" o "<<o<<endl;
    Float_t zRealVertex=o->At(2);
    cout<<" zRealVertex "<<zRealVertex<<endl;
    hRealVertex->Fill(zRealVertex);
       
  }
    Hfile = new TFile("figs.root","RECREATE","Histograms for T0 Vertex");
   printf("Writting histograms to root file \n");
   Hfile->cd();

 //Create a canvas, set the view range, show histograms
   
  gStyle->SetOptStat(111111);
  hVertex->SetXTitle("vertex position, mm");
  hVertex->SetYTitle("number of events");
  hVertex->Write();
  hRealVertex->SetXTitle("vertex position, mm");
  hRealVertex->SetYTitle("number of events");
  hRealVertex->Write();

} // end of macro




 readVertex.C:1
 readVertex.C:2
 readVertex.C:3
 readVertex.C:4
 readVertex.C:5
 readVertex.C:6
 readVertex.C:7
 readVertex.C:8
 readVertex.C:9
 readVertex.C:10
 readVertex.C:11
 readVertex.C:12
 readVertex.C:13
 readVertex.C:14
 readVertex.C:15
 readVertex.C:16
 readVertex.C:17
 readVertex.C:18
 readVertex.C:19
 readVertex.C:20
 readVertex.C:21
 readVertex.C:22
 readVertex.C:23
 readVertex.C:24
 readVertex.C:25
 readVertex.C:26
 readVertex.C:27
 readVertex.C:28
 readVertex.C:29
 readVertex.C:30
 readVertex.C:31
 readVertex.C:32
 readVertex.C:33
 readVertex.C:34
 readVertex.C:35
 readVertex.C:36
 readVertex.C:37
 readVertex.C:38
 readVertex.C:39
 readVertex.C:40
 readVertex.C:41
 readVertex.C:42
 readVertex.C:43
 readVertex.C:44
 readVertex.C:45
 readVertex.C:46
 readVertex.C:47
 readVertex.C:48
 readVertex.C:49
 readVertex.C:50
 readVertex.C:51
 readVertex.C:52
 readVertex.C:53
 readVertex.C:54
 readVertex.C:55
 readVertex.C:56
 readVertex.C:57
 readVertex.C:58
 readVertex.C:59
 readVertex.C:60
 readVertex.C:61
 readVertex.C:62
 readVertex.C:63
 readVertex.C:64
 readVertex.C:65
 readVertex.C:66
 readVertex.C:67
 readVertex.C:68
 readVertex.C:69
 readVertex.C:70