Jpp 19.3.0-rc.5
the software that should make you happy
Loading...
Searching...
No Matches
JHistogram3D.cc File Reference

Example program to test JTOOLS::JMultiHistogram. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TMath.h"
#include "TRandom.h"
#include "JTools/JHistogram1D_t.hh"
#include "JTools/JHistogramMap_t.hh"
#include "JTools/JMultiHistogram.hh"
#include "JTools/JMultiSet.hh"
#include "JTools/JQuadrature.hh"
#include "JTools/JToolsToolkit.hh"
#include "JTools/JFunction1D_t.hh"
#include "JTools/JQuantile.hh"
#include "JTools/JMultiPDF.hh"
#include "JIO/JFileStreamIO.hh"
#include "JLang/JObjectIO.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

Example program to test JTOOLS::JMultiHistogram.

Author
mdejong

Definition in file JTools/JHistogram3D.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 53 of file JTools/JHistogram3D.cc.

54{
55 using namespace std;
56 using namespace JPP;
57
58 string inputFile;
59 string outputFile;
60 int numberOfEvents;
61 int numberOfBins;
62 int debug;
63
64 try {
65
66 JParser<> zap("Example program to test 3D histogram.");
67
68 zap['f'] = make_field(inputFile) = "";
69 zap['o'] = make_field(outputFile) = "";
70 zap['n'] = make_field(numberOfEvents);
71 zap['N'] = make_field(numberOfBins) = 11;
72 zap['d'] = make_field(debug) = 3;
73
74 zap(argc, argv);
75 }
76 catch(const exception &error) {
77 FATAL(error.what() << endl);
78 }
79
80
81 if (numberOfEvents <= 0) {
82 FATAL("No events." << endl);
83 }
84
87 JPolint1FunctionalMap>::maplist> JMultiPDF_t;
88
89
90 if (outputFile != "") {
91
93 JHistogramMap_t>::maplist JMapList_t;
94
95 typedef JMultiHistogram<JHistogram1D_t, JMapList_t> JMultiHistogram_t;
96
97
98 JMultiHistogram_t histogram;
99
101
102
103 // fill
104
105 for (int i = 0; i != numberOfEvents; ++i) {
106
107 if (i%1000 == 0) {
108 STATUS("event: " << setw(10) << i << '\r'); DEBUG(endl);
109 }
110
111 const double x = gRandom->Gaus(0.0, 1.0);
112 const double y = gRandom->Gaus(0.0, 1.0);
113 const double z = gRandom->Gaus(0.0, 1.0);
114 const double w = 1.0;
115
116 histogram.fill(x, y, z, w);
117 }
118 STATUS(endl);
119
120 histogram.div((double) numberOfEvents);
121
122
123 try {
124
125 JMultiPDF_t pdf(histogram);
126
128 }
129 catch(const JException& error) {
130 FATAL(error.what() << endl);
131 }
132 }
133
134
135 if (inputFile != "") {
136
137 JMultiPDF_t pdf;
138
139 JLANG::load<JIO::JFileStreamReader>(inputFile.c_str(), pdf);
140
141 JQuantile Q;
142
143 for (int i = 0; i != numberOfEvents; ++i) {
144
145 const double x = gRandom->Gaus(0.0, 1.0);
146 const double y = gRandom->Gaus(0.0, 1.0);
147 const double z = gRandom->Gaus(0.0, 1.0);
148
149 try {
150
151 const double u = g3 (x, y, z);
152 const double v = pdf(x, y, z);
153
154 Q.put(u - v);
155 }
156 catch(const std::exception& error) {}
157 }
158
161 JMapList<JPolint1FunctionalMap> > > JMultiFunction_t;
162
163 cout << "normalisation " << FIXED(5,3) << getIntegral(static_cast<const JMultiFunction_t&>(pdf)) << endl;
164 cout << "efficiency " << FIXED(5,3) << (double) Q.getCount() / (double) numberOfEvents << endl;
165
166 Q.print(cout);
167 }
168}
string outputFile
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define STATUS(A)
Definition JMessage.hh:63
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
int numberOfBins
number of bins for average CDF integral of optical module
Definition JSirene.cc:73
General exception.
Definition JException.hh:24
virtual const char * what() const override
Get error message.
Definition JException.hh:64
Utility class to parse command line options.
Definition JParser.hh:1698
Numerical integrator for .
Multidimensional interpolation method.
Multidimensional histogram.
General purpose class for multi-dimensional probability density function (PDF).
Definition JMultiPDF.hh:37
T make_set(T __begin, T __end, JResult_t std::iterator_traits< T >::value_type::*value, const JComparator_t &comparator)
Method to exclude outliers from already sorted data.
void store(const std::string &file_name, const T &object)
Store object to output file.
Definition JObjectIO.hh:68
void load(const std::string &file_name, T &object)
Load object from input file.
Definition JObjectIO.hh:55
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
JContainer_t::ordinate_type getIntegral(const JContainer_t &input)
Get integral of input data points.
void configure(const T &value, const JAbstractCollection< JAbscissa_t > &bounds, JBool< false > option)
Configuration of value.
Auxiliary data structure for floating point format specification.
Definition JManip.hh:448
Type definition of a JHistogramMap based on JMap implementation.
Auxiliary class for recursive map list generation.
Definition JMapList.hh:109
Map list.
Definition JMapList.hh:25
Type definition of a 1st degree polynomial interpolation with result type double.
Type definition of a 1st degree polynomial interpolation based on a JMap implementation.
Auxiliary data structure for running average, standard deviation and quantiles.
Definition JQuantile.hh:46
std::ostream & print(std::ostream &out, bool lpr=true) const
Print quantile.
Definition JQuantile.hh:382
void put(const double x, const double w=1.0)
Put value.
Definition JQuantile.hh:133
long long int getCount() const
Get total count.
Definition JQuantile.hh:186