Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:30:22

0001 #include <vector>
0002 #include <string>
0003 #include <algorithm>
0004 #include <iostream>
0005 #include <iomanip>
0006 
0007 #include "TFile.h"
0008 #include "TTree.h"
0009 #include "TList.h"
0010 #include "TIterator.h"
0011 
0012 void print_rates(TFile * file) {
0013   TTree * tree = (TTree *) file->Get("l1uGTTree/L1uGTTree");
0014 
0015   // extract the list of Aliases
0016   std::vector<std::string> names;
0017   TList * aliases = tree->GetListOfAliases();
0018   TIter iter(aliases);
0019   std::for_each(iter.Begin(), TIter::End(), [&](TObject* alias){ names.push_back(alias->GetName()); } );
0020 
0021   unsigned long long entries = tree->GetEntries();
0022   if (entries == 0)
0023     return;
0024 
0025   int digits = std::log(entries) / std::log(10) + 1;
0026   for (auto const & name: names) {
0027     unsigned long long counts = tree->GetEntries(name.c_str());
0028     std::cout << std::setw(digits) << counts << " / " << std::setw(digits) << entries << "  " << name << std::endl;
0029   }
0030 }
0031 
0032 
0033 int main(int argc, char** argv) {
0034   if (argc < 2)
0035     return 0;
0036 
0037   TFile * file = TFile::Open(argv[1]);
0038   print_rates(file);
0039 }