Jpp  17.3.0-rc.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
getPoisson.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <iomanip>
3 
4 #include "TRandom3.h"
5 
7 
8 #include "Jeep/JParser.hh"
9 #include "Jeep/JMessage.hh"
10 
11 
12 /**
13  * \file
14  *
15  * Auxiliary program to print random a number according Poisson statistics or the Poisson probability.
16  * \author mdejong
17  */
18 int main(int argc, char**argv)
19 {
20  using namespace std;
21  using namespace JPP;
22 
23  double value;
24  int n;
25  UInt_t seed;
26  int debug;
27 
28  try {
29 
30  JParser<> zap("Auxiliary program to print a random number according Poisson statistics or the Poisson probability."\
31  "\nIf the number of events is less than zero, the random number is printed, else the probability.");
32 
33  zap['e'] = make_field(value, "expectation value");
34  zap['n'] = make_field(n, "number of events") = -1;
35  zap['S'] = make_field(seed) = 0;
36  zap['d'] = make_field(debug) = 3;
37 
38  zap(argc, argv);
39  }
40  catch(const exception &error) {
41  FATAL(error.what() << endl);
42  }
43 
44  if (n < 0) {
45 
46  gRandom->SetSeed(seed);
47 
48  cout << gRandom->Poisson(value) << endl;
49 
50  } else {
51 
52  cout << SCIENTIFIC(12,5) << poisson(n, value) << endl;
53  }
54 }
Utility class to parse command line options.
Definition: JParser.hh:1517
int main(int argc, char *argv[])
Definition: Main.cc:15
Auxiliary methods for mathematics.
const int n
Definition: JPolint.hh:697
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1993
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Utility class to parse command line options.
double poisson(const size_t n, const double mu)
Poisson probability density distribition.
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:484
int debug
debug level