|
| 1 | +// This file is part of the ACTS project. |
| 2 | +// |
| 3 | +// Copyright (C) 2016 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 https://mozilla.org/MPL/2.0/. |
| 8 | + |
| 9 | +#pragma once |
| 10 | + |
| 11 | +#include "Acts/Geometry/GeometryIdentifier.hpp" |
| 12 | +#include "Acts/Propagator/EigenStepper.hpp" |
| 13 | +#include "Acts/Propagator/Navigator.hpp" |
| 14 | +#include "Acts/Propagator/Propagator.hpp" |
| 15 | +#include "Acts/Propagator/detail/SteppingLogger.hpp" |
| 16 | +#include "Acts/TrackFitting/KalmanFitter.hpp" |
| 17 | +#include "ActsAlignment/Kernel/Alignment.hpp" |
| 18 | +#include "ActsExamples/EventData/Measurement.hpp" |
| 19 | +#include "ActsExamples/EventData/Track.hpp" |
| 20 | +#include "ActsExamples/Framework/DataHandle.hpp" |
| 21 | +#include "ActsExamples/Framework/IAlgorithm.hpp" |
| 22 | + |
| 23 | +#include <memory> |
| 24 | + |
| 25 | +#include "Mille/MilleFactory.h" |
| 26 | + |
| 27 | +namespace Acts { |
| 28 | +class MagneticFieldProvider; |
| 29 | +} |
| 30 | + |
| 31 | +namespace ActsExamples { |
| 32 | + |
| 33 | +/// @brief Sandbox algorithm for experimenting with |
| 34 | +/// writing ACTS Kalman tracks to Millepede |
| 35 | +/// and passing them to the (external) |
| 36 | +/// Millepede alignment fit. |
| 37 | +/// Will consume an input track collection, |
| 38 | +/// pass the tracks through the existing |
| 39 | +/// Kalman alignment module and then |
| 40 | +/// write this information to a user-configured |
| 41 | +/// Mille binary that can be read by the solver. |
| 42 | +/// |
| 43 | +/// You can either pass standard MC tracks and |
| 44 | +/// look for a zero-correction, or pass |
| 45 | +/// deliberately misaligned tracks and fit back |
| 46 | +/// out the injected misalignment. The module |
| 47 | +/// will **ignore** any external geometry context, |
| 48 | +/// so injected alignment corrections in the upstream |
| 49 | +/// job will show up as distortions here. |
| 50 | +class MillePedeAlignmentSandbox final : public IAlgorithm { |
| 51 | + public: |
| 52 | + using SteppingLogger = Acts::detail::SteppingLogger; |
| 53 | + using EndOfWorld = Acts::EndOfWorldReached; |
| 54 | + using Stepper = Acts::EigenStepper<>; |
| 55 | + using Propagator = Acts::Propagator<Stepper, Acts::Navigator>; |
| 56 | + using Fitter = Acts::KalmanFitter<Propagator, Acts::VectorMultiTrajectory>; |
| 57 | + using Alignment = ActsAlignment::Alignment<Fitter>; |
| 58 | + |
| 59 | + using AlignmentParameters = |
| 60 | + std::unordered_map<Acts::SurfacePlacementBase*, Acts::Transform3>; |
| 61 | + |
| 62 | + /// configuration |
| 63 | + struct Config { |
| 64 | + /// name of the mille output binary. You can choose |
| 65 | + /// between ".root" / ".csv" / ".dat" extensions |
| 66 | + /// to get ROOT tree / plain text / classic Millepede |
| 67 | + /// binary outputs. All three can be read by the solver. |
| 68 | + std::string milleOutput; |
| 69 | + /// Input measurements collection. |
| 70 | + std::string inputMeasurements; |
| 71 | + /// Input tracks |
| 72 | + std::string inputTracks; |
| 73 | + // the tracking geometry to use |
| 74 | + std::shared_ptr<const Acts::TrackingGeometry> trackingGeometry; |
| 75 | + // magnetic field |
| 76 | + std::shared_ptr<const Acts::MagneticFieldProvider> magneticField; |
| 77 | + // modules to fix in the alignment to suppress global movements |
| 78 | + std::set<Acts::GeometryIdentifier> fixModules; |
| 79 | + }; |
| 80 | + |
| 81 | + /// Constructor of the sandbox algorithm |
| 82 | + /// @param cfg is the config struct to configure the algorithm |
| 83 | + /// @param level is the logging level |
| 84 | + explicit MillePedeAlignmentSandbox( |
| 85 | + Config cfg, std::unique_ptr<const Acts::Logger> logger = nullptr); |
| 86 | + |
| 87 | + /// Framework execute method of the sandbox algorithm |
| 88 | + /// |
| 89 | + /// @param ctx is the algorithm context that holds event-wise information |
| 90 | + /// @return a process code to steer the algorithm flow |
| 91 | + ProcessCode execute(const AlgorithmContext& ctx) const override; |
| 92 | + ProcessCode finalize() override; |
| 93 | + |
| 94 | + /// Get readonly access to the config parameters |
| 95 | + const Config& config() const { return m_cfg; } |
| 96 | + |
| 97 | + private: |
| 98 | + /// configuration instance |
| 99 | + Config m_cfg; |
| 100 | + |
| 101 | + /// measurement container containing the measurements on the input tracks |
| 102 | + /// below |
| 103 | + ReadDataHandle<MeasurementContainer> m_inputMeasurements{this, |
| 104 | + "InputMeasurements"}; |
| 105 | + /// tracks to use for the alignment |
| 106 | + ReadDataHandle<ConstTrackContainer> m_inputTracks{this, "InputTracks"}; |
| 107 | + |
| 108 | + /// alignment module instance - reuse as much as possible |
| 109 | + std::shared_ptr<Alignment> m_align; |
| 110 | + /// tracking geometry |
| 111 | + std::shared_ptr<const Acts::TrackingGeometry> m_trackingGeometry; |
| 112 | + /// the Mille record instance for writing our alignment info. |
| 113 | + std::unique_ptr<Mille::MilleRecord> m_milleOut = nullptr; |
| 114 | +}; |
| 115 | + |
| 116 | +} // namespace ActsExamples |
0 commit comments