22#define mass_e 0.511e-3
23#define mass_mu 105.658e-3
24#define mass_pi 139.570e-3
25#define mass_k 493.677e-3
26#define mass_p 938.272e-3
31void collect(TString filename,
int type, TTree *tree);
35 TFile *
f =
new TFile(
"pre_data.root",
"recreate");
36 TTree *
t =
new TTree(
"n103",
"predata");
37 t->Branch(
"dEdx_meas", &
dEdx_meas,
"dEdx_meas/f");
38 t->Branch(
"costheta", &
costheta,
"costheta/f");
39 t->Branch(
"charge", &
charge,
"charge/f");
40 t->Branch(
"bg", &
bg,
"bg/f");
41 t->Branch(
"nhits", &
nhits,
"nhits/I");
42 t->Branch(
"dEdx_hit",
dEdx_hit,
"dEdx_hit[nhits]/f");
45 cout <<
"begin to collect data" << endl;
46 collect(
"../hadron_track/proton/proton.root", 0,
t);
47 cout <<
"proton collected" << endl;
48 collect(
"../hadron_track/kaon/kaon.root", 1,
t);
49 cout <<
"kaon collected" << endl;
50 collect(
"../hadron_track/pion/pion.root", 2,
t);
51 cout <<
"pion collected" << endl;
52 collect(
"../hadron_track/muon/muon.root", 3,
t);
53 cout <<
"muon collected" << endl;
54 collect(
"../hadron_track/electron/electron.root", 4,
t);
55 cout <<
"electron collected" << endl;
66void collect(TString filename,
int type, TTree *
t){
67 TFile *ff =
new TFile(filename);
68 TTree* trk = (TTree*)ff->Get(
"n103");
69 trk->SetBranchAddress(
"dEdx_meas", &
dEdx_meas);
70 trk->SetBranchAddress(
"ptrk", &
ptrk);
71 trk->SetBranchAddress(
"costheta", &
costheta);
72 trk->SetBranchAddress(
"charge", &
charge);
73 trk->SetBranchAddress(
"ndedxhit", &
nhits);
74 trk->SetBranchAddress(
"dEdx_hit",
dEdx_hit);
94 cout <<
"Error: no such sample type!" << endl;
97 int m_ntot = trk->GetEntries();
99 for (
int i = 0; i <
m_ntot; i++){
101 if (type == 0 &&
dEdx_meas < 500)
continue;
102 if (type == 4 &&
dEdx_meas > 1200)
continue;
103 if(ptrk <= 0 || ptrk > 2.3)
continue;
104 if(fabs(
costheta) >= 0.93)
continue;
112 TFile *
f =
new TFile(
"pre_data.root");
113 TTree *
t = (TTree*)
f->Get(
"n103");
114 bool small_flag(
true);
121 cout <<
"now: " << current << endl;
123 accu =
t->GetEntries(Form(
"bg>=%f && bg<%f", current, current+step));
125 if(accu > threshold){
126 cout <<
"point: " << current <<
" events: " << accu << endl;
131 accu =
t->GetEntries(Form(
"bg>=%f && bg<%f", current, current+step));
133 if(accu < threshold){
134 cout <<
"point: " << current <<
" events: " << accu << endl;
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
********INTEGER modcns REAL m_twom24 INTEGER m_ntot
void collect(TString filename, int type, TTree *tree)