BOSS
7.1.2
BESIII Offline Software System
Loading...
Searching...
No Matches
writeTree.cc
Go to the documentation of this file.
1
#include <unistd.h>
// Check the file
2
3
void
writeTree
(){
4
int
rBin,phiBin,zBin;
5
const
int
nR
= 43;
6
const
int
nPhi
= 6;
7
const
int
nZ
= 6;
8
float
efficiency0,
x
[400],
y
[400];
9
TTree *
t
=
new
TTree(
"effTree"
,
"colEff"
);
10
11
float
t1;
12
TH1F* h1 =
new
TH1F(
"h1"
,
"time distr.(ns)"
,400,0,20);
13
char
file
[200];
14
15
t
->Branch(
"rBin"
, &rBin,
"rBin/I"
);
16
t
->Branch(
"phiBin"
, &phiBin,
"phiBin/I"
);
17
t
->Branch(
"zBin"
, &zBin,
"zBin/I"
);
18
t
->Branch(
"efficiency0"
, &efficiency0,
"efficiency0/F"
);
19
t
->Branch(
"x"
,
x
,
"x[400]/F"
);
20
t
->Branch(
"y"
,
y
,
"y[400]/F"
);
21
22
for
(Int_t i = 0; i <
nR
; i++){
23
rBin = i;
24
for
(Int_t j = 0; j<
nPhi
;j++){
25
phiBin = j;
26
for
(Int_t k=0;k<
nZ
;k++){
27
int
rPos = 400+i*10;
28
sprintf
(
file
,
"/ihepbatch/besd12/liuy/EndcapTof/OpInETof2/results/%d/timeSta_%d_%d_%d.root"
,rPos,rPos,j,k);
29
//if(access(file,F_OK) < 0) // Check if the file exists or not. Thx to zoujh.
30
//{
31
// cout << "The file does NOT exist!" << endl;
32
// continue;
33
//}
34
//else
35
//{
36
cout <<
"The file:"
<<
file
<< endl;
37
TFile*
f1
= TFile::Open(
file
);
38
TNtuple*
n1
= (TNtuple*)
f1
-> Get(
"timeTuple"
);
39
n1
->SetBranchAddress(
"inTimePre"
,&t1);
40
int
nEntries = (Int_t)
n1
->GetEntries();
41
cout <<
"nEntries:"
<< nEntries <<
"\n"
<< endl;
42
43
for
(
int
m=0;m<nEntries;m++)
44
{
45
n1
->GetEntry(m);
46
h1->Fill(t1);
47
}
48
double
norm = h1->Integral();
49
efficiency0 = norm/2000000.;
// 200 events per run ; 10k photons per event
50
//cout << "norm:" << norm << "; efficiency0: " << efficiency0 << "\n" << endl;
51
if
(norm!=0)
52
h1->Scale(1./norm);
53
else
54
{
55
cout <<
"The eff is null!"
<< endl;
56
continue
;
57
}
58
TAxis* xaxis = h1->GetXaxis();
59
for
(
int
m=0;m<400;m++)
60
{
61
x
[m] = xaxis->GetBinCenter(m);
62
y
[m] = h1->GetBinContent(m);
63
}
64
f1
->Close();
65
66
zBin = k;
67
t
->Fill();
68
//}
69
}
70
}
71
72
}
73
TFile *
f
=
new
TFile(
"effTree.root"
,
"recreate"
);
74
cout <<
"TTree write"
<<endl;
75
t
->Write();
76
f
->Close();
77
}
78
79
nPhi
const int nPhi
Definition
BesTofDigitizerEcV3.hh:37
nZ
const int nZ
Definition
BesTofDigitizerEcV3.hh:38
nR
const int nR
Definition
BesTofDigitizerEcV3.hh:36
sprintf
sprintf(cut,"kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)
f
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
file
char * file
Definition
DQA_TO_DB.cxx:15
f1
TFile * f1
Definition
DataBase/tau_mode.c:4
x
Double_t x[10]
Definition
DataBase/tau_mode.c:57
n1
int n1
Definition
SD0Tag.cxx:54
t
TTree * t
Definition
binning.cxx:23
y
double y[1000]
Definition
draw_charge_space_coarse_II.cxx:8
writeTree
void writeTree()
Definition
writeTree.cc:3
7.1.2
Simulation
BOOST
TofSim
TofSim-00-02-40
dat
writeTree.cc
Generated by
1.12.0