Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AlignedDetectorWithOptions.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file AlignedDetectorWithOptions.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 
12 
13 #include <boost/program_options.hpp>
14 
15 using namespace Acts::UnitLiterals;
16 
17 namespace ActsExamples {
18 
19 void AlignedDetectorWithOptions::addOptions(
20  boost::program_options::options_description& opt) const {
21  // Add the generic geometry options
23  // specify the rotation setp
24  opt.add_options()(
25  "align-seed",
26  boost::program_options::value<size_t>()->default_value(1324354657),
27  "Seed for the decorator random numbers.")(
28  "align-iovsize",
29  boost::program_options::value<size_t>()->default_value(100),
30  "Size of a valid IOV.")(
31  "align-flushsize",
32  boost::program_options::value<size_t>()->default_value(200),
33  "Span until garbage collection is active.")(
34  "align-no-gc", boost::program_options::bool_switch())(
35  "align-sigma-iplane",
36  boost::program_options::value<double>()->default_value(100.),
37  "Sigma of the in-plane misalignment in [um]")(
38  "align-sigma-oplane",
39  boost::program_options::value<double>()->default_value(50.),
40  "Sigma of the out-of-plane misalignment in [um]")(
41  "align-sigma-irot",
42  boost::program_options::value<double>()->default_value(20.),
43  "Sigma of the in-plane rotation misalignment in [mrad]")(
44  "align-sigma-orot",
45  boost::program_options::value<double>()->default_value(0.),
46  "Sigma of the out-of-plane rotation misalignment in [mrad]")(
47  "align-loglevel",
48  boost::program_options::value<size_t>()->default_value(3),
49  "Output log level of the alignment decorator.")(
50  "align-firstnominal",
51  boost::program_options::value<bool>()->default_value(false),
52  "Keep the first iov batch nominal.")(
53  "align-mode",
54  boost::program_options::value<std::string>()->default_value("internal"));
55 }
56 
58  const boost::program_options::variables_map& vm,
59  std::shared_ptr<const Acts::IMaterialDecorator> mdecorator)
60  -> std::pair<TrackingGeometryPtr, ContextDecorators> {
61  // --------------------------------------------------------------------------------
62 
64  Config cfg;
65 
66  cfg.buildLevel = vm["geo-generic-buildlevel"].template as<size_t>();
67  // set geometry building logging level
68  cfg.surfaceLogLevel =
69  Acts::Logging::Level(vm["geo-surface-loglevel"].template as<size_t>());
70  cfg.layerLogLevel =
71  Acts::Logging::Level(vm["geo-layer-loglevel"].template as<size_t>());
72  cfg.volumeLogLevel =
73  Acts::Logging::Level(vm["geo-volume-loglevel"].template as<size_t>());
74 
75  cfg.buildProto = (vm["mat-input-type"].template as<std::string>() == "proto");
76 
77  cfg.decoratorLogLevel =
78  Acts::Logging::Level(vm["align-loglevel"].template as<size_t>());
79 
80  cfg.seed = vm["align-seed"].template as<size_t>();
81  cfg.iovSize = vm["align-iovsize"].template as<size_t>();
82  cfg.flushSize = vm["align-flushsize"].template as<size_t>();
83  cfg.doGarbageCollection = !vm["align-no-gc"].as<bool>();
84 
85  // The misalignments
86  cfg.sigmaInPlane = vm["align-sigma-iplane"].template as<double>() * 1_um;
87  cfg.sigmaOutPlane = vm["align-sigma-oplane"].template as<double>() * 1_um;
88  cfg.sigmaInRot = vm["align-sigma-irot"].template as<double>() * 0.001;
89  cfg.sigmaOutRot = vm["align-sigma-orot"].template as<double>() * 0.001;
90  cfg.firstIovNominal = vm["align-firstnominal"].template as<bool>();
91 
92  auto mode = vm["align-mode"].as<std::string>();
93  if (mode == "external") {
94  cfg.mode = Config::Mode::External;
95  } else if (mode == "internal") {
96  cfg.mode = Config::Mode::Internal;
97  } else {
98  throw std::invalid_argument{
99  "--align-mode must be 'external' or 'internal'"};
100  }
101 
102  return m_detector.finalize(cfg, mdecorator);
103 }
104 
105 } // namespace ActsExamples