removed separate histograms for Calib and physics data
[u/mrichter/AliRoot.git] / T0 / readESD.C
CommitLineData
d407091e 1void readESD()
2{
3 //read T0 ESD from reconstructed cosmic data
4
5 char filename[100];
6 sprintf(filename,"");
7 TFile *file = new TFile("AliESDs.root");
8
9 // TH1F *hMean= new TH1F("hMean"," T0 ", 10000,1.249e6,1.259e6);
10 TH1F *hMean= new TH1F("hMean"," T0 ",6000,0,6000);
11 TH1F *hVertex = new TH1F("hVertex","Z position of vertex", 100,-120,-110);
12
13 // TH1F *hAmp = new TH1F("hAmp"," amplitude", 2500, 10,2510);
14 // TH1F *hTime = new TH1F("hTime"," time", 500,1250000,1250500);
15 TH1F *hAmp[24]; TH1F * hTime[24];
16 Char_t buf1[20], buf2[20];
17
18 for(Int_t ic=0; ic<24; ic++)
19 {
20 sprintf(buf1,"Amp%i",ic+1);
21 hAmp[ic] = new TH1F(buf1,"Amp",50, 0,50 );
22 sprintf(buf2,"Time%i",ic+1);
23 // hTime[ic] = new TH1F("hTime"," time", 10000,1.249e6,1.259e6);
24 hTime[ic] = new TH1F("hTime"," time", 6000,0,6000);
25 }
26
27 Double_t *amp, *time;
28 TTree *esdTree = (TTree*)file->Get("esdTree");
29 esdTree->ls();
30
31 TBranch *brRec=esdTree->GetBranch("AliESDTZERO.");
32 AliESDTZERO *fesdT0 = new AliESDTZERO();
33 if (brRec) {
34 brRec->SetAddress(&fesdT0);
35 }else{
36 cerr<<"EXEC Branch T0 not found"<<endl;
37 return;
38 }
39 // brRec->GetEntry(0);
40
41 // Event ------------------------- LOOP
42 for (Int_t ievent=0; ievent<brRec->GetEntries(); ievent++){
43 brRec->GetEntry(ievent);
44 Int_t mean = fesdT0->GetT0();
45 hMean->Fill(mean);
46 Float_t vertex= fesdT0->GetT0zVertex();
47 if (ievent <100) cout<<ievent<<" "<<mean<<" vertex "<<vertex<<endl;
48 if(vertex<999){
49 hVertex->Fill(vertex);
50 amp=fesdT0->GetT0amplitude();
51 time=fesdT0->GetT0time();
52 for (Int_t i=0; i<24; i++){
53 hAmp[i]->Fill(amp[i]);
54 hTime[i]->Fill(time[i]);
55 if (ievent <100) cout<<ievent<<" "<<i<<" time "<<time[i]<<" amp "<<amp[i]<<endl;
56 }
57 }
58 }
59
60 Hfile = new TFile("FigESD_25081.root","RECREATE","Histograms for T0
61digits");
62 printf("Writting histograms to root file \n");
63 Hfile->cd();
64 //Create a canvas, set the view range, show histograms
65 // g
66 // gStyle->SetOptStat(111111);
67 hVertex->Write();
68 hMean->Write();
69 for (Int_t i=0; i<24; i++){
70 hAmp[i]->Write();
71 hTime[i]->Write();
72 }
73
74 TCanvas *c1 = new TCanvas("c1", "Time C side",0,48,1280,951);
75 c1->Divide(4,3);
76 // gStyle->SetOptFit(1111);
77 for (Int_t i=0; i<12; i++)
78 {
79 c1->cd(i+1);
80 hTime[i]->Draw();
81 }
82 TCanvas *c2 = new TCanvas("c2", "Time A side",0,48,1280,951);
83 c2->Divide(4,3);
84 gStyle->SetOptFit(1111);
85 for (Int_t i=12; i<24; i++)
86 {
87 c2->cd(i+1-12);
88 hTime[i]->Draw();
89 }
90
91 TCanvas *c3 = new TCanvas("c3", "Time mean & vertex",0,48,1280,951);
92 c3->Divide(1,2);
93 c3->cd(1);
94 hVertex->Draw();
95 c3->cd(2);
96 hMean->Draw();
97
98
99
100
101} // end of macro