Jpp
Functions
JAddHDE.cc File Reference
#include <string>
#include <iostream>
#include <fstream>
#include <iomanip>
#include "JPhysics/JPDFTable.hh"
#include "JIO/JFileStreamIO.hh"
#include "JTools/JHistogram1D_t.hh"
#include "JTools/JHistogramMap_t.hh"
#include "JTools/JTransformableMultiHistogram.hh"
#include "JTools/JFunction1D_t.hh"
#include "JTools/JFunctionalMap_t.hh"
#include "JGeometry3D/JAngle3D.hh"
#include "JGeometry3D/JVersor3D.hh"
#include "JTools/JConstants.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
#include "JPhysics/JPDFTransformer.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Program to add 5-dimensional histograms of shower light

Author
jseneca

Definition in file JAddHDE.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 32 of file JAddHDE.cc.

33 {
34  using namespace std;
35  using namespace JPP;
36 
37  vector<string> inputFile;
38  string outputFile;
39  string outputSuffix;
40  int debug;
41 
42  try {
43 
44  JParser<> zap("Program to add multi-dimensional histograms of shower light");
45 
46  zap['f'] = make_field(inputFile);
47  zap['o'] = make_field(outputFile);
48  zap['d'] = make_field(debug) = 1;
49 
50  if (zap.read(argc, argv) != 0)
51  return 1;
52  }
53  catch(const exception &error) {
54  FATAL(error.what() << endl);
55  }
56 
57 
58  typedef JHistogram1D_t::abscissa_type abscissa_type;
59 
60  typedef JTransformableMultiHistogram<JHistogram1D_t,
61  JMAPLIST<JHistogramMap_t,
62  JHistogramMap_t,
63  JHistogramMap_t,
64  JHistogramGridMap_t,
65  JHistogramGridMap_t>::maplist> JMultiHistogram_t;
66 
67  typedef JPDFTransformer<5, abscissa_type> JFunction5DTransformer_t;
68 
69  JMultiHistogram_t h0; // occurrence rate of PMT (used for normalisation)
70  JMultiHistogram_t h1; // light from cascade
71 
72  h1.transformer.reset(new JFunction5DTransformer_t());
73 
74  bool add = false;
75 
76  for(vector<string>::const_iterator file_name = inputFile.begin(); file_name != inputFile.end(); ++file_name) {
77 
78  NOTICE("loading input from file " << *file_name << "... " << flush);
79 
80  try {
81 
82  JFileStreamReader in(file_name->c_str());
83 
84  if (add) {
85 
86  JMultiHistogram_t p0;
87  JMultiHistogram_t p1;
88 
89  p1.transformer.reset(new JFunction5DTransformer_t());
90 
91  for(JMultiHistogram_t* buffer[] = { &p0, &p1, NULL }, **i = buffer; *i != NULL; ++i) {
92  in.load(**i);
93  }
94 
95  in.close();
96 
97  NOTICE("done." << endl);
98 
99  // Add new histogram to first histogram
100 
101  double integral1 = 0.0;
102  double integral2 = 0.0;
103 
104  for(JMultiHistogram_t::super_iterator
105  i0 = h0.super_begin(), i1 = h1.super_begin(),
106  j0 = p0.super_begin(), j1 = p1.super_begin(); i1 != h1.super_end(); ++i0, ++i1, ++j0, ++j1) {
107 
108  integral1 += i0.getValue().getIntegral();
109 
110  i0.getValue().add(j0.getValue());
111  i1.getValue().add(j1.getValue());
112 
113  integral2 += i0.getValue().getIntegral();
114  }
115  }
116  else {
117 
118  for(JMultiHistogram_t* buffer[] = { &h0, &h1, NULL }, **i = buffer; *i != NULL; ++i) {
119  in.load(**i);
120  }
121 
122  in.close();
123 
124  NOTICE("done." << endl);
125 
126  add = true;
127  }
128  }
129  catch(const JException& error) {
130  FATAL(error.what() << endl);
131  }
132  }
133 
134  JFileStreamWriter out(outputFile.c_str());
135 
136  NOTICE("Storing output to file " << outputFile << "... " << flush);
137 
138  for (const JMultiHistogram_t* buffer[] = { &h0, &h1, NULL }, **i = buffer; *i != NULL; ++i) {
139  out.store(**i);
140  }
141 
142  out.close();
143  NOTICE("JAddHDE done." << endl);
144 }
std::vector
Definition: JSTDTypes.hh:12
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
NOTICE
#define NOTICE(A)
Definition: JMessage.hh:64
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JTOOLS::JHistogram1D::abscissa_type
collection_type::abscissa_type abscissa_type
Definition: JHistogram1D.hh:121
debug
int debug
debug level
Definition: JSirene.cc:59
JTOOLS::JHistogram1D_t
JHistogram1D< JElement2D< double, double >, JCollection > JHistogram1D_t
Type definition of a 1 dimensional histogram based on a JCollection.
Definition: JHistogram1D_t.hh:22
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
std
Definition: jaanetDictionary.h:36
p1
TPaveText * p1
Definition: JDrawModule3D.cc:35
FATAL
#define FATAL(A)
Definition: JMessage.hh:67
outputFile
string outputFile
Definition: JDAQTimesliceSelector.cc:37