Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ShowFatrasGeneric.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ShowFatrasGeneric.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019-2020 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 
12 
23 
24 #include <memory>
25 
26 #include <boost/program_options.hpp>
27 
28 using namespace ActsExamples;
30 
31 int main(int argc, char* argv[]) {
33 
34  // setup and parse options
35  auto desc = Options::makeDefaultOptions("Read and print Fatras CSV files");
36  auto opts = desc.add_options();
38  opts("input-dir", value<std::string>()->default_value(""), "");
40  detector.addOptions(desc);
42  auto vars = Options::parse(desc, argc, argv);
43  if (vars.empty()) {
44  return EXIT_FAILURE;
45  }
46 
47  Sequencer sequencer(Options::readSequencerConfig(vars));
48 
49  // read options
50  auto logLevel = Options::readLogLevel(vars);
51  auto inputDir = vars["input-dir"].as<std::string>();
52 
53  // setup detector
54  auto [trackingGeometry, contextDecorators] = Geometry::build(vars, detector);
55  for (const auto& cdr : contextDecorators) {
56  sequencer.addContextDecorator(cdr);
57  }
58 
59  // read initial/final particles
60  CsvParticleReader::Config readInitialCfg;
61  readInitialCfg.inputDir = inputDir;
62  readInitialCfg.inputStem = "particles_initial";
63  readInitialCfg.outputParticles = "particles_initial";
64  sequencer.addReader(
65  std::make_shared<CsvParticleReader>(readInitialCfg, logLevel));
66  CsvParticleReader::Config readFinalCfg;
67  readFinalCfg.inputDir = inputDir;
68  readFinalCfg.inputStem = "particles_final";
69  readFinalCfg.outputParticles = "particles_final";
70  sequencer.addReader(
71  std::make_shared<CsvParticleReader>(readFinalCfg, logLevel));
72 
73  // read clusters/hits
74  CsvPlanarClusterReader::Config readClustersCfg;
75  readClustersCfg.inputDir = inputDir;
76  readClustersCfg.outputClusters = "clusters";
77  readClustersCfg.outputMeasurementParticlesMap = "hit_particle_map";
78  readClustersCfg.outputHitIds = "hit_ids";
79  readClustersCfg.outputSimHits = "simulated_hits";
80  readClustersCfg.trackingGeometry = trackingGeometry;
81  sequencer.addReader(std::make_shared<ActsExamples::CsvPlanarClusterReader>(
82  readClustersCfg, logLevel));
83 
84  // print event data
85  ParticlesPrinter::Config printInitialCfg;
86  printInitialCfg.inputParticles = readInitialCfg.outputParticles;
87  sequencer.addAlgorithm(
88  std::make_shared<ParticlesPrinter>(printInitialCfg, logLevel));
89  ParticlesPrinter::Config printFinalCfg;
90  printFinalCfg.inputParticles = readFinalCfg.outputParticles;
91  sequencer.addAlgorithm(
92  std::make_shared<ParticlesPrinter>(printFinalCfg, logLevel));
93  HitsPrinter::Config printHitsCfg;
94  printHitsCfg.inputClusters = readClustersCfg.outputClusters;
95  printHitsCfg.inputMeasurementParticlesMap =
96  readClustersCfg.outputMeasurementParticlesMap;
97  printHitsCfg.inputHitIds = readClustersCfg.outputHitIds;
98  // print all hits in the container
99  printHitsCfg.selectIndexLength = SIZE_MAX;
100  // print all hits within a volume/layer/volume
101  // printHitsCfg.selectVolume = 9;
102  // printHitsCfg.selectLayer = 6;
103  // printHits.selectModule = 116;
104  sequencer.addAlgorithm(std::make_shared<HitsPrinter>(printHitsCfg, logLevel));
105 
106  return sequencer.run();
107 }