BOSS 7.0.1
BESIII Offline Software System
Loading...
Searching...
No Matches
check_hist_entries.cxx File Reference
#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[])
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 15 of file check_hist_entries.cxx.

15 {
16 if(argc<3){
17 cout << "please append a root file name and threshod numbers" << endl;
18 cout << "Ex. check_hist_ent.exe test.root 1000" << endl;
19 return 1;
20 }
21
22 TString str_root_file(argv[1]);
23 TFile f(str_root_file);
24 TList *l = f.GetListOfKeys();
25 double m_min(99999), m_max(0), m_total(0), m_ave(0), m_size(0);
26 Int_t m_temp;
27 Int_t m_thres;
28 TH1F *h(0);
29 sscanf(argv[2], "%d", &m_thres);
30 TIter next(l);
31 TKey *obj(0);
32 while ((obj = (TKey*)next())){
33 TString str_temp(obj->GetClassName());
34 if(str_temp.Contains("TTree")) continue;
35 m_size += 1;
36 h = (TH1F*)f.Get(obj->GetName());
37 m_temp = h->GetEntries();
38 m_total += m_temp;
39 if(m_temp<m_min) m_min = m_temp;
40 if(m_temp>m_max) m_max = m_temp;
41 if(m_temp<m_thres) cout << h->GetName() << " has entries " << m_temp << " less than threshod" << endl;
42 }
43 m_ave = m_total/m_size;
44 cout << "min: " << m_min << " max: " << m_max << " ave: " << m_ave << " size: " << m_size << endl;
45 return 0;
46}
Index next(Index i)
Definition: EvtCyclic3.cc:107