19#include "BDSException.hh"
20#include "BDSOutputLoader.hh"
21#include "BDSOutputROOTEventBeam.hh"
22#include "BDSOutputROOTEventHeader.hh"
23#include "BDSOutputROOTEventInfo.hh"
24#include "BDSOutputROOTEventOptions.hh"
26#include "parser/beam.h"
27#include "parser/beamBase.h"
28#include "parser/options.h"
29#include "parser/optionsBase.h"
38BDSOutputLoader::BDSOutputLoader(
const G4String& filePath):
44 localOptions(nullptr),
45 localEventSummary(nullptr),
50 G4cout << __METHOD_NAME__ <<
"Opening file: " << filePath << G4endl;
52 file =
new TFile(filePath.c_str(),
"READ");
55 badFilePath = file->IsZombie();
57 {
throw BDSException(__METHOD_NAME__,
"No such file \"" + filePath +
"\"");}
60 rootEventFile = file->GetListOfKeys()->Contains(
"Event");
62 {
throw BDSException(__METHOD_NAME__,
"Not a BDSIM rootevent output format ROOT file");}
66 TTree* headerTree =
dynamic_cast<TTree*
>(file->Get(
"Header"));
68 {
throw BDSException(__METHOD_NAME__,
"\"" + filePath +
"\" Not a BDSIM output file");}
70 headerTree->SetBranchAddress(
"Header.", &headerLocal);
71 headerTree->GetEntry(0);
76 beamTree =
dynamic_cast<TTree*
>(file->Get(
"Beam"));
78 {
throw BDSException(__METHOD_NAME__,
"Invalid file \"" + filePath +
"\" - doesn't contain beam Tree");}
80 beamTree->SetBranchAddress(
"Beam.", &localBeam);
81 beamTree->GetEntry(0);
84 optionsTree =
dynamic_cast<TTree*
>(file->Get(
"Options"));
86 {
throw BDSException(__METHOD_NAME__,
"Invalid file \"" + filePath +
"\" - doesn't contain options structure.");}
88 optionsTree->SetBranchAddress(
"Options.", &localOptions);
89 optionsTree->GetEntry(0);
91 eventTree =
dynamic_cast<TTree*
>(file->Get(
"Event"));
94 {eventTree->SetBranchAddress(
"Info.", &localEventSummary);}
96 {eventTree->SetBranchAddress(
"Summary.", &localEventSummary);}
99BDSOutputLoader::~BDSOutputLoader()
104 delete localEventSummary;
111 beamTree->GetEntry(0);
124 optionsTree->GetEntry(0);
140 if (eventNumber > eventTree->GetEntries())
142 G4cout << __METHOD_NAME__ <<
"event index beyond number stored in file - no seed state loaded" << G4endl;
145 eventTree->GetEntry((
int)eventNumber);
General exception with possible name of object and message.
G4String SeedState(G4int eventNumber=0)
Access the seed state for a given event index in the file (0 counting).
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.