Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ContextualAlignment.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ContextualAlignment.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 
11 
12 #include "DetectorAlignment.hpp"
13 
14 int main(int argc, char* argv[]) {
15  // 1. The aligned transform updater
16  ActsAlignment::AlignedTransformUpdater alignedTransformUpdater =
17  [](Acts::DetectorElementBase* detElement,
20  auto* alignedDetElement = dynamic_cast<
22  detElement);
23  assert(alignedDetElement != nullptr && "Got wrong detector element");
24  auto alignContext =
27  if (alignedDetElement != nullptr) {
28  alignedDetElement->addAlignedTransform(aTransform, alignContext.iov);
29  return true;
30  }
31  return false;
32  };
33 
34  // 2. Selector for the detector elements to be aligned
35  // @todo: allow different levels of alignment
36  auto alignedDetElementsGetter =
37  [](const std::shared_ptr<ActsExamples::IBaseDetector>& detector,
38  const std::vector<Acts::GeometryIdentifier>& geometrySelection)
39  -> std::vector<Acts::DetectorElementBase*> {
40  std::vector<Acts::DetectorElementBase*> dets;
41  auto* alignedDetector =
42  &dynamic_cast<ActsExamples::AlignedDetectorWithOptions*>(detector.get())
43  ->m_detector;
44  for (auto& lstore : alignedDetector->detectorStore()) {
45  for (auto& ldet : lstore) {
46  // get the detector surface
47  const auto& surface = &ldet->surface();
48  auto geoID = surface->geometryId();
49  auto it = std::find(geometrySelection.begin(), geometrySelection.end(),
50  geoID);
51  if (it != geometrySelection.end()) {
52  dets.push_back(ldet.get());
53  }
54  }
55  }
56  return dets;
57  };
58 
59  return runDetectorAlignment(
60  argc, argv, std::make_shared<ActsExamples::AlignedDetectorWithOptions>(),
61  alignedTransformUpdater, alignedDetElementsGetter);
62 }