]> git.uio.no Git - u/mrichter/AliRoot.git/blob - START/readRec.C
macros for reading RecPoints
[u/mrichter/AliRoot.git] / START / readRec.C
1 void readRec() 
2 {
3   //read START RecPoints and plots histos 
4
5   // Dynamically link some shared libs
6   /*  if (gClassTable->GetID("AliRun") < 0) {
7     gROOT->LoadMacro("loadlibs.C");
8     loadlibs();
9   }
10   */
11     char filename[100];
12     sprintf(filename,"galice.root");
13     AliRunLoader* rl = AliRunLoader::Open("galice.root",AliConfig::GetDefaultEventFolderName(),"read");
14     if (rl == 0x0)
15    {
16      cerr<<"Can not open session for file galice.root\n";
17      return;
18    }
19     
20     rl->LoadgAlice();
21     gAlice = rl->GetAliRun();
22     
23     AliSTART* START  = (AliSTART *)gAlice->GetDetector("START");
24     
25     rl->LoadHeader();
26     Int_t retval;
27     AliLoader* lstart = rl->GetLoader("STARTLoader");
28
29   Int_t iNevents=rl->GetNumberOfEvents();
30   cout<<"  nevents   "<<iNevents<<endl;
31
32
33   TH1F *hBestTimeC = new TH1F("hBestTimeC","First time Cside",
34                                   100,12.,13.);
35   TH1F *hBestTimeA = new TH1F("hBestTimeA","First time Aside",100,12.,13.);
36   TH1F *hMean= new TH1F("hMean"," T0 ",100,12.,13.);
37   TH1F *hAcc = new TH1F("hAcc","rec - real vertex",100,-10,10);
38                                  
39   TH1F *hRealVertex = new TH1F("hRealVertex","Real Vertex",100,-15,15);
40   
41   TH1F *hVertex = new TH1F("hVertex","Z position of vertex",   100,-15,15);
42   AliSTARTRecPoint *fRec   ; // digits
43   fRec = new AliSTARTRecPoint();
44
45  // Event ------------------------- LOOP  
46   for (Int_t ievent=0; ievent<iNevents; ievent++){
47     rl->GetEvent(ievent);
48
49     AliHeader *header = gAlice->GetHeader();
50     AliGenEventHeader* genHeader = header->GenEventHeader();
51     TArrayF *o = new TArrayF(3); 
52     genHeader->PrimaryVertex(*o);
53     Float_t zRealVertex=o->At(2);
54     hRealVertex->Fill( zRealVertex);
55
56     lstart->LoadRecPoints("READ");
57     TTree *recTree =  lstart->TreeR();
58     TBranch *brRec=recTree->GetBranch("START");
59     AliSTARTRecPoint *fRec = new AliSTARTRecPoint();
60     if (brRec) {
61       brRec->SetAddress(&fRec);
62     }else{
63       cerr<<"EXEC Branch START Recpoints not found"<<endl;
64       return;
65     }
66     brRec->GetEntry(0);
67     Int_t   mean = fRec->GetMeanTime();
68     hMean->Fill(mean/1000.);
69     Int_t   besttimeleft = fRec->GetBestTimeLeft();
70     Int_t   besttimeright = fRec->GetBestTimeRight();
71     hBestTimeC->Fill(0.001 * besttimeright);
72     hBestTimeA->Fill(0.001 * besttimeleft );
73     Float_t vertex= fRec->GetVertex();
74     cout<<ievent<<" "<<mean<<" real vertex "<< zRealVertex<<" vertex "<<vertex<<
75       " a "<< besttimeleft<<" c "<< besttimeright<<endl;
76     hAcc->Fill(zRealVertex-vertex/2.);
77     hVertex->Fill(vertex/2.);
78   }
79   Hfile = new TFile("FigRec.root","RECREATE","Histograms for START 
80 digits");
81   printf("Writting histograms to root file \n");
82   Hfile->cd();
83   //Create a canvas, set the view range, show histograms
84   gStyle->SetOptStat(111111);
85   //  TCanvas *c1 = new TCanvas("c1","Alice START Time ",400,10,600,600);
86  //  hTimediff->Write();
87   hBestTimeC->Write(); 
88   hBestTimeA ->Write(); 
89   hVertex->Write();
90   hRealVertex->Write();
91   hAcc->Write();  
92  hMean->Write();
93 } // end of macro
94
95
96
97