Jpp 19.3.0-rc.5
the software that should make you happy
Loading...
Searching...
No Matches
JRandom.cc File Reference

Program to test TRandom reproducibility. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <limits>
#include "TFile.h"
#include "TRandom3.h"
#include "JROOT/JRootFileReader.hh"
#include "JROOT/JRootFileWriter.hh"
#include "JROOT/JRandom.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

Program to test TRandom reproducibility.

Author
mdejong

Definition in file JRandom.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 24 of file JRandom.cc.

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}
#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
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
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.