Jpp  18.0.0-rc.2
the software that should make you happy
 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 #include "TError.h"
11 
12 #include "JPhysics/JPDFTypes.hh"
13 
14 #include "Jeep/JPrint.hh"
15 #include "Jeep/JParser.hh"
16 #include "Jeep/JMessage.hh"
17 
18 
19 /**
20  * \file
21  *
22  * Auxiliary program to print JSirene.cc job statistics.
23  * \author mdejong
24  */
25 int main(int argc, char **argv)
26 {
27  using namespace std;
28 
29  string inputFile;
30  int debug;
31 
32  try {
33 
34  JParser<> zap("Auxiliary program to print JSirene job statistics.");
35 
36  zap['f'] = make_field(inputFile);
37  zap['d'] = make_field(debug) = 2;
38 
39  zap(argc, argv);
40  }
41  catch(const exception &error) {
42  FATAL(error.what() << endl);
43  }
44 
45 
46  gErrorIgnoreLevel = kError;
47 
48  TFile* in = TFile::Open(inputFile.c_str(), "exist");
49 
50  if (in == NULL || !in->IsOpen()) {
51  FATAL("File: " << inputFile << " not opened." << endl);
52  }
53 
54 
55  TH1D* job = dynamic_cast<TH1D*>(in->Get("job"));
56 
57  if (job == NULL) {
58  FATAL("No job statistics.");
59  }
60 
61  using namespace JPP;
62 
63  const int hit_types[] = {
64  DIRECT_LIGHT_FROM_MUON, // muon
70 
71  DIRECT_LIGHT_FROM_MUON + 20, // tau
72  SCATTERED_LIGHT_FROM_MUON + 20, //
73  DIRECT_LIGHT_FROM_DELTARAYS + 20, //
74  SCATTERED_LIGHT_FROM_DELTARAYS + 20, //
75 
76  DIRECT_LIGHT_FROM_EMSHOWER + 40, // electrons/hadrons
77  SCATTERED_LIGHT_FROM_EMSHOWER + 40, //
78 
79  -1 // end marker
80  };
81 
82 
83  typedef map<int, string> map_type;
84 
85  map_type zmap;
86 
87  zmap[100] = "Number of photons";
88  zmap[200] = "Number of errors";
89  zmap[300] = "Number of misses";
90 
91 
92  NOTICE("Job summary" << endl);
93 
94  NOTICE(LEFT(40) << "Number of events input " << RIGHT(10) << (int) job->GetBinContent( 1) << endl);
95  NOTICE(LEFT(40) << "Number of muons " << RIGHT(10) << (int) job->GetBinContent( 2) << endl);
96  NOTICE(LEFT(40) << "Number of muons in can " << RIGHT(10) << (int) job->GetBinContent( 3) << endl);
97  NOTICE(LEFT(40) << "Number of muons within road " << RIGHT(10) << (int) job->GetBinContent( 4) << endl);
98  NOTICE(LEFT(40) << "Number of decayed particles (i.e. tau) " << RIGHT(10) << (int) job->GetBinContent( 6) << endl);
99  NOTICE(LEFT(40) << "Number of detectable decayed particles " << RIGHT(10) << (int) job->GetBinContent( 7) << endl);
100  NOTICE(LEFT(40) << "Number of electrons/hadrons " << RIGHT(10) << (int) job->GetBinContent( 8) << endl);
101  NOTICE(LEFT(40) << "Number of detectable electrons/hadrons " << RIGHT(10) << (int) job->GetBinContent( 9) << endl);
102  NOTICE(LEFT(40) << "Number of events output " << RIGHT(10) << (int) job->GetBinContent( 10) << endl);
103  NOTICE(LEFT(40) << "Number of unknown particles " << RIGHT(10) << (int) job->GetBinContent( 21) << endl);
104 
105  for (map_type::const_iterator entry = zmap.begin(); entry != zmap.end(); ++entry) {
106  NOTICE(endl);
107  for (const int* i = hit_types; *i != -1; ++i) {
108  NOTICE(""
109  << LEFT (19) << entry->second << FILL(1)
110  << RIGHT( 2) << *i << FILL(8)
111  << FILL (10)
112  << RIGHT(10) << (int) job->GetBinContent(entry->first + *i) << endl);
113  }
114  }
115 
116  in->Close();
117 }
Utility class to parse command line options.
Definition: JParser.hh:1514
int main(int argc, char *argv[])
Definition: Main.cc:15
scattered light from EM shower
Definition: JPDFTypes.hh:38
direct light from muon
Definition: JPDFTypes.hh:26
Numbering scheme for PDF types.
scattered light from muon
Definition: JPDFTypes.hh:27
I/O formatting auxiliaries.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
scattered light from delta-rays
Definition: JPDFTypes.hh:33
#define NOTICE(A)
Definition: JMessage.hh:64
direct light from EM shower
Definition: JPDFTypes.hh:37
General purpose messaging.
Auxiliary data structure for sequence of same character.
Definition: JManip.hh:328
#define FATAL(A)
Definition: JMessage.hh:67
direct light from delta-rays
Definition: JPDFTypes.hh:32
Utility class to parse command line options.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
int debug
debug level