GGS(GenericGEANT4Simulation)Software  2.99.0
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Macros
GGSTRngStateReader.cpp
Go to the documentation of this file.
1 /*
2  * GGSTRngStateReader.cpp
3  *
4  * Created on: 4 Dec 2020
5  * Author: Nicola Mori
6  */
7 
11 
12 #include "TFile.h"
13 #include "TKey.h"
14 
15 GGSTRngStateReader::GGSTRngStateReader() : _rngState(nullptr), _rngStateChain(nullptr) {}
16 
17 bool GGSTRngStateReader::SetChain(TChain *rngStateChain) {
18 
19  _rngStateChain = rngStateChain;
20  if (_rngStateChain->SetBranchAddress("rngState", &_rngState) == 0) {
21  return true;
22  } else {
23  return false;
24  }
25 }
26 
27 void GGSTRngStateReader::GetEntry(Long64_t entry) {
28  if (entry != _rngStateChain->GetEntries()) {
29  _rngStateChain->GetEntry(entry);
30  }
31 }
32 
33 const std::string GGSTRngStateReader::GetName() {
34  if (_rngName == "") {
35  if (_rngStateChain) {
36  TKey *key = _rngStateChain->GetFile()->GetKey("rngName");
37  if (key) {
38  _rngName = *((std::string *)(key->ReadObjectAny(TClass::GetClass("std::string"))));
39  }
40  }
41  }
42  return _rngName;
43 }
GGSTRngStateReader()
Constructor.
bool SetChain(TChain *rngStateChain)
Sets the chain.
const std::string GetName()
Gets the name of the random number generator for the current event.
void GetEntry(Long64_t entry)