Jpp  18.6.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JPrintDomino.cc File Reference

Auxiliary program to print JDomino.cc statistics. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "JAAnet/JAAnetToolkit.hh"
#include "JAAnet/JPDB.hh"
#include "Jeep/JeepToolkit.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program to print JDomino.cc statistics.

Author
mdejong

Definition in file JPrintDomino.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 26 of file JPrintDomino.cc.

27 {
28  using namespace std;
29 
30  vector<string> inputFile;
31  bool combine;
32  int debug;
33 
34  try {
35 
36  JParser<> zap("Auxiliary program to print JDomino statistics.");
37 
38  zap['f'] = make_field(inputFile);
39  zap['c'] = make_field(combine);
40  zap['d'] = make_field(debug) = 2;
41 
42  zap(argc, argv);
43  }
44  catch(const exception &error) {
45  FATAL(error.what() << endl);
46  }
47 
48  using namespace JPP;
49 
50  vector<TH1D*> buffer;
51 
52  for (vector<string>::const_iterator file_name = inputFile.begin(); file_name != inputFile.end(); ++file_name) {
53 
54  TFile* in = TFile::Open(file_name->c_str(), "exist");
55 
56  if (in == NULL || !in->IsOpen()) {
57  FATAL("File: " << *file_name << " not opened." << endl);
58  }
59 
60  TH1D* job = dynamic_cast<TH1D*>(in->Get("job"));
61 
62  if (job == NULL) {
63  FATAL("No job statistics.");
64  }
65 
66  buffer.push_back(job);
67  }
68 
69 
70  if (!buffer.empty()) {
71 
72  const int WIDTH = 32;
73 
74  DEBUG(setw(6) << ' ' << ' ' << FILL(WIDTH, ' '));
75 
76  for (vector<string>::const_iterator file_name = inputFile.begin(); file_name != inputFile.end(); ++file_name) {
77  DEBUG(' ' << setw(12) << getFilename(*file_name));
78  }
79  DEBUG(endl);
80 
81  TH1D* h0 = buffer[0];
82 
83  for (int i0 = 1; i0 <= h0->GetNbinsX(); ++i0) {
84 
85  const Double_t x = h0->GetBinCenter(i0);
86  const int type = (int) x;
87  const Int_t i1 = h0->FindBin(-x);
88 
89  if (combine) {
90  if (type > 0) {
91  break;
92  }
93  }
94 
95  double W = 0.0;
96 
97  for (vector<TH1D*>::iterator h1 = buffer.begin(); h1 != buffer.end(); ++h1) {
98  W += (combine ? (*h1)->GetBinContent(i0) + (*h1)->GetBinContent(i1) : (*h1)->GetBinContent(i0));
99  }
100 
101  if (W > 0.0 || JPDB::getInstance().hasPDG(combine ? abs(type) : type)) {
102 
103  NOTICE(setw(6) << right << (combine ? abs(type) : type));
104 
105  try {
106 
107  JParticle particle = JPDB::getInstance().getPDG(combine ? abs(type) : type);
108 
109  NOTICE(' ' << setw(WIDTH) << left << particle.name);
110  }
111  catch(const exception& error) {
112 
113  NOTICE(' ' << setw(WIDTH) << left << "unknown");
114  }
115 
116  for (vector<TH1D*>::iterator h1 = buffer.begin(); h1 != buffer.end(); ++h1) {
117  NOTICE(noshowpos << ' ' << FIXED(12,6) << (combine ? (*h1)->GetBinContent(i0) + (*h1)->GetBinContent(i1) : (*h1)->GetBinContent(i0)));
118  }
119 
120  NOTICE(endl);
121  }
122  }
123  }
124 }
Auxiliary data structure for alignment of data.
Definition: JManip.hh:231
Utility class to parse command line options.
Definition: JParser.hh:1711
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
then set_variable PMT_FILE set_variable DAQ_FILE set_variable OUTPUT_FILE set_variable DETECTOR else fatal Wrong number of arguments fi JPrintTree f $DAQ_FILE type
T & getInstance(const T &object)
Get static instance from temporary object.
Definition: JObject.hh:75
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
#define NOTICE(A)
Definition: JMessage.hh:64
Auxiliary data structure for sequence of same character.
Definition: JManip.hh:328
JRange< T, JComparator_t > combine(const JRange< T, JComparator_t > &first, const JRange< T, JComparator_t > &second)
Combine ranges.
Definition: JRange.hh:676
#define FATAL(A)
Definition: JMessage.hh:67
then fatal The output file must have the wildcard in the e g root fi 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:48
std::string getFilename(const std::string &file_name)
Get file name part, i.e. part after last JEEP::PATHNAME_SEPARATOR if any.
Definition: JeepToolkit.hh:128
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62