Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JMakeHDG.cc
Go to the documentation of this file.
1#include <string>
2#include <iostream>
3#include <fstream>
4#include <iomanip>
5
8
10
16
20
21#include "Jeep/JParser.hh"
22#include "Jeep/JMessage.hh"
23
25
26
27/**
28 * \file
29 *
30 * Program to convert multi-dimensional histograms of shower light to multi-dimensional PDFs.
31 * \author lquinn
32 */
33int main(int argc, char **argv)
34{
35 using namespace std;
36 using namespace JPP;
37
38 string inputFile;
39 string fileDescriptor;
40 int debug;
41
42 try {
43
44 JParser<> zap("Program to convert multi-dimensional histograms of shower light to multi-dimensional PDFs.");
45
46 zap['f'] = make_field(inputFile);
47 zap['o'] = make_field(fileDescriptor) = "J%p.dat";
48 zap['d'] = make_field(debug) = 1;
49
50 zap(argc, argv);
51 }
52 catch(const exception &error) {
53 FATAL(error.what() << endl);
54 }
55
56
57 if (!hasWildCard(fileDescriptor)) {
58 FATAL("error file descriptor " << fileDescriptor << endl);
59 }
60
61 typedef JHistogram1D_t::abscissa_type abscissa_type;
62
67 JHistogramGridMap_t>::maplist> JMultiHistogram_t;
68
69 typedef JPHYSICS::JPDFTransformer<4, abscissa_type> JFunction4DTransformer_t;
70
71 JMultiHistogram_t h0; // occurrence rate of PMT (used for normalisation)
72 JMultiHistogram_t h1; // light from cascade
73
74 h1.transformer.reset(new JFunction4DTransformer_t());
75
76 // input
77
78 NOTICE("Loading in input, " << flush);
79
80 JFileStreamReader in(inputFile.c_str());
81
82 for (JMultiHistogram_t* p : { &h0, &h1 }) {
83 in.load(*p);
84 }
85
86 in.close();
87
88 NOTICE("done." << endl);
89
90 // rebin histograms according angle of incidence on PMT and normalise contents to PMT occurennce rate
91
92 for (JMultiHistogram_t::super_iterator
93 i0 = h0.super_begin(),
94 i1 = h1.super_begin(); i1 != h1.super_end(); ++i0, ++i1) {
95
96 const double W = i0.getValue().getIntegral();
97
98 if (W != 0.0) {
99
100 const JDirection3D u(JAngle3D(i0->second->first, i0->second->second->first));
101 const JDirection3D v(getSinThetaC(), 0.0, getCosThetaC());
102
103 int number_of_bins = (int) (2 + u.getDot(v));
104
105 i1.getValue().rebin(JHistogram1D_t::JRebin(number_of_bins));
106 i1.getValue().div(W);
107 }
108 }
109
110 NOTICE("done." << endl);
111
112 // output
113
114 struct tuple {
115 const JPDFType_t type;
116 const JMultiHistogram_t& value;
117 };
118
123 JPolint1FunctionalGridMap>::maplist> JPDF_t;
124
125 const string file_name = getFilename(fileDescriptor, DIRECT_LIGHT_FROM_EMSHOWER);
126
127 try {
128 NOTICE("storing output to file " << file_name << "... " << flush);
129
130 const JPDF_t pdf(h1);
131
132 pdf.store(file_name.c_str());
133
134 NOTICE("OK" << endl);
135 }
136 catch(const JException& error) {
137 FATAL(error.what() << endl);
138 }
139}
Various implementations of functional maps.
int main(int argc, char **argv)
Definition JMakeHDG.cc:33
General purpose messaging.
#define NOTICE(A)
Definition JMessage.hh:64
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
Numbering scheme for PDF types.
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Physics constants.
Data structure for angles in three dimensions.
Definition JAngle3D.hh:35
Data structure for direction in three dimensions.
double getDot(const JAngle3D &angle) const
Get dot product.
Binary buffered file input.
JReader & load(JSerialisable &object)
Read object.
General exception.
Definition JException.hh:24
Utility class to parse command line options.
Definition JParser.hh:1698
Multi-dimensional PDF table for arrival time of Cherenkov light.
Definition JPDFTable.hh:44
Template definition of transformer of the probability density function (PDF) of the time response of ...
Histogram in 1D.
collection_type::abscissa_type abscissa_type
Transformable multidimensional histogram.
JPDFType_t
PDF types.
Definition JPDFTypes.hh:24
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Type definition of a JHistogramMap based on JGridMap implementation.
Type definition of a JHistogramMap based on JMap implementation.
Auxiliary class for recursive map list generation.
Definition JMapList.hh:109
Type definition of a 1st degree polynomial interpolation with result type double.
Type definition of a 1st degree polynomial interpolation based on a JGridMap implementation.
Type definition of a 1st degree polynomial interpolation based on a JMap implementation.
Auxiliary class for merging of fixed number of consecutive bins.