13int main(
int argc,
char* argv[]){
15 cout <<
"please append path name and root file name [and tree names] [and tag name]" << endl;
19 TString str_root_file(argv[1]);
20 str_root_file.Append(argv[2]);
21 TFile
f(str_root_file);
23 if(argc>3)
t = (TTree*)
f.Get(argv[3]);
25 TList *l =
f.GetListOfKeys();
26 if(l->GetEntries()<1){
27 cout <<
"the root file " << argv[2] <<
" is empty, check it!" << endl;
30 else t = (TTree*)
f.Get(l->At(0)->GetName());
32 Long_t m_totnum =
t->GetEntries();
34 int m_run(0), m_event(0), m_cur_run(0);
35 char str_run_name[20];
36 TString str_run_name_II(
"");
37 t->SetBranchAddress(
"run", &m_run);
38 t->SetBranchAddress(
"event", &m_event);
40 cout <<
"total events: " << m_totnum << endl;
41 for(Long_t i=0; i<m_totnum; i++){
44 if(i%10000==0) cout <<
"i = " << i <<
" run: " << m_run <<
" event: " << m_event << endl;
45 if(m_run != m_cur_run && m_run>1){
46 if(f_out.is_open()) f_out.close();
47 int m_temp_run = (int)m_run;
49 sprintf(str_run_name,
"%d.txt", m_temp_run);
50 str_run_name_II = argv[2];
51 str_run_name_II.ReplaceAll(
"_",
"");
52 str_run_name_II.ReplaceAll(
".root",
"_runnumber");
53 str_run_name_II.ReplaceAll(
"runnumber", str_run_name);
54 cout <<
"run file: " << str_run_name_II << endl;
55 f_out.open(str_run_name_II, ios::app);
58 sprintf(str_run_name,
"%s_%d.txt", argv[4], m_temp_run);
59 cout <<
"run file: " << str_run_name << endl;
60 f_out.open(str_run_name, ios::app);
64 if(!f_out.is_open()){ cout <<
"cannot open file " << endl;
return 1; }
65 f_out << (long)m_run <<
" " << (
long)m_event << endl;
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")