Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DigitizationConfigExample.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DigitizationConfigExample.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2020-2021 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 
19 
20 #include <fstream>
21 #include <memory>
22 
23 #include <boost/program_options.hpp>
24 
25 #include "DigitizationInput.hpp"
26 
27 using namespace ActsExamples;
28 
30  int argc, char* argv[],
31  const std::shared_ptr<ActsExamples::IBaseDetector>& detector) {
32  // Setup and parse options
33  auto desc = Options::makeDefaultOptions();
38 
39  auto opt = desc.add_options();
40  opt("digi-compactify-output", boost::program_options::bool_switch(),
41  "Try to compactify the resulting output .json file by "
42  "identifying common items.");
43 
44  // Add specific options for this geometry
45  detector->addOptions(desc);
46  auto vm = Options::parse(desc, argc, argv);
47  if (vm.empty()) {
48  return EXIT_FAILURE;
49  }
50 
51  // Get the input configuration
52  auto inputConfig =
53  readDigiConfigFromJson(vm["digi-config-file"].as<std::string>());
54 
55  // The geometry, material and decoration
56  auto geometry = Geometry::build(vm, *detector);
57 
58  // Build a parser and visit the geometry
60  digiConfigurator.compactify = vm["digi-compactify-output"].as<bool>();
61  digiConfigurator.inputDigiComponents = inputConfig;
62 
63  geometry.first->visitSurfaces(digiConfigurator);
64 
66  digiConfigurator.outputDigiComponents);
67 
68  if (not vm["dump-digi-config"].as<std::string>().empty()) {
69  writeDigiConfigToJson(outputConfig,
70  vm["dump-digi-config"].as<std::string>());
71  }
72 
73  return 0;
74 }