Reading muon trigger scalers with the DA of the muon trigger and transfer
[u/mrichter/AliRoot.git] / T0 / readRec.C
CommitLineData
dc7ca31d 1void readRec()
2{
3 //read T0 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 AliT0* T0 = (AliT0 *)gAlice->GetDetector("T0");
24
25 rl->LoadHeader();
26 Int_t retval;
27 AliLoader* lstart = rl->GetLoader("T0Loader");
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
43 TH1F *hAmp = new TH1F("hAmp"," amplitude", 100, 10,1000);
44 TH1F *hTime = new TH1F("hTime"," time", 100,12000.,20000);
45
46 TArrayI *amp = new TArrayI(24);
47 TArrayI *time = new TArrayI(24);
48
49 AliT0RecPoint *fRec ; // digits
50 fRec = new AliT0RecPoint();
51
52 // Event ------------------------- LOOP
53 for (Int_t ievent=0; ievent<iNevents; ievent++){
54 // for (Int_t ievent=0; ievent<990; ievent++){
55 rl->GetEvent(ievent);
56
57 AliHeader *header = gAlice->GetHeader();
58 AliGenEventHeader* genHeader = header->GenEventHeader();
59 TArrayF *o = new TArrayF(3);
60 genHeader->PrimaryVertex(*o);
61 Float_t zRealVertex=o->At(2);
62 hRealVertex->Fill( zRealVertex);
63
64 lstart->LoadRecPoints("READ");
65 TTree *recTree = lstart->TreeR();
66 TBranch *brRec=recTree->GetBranch("T0");
67 AliT0RecPoint *fRec = new AliT0RecPoint();
68 if (brRec) {
69 brRec->SetAddress(&fRec);
70 }else{
71 cerr<<"EXEC Branch T0 Recpoints not found"<<endl;
72 return;
73 }
74 brRec->GetEntry(0);
75 Int_t mean = fRec->GetMeanTime();
76 hMean->Fill(mean/1000.);
77 Int_t besttimeleft = fRec->GetBestTimeLeft();
78 Int_t besttimeright = fRec->GetBestTimeRight();
79 hBestTimeC->Fill(0.001 * besttimeright);
80 hBestTimeA->Fill(0.001 * besttimeleft );
81 Float_t vertex= fRec->GetVertex();
82 if(vertex<99){
83 cout<<ievent<<" "<<mean<<" real vertex "<< zRealVertex<<" vertex "<<vertex<<
84 " a "<< besttimeleft<<" c "<< besttimeright<<endl;
85 hAcc->Fill(zRealVertex-vertex);
86 hVertex->Fill(vertex);
87 for (Int_t i=0; i<24; i++){
88 hAmp->Fill(fRec->GetAmp(i));
89 hTime->Fill(fRec->GetTime(i));
90 // cout<<"time "<<fRec->GetTime(i)<<" amp "<<fRec->GetAmp(i)<<endl;
91 }
92 }
93 }
94 Hfile = new TFile("FigRec.root","RECREATE","Histograms for T0
95digits");
96 printf("Writting histograms to root file \n");
97 Hfile->cd();
98 //Create a canvas, set the view range, show histograms
99 gStyle->SetOptStat(111111);
100 // TCanvas *c1 = new TCanvas("c1","Alice T0 Time ",400,10,600,600);
101 // hTimediff->Write();
102 hBestTimeC->Write();
103 hBestTimeA ->Write();
104 hVertex->Write();
105 hRealVertex->Write();
106 hAcc->Write();
107 hMean->Write();
108 hAmp->Write();
109 hTime->Write();
110} // end of macro
111
112
113
114