Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExampleAlgorithms.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ExampleAlgorithms.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 
19 
20 #include <vector>
21 
22 #include <pybind11/pybind11.h>
23 #include <pybind11/stl.h>
24 
25 namespace py = pybind11;
26 
27 using namespace ActsExamples;
28 using namespace Acts;
29 
30 namespace Acts::Python {
31 
33  auto [m, mex] = ctx.get("main", "examples");
34 
35  mex.def("readJsonGeometryList", ActsExamples::readJsonGeometryList);
36 
38  ActsExamples::FatrasSimulation, mex, "FatrasSimulation", inputParticles,
40  imputParametrisationNuclearInteraction, randomNumbers, trackingGeometry,
41  magneticField, pMin, emScattering, emEnergyLossIonisation,
42  emEnergyLossRadiation, emPhotonConversion, generateHitsOnSensitive,
43  generateHitsOnMaterial, generateHitsOnPassive, averageHitsPerParticle);
44 
46  "ParticlesPrinter", inputParticles);
47 
49  ActsExamples::HitsPrinter, mex, "HitsPrinter", inputClusters,
50  inputMeasurementParticlesMap, inputHitIds, selectIndexStart,
51  selectIndexLength, selectVolume, selectLayer, selectModule);
52 
54  "TrackParametersPrinter", inputTrackParameters);
55 
56  {
58  using Config = Alg::Config;
59 
60  auto alg = py::class_<Alg, IAlgorithm, std::shared_ptr<Alg>>(
61  mex, "TrackSelectorAlgorithm")
62  .def(py::init<const Alg::Config&, Acts::Logging::Level>(),
63  py::arg("config"), py::arg("level"))
64  .def_property_readonly("config", &Alg::config);
65 
66  auto c = py::class_<Config>(alg, "Config").def(py::init<>());
67 
71  ACTS_PYTHON_MEMBER(selectorConfig);
73  }
74 
75  {
76  using EtaBinnedConfig = Acts::TrackSelector::EtaBinnedConfig;
78 
79  auto tool = py::class_<Acts::TrackSelector>(m, "TrackSelector")
80  .def(py::init<const Config&>(), py::arg("config"))
81  .def(py::init<const EtaBinnedConfig&>(), py::arg("config"));
82 
83  {
84  auto c = py::class_<Config>(tool, "Config").def(py::init<>());
85 
87 
89  ACTS_PYTHON_MEMBER(loc0Min);
90  ACTS_PYTHON_MEMBER(loc0Max);
91  ACTS_PYTHON_MEMBER(loc1Min);
92  ACTS_PYTHON_MEMBER(loc1Max);
93  ACTS_PYTHON_MEMBER(timeMin);
94  ACTS_PYTHON_MEMBER(timeMax);
96  ACTS_PYTHON_MEMBER(phiMax);
97  ACTS_PYTHON_MEMBER(etaMin);
98  ACTS_PYTHON_MEMBER(etaMax);
99  ACTS_PYTHON_MEMBER(absEtaMin);
100  ACTS_PYTHON_MEMBER(absEtaMax);
101  ACTS_PYTHON_MEMBER(ptMin);
102  ACTS_PYTHON_MEMBER(ptMax);
103  ACTS_PYTHON_MEMBER(minMeasurements);
105 
106  pythonRangeProperty(c, "loc0", &Config::loc0Min, &Config::loc0Max);
107  pythonRangeProperty(c, "loc1", &Config::loc1Min, &Config::loc1Max);
108  pythonRangeProperty(c, "time", &Config::timeMin, &Config::timeMax);
109  pythonRangeProperty(c, "phi", &Config::phiMin, &Config::phiMax);
110  pythonRangeProperty(c, "eta", &Config::etaMin, &Config::etaMax);
111  pythonRangeProperty(c, "absEta", &Config::absEtaMin, &Config::absEtaMax);
112  pythonRangeProperty(c, "pt", &Config::ptMin, &Config::ptMax);
113  }
114 
115  {
116  auto c = py::class_<EtaBinnedConfig>(tool, "EtaBinnedConfig")
117  .def(py::init<>())
118  .def(py::init<const Config&>());
119 
120  c.def_property_readonly("nEtaBins", &EtaBinnedConfig::nEtaBins);
121 
122  ACTS_PYTHON_STRUCT_BEGIN(c, EtaBinnedConfig);
123  ACTS_PYTHON_MEMBER(cutSets);
124  ACTS_PYTHON_MEMBER(absEtaEdges);
126  }
127  }
128 }
129 } // namespace Acts::Python