1#ifndef __JROOT__JRANDOM__
2#define __JROOT__JRANDOM__
12#include <TBufferJSON.h>
22namespace JPP {
using namespace JROOT; }
51 static_cast<TString&
>(*this) = buffer;
62 static_cast<TString&
>(*this) += seed;
75 return in >>
static_cast<TString&
>(object);
88 return out <<
object.Data();
98 bool set(TRandom*& pr)
const
107 pr->SetSeed(this->Atoll());
113 return JRandom::read(
static_cast<const TString&
>(*
this), pr);
128 static bool read(
const TString& file_name, TRandom*& pr)
135 if (file_name.EndsWith(
".root")) {
141 TRandom* p = in.next();
143 pr = (TRandom*) p->Clone();
148 }
else if (file_name.EndsWith(
".txt")) {
150 fstream in(file_name.Data());
154 if (io << in.rdbuf()) {
156 pr = (TRandom*) TBufferJSON::ConvertFromJSON(io.str().c_str());
174 static bool write(
const TString& file_name, TRandom* pr)
181 if (file_name.EndsWith(
".root")) {
191 }
else if (file_name.EndsWith(
".txt")) {
193 ofstream out(file_name.Data());
195 out << TBufferJSON::ConvertToJSON(gRandom).Data();
virtual bool put(const T &object)=0
Object output.
virtual void close() override
Close file.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary classes and methods for ROOT I/O.
Auxiliary data structure to configure random number generator.
JRandom(const ULong_t seed)
Constructor.
bool set(TRandom *&pr) const
Configure random number generator.
friend std::istream & operator>>(std::istream &in, JRandom &object)
Read random from input.
JRandom(const TString &buffer)
Constructor.
static bool read(const TString &file_name, TRandom *&pr)
Read random number generator from file.
JRandom()
Default constructor.
friend std::ostream & operator<<(std::ostream &out, const JRandom &object)
Write random to output.
static bool write(const TString &file_name, TRandom *pr)
Write random number generator to file.