Jpp  18.0.1-rc.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JTools/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

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 
87  typedef JMultiPDF<JPolint1Function1D_t,
88  JMAPLIST<JPolint1FunctionalMap,
89  JPolint1FunctionalMap>::maplist> JMultiPDF_t;
90 
91 
92  if (outputFile != "") {
93 
94  typedef JMAPLIST<JHistogramMap_t,
95  JHistogramMap_t>::maplist JMapList_t;
96 
97  typedef JMultiHistogram<JHistogram1D_t, JMapList_t> JMultiHistogram_t;
98 
99 
100  JMultiHistogram_t histogram;
101 
102  configure(histogram, make_set(JGaussHermite(numberOfBins)));
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 
129  JLANG::store<JIO::JFileStreamWriter>(outputFile.c_str(), pdf);
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 
161  typedef JMultiFunction<JPolint1Function1D_t,
162  JMapList<JPolint1FunctionalMap,
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 }
Utility class to parse command line options.
Definition: JParser.hh:1514
data_type w[N+1][M+1]
Definition: JPolint.hh:778
Q(UTCMax_s-UTCMin_s)-livetime_s
#define STATUS(A)
Definition: JMessage.hh:63
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
string outputFile
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
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.
Definition: JVectorize.hh:169
#define FATAL(A)
Definition: JMessage.hh:67
void configure(const T &value, const JAbstractCollection< JAbscissa_t > &bounds, JBool< false > option)
Configuration of value.
data_type v[N+1][M+1]
Definition: JPolint.hh:777
double u[N+1]
Definition: JPolint.hh:776
int numberOfBins
number of bins for average CDF integral of optical module
Definition: JSirene.cc:69
JContainer_t::ordinate_type getIntegral(const JContainer_t &input)
Get integral of input data points.
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62