ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AlignedDetector.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file AlignedDetector.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 
10 
11 #include <boost/program_options.hpp>
12 
23 #include "Acts/Utilities/Units.hpp"
24 
26  boost::program_options::options_description& opt) const {
27  // Add the generic geometry options
29  // Add the bfield options for the magnetic field scaling
31  // specify the rotation setp
32  opt.add_options()(
33  "align-seed",
34  boost::program_options::value<size_t>()->default_value(1324354657),
35  "Seed for the decorator random numbers.")(
36  "align-iovsize",
37  boost::program_options::value<size_t>()->default_value(100),
38  "Size of a valid IOV.")(
39  "align-flushsize",
40  boost::program_options::value<size_t>()->default_value(200),
41  "Span until garbage collection is active.")(
42  "align-sigma-iplane",
43  boost::program_options::value<double>()->default_value(100.),
44  "Sigma of the in-plane misalignment in [um]")(
45  "align-sigma-oplane",
46  boost::program_options::value<double>()->default_value(50.),
47  "Sigma of the out-of-plane misalignment in [um]")(
48  "align-sigma-irot",
49  boost::program_options::value<double>()->default_value(20.),
50  "Sigma of the in-plane rotation misalignment in [mrad]")(
51  "align-sigma-orot",
52  boost::program_options::value<double>()->default_value(0.),
53  "Sigma of the out-of-plane rotation misalignment in [mrad]")(
54  "align-loglevel",
55  boost::program_options::value<size_t>()->default_value(3),
56  "Output log level of the alignment decorator.")(
57  "align-firstnominal",
58  boost::program_options::value<bool>()->default_value(false),
59  "Keep the first iov batch nominal.");
60 }
61 
63  const boost::program_options::variables_map& vm,
64  std::shared_ptr<const Acts::IMaterialDecorator> mdecorator)
65  -> std::pair<TrackingGeometryPtr, ContextDecorators> {
66  // --------------------------------------------------------------------------------
67  DetectorElement::ContextType nominalContext;
68 
69  auto buildLevel = vm["geo-generic-buildlevel"].template as<size_t>();
70  // set geometry building logging level
71  Acts::Logging::Level surfaceLogLevel =
72  Acts::Logging::Level(vm["geo-surface-loglevel"].template as<size_t>());
73  Acts::Logging::Level layerLogLevel =
74  Acts::Logging::Level(vm["geo-layer-loglevel"].template as<size_t>());
75  Acts::Logging::Level volumeLogLevel =
76  Acts::Logging::Level(vm["geo-volume-loglevel"].template as<size_t>());
77 
78  bool buildProto =
79  (vm["mat-input-type"].template as<std::string>() == "proto");
80 
82  TrackingGeometryPtr aTrackingGeometry =
83  FW::Generic::buildDetector<DetectorElement>(
84  nominalContext, detectorStore, buildLevel, std::move(mdecorator),
85  buildProto, surfaceLogLevel, layerLogLevel, volumeLogLevel);
86 
87  Acts::Logging::Level decoratorLogLevel =
88  Acts::Logging::Level(vm["align-loglevel"].template as<size_t>());
89 
90  // Let's create a reandom number service
91  FW::RandomNumbers::Config randomNumberConfig;
92  randomNumberConfig.seed = vm["align-seed"].template as<size_t>();
93  auto randomNumberSvc =
94  std::make_shared<FW::RandomNumbers>(randomNumberConfig);
95 
96  // Alignment decorator service
97  Decorator::Config agcsConfig;
98  agcsConfig.detectorStore = detectorStore;
99  agcsConfig.iovSize = vm["align-iovsize"].template as<size_t>();
100  agcsConfig.flushSize = vm["align-flushsize"].template as<size_t>();
101 
102  // The misalingments
103  double sigmaIp = vm["align-sigma-iplane"].template as<double>();
104  double sigmaOp = vm["align-sigma-oplane"].template as<double>();
105  double sigmaIr = vm["align-sigma-irot"].template as<double>();
106  double sigmaOr = vm["align-sigma-orot"].template as<double>();
107  agcsConfig.gSigmaX = sigmaIp * Acts::units::_um;
108  agcsConfig.gSigmaY = sigmaIp * Acts::units::_um;
109  agcsConfig.gSigmaZ = sigmaOp * Acts::units::_um;
110  agcsConfig.aSigmaX = sigmaOr * 0.001; // millirad
111  agcsConfig.aSigmaY = sigmaOr * 0.001; // millirad
112  agcsConfig.aSigmaZ = sigmaIr * 0.001; // millirad
113  agcsConfig.randomNumberSvc = randomNumberSvc;
114  agcsConfig.firstIovNominal = vm["align-firstnominal"].template as<bool>();
115 
116  // Now create the alignment decorator
117  ContextDecorators aContextDecorators = {std::make_shared<Decorator>(
118  agcsConfig,
119  Acts::getDefaultLogger("AlignmentDecorator", decoratorLogLevel))};
120 
121  if (vm["bf-context-scalable"].template as<bool>()) {
123  bfsConfig.scalor = vm["bf-bscalor"].template as<double>();
124 
125  auto bfDecorator = std::make_shared<FW::BField::BFieldScalor>(bfsConfig);
126 
127  aContextDecorators.push_back(bfDecorator);
128  }
129 
130  // return the pair of geometry and the alignment decorator(s)
131  return std::make_pair<TrackingGeometryPtr, ContextDecorators>(
132  std::move(aTrackingGeometry), std::move(aContextDecorators));
133 }