/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Mdc/DedxCalibAlg/DedxCalibAlg-00-01-15/share/shell/genRawScript/check_hist_entries.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 #include <TH1F.h>
00011 #include <TKey.h>
00012 
00013 using namespace std;
00014 
00015 int main(int argc, char *argv[]){
00016   if(argc<3){
00017     cout << "please append a root file name and threshod numbers" << endl;
00018     cout << "Ex. check_hist_ent.exe test.root 1000" << endl;
00019     return 1;
00020   }
00021 
00022   TString str_root_file(argv[1]);
00023   TFile f(str_root_file);
00024   TList *l = f.GetListOfKeys();
00025   double m_min(99999), m_max(0), m_total(0), m_ave(0), m_size(0);
00026   Int_t m_temp;
00027   Int_t m_thres;
00028   TH1F *h(0);
00029   sscanf(argv[2], "%d", &m_thres);
00030   TIter next(l);
00031   TKey *obj(0);
00032   while ((obj = (TKey*)next())){
00033     TString str_temp(obj->GetClassName());
00034     if(str_temp.Contains("TTree")) continue;
00035     m_size += 1;
00036     h = (TH1F*)f.Get(obj->GetName());
00037     m_temp = h->GetEntries();
00038     m_total += m_temp;
00039     if(m_temp<m_min) m_min = m_temp;
00040     if(m_temp>m_max) m_max = m_temp;
00041     if(m_temp<m_thres) cout << h->GetName() << " has entries " << m_temp << " less than threshod" << endl;
00042   }
00043   m_ave = m_total/m_size;
00044   cout << "min: " << m_min << "  max: " << m_max << "  ave: " << m_ave << " size: " << m_size << endl;
00045   return 0;
00046 }

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