Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ParticleSelectorOptions.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ParticleSelectorOptions.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2022 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 
10 
13 
14 #include <boost/program_options.hpp>
15 
16 namespace ActsExamples {
17 namespace Options {
18 
20  using boost::program_options::bool_switch;
22  using Options::Interval;
23 
24  auto opt = desc.add_options();
25  opt("select-rho-mm", value<Interval>()->value_name("MIN:MAX"),
26  "Select particle transverse distance to the origin in mm");
27  opt("select-absz-mm", value<Interval>()->value_name("MIN:MAX"),
28  "Select particle absolute longitudinal distance to the origin in mm");
29  opt("select-time-ns", value<Interval>()->value_name("MIN:MAX"),
30  "Select particle time in ns");
31  opt("select-phi-degree", value<Interval>()->value_name("MIN:MAX"),
32  "Select particle direction angle in the transverse plane in degree");
33  opt("select-eta", value<Interval>()->value_name("MIN:MAX"),
34  "Select particle pseudo-rapidity");
35  opt("select-abseta", value<Interval>()->value_name("MIN:MAX"),
36  "Select particle absolute pseudo-rapidity");
37  opt("select-pt-gev", value<Interval>()->value_name("MIN:MAX"),
38  "Select particle transverse momentum in GeV");
39  opt("remove-charged", bool_switch(), "Remove charged particles");
40  opt("remove-neutral", bool_switch(), "Remove neutral particles");
41 }
42 
44  const Options::Variables& vars) {
45  using namespace Acts::UnitLiterals;
46 
47  // Set boundary values if the given config exists
48  auto extractInterval = [&](const char* name, auto unit, auto& lower,
49  auto& upper) {
50  if (vars[name].empty()) {
51  return;
52  }
53  auto interval = vars[name].as<Options::Interval>();
54  lower = interval.lower.value_or(lower) * unit;
55  upper = interval.upper.value_or(upper) * unit;
56  };
57 
59  extractInterval("select-rho-mm", 1_mm, cfg.rhoMin, cfg.rhoMax);
60  extractInterval("select-absz-mm", 1_mm, cfg.absZMin, cfg.absZMax);
61  extractInterval("select-time-ns", 1_ns, cfg.timeMin, cfg.timeMax);
62  extractInterval("select-phi-degree", 1_degree, cfg.phiMin, cfg.phiMax);
63  extractInterval("select-eta", 1.0, cfg.etaMin, cfg.etaMax);
64  extractInterval("select-abseta", 1.0, cfg.absEtaMin, cfg.absEtaMax);
65  extractInterval("select-pt-gev", 1_GeV, cfg.ptMin, cfg.ptMax);
66  cfg.removeCharged = vars["remove-charged"].as<bool>();
67  cfg.removeNeutral = vars["remove-neutral"].as<bool>();
68  return cfg;
69 }
70 
71 } // namespace Options
72 } // namespace ActsExamples