ATLAS Offline Software
Loading...
Searching...
No Matches
BeamSpotPreparatorAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
5
6
8#include "Acts/Surfaces/PerigeeSurface.hpp"
9#include "Acts/Surfaces/StrawSurface.hpp"
10#include "Acts/Definitions/Units.hpp"
11#include "Acts/Utilities/UnitVectors.hpp"
12
13using namespace Acts::UnitLiterals;
14
15
16
17namespace MuonCombinedR4 {
22 ATH_CHECK(m_ctxProvider.initialize());
23 return StatusCode::SUCCESS;
24 }
25 StatusCode BeamSpotPreparatorAlg::execute(const EventContext& ctx) const {
26 const InDet::BeamSpotData* beamSpotData{nullptr};
27 ATH_CHECK(SG::get(beamSpotData, m_beamSpotKey, ctx));
28 const xAOD::VertexContainer* vtxContainer{nullptr};
29 ATH_CHECK(SG::get(vtxContainer, m_vertexKey, ctx));
30
31 auto measCreator = m_beamSpotHandle.makeHandle(ctx, m_ctxProvider.getGeometryContext(ctx));
32 if (!measCreator.ok()) {
33 ATH_MSG_ERROR("Cannot create the auxilary measurement container");
34 return StatusCode::FAILURE;
35 }
37 if (vtxContainer) {
38 for (const xAOD::Vertex* vertex : *vtxContainer) {
39 if (vertex->vertexType() != xAOD::VxType::PriVtx ) {
40 continue;
41 }
42 Amg::Transform3D surfaceTrf{Amg::getTranslate3D(vertex->position())};
43 Acts::Matrix<2,3> projector{Acts::Matrix<2,3>::Zero()};
44 projector.row(0) = m_sigmaScaleR* Acts::makeDirectionFromPhiTheta(vertex->position().phi(),
45 90._degree);
46 projector.row(1) = m_sigmaScaleZ * Amg::Vector3D::UnitZ();
47
48 AmgSymMatrix(2) cov = projector * vertex->covariancePosition() * projector.transpose();
49
50 auto surface = Acts::Surface::makeShared<Acts::PerigeeSurface>(surfaceTrf);
51 measCreator->newMeasurement<2>(surface, ProjectorType::e2DimNoTime, cov);
52 }
53 } else if (beamSpotData) {
54 const InDet::BeamSpotData* beamSpot{nullptr};
55 ATH_CHECK(SG::get(beamSpot, m_beamSpotKey, ctx));
56 Amg::Transform3D beamSpotTrf = Amg::getTranslate3D(beamSpot->beamPos()) *
57 Amg::getRotateY3D(beamSpot->beamTilt(0)) *
58 Amg::getRotateX3D(beamSpot->beamTilt(1));
59 AmgSymMatrix(3) beamCov{AmgSymMatrix(3)::Identity()};
60 beamCov(0,0) = beamSpot->beamSigma(0);
61 beamCov(1,1) = beamSpot->beamSigma(1);
62 beamCov(2,2) = beamSpot->beamSigma(2);
63 beamCov(0,1) = beamCov(1,0) = beamSpot->beamSigma(5);
64
65 Acts::Matrix<2,3> projector{Acts::Matrix<2,3>::Zero()};
66 projector(0,0) = m_sigmaScaleR* Amg::Vector3D::UnitX().dot(beamSpotTrf.linear() * Amg::Vector3D::UnitX());
67 projector(0,1) = m_sigmaScaleR* Amg::Vector3D::UnitY().dot(beamSpotTrf.linear() * Amg::Vector3D::UnitY());
68 projector(1,2) = m_sigmaScaleZ;
69
70 AmgSymMatrix(2) cov = projector * beamCov * projector.transpose();
71 ATH_MSG_DEBUG(__func__<<"() "<<__LINE__<<" - Covariance \n"<<cov
72 <<",\n projector:\n"<<projector);
73
74 auto surface = Acts::Surface::makeShared<Acts::PerigeeSurface>(beamSpotTrf);
75 measCreator->newMeasurement<2>(surface, ProjectorType::e2DimNoTime, cov);
76 }
77 return StatusCode::SUCCESS;
78 }
79}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
#define AmgSymMatrix(dim)
ActsTrk::ContextUtility m_ctxProvider
Context provider for geometry, magnetic field and calibration contexts.
virtual StatusCode initialize() override final
Gaudi::Property< double > m_sigmaScaleZ
Extra scale factor on the longitudinal beam spot covariance position.
virtual StatusCode execute(const EventContext &ctx) const override final
ActsTrk::AuxiliaryMeasurementHandler m_beamSpotHandle
Handle the beam spot auxiliary measurement.
Gaudi::Property< std::string > m_writeKey
Key under which the auxiliary container will be registered in store gate.
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
Optional dependency on the beamspot container.
Gaudi::Property< double > m_sigmaScaleR
Extra scal factor on the radial beam spot covariance position.
Gaudi::Property< bool > m_useBeamSpot
Switch to toggle whether the beam spot or the primary vertex will be used as beamspot measuremenmt.
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexKey
Data dependency on the vertex container.
ActsTrk::detail::MeasurementCalibratorBase::ProjectorType ProjectorType
Use the calibration projector.
Amg::Transform3D getRotateX3D(double angle)
Rotate the coordinate system by an angle around the x-axis.
Amg::Transform3D getTranslate3D(const double X, const double Y, const double Z)
: Returns a shift transformation along an arbitrary axis
Eigen::Affine3d Transform3D
Amg::Transform3D getRotateY3D(double angle)
Rotate the coordinate system by an angle around the z-axis.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
@ PriVtx
Primary vertex.
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.