Analysis Software
Documentation for sPHENIX simulation 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 
23 
24 using namespace Acts::UnitLiterals;
25 namespace ActsExamples::Contextual {
26 
28  const Config& cfg,
29  std::shared_ptr<const Acts::IMaterialDecorator> mdecorator)
30  -> std::pair<TrackingGeometryPtr, ContextDecorators> {
31  ContextDecorators aContextDecorators;
32 
33  // Let's create a random number service
34  ActsExamples::RandomNumbers::Config randomNumberConfig;
35  randomNumberConfig.seed = cfg.seed;
36  auto randomNumberSvc =
37  std::make_shared<ActsExamples::RandomNumbers>(randomNumberConfig);
38 
39  auto fillDecoratorConfig = [&](AlignmentDecorator::Config& config) {
40  config.iovSize = cfg.iovSize;
41  config.flushSize = cfg.flushSize;
42  config.doGarbageCollection = cfg.doGarbageCollection;
43 
44  // The misalignments
45  config.gSigmaX = cfg.sigmaInPlane;
46  config.gSigmaY = cfg.sigmaInPlane;
47  config.gSigmaZ = cfg.sigmaOutPlane;
48  config.aSigmaX = cfg.sigmaOutRot;
49  config.aSigmaY = cfg.sigmaOutRot;
50  config.aSigmaZ = cfg.sigmaInRot;
51  config.randomNumberSvc = randomNumberSvc;
52  config.firstIovNominal = cfg.firstIovNominal;
53  };
54 
55  TrackingGeometryPtr aTrackingGeometry;
56  if (cfg.mode == Config::Mode::External) {
58 
60  fillDecoratorConfig(agcsConfig);
61 
62  std::vector<std::vector<std::shared_ptr<ExternallyAlignedDetectorElement>>>
63  detectorStore;
64 
65  aTrackingGeometry =
66  ActsExamples::Generic::buildDetector<ExternallyAlignedDetectorElement>(
67  nominalContext, detectorStore, cfg.buildLevel,
68  std::move(mdecorator), cfg.buildProto, cfg.surfaceLogLevel,
69  cfg.layerLogLevel, cfg.volumeLogLevel);
70 
71  agcsConfig.trackingGeometry = aTrackingGeometry;
72 
73  // need to upcast to store in this object as well
74  for (auto& lstore : detectorStore) {
75  auto& target = m_detectorStore.emplace_back();
76  for (auto& ldet : lstore) {
77  target.push_back(ldet);
78  }
79  }
80 
81  aContextDecorators.push_back(std::make_shared<ExternalAlignmentDecorator>(
82  std::move(agcsConfig),
83  Acts::getDefaultLogger("AlignmentDecorator", cfg.decoratorLogLevel)));
84  } else {
86  nominalContext.nominal = true;
87 
89  fillDecoratorConfig(agcsConfig);
90 
91  aTrackingGeometry =
92  ActsExamples::Generic::buildDetector<InternallyAlignedDetectorElement>(
93  nominalContext, agcsConfig.detectorStore, cfg.buildLevel,
94  std::move(mdecorator), cfg.buildProto, cfg.surfaceLogLevel,
95  cfg.layerLogLevel, cfg.volumeLogLevel);
96 
97  // need to upcast to store in this object as well
98  for (auto& lstore : agcsConfig.detectorStore) {
99  auto& target = m_detectorStore.emplace_back();
100  for (auto& ldet : lstore) {
101  target.push_back(ldet);
102  }
103  }
104 
105  aContextDecorators.push_back(std::make_shared<InternalAlignmentDecorator>(
106  std::move(agcsConfig),
107  Acts::getDefaultLogger("AlignmentDecorator", cfg.decoratorLogLevel)));
108  }
109 
110  // return the pair of geometry and the alignment decorator(s)
111  return std::make_pair<TrackingGeometryPtr, ContextDecorators>(
112  std::move(aTrackingGeometry), std::move(aContextDecorators));
113 }
114 
115 } // namespace ActsExamples::Contextual