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 "HeaderAnalysis.hh"
40#include "ModelAnalysis.hh"
41#include "OptionsAnalysis.hh"
42#include "RBDSException.hh"
43#include "RebdsimTypes.hh"
44#include "RunAnalysis.hh"
46int main(
int argc,
char *argv[])
49 if (argc < 2 || argc > 3)
51 std::cout <<
"usage: rebdsim <datafile> (<outputFile>)" << std::endl;
52 std::cout <<
" <datafile> - root file to operate on" << std::endl;
53 std::cout <<
" <outputfile> - output file name for analysis" << std::endl;
54 std::cout <<
" <outputfile> is optional - default is <datafile>_histos.root" << std::endl;
58 std::string inputFilePath = std::string(argv[1]);
59 std::string outputFileName;
61 {outputFileName = std::string(argv[2]);}
71 bool debug = config->
Debug();
110 unsigned long long int nEventsInFileTotal;
111 unsigned long long int nEventsInFileSkippedTotal;
112 unsigned long long int nEventsRequested;
113 unsigned int distrFileLoopNTimes;
115 nEventsInFileSkippedTotal,
117 distrFileLoopNTimes);
119 std::vector<Analysis*> analyses = {beaAnalysis,
125 for (
auto& analysis : analyses)
129 TFile* outputFile =
new TFile(config->
OutputFileName().c_str(),
"RECREATE");
140 TTree* headerTree =
new TTree(
"Header",
"REBDSIM Header");
141 headerTree->Branch(
"Header.",
"BDSOutputROOTEventHeader", headerOut);
143 headerTree->Write(
"", TObject::kOverwrite);
145 for (
auto& analysis : analyses)
146 {analysis->Write(outputFile);}
150 auto newTree = modelTree->CloneTree();
153 newTree->SetName(
"ModelTree");
154 newTree->Write(
"", TObject::kOverwrite);
158 std::cout <<
"Result written to: " << config->
OutputFileName() << std::endl;
160 for (
auto analysis : analyses)
164 {std::cerr << error.
what() << std::endl;
return 1;}
165 catch (
const std::exception& error)
166 {std::cerr << error.what() << std::endl;
return 1;}
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 PrintOut() const
Accessor.
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.
Header * GetHeader()
Accessor.
TChain * GetBeamTree()
Accessor.
TChain * GetOptionsTree()
Accessor.
TChain * GetRunTree()
Accessor.
TChain * GetModelTree()
Accessor.
Options * GetOptions()
Accessor.
TChain * GetEventTree()
Accessor.
Model * GetModel()
Accessor.
TChain * GetHeaderTree()
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.