Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:02:34

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #include "ActsExamples/Digitization/MeasurementCreation.hpp"
0010 
0011 #include "Acts/EventData/MeasurementHelpers.hpp"
0012 #include "Acts/Geometry/GeometryIdentifier.hpp"
0013 #include "Acts/Surfaces/RegularSurface.hpp"
0014 #include "ActsExamples/EventData/Measurement.hpp"
0015 
0016 #include <stdexcept>
0017 #include <string>
0018 
0019 ActsExamples::VariableBoundMeasurementProxy ActsExamples::createMeasurement(
0020     MeasurementContainer& container, Acts::GeometryIdentifier geometryId,
0021     const DigitizedParameters& dParams) {
0022   if (dParams.indices.size() > 4u) {
0023     std::string errorMsg = "Invalid/mismatching measurement dimension: " +
0024                            std::to_string(dParams.indices.size());
0025     throw std::runtime_error(errorMsg.c_str());
0026   }
0027 
0028   return Acts::visit_measurement(
0029       dParams.indices.size(), [&](auto dim) -> VariableBoundMeasurementProxy {
0030         auto [indices, par, cov] = measurementConstituents<dim>(dParams);
0031         return VariableBoundMeasurementProxy{
0032             container.emplaceMeasurement<dim>(geometryId, indices, par, cov)};
0033       });
0034 }
0035 
0036 Acts::Vector3 ActsExamples::measurementGlobalPosition(
0037     const DigitizedParameters& digitizedParameters,
0038     const Acts::Surface& surface, const Acts::GeometryContext& gctx) {
0039   // we need a regular surface to perform the local to global transformation
0040   // without direction input. the direction could be obtained from truth
0041   // information but we can leave it out here.
0042   const Acts::RegularSurface* regularSurface =
0043       dynamic_cast<const Acts::RegularSurface*>(&surface);
0044   if (regularSurface == nullptr) {
0045     throw std::invalid_argument(
0046         "Cannot make global measurement position for a non-regular surface");
0047   }
0048 
0049   Acts::Vector2 locPos = regularSurface->bounds().center();
0050   for (auto i = 0ul; i < digitizedParameters.indices.size(); ++i) {
0051     auto idx = digitizedParameters.indices.at(i);
0052     if (idx == Acts::eBoundLoc0 || idx == Acts::eBoundLoc1) {
0053       locPos[idx] = digitizedParameters.values.at(i);
0054     }
0055   }
0056 
0057   return regularSurface->localToGlobal(gctx, locPos);
0058 }