check_file_success_rate.C
Go to the documentation of this file.
1 #include "TH1.h"
2 #include "TLegend.h"
3 #include "TPad.h"
4 
5 #include <iostream>
6 #include <string>
7 #include <vector>
8 
9 #include <sys/types.h>
10 #include <sys/stat.h>
11 #include <unistd.h>
12 
13 void check_file_success_rate(char* elem, int stride = 50)
14 {
15  const std::vector<std::string> names = {"cc/nu_mu", "cc/nu_mu_bar", "cc/nu_e", "cc/nu_e_bar", "nc/nu", "nc/nu_bar"};
16  const int cols[6] = {kBlack, kRed, kGreen+2, kBlue, kMagenta, kOrange};
17  int colIdx = 0;
18 
19  TLegend* leg = new TLegend(.15, .15, .5, .5);
20  leg->SetFillStyle(0);
21 
22  bool once = true;
23 
24  for(std::string name: names){
25  TH1* h = new TH1I("", ";Process;Number of files", 100, 0, 10000);
26  h->SetLineColor(cols[colIdx++]);
27  h->SetDirectory(0);
28 
29  for(int i = 0; i < 10000; i += stride){
30  std::cout << name << " " << i << std::endl;
31 
32  const TString fname = TString::Format("/pnfs/nova/scratch/users/bckhouse/gibuu2019_sigmacut/%s/%s/%d/EventOutput.Lib.00000001.root", elem, name.c_str(), i);
33  struct stat junk;
34  if(stat(fname.Data(), &junk) != 0) continue;
35 
36  h->Fill(i);
37  }
38 
39  leg->AddEntry(h, name.c_str(), "l");
40 
41  h->Draw(once ? "hist" : "hist same");
42  if(once) leg->Draw();
43  once = false;
44 
45  gPad->Update();
46  }
47 
48  gPad->Print(TString::Format("success_rate_%s.pdf", elem).Data());
49 }
const XML_Char * name
Definition: expat.h:151
enum BeamMode kOrange
enum BeamMode kRed
void check_file_success_rate(char *elem, int stride=50)
const int cols[3]
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 kGreen
enum BeamMode kBlue
enum BeamMode string