ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FatrasMain.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FatrasMain.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #include "FatrasMain.hpp"
10 
11 #include <boost/program_options.hpp>
12 #include <memory>
13 
28 #include "FatrasEvgenBase.hpp"
29 #include "FatrasSimulationBase.hpp"
30 
31 int FW::fatrasMain(int argc, char* argv[],
32  std::shared_ptr<FW::IBaseDetector> detector) {
34 
35  // setup and parse options
47  desc.add_options()("evg-input-type",
48  value<std::string>()->default_value("pythia8"),
49  "Type of evgen input 'gun', 'pythia8'");
50  // Add specific options for this geometry
51  detector->addOptions(desc);
52  auto vm = FW::Options::parse(desc, argc, argv);
53  if (vm.empty()) {
54  return EXIT_FAILURE;
55  }
56 
58 
59  // auto logLevel = FW::Options::readLogLevel(vm);
60 
61  // Create the random number engine
62  auto randomNumberSvcCfg = FW::Options::readRandomNumbersConfig(vm);
63  auto randomNumberSvc =
64  std::make_shared<FW::RandomNumbers>(randomNumberSvcCfg);
65 
66  // The geometry, material and decoration
67  auto geometry = FW::Geometry::build(vm, *detector);
68  auto tGeometry = geometry.first;
69  auto contextDecorators = geometry.second;
70  // Add the decorator to the sequencer
71  for (auto cdr : contextDecorators) {
72  sequencer.addContextDecorator(cdr);
73  }
74 
75  // make sure the output directory exists
76  FW::ensureWritableDirectory(vm["output-dir"].as<std::string>());
77 
78  // (A) EVGEN
79  // Setup the evgen input to the simulation
80  setupEvgenInput(vm, sequencer, randomNumberSvc);
81 
82  // (B) SIMULATION
83  // Setup the simulation
84  setupSimulation(vm, sequencer, randomNumberSvc, tGeometry);
85 
86  // (C) DIGITIZATION
87  // Setup the digitization
88  setupDigitization(vm, sequencer, randomNumberSvc, tGeometry);
89 
90  return sequencer.run();
91 }