/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Mdc/DedxCalibAlg/DedxCalibAlg-00-01-15/share/shell/genRawScript/getMinMax.cxx

Go to the documentation of this file.
00001 #include <iostream>
00002 #include <fstream>
00003 #include <iomanip>
00004 #include <cstring>
00005 #include <string>
00006 #include <vector>
00007 #include <TFile.h>
00008 #include <TTree.h>
00009 #include <TString.h>
00010 
00011 using namespace std;
00012 
00013 // int main(int argc, char* argv[]){
00014 //      char runlist[200];
00015 //      char rawlist[200];
00016 //      if(argc > 2){
00017 //        sscanf(argv[1], "%s", runlist);
00018 //        sscanf(argv[2], "%s", rawlist);
00019 //      } else {
00020 //        cout << "too few arguments" << endl;
00021 //        return 0;
00022 //      }
00023 
00024 int main(int argc, char *argv[]){
00025   if(argc<2){
00026     cout << "please append a root file name " << endl;
00027     return 1;
00028   }
00029 
00030   TString str_root_file(argv[1]);
00031   str_root_file.Append(argv[2]);
00032   TFile f(str_root_file);
00033   TTree *t(0);
00034   if(argc>3) t = (TTree*)f.Get(argv[3]);
00035   else{
00036     TList *l = f.GetListOfKeys();
00037     if(l->GetEntries()<1){ 
00038       cout << "the root file " << argv[2] << " is empty, check it!" << endl;
00039       return 1;
00040     }
00041     else t = (TTree*)f.Get(l->At(0)->GetName());
00042   }
00043   Long_t m_totnum = t->GetEntries();
00044   double m_run(0), m_min(9999999), m_max(0), m_cur_run(0);
00045   t->SetBranchAddress("run", &m_run);
00046 
00047   for(Long_t i=0; i<m_totnum; i++){
00048     t->GetEntry(i);
00049     if(i%10000==0) cout << "i = " << i << "   run: " << m_run  << endl; 
00050     if(m_run != m_cur_run && m_run>1){
00051       if(m_min>m_run) m_min=m_run;
00052       if(m_max<m_run) m_max=m_run;
00053       m_cur_run = m_run;
00054     }
00055   }
00056   cout << "min " << (long)m_min << "  max " << (long)m_max << endl;
00057 
00058   return 0;
00059 }
00060 

Generated on Tue Nov 29 23:12:45 2016 for BOSS_7.0.2 by  doxygen 1.4.7