Jpp
Functions
JAddHDG.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 multi-dimensional histograms of shower light

Author
lquinn

Definition in file JAddHDG.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 32 of file JAddHDG.cc.

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  zap(argc, argv);
50  }
51  catch(const exception &error) {
52  FATAL(error.what() << endl);
53  }
54 
55 
56  typedef JHistogram1D_t::abscissa_type abscissa_type;
57 
58  typedef JTransformableMultiHistogram<JHistogram1D_t,
59  JMAPLIST<JHistogramMap_t,
60  JHistogramMap_t,
61  JHistogramGridMap_t,
62  JHistogramGridMap_t>::maplist> JMultiHistogram_t;
63 
64  typedef JPDFTransformer<4, abscissa_type> JFunction4DTransformer_t;
65 
66  JMultiHistogram_t h0; // occurrence rate of PMT (used for normalisation)
67  JMultiHistogram_t h1; // light from cascade
68 
69  h1.transformer.reset(new JFunction4DTransformer_t());
70 
71  bool add = false;
72 
73  for(vector<string>::const_iterator file_name = inputFile.begin(); file_name != inputFile.end(); ++file_name) {
74 
75  NOTICE("loading input from file " << *file_name << "... " << flush);
76 
77  try {
78 
79  JFileStreamReader in(file_name->c_str());
80 
81  if (add) {
82 
83  JMultiHistogram_t p0;
84  JMultiHistogram_t p1;
85 
86  p1.transformer.reset(new JFunction4DTransformer_t());
87 
88  for(JMultiHistogram_t* buffer[] = { &p0, &p1, NULL }, **i = buffer; *i != NULL; ++i) {
89  in.load(**i);
90  }
91 
92  in.close();
93 
94  NOTICE("done." << endl);
95 
96  // Add new histogram to first histogram
97 
98  double integral1 = 0.0;
99  double integral2 = 0.0;
100 
101  for(JMultiHistogram_t::super_iterator
102  i0 = h0.super_begin(), i1 = h1.super_begin(),
103  j0 = p0.super_begin(), j1 = p1.super_begin(); i1 != h1.super_end(); ++i0, ++i1, ++j0, ++j1) {
104 
105  integral1 += i0.getValue().getIntegral();
106 
107  i0.getValue().add(j0.getValue());
108  i1.getValue().add(j1.getValue());
109 
110  integral2 += i0.getValue().getIntegral();
111  }
112  }
113  else {
114 
115  for(JMultiHistogram_t* buffer[] = { &h0, &h1, NULL }, **i = buffer; *i != NULL; ++i) {
116  in.load(**i);
117  }
118 
119  in.close();
120 
121  NOTICE("done." << endl);
122 
123  add = true;
124  }
125  }
126  catch(const JException& error) {
127  FATAL(error.what() << endl);
128  }
129  }
130 
131  JFileStreamWriter out(outputFile.c_str());
132 
133  NOTICE("Storing, " << flush);
134 
135  for (const JMultiHistogram_t* buffer[] = { &h0, &h1, NULL }, **i = buffer; *i != NULL; ++i) {
136  out.store(**i);
137  }
138 
139  out.close();
140  NOTICE("done." << endl);
141 }
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