#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <TFile.h>
#include <TTree.h>
#include <TString.h>
#include <TH1F.h>
#include <TKey.h>
Go to the source code of this file.
Functions | |
int | main (int argc, char *argv[]) |
int main | ( | int | argc, | |
char * | argv[] | |||
) |
Definition at line 15 of file check_hist_entries.cxx.
References next.
00015 { 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 }