Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JPrintSirene.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 #include <map>
6 
7 #include "TROOT.h"
8 #include "TFile.h"
9 #include "TH1D.h"
10 
11 #include "JPhysics/JPDFTypes.hh"
12 
13 #include "Jeep/JPrint.hh"
14 #include "Jeep/JParser.hh"
15 #include "Jeep/JMessage.hh"
16 
17 
18 /**
19  * \file
20  *
21  * Auxiliary program to print JSirene.cc job statistics.
22  * \author mdejong
23  */
24 int main(int argc, char **argv)
25 {
26  using namespace std;
27 
28  string inputFile;
29  int debug;
30 
31  try {
32 
33  JParser<> zap("Auxiliary program to print JSirene job statistics.");
34 
35  zap['f'] = make_field(inputFile);
36  zap['d'] = make_field(debug) = 2;
37 
38  zap(argc, argv);
39  }
40  catch(const exception &error) {
41  FATAL(error.what() << endl);
42  }
43 
44 
45  TFile* in = TFile::Open(inputFile.c_str(), "exist");
46 
47  if (in == NULL || !in->IsOpen()) {
48  FATAL("File: " << inputFile << " not opened." << endl);
49  }
50 
51 
52  TH1D* job = dynamic_cast<TH1D*>(in->Get("job"));
53 
54  if (job == NULL) {
55  FATAL("No job statistics.");
56  }
57 
58  using namespace JPP;
59 
60  const int hit_types[] = {
61  DIRECT_LIGHT_FROM_MUON, // muon
67 
68  DIRECT_LIGHT_FROM_MUON + 20, // tau
69  SCATTERED_LIGHT_FROM_MUON + 20, //
70  DIRECT_LIGHT_FROM_DELTARAYS + 20, //
71  SCATTERED_LIGHT_FROM_DELTARAYS + 20, //
72 
73  DIRECT_LIGHT_FROM_EMSHOWER + 40, // electrons/hadrons
74  SCATTERED_LIGHT_FROM_EMSHOWER + 40, //
75 
76  -1 // end marker
77  };
78 
79 
80  typedef map<int, string> map_type;
81 
82  map_type zmap;
83 
84  zmap[100] = "Number of photons";
85  zmap[200] = "Number of errors";
86  zmap[300] = "Number of misses";
87 
88 
89  NOTICE("Job summary" << endl);
90 
91  NOTICE(LEFT(40) << "Number of events input " << RIGHT(10) << (int) job->GetBinContent( 1) << endl);
92  NOTICE(LEFT(40) << "Number of muons " << RIGHT(10) << (int) job->GetBinContent( 2) << endl);
93  NOTICE(LEFT(40) << "Number of muons in can " << RIGHT(10) << (int) job->GetBinContent( 3) << endl);
94  NOTICE(LEFT(40) << "Number of muons within road " << RIGHT(10) << (int) job->GetBinContent( 4) << endl);
95  NOTICE(LEFT(40) << "Number of taus " << RIGHT(10) << (int) job->GetBinContent( 6) << endl);
96  NOTICE(LEFT(40) << "Number of detectable taus " << RIGHT(10) << (int) job->GetBinContent( 7) << endl);
97  NOTICE(LEFT(40) << "Number of electrons/hadrons " << RIGHT(10) << (int) job->GetBinContent( 8) << endl);
98  NOTICE(LEFT(40) << "Number of detectable electrons/hadrons " << RIGHT(10) << (int) job->GetBinContent( 9) << endl);
99  NOTICE(LEFT(40) << "Number of events output " << RIGHT(10) << (int) job->GetBinContent( 10) << endl);
100  NOTICE(LEFT(40) << "Number of unknown particles " << RIGHT(10) << (int) job->GetBinContent( 21) << endl);
101 
102  for (map_type::const_iterator entry = zmap.begin(); entry != zmap.end(); ++entry) {
103  NOTICE(endl);
104  for (const int* i = hit_types; *i != -1; ++i) {
105  NOTICE(""
106  << LEFT (19) << entry->second << FILL(1)
107  << RIGHT( 2) << *i << FILL(8)
108  << FILL (10)
109  << RIGHT(10) << (int) job->GetBinContent(entry->first + *i) << endl);
110  }
111  }
112 
113  in->Close();
114 }
Utility class to parse command line options.
Definition: JParser.hh:1410
scattered light from EM shower
Definition: JPDFTypes.hh:41
direct light from muon
Definition: JPDFTypes.hh:29
Numbering scheme for PDF types.
scattered light from muon
Definition: JPDFTypes.hh:30
I/O formatting auxiliaries.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
scattered light from delta-rays
Definition: JPDFTypes.hh:36
#define NOTICE(A)
Definition: JMessage.hh:62
direct light from EM shower
Definition: JPDFTypes.hh:40
int debug
debug level
Definition: JSirene.cc:59
General purpose messaging.
Auxiliary data structure for sequence of same character.
Definition: JPrint.hh:342
#define FATAL(A)
Definition: JMessage.hh:65
direct light from delta-rays
Definition: JPDFTypes.hh:35
Utility class to parse command line options.
int main(int argc, char *argv[])
Definition: Main.cpp:15