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):
45 localOptions(nullptr),
46 localEventSummary(nullptr),
51 G4cout << __METHOD_NAME__ <<
"Opening file: " << filePath << G4endl;
53 file =
new TFile(filePath.c_str(),
"READ");
56 badFilePath = file->IsZombie();
58 {
throw BDSException(__METHOD_NAME__,
"No such file \"" + filePath +
"\"");}
61 rootEventFile = file->GetListOfKeys()->Contains(
"Event");
63 {
throw BDSException(__METHOD_NAME__,
"Not a BDSIM rootevent output format ROOT file");}
67 TTree* headerTree =
dynamic_cast<TTree*
>(file->Get(
"Header"));
69 {
throw BDSException(__METHOD_NAME__,
"\"" + filePath +
"\" Not a BDSIM output file");}
71 headerTree->SetBranchAddress(
"Header.", &headerLocal);
72 headerTree->GetEntry(0);
77 beamTree =
dynamic_cast<TTree*
>(file->Get(
"Beam"));
79 {
throw BDSException(__METHOD_NAME__,
"Invalid file \"" + filePath +
"\" - doesn't contain beam Tree");}
81 beamTree->SetBranchAddress(
"Beam.", &localBeam);
82 beamTree->GetEntry(0);
85 optionsTree =
dynamic_cast<TTree*
>(file->Get(
"Options"));
87 {
throw BDSException(__METHOD_NAME__,
"Invalid file \"" + filePath +
"\" - doesn't contain options structure.");}
89 optionsTree->SetBranchAddress(
"Options.", &localOptions);
90 optionsTree->GetEntry(0);
92 eventTree =
dynamic_cast<TTree*
>(file->Get(
"Event"));
95 {eventTree->SetBranchAddress(
"Info.", &localEventSummary);}
97 {eventTree->SetBranchAddress(
"Summary.", &localEventSummary);}
100BDSOutputLoader::~BDSOutputLoader()
105 delete localEventSummary;
112 beamTree->GetEntry(0);
125 optionsTree->GetEntry(0);
141 if (eventNumber > eventTree->GetEntries())
143 G4cout << __METHOD_NAME__ <<
"event index beyond number stored in file - no seed state loaded" << G4endl;
146 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.