Jpp  test_elongated_shower_pde
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JAddHDE.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <fstream>
4 #include <iomanip>
5 
6 #include "JPhysics/JPDFTable.hh"
7 
8 #include "JIO/JFileStreamIO.hh"
9 
10 #include "JTools/JHistogram1D_t.hh"
13 #include "JTools/JFunction1D_t.hh"
15 
16 #include "JGeometry3D/JAngle3D.hh"
17 #include "JGeometry3D/JVersor3D.hh"
18 #include "JPhysics/JConstants.hh"
19 
20 #include "Jeep/JParser.hh"
21 #include "Jeep/JMessage.hh"
22 
24 
25 
26 /**
27  * \file
28  *
29  * Program to add 5-dimensional histograms of shower light
30  * \author jseneca
31  */
32 int main(int argc, char **argv)
33 {
34  using namespace std;
35  using namespace JPP;
36 
37  vector<string> inputFile;
38  string outputFile;
39  int debug;
40 
41  try {
42 
43  JParser<> zap("Program to add multi-dimensional histograms of shower light");
44 
45  zap['f'] = make_field(inputFile);
46  zap['o'] = make_field(outputFile);
47  zap['d'] = make_field(debug) = 1;
48 
49  if (zap.read(argc, argv) != 0)
50  return 1;
51  }
52  catch(const exception &error) {
53  FATAL(error.what() << endl);
54  }
55 
56 
57  typedef JHistogram1D_t::abscissa_type abscissa_type;
58 
59  typedef JTransformableMultiHistogram<JHistogram1D_t,
60  JMAPLIST<JHistogramMap_t,
61  JHistogramMap_t,
62  JHistogramMap_t,
63  JHistogramGridMap_t,
64  JHistogramGridMap_t>::maplist> JMultiHistogram_t;
65 
66  typedef JPDFTransformer<5, abscissa_type> JFunction5DTransformer_t;
67 
68  JMultiHistogram_t h0; // occurrence rate of PMT (used for normalisation)
69  JMultiHistogram_t h1; // light from cascade
70 
71  h1.transformer.reset(new JFunction5DTransformer_t());
72 
73  bool add = false;
74 
75  for(vector<string>::const_iterator file_name = inputFile.begin(); file_name != inputFile.end(); ++file_name) {
76 
77  NOTICE("loading input from file " << *file_name << "... " << flush);
78 
79  try {
80 
81  JFileStreamReader in(file_name->c_str());
82 
83  if (add) {
84 
85  JMultiHistogram_t p0;
86  JMultiHistogram_t p1;
87 
88  p1.transformer.reset(new JFunction5DTransformer_t());
89 
90  for(JMultiHistogram_t* p : { &p0, &p1 }) {
91  in.load(*p);
92  }
93 
94  in.close();
95 
96  NOTICE("done." << endl);
97 
98  // Add new histogram to first histogram
99 
100  double integral1 = 0.0;
101  double integral2 = 0.0;
102 
103  for(JMultiHistogram_t::super_iterator
104  i0 = h0.super_begin(), i1 = h1.super_begin(),
105  j0 = p0.super_begin(), j1 = p1.super_begin(); i1 != h1.super_end(); ++i0, ++i1, ++j0, ++j1) {
106 
107  integral1 += i0.getValue().getIntegral();
108 
109  i0.getValue().add(j0.getValue());
110  i1.getValue().add(j1.getValue());
111 
112  integral2 += i0.getValue().getIntegral();
113  }
114  }
115  else {
116 
117  for(JMultiHistogram_t* p : { &h0, &h1 }) {
118  in.load(*p);
119  }
120 
121  in.close();
122 
123  NOTICE("done." << endl);
124 
125  add = true;
126  }
127  }
128  catch(const JException& error) {
129  FATAL(error.what() << endl);
130  }
131  }
132 
133  JFileStreamWriter out(outputFile.c_str());
134 
135  NOTICE("Storing output to file " << outputFile << "... " << flush);
136 
137  for (const JMultiHistogram_t* p : { &h0, &h1 }) {
138  out.store(*p);
139  }
140 
141  out.close();
142  NOTICE("JAddHDE done." << endl);
143 }
Utility class to parse command line options.
Definition: JParser.hh:1500
int main(int argc, char *argv[])
Definition: Main.cc:15
TPaveText * p1
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:71
string outputFile
Various implementations of functional maps.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
#define NOTICE(A)
Definition: JMessage.hh:64
Physics constants.
JHistogram1D< JElement2D< double, double >, JCollection > JHistogram1D_t
Type definition of a 1 dimensional histogram based on a JCollection.
int debug
debug level
Definition: JSirene.cc:68
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
int read(const int argc, const char *const argv[])
Parse the program&#39;s command line options.
Definition: JParser.hh:1798
Utility class to parse command line options.
collection_type::abscissa_type abscissa_type
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 source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:42