30#include "BDSOutputROOTEventHeader.hh"
31#include "BDSOutputROOTEventOptions.hh"
32#include "BDSOutputROOTEventModel.hh"
36#include "DataLoader.hh"
37#include "BeamAnalysis.hh"
38#include "EventAnalysis.hh"
39#include "ModelAnalysis.hh"
40#include "OptionsAnalysis.hh"
41#include "RBDSException.hh"
42#include "RebdsimTypes.hh"
43#include "RunAnalysis.hh"
45int main(
int argc,
char *argv[])
48 if (argc < 2 || argc > 3)
50 std::cout <<
"usage: rebdsim <datafile> (<outputFile>)" << std::endl;
51 std::cout <<
" <datafile> - root file to operate on" << std::endl;
52 std::cout <<
" <outputfile> - output file name for analysis" << std::endl;
53 std::cout <<
" <outputfile> is optional - default is <datafile>_histos.root" << std::endl;
57 std::string inputFilePath = std::string(argv[1]);
58 std::string outputFileName;
60 {outputFileName = std::string(argv[2]);}
68 bool debug = config->
Debug();
80 {std::cerr << error.
what() << std::endl;
return 1;}
81 catch (
const std::exception& error)
82 {std::cerr << error.what() << std::endl;
return 1;}
100 {std::cerr << error.
what() << std::endl;
return 1;}
115 std::vector<Analysis*> analyses = {beaAnalysis,
121 for (
auto& analysis : analyses)
127 TFile* outputFile =
new TFile(config->
OutputFileName().c_str(),
"RECREATE");
134 TTree* headerTree =
new TTree(
"Header",
"REBDSIM Header");
135 headerTree->Branch(
"Header.",
"BDSOutputROOTEventHeader", headerOut);
137 headerTree->Write(
"", TObject::kOverwrite);
139 for (
auto& analysis : analyses)
140 {analysis->Write(outputFile);}
144 auto newTree = modelTree->CloneTree();
147 newTree->SetName(
"ModelTree");
148 newTree->Write(
"", TObject::kOverwrite);
152 std::cout <<
"Result written to: " << config->
OutputFileName() << std::endl;
155 {std::cerr << error.
what() << std::endl;
return 1;}
156 catch (
const std::exception& error)
157 {std::cerr << error.what() << std::endl;
return 1;}
159 for (
auto analysis : analyses)
virtual void Execute()
Method which calls all other methods in order.
Analysis of the options tree.
Configuration and configuration parser class.
std::string InputFilePath() const
Accessor.
bool PerEntryEvent() const
bool AllBranchesToBeActivated() const
bool GetOptionBool(const std::string &key) const
General accessor for option.
double PrintModuloFraction() const
Accessor.
static Config * Instance(const std::string &fileName="", const std::string &inputFilePath="", const std::string &outputFileName="", const std::string &defaultOutputFileSuffix="_ana")
Singleton accessor.
bool PerEntryModel() const
bool PerEntryOption() const
bool Debug() const
Accessor.
bool PerEntryBeam() const
std::string OutputFileName() const
Accessor.
bool ProcessSamplers() const
Accessor.
const RBDS::VectorString & BranchesToBeActivated(const std::string &treeName) const
Loader for a ROOT file using classes used to generate the file.
std::vector< std::string > GetFileNames()
Accessor.
Event * GetEvent()
Accessor.
Beam * GetBeam()
Accessor.
TChain * GetBeamTree()
Accessor.
TChain * GetOptionsTree()
Accessor.
TChain * GetRunTree()
Accessor.
TChain * GetModelTree()
Accessor.
Options * GetOptions()
Accessor.
TChain * GetEventTree()
Accessor.
Model * GetModel()
Accessor.
Analysis of the model tree.
Analysis of the options tree.
General exception with possible name of object and message.
const char * what() const noexcept override
Override message in std::exception.