count_library_stats.C
Go to the documentation of this file.
1 #include "TFile.h"
2 #include "TTree.h"
3 
4 #include <iostream>
5 #include <fstream>
6 
8 {
9  TFile fin(fname.c_str());
10 
11  std::ofstream fout("lib_stats.tex");
12 
13  fout << "\\begin{tabular}{r|rr|rr|rr|rr}" << std::endl;
14  fout << "& \\multicolumn{2}{c|}{$\\nu_\\mu$} & \\multicolumn{2}{c|}{$\\bar\\nu_\\mu$} & \\multicolumn{2}{c|}{$\\nu_e$} & \\multicolumn{2}{c}{$\\bar\\nu_e$} \\\\" << std::endl;
15  for(int i = 0; i < 4; ++i)
16  fout << " & \\multicolumn{1}{|c}{CC} & \\multicolumn{1}{c}{NC}";
17  fout << "\\\\" << std::endl << "\\hline" << std::endl;
18 
19  for(std::string tgt: {"H1", "C12", "O16", "Cl35", "Ti48", "Fe56"}){
20  fout << tgt;
21  for(std::string probe: {"nu_mu", "nu_mu_bar", "nu_e", "nu_e_bar"}){
22  for(std::string current: {"cc", "nc"}){
23  TTree* tr = (TTree*)fin.Get(TString::Format("%s/%s/%s/records",
24  tgt.c_str(),
25  probe.c_str(),
26  current.c_str()).Data());
27  const int N = tr ? tr->GetEntries() : 0;
28  std::cout << tgt << " " << probe << " " << current << " " << N << std::endl;
29  if(N == 0){
30  fout << " & --";
31  }
32  else{
33  if(N < 1000000)
34  fout << " & " << N/1000 << "k";
35  else
36  fout << " & " << N/1000000 << "m";
37  }
38  }
39  }
40  fout << "\\\\" << std::endl;
41  } // end for tgt
42 
43  fout << "\\end{tabular}" << std::endl;
44 
45  std::cout << "Wrote lib_stats.tex" << std::endl;
46 }
TString fin
Definition: Style.C:24
void count_library_stats(std::string fname)
OStream cout
Definition: OStream.cxx:6
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
enum BeamMode string