EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RecCKFTracks.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file RecCKFTracks.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 
26 #include <Acts/Utilities/Units.hpp>
27 
28 #include <memory>
29 
30 using namespace Acts::UnitLiterals;
31 using namespace ActsExamples;
32 
33 int main(int argc, char* argv[]) {
34  GenericDetector detector;
35 
36  // setup and parse options
44  detector.addOptions(desc);
47 
48  auto vm = Options::parse(desc, argc, argv);
49  if (vm.empty()) {
50  return EXIT_FAILURE;
51  }
52 
54 
55  // Read some standard options
56  auto logLevel = Options::readLogLevel(vm);
57  auto inputDir = vm["input-dir"].as<std::string>();
58  auto outputDir = ensureWritableDirectory(vm["output-dir"].as<std::string>());
59  auto rnd = std::make_shared<ActsExamples::RandomNumbers>(
61 
62  // Setup detector geometry
63  auto geometry = Geometry::build(vm, detector);
64  auto trackingGeometry = geometry.first;
65  // Add context decorators
66  for (auto cdr : geometry.second) {
67  sequencer.addContextDecorator(cdr);
68  }
69  // Setup the magnetic field
71 
72  // Read particles (initial states) and clusters from CSV files
73  auto particleReader = Options::readCsvParticleReaderConfig(vm);
74  particleReader.inputStem = "particles_initial";
75  particleReader.outputParticles = "particles_initial";
76  sequencer.addReader(
77  std::make_shared<CsvParticleReader>(particleReader, logLevel));
78  // Read clusters from CSV files
79  auto clusterReaderCfg = Options::readCsvPlanarClusterReaderConfig(vm);
80  clusterReaderCfg.trackingGeometry = trackingGeometry;
81  clusterReaderCfg.outputClusters = "clusters";
82  clusterReaderCfg.outputHitIds = "hit_ids";
83  clusterReaderCfg.outputHitParticlesMap = "hit_particles_map";
84  clusterReaderCfg.outputSimulatedHits = "hits";
85  sequencer.addReader(
86  std::make_shared<CsvPlanarClusterReader>(clusterReaderCfg, logLevel));
87 
88  // Pre-select particles
89  // The pre-selection will select truth particles satisfying provided criteria
90  // from all particles read in by particle reader for further processing. It
91  // has no impact on the truth hits read-in by the cluster reader.
92  // @TODO: add options for truth particle selection criteria
93  TruthSeedSelector::Config particleSelectorCfg;
94  particleSelectorCfg.inputParticles = particleReader.outputParticles;
95  particleSelectorCfg.inputHitParticlesMap =
96  clusterReaderCfg.outputHitParticlesMap;
97  particleSelectorCfg.outputParticles = "particles_selected";
98  particleSelectorCfg.ptMin = 1_GeV;
99  particleSelectorCfg.nHitsMin = 9;
100  sequencer.addAlgorithm(
101  std::make_shared<TruthSeedSelector>(particleSelectorCfg, logLevel));
102 
103  // Create smeared measurements
104  HitSmearing::Config hitSmearingCfg;
105  hitSmearingCfg.inputSimulatedHits = clusterReaderCfg.outputSimulatedHits;
106  hitSmearingCfg.outputSourceLinks = "sourcelinks";
107  hitSmearingCfg.sigmaLoc0 = 25_um;
108  hitSmearingCfg.sigmaLoc1 = 100_um;
109  hitSmearingCfg.randomNumbers = rnd;
110  hitSmearingCfg.trackingGeometry = trackingGeometry;
111  sequencer.addAlgorithm(
112  std::make_shared<HitSmearing>(hitSmearingCfg, logLevel));
113 
114  const auto& inputParticles = particleSelectorCfg.outputParticles;
115  // Create smeared particles states
116  ParticleSmearing::Config particleSmearingCfg;
117  particleSmearingCfg.inputParticles = inputParticles;
118  particleSmearingCfg.outputTrackParameters = "smearedparameters";
119  particleSmearingCfg.randomNumbers = rnd;
120  // Gaussian sigmas to smear particle parameters
121  particleSmearingCfg.sigmaD0 = 20_um;
122  particleSmearingCfg.sigmaD0PtA = 30_um;
123  particleSmearingCfg.sigmaD0PtB = 0.3 / 1_GeV;
124  particleSmearingCfg.sigmaZ0 = 20_um;
125  particleSmearingCfg.sigmaZ0PtA = 30_um;
126  particleSmearingCfg.sigmaZ0PtB = 0.3 / 1_GeV;
127  particleSmearingCfg.sigmaPhi = 1_degree;
128  particleSmearingCfg.sigmaTheta = 1_degree;
129  particleSmearingCfg.sigmaPRel = 0.01;
130  particleSmearingCfg.sigmaT0 = 1_ns;
131  sequencer.addAlgorithm(
132  std::make_shared<ParticleSmearing>(particleSmearingCfg, logLevel));
133 
134  // Setup the track finding algorithm with CKF
135  // It takes all the source links created from truth hit smearing, seeds from
136  // truth particle smearing and source link selection config
137  auto trackFindingCfg = Options::readTrackFindingConfig(vm);
138  trackFindingCfg.inputSourceLinks = hitSmearingCfg.outputSourceLinks;
139  trackFindingCfg.inputInitialTrackParameters =
140  particleSmearingCfg.outputTrackParameters;
141  trackFindingCfg.outputTrajectories = "trajectories";
142  trackFindingCfg.findTracks = TrackFindingAlgorithm::makeTrackFinderFunction(
144  sequencer.addAlgorithm(
145  std::make_shared<TrackFindingAlgorithm>(trackFindingCfg, logLevel));
146 
147  // Write CKF performance data
148  CKFPerformanceWriter::Config perfWriterCfg;
149  perfWriterCfg.inputParticles = inputParticles;
150  perfWriterCfg.inputTrajectories = trackFindingCfg.outputTrajectories;
151  perfWriterCfg.outputDir = outputDir;
152  sequencer.addWriter(
153  std::make_shared<CKFPerformanceWriter>(perfWriterCfg, logLevel));
154 
155  return sequencer.run();
156 }