ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GenericReadCsvExample.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file GenericReadCsvExample.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 <memory>
10 
22 
23 int main(int argc, char* argv[]) {
24  GenericDetector detector;
25 
26  // setup and parse options
32  detector.addOptions(desc);
33 
34  auto vm = FW::Options::parse(desc, argc, argv);
35  if (vm.empty()) {
36  return EXIT_FAILURE;
37  }
38 
40 
41  // Read some standard options
42  auto logLevel = FW::Options::readLogLevel(vm);
43  auto inputDir = vm["input-dir"].as<std::string>();
44 
45  // Setup detector geometry
46  auto geometry = FW::Geometry::build(vm, detector);
47  auto trackingGeometry = geometry.first;
48  // Add context decorators
49  for (auto cdr : geometry.second) {
50  sequencer.addContextDecorator(cdr);
51  }
52 
53  // Read particles from CSV files
54  auto particleReaderCfg = FW::Options::readCsvParticleReaderConfig(vm);
55  particleReaderCfg.outputParticles = "particles";
56  sequencer.addReader(
57  std::make_shared<FW::CsvParticleReader>(particleReaderCfg, logLevel));
58 
59  // Read clusters from CSV files
60  auto clusterReaderCfg = FW::Options::readCsvPlanarClusterReaderConfig(vm);
61  clusterReaderCfg.trackingGeometry = trackingGeometry;
62  clusterReaderCfg.outputClusters = "clusters";
63  clusterReaderCfg.outputHitParticlesMap = "hit_particle_map";
64  clusterReaderCfg.outputHitIds = "hit_ids";
65  sequencer.addReader(
66  std::make_shared<FW::CsvPlanarClusterReader>(clusterReaderCfg, logLevel));
67 
68  // Print some information as crosscheck
69  FW::PrintHits::Config printCfg;
70  printCfg.inputClusters = clusterReaderCfg.outputClusters;
71  printCfg.inputHitParticlesMap = clusterReaderCfg.outputHitParticlesMap;
72  printCfg.inputHitIds = clusterReaderCfg.outputHitIds;
73  // the following print selections work for the original author.
74  // you probably need to adapt them to your data.
75  printCfg.hitIdStart = 10224;
76  printCfg.hitIdLength = 8;
77  printCfg.volumeId = 13;
78  printCfg.layerId = 4;
79  printCfg.moduleId = 116;
80  sequencer.addAlgorithm(std::make_shared<FW::PrintHits>(printCfg, logLevel));
81 
82  return sequencer.run();
83 }