susy_cfa  b611ccad937ea179f86a1f5663960264616c0a20
view_provenance.cxx
Go to the documentation of this file.
1 #include <iostream>
2 
3 #include "TFile.h"
4 #include "TTree.h"
5 #include "TString.h"
6 
7 #include "utilities.hpp"
8 
9 using namespace std;
10 
11 int main(int argc, char *argv[]){
12  for(int arg = 1; arg < argc; ++arg){
13  TFile file(argv[arg],"read");
14  if(file.IsZombie() || !file.IsOpen()){
15  cerr << "Could not open " << argv[arg] << '\n' << endl;
16  continue;
17  }
18 
19  TTree *tree = NULL;
20  file.GetObject("treeglobal", tree);
21  if(!tree){
22  cerr << "Could not find \"treeglobal\" in " << argv[arg] << '\n' << endl;
23  continue;
24  }
25 
26  TString *model = NULL;
27  TString *commit = NULL;
28  TString *type = NULL;
29  int nev_file = -1;
30  int nev_sample = -1;
31 
32  tree->SetBranchAddress("model", &model);
33  tree->SetBranchAddress("type", &type);
34  tree->SetBranchAddress("nev_file", &nev_file);
35  tree->SetBranchAddress("nev_sample", &nev_sample);
36  tree->SetBranchAddress("commit", &commit);
37 
38  const int num_entries = tree->GetEntries();
39  if(num_entries <= 0){
40  cerr << "\"treeglobal\" has no entries in " << argv[arg] << '\n' << endl;
41  continue;
42  }else if(num_entries > 1){
43  cerr << "\"treeglobal has multiple entries in " << argv[arg] << '\n' << endl;
44  continue;
45  }
46 
47  const int bytes_read = tree->GetEntry(0);
48  if(bytes_read <= 0){
49  cerr << "\"Could not get entry 0 from \"treeglobal\" in " << argv[arg] << '\n' << endl;
50  continue;
51  }
52 
53  if(!model){
54  cerr << "Read a null pointer for model string in " << argv[arg] << '\n' << endl;
55  continue;
56  }
57 
58  if(!commit){
59  cerr << "Read a null pointer for commit string in " << argv[arg] << '\n' << endl;
60  continue;
61  }
62 
63  if(!type){
64  cerr << "Read a null pointer for type string in " << argv[arg] << '\n' << endl;
65  continue;
66  }
67 
68  cout << " File: " << argv[arg] << endl;
69  cout << " Model: " << RemoveTrailingNewlines(model->Data()) << endl;
70  cout << " File Entries: " << nev_file << endl;
71  cout << "Sample Entries: " << nev_sample << endl;
72  cout << " Git Commit: " << RemoveTrailingNewlines(commit->Data()) << endl;
73  cout << " File Type: " << RemoveTrailingNewlines(type->Data()) << '\n' << endl;
74 
75  file.Close();
76  }
77 }
STL namespace.
std::string RemoveTrailingNewlines(std::string str)
Definition: utilities.cpp:348
int main(int argc, char *argv[])