Jpp in_tag_pdf_generation
the software that should make you happy
Loading...
Searching...
No Matches
JRandom.cc
Go to the documentation of this file.
1#include <string>
2#include <iostream>
3#include <iomanip>
4#include <sstream>
5#include <limits>
6
7#include "TFile.h"
8#include "TRandom3.h"
9
12#include "JROOT/JRandom.hh"
13
14#include "Jeep/JParser.hh"
15#include "Jeep/JMessage.hh"
16
17
18/**
19 * \file
20 *
21 * Program to test TRandom reproducibility.
22 * \author mdejong
23 */
24int main(int argc, char **argv)
25{
26 using namespace std;
27 using namespace JPP;
28
29 TString file_name;
30 JRandom seed;
31 int debug;
32
33 try {
34
35 JParser<> zap("Program to test TRandom reproducibility.");
36
37 zap['f'] = make_field(file_name);
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 (!seed.set(gRandom)) {
48 FATAL("Invalid configuration for random number generator " << seed << endl);
49 }
50
51 DEBUG("seed: <" << seed << "> -> " << gRandom->TRandom::GetSeed() << endl);
52
53 const UInt_t MAX = numeric_limits<UInt_t>::max();
54
55 UInt_t value[2] = { 0, 0 };
56
57 if (!JRandom::write(file_name, gRandom)) {
58 FATAL("Failure writing to file <" << file_name << ">." << endl);
59 }
60
61 value[0] = gRandom->Integer(MAX);
62
63 DEBUG("random[0]: " << value[0] << endl);
64
65 seed = file_name;
66
67 if (!seed.set(gRandom)) {
68 FATAL("Invalid configuration for random number generator " << seed << endl);
69 }
70
71 value[1] = gRandom->Integer(MAX);
72
73 DEBUG("random[1]: " << value[1] << endl);
74
75 ASSERT(value[0] == value[1]);
76
77 return 0;
78}
General purpose messaging.
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define ASSERT(A,...)
Assert macro.
Definition JMessage.hh:90
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
int main(int argc, char **argv)
Definition JRandom.cc:24
Utility class to parse command line options.
Definition JParser.hh:1698
#define MAX(x, y)
Definition crypt.cc:49
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Template definition of random value generator.