BOSS 7.0.7
BESIII Offline Software System
Loading...
Searching...
No Matches
genRunList.cxx File Reference
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <TFile.h>
#include <TTree.h>
#include <TString.h>

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 13 of file genRunList.cxx.

13 {
14 if(argc<3){
15 cout << "please append path name and root file name [and tree names] [and tag name]" << endl;
16 return 1;
17 }
18
19 TString str_root_file(argv[1]);
20 str_root_file.Append(argv[2]);
21 TFile f(str_root_file);
22 TTree *t(0);
23 if(argc>3) t = (TTree*)f.Get(argv[3]);
24 else{
25 TList *l = f.GetListOfKeys();
26 if(l->GetEntries()<1){
27 cout << "the root file " << argv[2] << " is empty, check it!" << endl;
28 return 1;
29 }
30 else t = (TTree*)f.Get(l->At(0)->GetName());
31 }
32 Long_t m_totnum = t->GetEntries();
33 // double m_run(0), m_event(0), m_cur_run(0);
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);
39 ofstream f_out;
40 cout << "total events: " << m_totnum << endl;
41 for(Long_t i=0; i<m_totnum; i++){
42
43 t->GetEntry(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;
48 if(argc<5){
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);
56 }
57 else{
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);
61 }
62 m_cur_run = m_run;
63 }
64 if(!f_out.is_open()){ cout << "cannot open file " << endl; return 1; }
65 f_out << (long)m_run << " " << (long)m_event << endl;
66 // cout << (long)m_run << " " << (long)m_event << endl;
67 }
68 f_out.close();
69
70 return 0;
71}
TTree * t
Definition: binning.cxx:23
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")
std::ofstream ofstream
Definition: bpkt_streams.h:42