BOSS 7.0.2
BESIII Offline Software System
Loading...
Searching...
No Matches
getMinMax.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 24 of file getMinMax.cxx.

24 {
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}
int t()
Definition: t.c:1