Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MeasurementsToSpacepoints.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file MeasurementsToSpacepoints.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 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 
14 #include "ActsExamples/Io/Csv/CsvParticleReader.hpp" // for evaluating performance
17 #include "ActsExamples/Io/Json/JsonDigitizationConfig.hpp" // to read digi config
23 #include "ActsExamples/TruthTracking/TruthSeedSelector.hpp" // for evaluating performance
27 
28 #include <iostream>
29 
30 #include <boost/program_options.hpp>
31 
32 using namespace Acts::UnitLiterals;
33 using namespace ActsExamples;
34 
35 static std::unique_ptr<const Acts::Logger> m_logger;
36 const Acts::Logger& logger() {
37  return *m_logger;
38 }
40  int argc, char* argv[],
41  const std::shared_ptr<ActsExamples::IBaseDetector>& detector) {
42  // Setup and parse options
43  auto desc = Options::makeDefaultOptions();
48  Options::addOutputOptions(desc, OutputFormat::Csv | OutputFormat::Root);
51 
52  // Add specific options for this geometry
53  // <TODO> make it as an argument.
54  // auto detector = std::make_shared<TGeoDetector>();
55  detector->addOptions(desc);
56 
57  auto vm = Options::parse(desc, argc, argv);
58  if (vm.empty()) {
59  return EXIT_FAILURE;
60  }
61 
63 
64  // Now read the standard options
66  auto outputDir = ensureWritableDirectory(vm["output-dir"].as<std::string>());
67 
68  m_logger = Acts::getDefaultLogger("MeasurementsToSP", logLevel);
69  ACTS_INFO("after parsing input options");
70 
71  // The geometry, material and decoration
72  // build the detector
73  auto geometry = Geometry::build(vm, *detector);
74  auto tGeometry = geometry.first;
75  auto contextDecorators = geometry.second;
76  auto randomNumbers =
77  std::make_shared<RandomNumbers>(Options::readRandomNumbersConfig(vm));
78 
79  ACTS_INFO("after building geometry");
80 
81  // Add the decorator to the sequencer
82  for (const auto& cdr : contextDecorators) {
83  sequencer.addContextDecorator(cdr);
84  }
85 
86  ACTS_INFO("after adding context decorator");
87 
88  // Setup the magnetic field
91 
92  ACTS_INFO("after setting magnetic field");
93 
94  // Read the inputs
95  auto simHitReaderCfg = setupSimHitReading(vm, sequencer);
96  auto particleReader = setupParticleReading(vm, sequencer);
97  auto measurementsReader = setupMeasurementReading(vm, sequencer);
98 
99  ACTS_INFO("after reading SimHits and particles");
100 
101  // Now measurements --> SpacePoints
103  spCfg.inputSourceLinks = measurementsReader.outputSourceLinks;
104  spCfg.inputMeasurements = measurementsReader.outputMeasurements;
105  spCfg.outputSpacePoints = "spacepoints";
106  spCfg.trackingGeometry = tGeometry;
108  sequencer.addAlgorithm(std::make_shared<SpacePointMaker>(spCfg, logLevel));
109 
110  // // write out spacepoints...
111  CsvSpacepointWriter::Config spWriterCfg;
112  spWriterCfg.inputSpacepoints = spCfg.outputSpacePoints;
113  spWriterCfg.outputDir = outputDir;
114  sequencer.addWriter(
115  std::make_shared<CsvSpacepointWriter>(spWriterCfg, logLevel));
116 
117  return sequencer.run();
118 }