Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JQuantile.cc File Reference

Example program to test JTOOLS::JQuantile calculation. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TRandom.h"
#include "JTools/JQuantile.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::JQuantile calculation.

Author
mdejong

Definition in file JQuantile.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 20 of file JQuantile.cc.

21 {
22  using namespace std;
23 
24  int numberOfEvents;
25  double x;
26  double sigma;
27  UInt_t seed;
28  int debug;
29 
30  try {
31 
32  JParser<> zap("Example program to test quantile calculation.");
33 
34  zap['n'] = make_field(numberOfEvents);
35  zap['x'] = make_field(x) = 0.0;
36  zap['s'] = make_field(sigma) = 1.0;
37  zap['S'] = make_field(seed) = 0;
38  zap['d'] = make_field(debug) = 3;
39 
40  zap(argc, argv);
41  }
42  catch(const exception &error) {
43  FATAL(error.what() << endl);
44  }
45 
46  if (numberOfEvents < 2) {
47  FATAL("Fatal error: number of events " << numberOfEvents << endl);
48  }
49 
50  gRandom->SetSeed(seed);
51 
52  JTOOLS::JQuantile quantile;
53 
54  // fill
55 
56  for (int i = 0; i != numberOfEvents; ++i) {
57  quantile.put(gRandom->Gaus(x, sigma));
58  }
59 
60 
61  NOTICE("quantity " << "calculated" << " | " << " true " << endl);
62  NOTICE("mean " << fixed << showpos << setw(10) << quantile.getMean() << " | " << setw(10) << x << endl);
63  NOTICE("RMS " << fixed << showpos << setw(10) << quantile.getSTDev() << " | " << setw(10) << sigma << endl);
64 }
Utility class to parse command line options.
Definition: JParser.hh:1500
Quantile calculator.
Definition: JQuantile.hh:88
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
#define NOTICE(A)
Definition: JMessage.hh:64
void put(const double x, const double w=1.0)
Put value.
Definition: JQuantile.hh:173
int debug
debug level
Definition: JSirene.cc:63
#define FATAL(A)
Definition: JMessage.hh:67