BOSS 7.0.5
BESIII Offline Software System
Loading...
Searching...
No Matches
getMinMax.cxx
Go to the documentation of this file.
1#include <iostream>
2#include <fstream>
3#include <iomanip>
4#include <cstring>
5#include <string>
6#include <vector>
7#include <TFile.h>
8#include <TTree.h>
9#include <TString.h>
10
11using namespace std;
12
13// int main(int argc, char* argv[]){
14// char runlist[200];
15// char rawlist[200];
16// if(argc > 2){
17// sscanf(argv[1], "%s", runlist);
18// sscanf(argv[2], "%s", rawlist);
19// } else {
20// cout << "too few arguments" << endl;
21// return 0;
22// }
23
24int main(int argc, char *argv[]){
25 if(argc<2){
26 cout << "please append a root file name " << endl;
27 return 1;
28 }
29
30 TString str_root_file(argv[1]);
31 str_root_file.Append(argv[2]);
32 TFile f(str_root_file);
33 TTree *t(0);
34 if(argc>3) t = (TTree*)f.Get(argv[3]);
35 else{
36 TList *l = f.GetListOfKeys();
37 if(l->GetEntries()<1){
38 cout << "the root file " << argv[2] << " is empty, check it!" << endl;
39 return 1;
40 }
41 else t = (TTree*)f.Get(l->At(0)->GetName());
42 }
43 Long_t m_totnum = t->GetEntries();
44 double m_run(0), m_min(9999999), m_max(0), m_cur_run(0);
45 t->SetBranchAddress("run", &m_run);
46
47 for(Long_t i=0; i<m_totnum; i++){
48 t->GetEntry(i);
49 if(i%10000==0) cout << "i = " << i << " run: " << m_run << endl;
50 if(m_run != m_cur_run && m_run>1){
51 if(m_min>m_run) m_min=m_run;
52 if(m_max<m_run) m_max=m_run;
53 m_cur_run = m_run;
54 }
55 }
56 cout << "min " << (long)m_min << " max " << (long)m_max << endl;
57
58 return 0;
59}
60
TTree * t
Definition: binning.cxx:23
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
int main()
Definition: test_IFile.cxx:11