ROOT logo
void readRec() 
{
  //read T0 RecPoints and plots histos 

  // Dynamically link some shared libs
  /*  if (gClassTable->GetID("AliRun") < 0) {
    gROOT->LoadMacro("loadlibs.C");
    loadlibs();
  }
  */
    char filename[100];
    sprintf(filename,"galice.root");
    AliRunLoader* rl = AliRunLoader::Open("galice.root",AliConfig::GetDefaultEventFolderName(),"read");
    if (rl == 0x0)
   {
     cerr<<"Can not open session for file galice.root\n";
     return;
   }
    
    rl->LoadgAlice();
    gAlice = rl->GetAliRun();
    
    AliT0* T0  = (AliT0 *)gAlice->GetDetector("T0");
    
    rl->LoadHeader();
    Int_t retval;
    AliLoader* lstart = rl->GetLoader("T0Loader");

  Int_t iNevents=rl->GetNumberOfEvents();
  cout<<"  nevents   "<<iNevents<<endl;


  TH1F *hBestTimeC = new TH1F("hBestTimeC","First time Cside",
				  100,12.,13.);
  TH1F *hBestTimeA = new TH1F("hBestTimeA","First time Aside",100,12.,13.);
  TH1F *hMean= new TH1F("hMean"," T0 ",100,12.,13.);
  TH1F *hAcc = new TH1F("hAcc","rec - real vertex",100,-10,10);
				 
  TH1F *hRealVertex = new TH1F("hRealVertex","Real Vertex",100,-15,15);
  
  TH1F *hVertex = new TH1F("hVertex","Z position of vertex",   100,-15,15);
 
  TH1F *hAmp = new TH1F("hAmp"," amplitude",   100, 10,1000);
  TH1F *hTime = new TH1F("hTime"," time",   100,12000.,20000);

  TArrayI *amp = new TArrayI(24);  
  TArrayI *time = new TArrayI(24);  

  AliT0RecPoint *fRec   ; // digits
  fRec = new AliT0RecPoint();

 // Event ------------------------- LOOP  
  for (Int_t ievent=0; ievent<iNevents; ievent++){
    // for (Int_t ievent=0; ievent<990; ievent++){
    rl->GetEvent(ievent);

    AliHeader *header = gAlice->GetHeader();
    AliGenEventHeader* genHeader = header->GenEventHeader();
    TArrayF *o = new TArrayF(3); 
    genHeader->PrimaryVertex(*o);
    Float_t zRealVertex=o->At(2);
    hRealVertex->Fill( zRealVertex);

    lstart->LoadRecPoints("READ");
    TTree *recTree =  lstart->TreeR();
    TBranch *brRec=recTree->GetBranch("T0");
    AliT0RecPoint *fRec = new AliT0RecPoint();
    if (brRec) {
      brRec->SetAddress(&fRec);
    }else{
      cerr<<"EXEC Branch T0 Recpoints not found"<<endl;
      return;
    }
    brRec->GetEntry(0);
    Int_t   mean = fRec->GetMeanTime();
    hMean->Fill(mean/1000.);
    Int_t   besttimeleft = fRec->GetBestTimeLeft();
    Int_t   besttimeright = fRec->GetBestTimeRight();
    hBestTimeC->Fill(0.001 * besttimeright);
    hBestTimeA->Fill(0.001 * besttimeleft );
    Float_t vertex= fRec->GetVertex();
    if(vertex<99){
    cout<<ievent<<" "<<mean<<" real vertex "<< zRealVertex<<" vertex "<<vertex<<
      " a "<< besttimeleft<<" c "<< besttimeright<<endl;
    hAcc->Fill(zRealVertex-vertex);
    hVertex->Fill(vertex);
     for (Int_t i=0; i<24; i++){ 
      hAmp->Fill(fRec->GetAmp(i));
      hTime->Fill(fRec->GetTime(i));
      //  cout<<"time "<<fRec->GetTime(i)<<" amp "<<fRec->GetAmp(i)<<endl;
    } 
    }
  }
  Hfile = new TFile("FigRec.root","RECREATE","Histograms for T0 
digits");
  printf("Writting histograms to root file \n");
  Hfile->cd();
  //Create a canvas, set the view range, show histograms
  gStyle->SetOptStat(111111);
  //  TCanvas *c1 = new TCanvas("c1","Alice T0 Time ",400,10,600,600);
 //  hTimediff->Write();
  hBestTimeC->Write(); 
  hBestTimeA ->Write(); 
  hVertex->Write();
  hRealVertex->Write();
  hAcc->Write();  
  hMean->Write();
  hAmp->Write();
  hTime->Write();
} // end of macro




 readRec.C:1
 readRec.C:2
 readRec.C:3
 readRec.C:4
 readRec.C:5
 readRec.C:6
 readRec.C:7
 readRec.C:8
 readRec.C:9
 readRec.C:10
 readRec.C:11
 readRec.C:12
 readRec.C:13
 readRec.C:14
 readRec.C:15
 readRec.C:16
 readRec.C:17
 readRec.C:18
 readRec.C:19
 readRec.C:20
 readRec.C:21
 readRec.C:22
 readRec.C:23
 readRec.C:24
 readRec.C:25
 readRec.C:26
 readRec.C:27
 readRec.C:28
 readRec.C:29
 readRec.C:30
 readRec.C:31
 readRec.C:32
 readRec.C:33
 readRec.C:34
 readRec.C:35
 readRec.C:36
 readRec.C:37
 readRec.C:38
 readRec.C:39
 readRec.C:40
 readRec.C:41
 readRec.C:42
 readRec.C:43
 readRec.C:44
 readRec.C:45
 readRec.C:46
 readRec.C:47
 readRec.C:48
 readRec.C:49
 readRec.C:50
 readRec.C:51
 readRec.C:52
 readRec.C:53
 readRec.C:54
 readRec.C:55
 readRec.C:56
 readRec.C:57
 readRec.C:58
 readRec.C:59
 readRec.C:60
 readRec.C:61
 readRec.C:62
 readRec.C:63
 readRec.C:64
 readRec.C:65
 readRec.C:66
 readRec.C:67
 readRec.C:68
 readRec.C:69
 readRec.C:70
 readRec.C:71
 readRec.C:72
 readRec.C:73
 readRec.C:74
 readRec.C:75
 readRec.C:76
 readRec.C:77
 readRec.C:78
 readRec.C:79
 readRec.C:80
 readRec.C:81
 readRec.C:82
 readRec.C:83
 readRec.C:84
 readRec.C:85
 readRec.C:86
 readRec.C:87
 readRec.C:88
 readRec.C:89
 readRec.C:90
 readRec.C:91
 readRec.C:92
 readRec.C:93
 readRec.C:94
 readRec.C:95
 readRec.C:96
 readRec.C:97
 readRec.C:98
 readRec.C:99
 readRec.C:100
 readRec.C:101
 readRec.C:102
 readRec.C:103
 readRec.C:104
 readRec.C:105
 readRec.C:106
 readRec.C:107
 readRec.C:108
 readRec.C:109
 readRec.C:110
 readRec.C:111
 readRec.C:112
 readRec.C:113
 readRec.C:114
 readRec.C:115