CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
readTree.cxx
Go to the documentation of this file.
1void readTree(){
2 int rBin,phiBin,zBin;
3 const int nR = 43;
4 const int nPhi = 6;
5 const int nZ = 6;
6 float eff,x[400],y[400];
7
8 TFile *f = new TFile("effTree.root", "read");
9 TTree *t = (TTree*)f->Get("effTree");
10
11 t->SetBranchAddress("rBin", &rBin);
12 t->SetBranchAddress("phiBin", &phiBin);
13 t->SetBranchAddress("zBin", &zBin);
14 t->SetBranchAddress("eff", &eff);
15 t->SetBranchAddress("x", x);
16 t->SetBranchAddress("y", y);
17
18 int r,phi,z;
19 float efficiency[43][6][6];
20 float propTime[43][6][6][400];
21 float prob[43][6][6][400];
22
23 for (Int_t i = 0; i < nR*nPhi*nZ; i++){
24 t->GetEntry(i);
25 r = rBin;
26 phi = phiBin;
27 z = zBin;
28 efficiency[r][phi][z] = eff;
29 for (Int_t j = 0; j < 400; j++){
30 propTime[r][phi][z][j] = x[j];
31 prob[r][phi][z][j] = y[j];
32 //cout << "\n" << propTime[r][phi][z][j] << " " << prob[r][phi][z][j] << endl;
33 }
34 }
35 //TH1F *h1 = new TH1F("h1","propTime",400,0,20);
36 int r0 = 41;
37 int phi0 = 2;
38 int z0 = 0;
39 Float_t x0[400], y0[400];
40
41 char file[200];
42 int rPos = 400+r0*10;
43 float x1[400],y1[400];
44 float t1;
45 sprintf(file,"/ihepbatch/besd12/liuy/EndcapTof/OpInETof2/results/%d/timeSta_%d_%d_%d.root",rPos,rPos,phi0,z0);
46 cout << file << endl;
47 TH1F* h1 = new TH1F("h1","time distr.(ns)",400,0,20);
48 TFile* f1 = TFile::Open(file);
49 TNtuple* n1 = (TNtuple*)f1 -> Get("timeTuple");
50 n1->SetBranchAddress("inTimePre",&t1);
51 int nEntries = (Int_t)n1->GetEntries();
52 cout << "nEntries:" << nEntries << "\n" << endl;
53
54 for(int m=0;m<nEntries;m++)
55 {
56 n1->GetEntry(m);
57 h1->Fill(t1);
58 }
59 double norm = h1->Integral();
60 eff = norm/2000000.; // 200 events per run ; 10k photons per event
61 if(norm!=0)
62 h1->Scale(1./norm);
63 else
64 {
65 cout << "The eff is null!" << endl;
66 continue;
67 }
68 TAxis* xaxis = h1->GetXaxis();
69 for(int m=0;m<400;m++)
70 {
71 x1[m] = xaxis->GetBinCenter(m);
72 y1[m] = h1->GetBinContent(m);
73 }
74 f1->Close();
75
76 for(Int_t i=0;i<400;i++)
77 {
78 x0[i] = propTime[r0][phi0][z0][i] - x1[i];
79 y0[i] = prob[r0][phi0][z0][i] - y1[i];
80 }
81
82 TGraph *g = new TGraph( 400, x0, y0);
83 g->Draw("APL");
84
85 f->Close();
86}
TFile * f1
Double_t x[10]
int n1
Definition: SD0Tag.cxx:54
void readTree()
Definition: readTree.cxx:1
int t()
Definition: t.c:1