ATLAS Offline Software
Loading...
Searching...
No Matches
ActsMaterialStepConverterTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7// ATHENA
8#include "GaudiKernel/EventContext.h"
9
10// PACKAGE
12
13// Tracking
15
16// ACTS
17#include "Acts/Material/MaterialSlab.hpp"
18
19// STL
20#include <iostream>
21#include <memory>
22
23ActsMaterialStepConverterTool::ActsMaterialStepConverterTool(const std::string& type, const std::string& name,
24 const IInterface* parent)
25 : base_class(type, name, parent)
26{
27}
28
29StatusCode
31{
32 ATH_MSG_INFO(name() << " initializing");
33
34 return StatusCode::SUCCESS;
35}
36
37
40{
42 std::vector<Acts::MaterialInteraction> nStep;
43 Acts::RecordedMaterial recorded;
44 double sum_X0 = 0;
45 double sum_L0 = 0;
46
47 // check you are working with the correct dataset, otherwise write out a warning
48 // for mapping geantinos must be produced from (0, 0, 0), hence expecting z being very small!
49 double deltaZ = colStep.back()->hitZ() - colStep.front()->hitZ();
50 double deltaR = colStep.back()->hitR() - colStep.front()->hitR();
51 double vertexZ = colStep.front()->hitZ() - (deltaZ/deltaR)*colStep.front()->hitR();
52 if (std::abs(vertexZ)>s_tolerance)
53 ATH_MSG_WARNING("z-vertex position larger than expected for material mapping. Check the beamspot config used for production of material steps!");
54
55 Acts::Vector3 v_pos{0, 0, 0};
56 Acts::Vector3 v_imp{colStep.back()->hitX(), colStep.back()->hitY(), colStep.back()->hitZ()};
57 v_imp = v_imp.normalized();
58
59 for(auto const step: colStep) {
60 Acts::Vector3 pos{step->hitX(), step->hitY(), step->hitZ()};
61 Acts::MaterialSlab matProp(Acts::Material::fromMassDensity(step->x0(), step->l0(), step->A(), step->Z(), (step->rho() * Acts::UnitConstants::g) ),step->steplength());
62 Acts::MaterialInteraction interaction;
63 interaction.position = pos;
64 interaction.direction = Acts::Vector3(pos.x(), pos.y(), pos.z());
65 interaction.direction = interaction.direction.normalized();
66 interaction.materialSlab = matProp;
67 sum_X0 += step->steplengthInX0();
68 sum_L0 += step->steplengthInL0();
69 nStep.push_back(interaction);
70 }
71
72 recorded.materialInX0 = sum_X0;
73 recorded.materialInL0 = sum_L0;
74 recorded.materialInteractions = std::move(nStep);
75
76 mTrack = std::make_pair(std::make_pair(v_pos, v_imp), recorded);
77
78 return mTrack;
79
80}
Scalar deltaR(const MatrixBase< Derived > &vec) const
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
ActsMaterialStepConverterTool(const std::string &type, const std::string &name, const IInterface *parent)
virtual const Acts::RecordedMaterialTrack convertToMaterialTrack(const Trk::MaterialStepCollection &colStep) const override
const T * back() const
Access the last element in the collection as an rvalue.
const T * front() const
Access the first element in the collection as an rvalue.
double hitY() const
double hitR() const
double hitX() const
Access method : hitX,Y,Z,R.
double hitZ() const
std::pair< std::pair< Acts::Vector3, Acts::Vector3 >, RecordedMaterial > RecordedMaterialTrack
Recorded material track.
DataVector< Trk::MaterialStep > MaterialStepCollection