BOSS 8.0.0
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
3void 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 {
24 rBin = i;
25 for ( Int_t j = 0; j < nPhi; j++ )
26 {
27 phiBin = j;
28 for ( Int_t k = 0; k < nZ; k++ )
29 {
30 int rPos = 400 + i * 10;
32 "/ihepbatch/besd12/liuy/EndcapTof/OpInETof2/results/%d/timeSta_%d_%d_%d.root",
33 rPos, rPos, j, k );
34 // if(access(file,F_OK) < 0) // Check if the file exists or not. Thx to zoujh.
35 //{
36 // cout << "The file does NOT exist!" << endl;
37 // continue;
38 // }
39 // else
40 //{
41 cout << "The file:" << file << endl;
42 TFile* f1 = TFile::Open( file );
43 TNtuple* n1 = (TNtuple*)f1->Get( "timeTuple" );
44 n1->SetBranchAddress( "inTimePre", &t1 );
45 int nEntries = (Int_t)n1->GetEntries();
46 cout << "nEntries:" << nEntries << "\n" << endl;
47
48 for ( int m = 0; m < nEntries; m++ )
49 {
50 n1->GetEntry( m );
51 h1->Fill( t1 );
52 }
53 double norm = h1->Integral();
54 efficiency0 = norm / 2000000.; // 200 events per run ; 10k photons per event
55 // cout << "norm:" << norm << "; efficiency0: " << efficiency0 << "\n" << endl;
56 if ( norm != 0 ) h1->Scale( 1. / norm );
57 else
58 {
59 cout << "The eff is null!" << endl;
60 continue;
61 }
62 TAxis* xaxis = h1->GetXaxis();
63 for ( int m = 0; m < 400; m++ )
64 {
65 x[m] = xaxis->GetBinCenter( m );
66 y[m] = h1->GetBinContent( m );
67 }
68 f1->Close();
69
70 zBin = k;
71 t->Fill();
72 //}
73 }
74 }
75 }
76 TFile* f = new TFile( "effTree.root", "recreate" );
77 cout << "TTree write" << endl;
78 t->Write();
79 f->Close();
80}
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)
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
char * file
Definition DQA_TO_DB.cxx:16
TFile * f1
int n1
Definition SD0Tag.cxx:58
int t()
Definition t.c:1
void writeTree()
Definition writeTree.cc:3