Jpp 19.3.0-rc.1
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
57 string inputFile;
58 string outputFile;
59 int numberOfEvents;
60 int numberOfBins;
61 int debug;
62
63 try {
64
65 JParser<> zap("Example program to test 3D histogram.");
66
67 zap['f'] = make_field(inputFile) = "";
68 zap['o'] = make_field(outputFile) = "";
69 zap['n'] = make_field(numberOfEvents);
70 zap['N'] = make_field(numberOfBins) = 11;
71 zap['d'] = make_field(debug) = 3;
72
73 zap(argc, argv);
74 }
75 catch(const exception &error) {
76 FATAL(error.what() << endl);
77 }
78
79
80 if (numberOfEvents <= 0) {
81 FATAL("No events." << endl);
82 }
83
84 using namespace JPP;
85
86
89 JPolint1FunctionalMap>::maplist> JMultiPDF_t;
90
91
92 if (outputFile != "") {
93
95 JHistogramMap_t>::maplist JMapList_t;
96
97 typedef JMultiHistogram<JHistogram1D_t, JMapList_t> JMultiHistogram_t;
98
99
100 JMultiHistogram_t histogram;
101
103
104
105 // fill
106
107 for (int i = 0; i != numberOfEvents; ++i) {
108
109 if (i%1000 == 0) {
110 STATUS("event: " << setw(10) << i << '\r'); DEBUG(endl);
111 }
112
113 const double x = gRandom->Gaus(0.0, 1.0);
114 const double y = gRandom->Gaus(0.0, 1.0);
115 const double z = gRandom->Gaus(0.0, 1.0);
116 const double w = 1.0;
117
118 histogram.fill(x, y, z, w);
119 }
120 STATUS(endl);
121
122 histogram.div((double) numberOfEvents);
123
124
125 try {
126
127 JMultiPDF_t pdf(histogram);
128
130 }
131 catch(const JException& error) {
132 FATAL(error.what() << endl);
133 }
134 }
135
136
137 if (inputFile != "") {
138
139 JMultiPDF_t pdf;
140
141 JLANG::load<JIO::JFileStreamReader>(inputFile.c_str(), pdf);
142
143 JQuantile Q;
144
145 for (int i = 0; i != numberOfEvents; ++i) {
146
147 const double x = gRandom->Gaus(0.0, 1.0);
148 const double y = gRandom->Gaus(0.0, 1.0);
149 const double z = gRandom->Gaus(0.0, 1.0);
150
151 try {
152
153 const double u = g3 (x, y, z);
154 const double v = pdf(x, y, z);
155
156 Q.put(u - v);
157 }
158 catch(const std::exception& error) {}
159 }
160
163 JMapList<JPolint1FunctionalMap> > > JMultiFunction_t;
164
165 cout << "normalisation " << FIXED(5,3) << getIntegral(static_cast<const JMultiFunction_t&>(pdf)) << endl;
166 cout << "efficiency " << FIXED(5,3) << (double) Q.getCount() / (double) numberOfEvents << endl;
167
168 Q.print(cout);
169 }
170}
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