20#include "BDSException.hh"
21#include "BDSOutputLoader.hh"
22#include "BDSOutputROOTEventBeam.hh"
23#include "BDSOutputROOTEventHeader.hh"
24#include "BDSOutputROOTEventInfo.hh"
25#include "BDSOutputROOTEventOptions.hh"
27#include "parser/beam.h"
28#include "parser/beamBase.h"
29#include "parser/options.h"
30#include "parser/optionsBase.h"
39BDSOutputLoader::BDSOutputLoader(
const G4String& filePath):
44 localOptions(nullptr),
45 localEventSummary(nullptr),
51 file =
new TFile(filePath.c_str(),
"READ");
54 badFilePath = file->IsZombie();
56 {
throw BDSException(__METHOD_NAME__,
"No such file \"" + filePath +
"\"");}
59 rootEventFile = file->GetListOfKeys()->Contains(
"Event");
61 {
throw BDSException(__METHOD_NAME__,
"Not a BDSIM rootevent output format ROOT file");}
65 TTree* headerTree =
static_cast<TTree*
>(file->Get(
"Header"));
67 {
throw BDSException(__METHOD_NAME__,
"\"" + filePath +
"\" Not a BDSIM output file");}
69 headerTree->SetBranchAddress(
"Header.", &headerLocal);
70 headerTree->GetEntry(0);
74 beamTree =
static_cast<TTree*
>(file->Get(
"Beam"));
76 {
throw BDSException(__METHOD_NAME__,
"Invalid file \"" + filePath +
"\" - doesn't contain beam Tree");}
78 beamTree->SetBranchAddress(
"Beam.", &localBeam);
79 beamTree->GetEntry(0);
82 optionsTree =
static_cast<TTree*
>(file->Get(
"Options"));
84 {
throw BDSException(__METHOD_NAME__,
"Invalid file \"" + filePath +
"\" - doesn't contain options structure.");}
86 optionsTree->SetBranchAddress(
"Options.", &localOptions);
87 optionsTree->GetEntry(0);
89 eventTree =
static_cast<TTree*
>(file->Get(
"Event"));
92 {eventTree->SetBranchAddress(
"Info.", &localEventSummary);}
94 {eventTree->SetBranchAddress(
"Summary.", &localEventSummary);}
97BDSOutputLoader::~BDSOutputLoader()
102 delete localEventSummary;
109 beamTree->GetEntry(0);
122 optionsTree->GetEntry(0);
131G4String BDSOutputLoader::SeedState(G4int eventNumber)
138 if (eventNumber > eventTree->GetEntries())
140 G4cout << __METHOD_NAME__ <<
"event index beyond number stored in file - no seed state loaded" << G4endl;
143 eventTree->GetEntry((
int)eventNumber);
General exception with possible name of object and message.
Class to store all beam options for a BDSIM run.
Information pertaining to an individual event.
std::string seedStateAtStart
Seed state at the start of the event.
Class to store all options for a BDSIM run.
Options for a beam distribution.
Basic options class independent of Geant4.