Jpp - the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JQuantile.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 
6 #include "TRandom.h"
7 
8 #include "JTools/JQuantile.hh"
9 
10 #include "Jeep/JParser.hh"
11 #include "Jeep/JMessage.hh"
12 
13 
14 /**
15  * \file
16  *
17  * Example program to test JTOOLS::JQuantile calculation.
18  * \author mdejong
19  */
20 int main(int argc, char **argv)
21 {
22  using namespace std;
23  using namespace JPP;
24 
25  int numberOfEvents;
26  double x;
27  double sigma;
28  UInt_t seed;
29  int debug;
30 
31  try {
32 
33  JParser<> zap("Example program to test quantile calculation.");
34 
35  zap['n'] = make_field(numberOfEvents);
36  zap['x'] = make_field(x) = 0.0;
37  zap['s'] = make_field(sigma) = 1.0;
38  zap['S'] = make_field(seed) = 0;
39  zap['d'] = make_field(debug) = 3;
40 
41  zap(argc, argv);
42  }
43  catch(const exception &error) {
44  FATAL(error.what() << endl);
45  }
46 
47  if (numberOfEvents < 2) {
48  FATAL("Fatal error: number of events " << numberOfEvents << endl);
49  }
50 
51  gRandom->SetSeed(seed);
52 
53  JQuantile quantile;
54 
55  for (int i = 0; i != numberOfEvents; ++i) {
56  quantile.put(gRandom->Gaus(x, sigma));
57  }
58 
59  NOTICE("quantity " << CENTER(10) << "calculated" << " | " << CENTER(10) << "true" << endl);
60  NOTICE("mean " << FIXED(10,3) << quantile.getMean() << " | " << FIXED(10,3) << x << endl);
61  NOTICE("RMS " << FIXED(10,3) << quantile.getSTDev() << " | " << FIXED(10,3) << sigma << endl);
62 }
63 
Utility class to parse command line options.
Definition: JParser.hh:1500
int main(int argc, char *argv[])
Definition: Main.cc:15
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
Auxiliary data structure for alignment of data.
Definition: JManip.hh:366
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
#define NOTICE(A)
Definition: JMessage.hh:64
int debug
debug level
Definition: JSirene.cc:63
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Utility class to parse command line options.