12 #include "GaudiKernel/ITHistSvc.h"
13 #include "GaudiKernel/EventContext.h"
16 #include "CLHEP/Units/SystemOfUnits.h"
17 #include "CLHEP/Geometry/Transform3D.h"
26 #include "Acts/Surfaces/PerigeeSurface.hpp"
27 #include "Acts/Surfaces/PlaneSurface.hpp"
31 #include "Acts/Geometry/GeometryContext.hpp"
32 #include "Acts/Geometry/TrackingGeometry.hpp"
37 m_extrapolationEngine(
""),
38 m_actsExtrapolator(
""),
39 m_extrapolateDirectly(true),
40 m_extrapolateIncrementally(true),
41 m_parameterCache(nullptr),
42 m_actsParameterCache(std::nullopt),
44 m_tX0NonSensitiveCache(0.),
45 m_tNonSensitiveCache(0.),
48 m_validationTreeName(
"G4Follower_"+
n),
49 m_validationTreeDescription(
"Output of the G4Follower_"),
50 m_validationTreeFolder(
"/val/G4Follower_"+
n),
51 m_validationTree(nullptr)
76 return StatusCode::FAILURE;
81 return StatusCode::FAILURE;
140 ITHistSvc* tHistSvc = 0;
141 if (service(
"THistSvc",tHistSvc).isFailure()){
142 ATH_MSG_ERROR(
"Could not find Hist Service -> Switching ValidationMode Off !" );
146 ATH_MSG_ERROR(
"Could not register the validation Tree -> Switching ValidationMode Off !" );
151 return StatusCode::SUCCESS;
156 return StatusCode::SUCCESS;
179 const G4ThreeVector&
mom,
181 float t,
float X0,
bool isSensitive)
184 const EventContext &ctx = Gaudi::Hive::currentContext();
186 auto trackingGeometry =
m_actsExtrapolator->trackingGeometryTool()->trackingGeometry();
195 ATH_MSG_INFO(
"Initial step ... preparing event cache.");
210 std::shared_ptr<Acts::PerigeeSurface> surface =
211 Acts::Surface::makeShared<Acts::PerigeeSurface>(
217 Acts::Vector4 actsStart(
pos.x(),
pos.y(),
pos.z(),0);
218 Acts::Vector3
dir = nmom.normalized();
221 Acts::AnyCharge{
static_cast<float>(
charge)}};
223 surface, gctx.
context(), actsStart,
dir,
charge/(
mom.mag()/1000), std::nullopt, hypothesis)
228 float tX0 =
X0 > 10
e-5 ?
t/
X0 : 0.;
262 if(eCodeSteps.code != 2 ){
263 ATH_MSG_ERROR(
"Error in the Extrapolator Engine, skip the current step");
268 auto destinationSurfaceActs = Acts::Surface::makeShared<Acts::PlaneSurface>(destinationSurface.
center(), destinationSurface.
normal());
269 std::optional<Acts::BoundTrackParameters> actsParameters =
m_actsExtrapolator->propagate(ctx,
271 *destinationSurfaceActs,
272 Acts::Direction::Forward,
277 *destinationSurfaceActs,
278 Acts::Direction::Forward,
281 if(not actsParameters.has_value()){
282 ATH_MSG_ERROR(
"Error in the Acts extrapolation, skip the current step");
285 int volID = trackingGeometry->lowestTrackingVolume(gctx.
context(), actsParameters->position(gctx.
context()))->geometryId().volume();
326 float tATLAS = (trkParameters->
position() - previousPos).
norm();
335 m_treeData->m_acts_pt[
m_treeData->m_g4_steps] = actsParameters ? actsParameters->transverseMomentum()*1000 : 0.;
336 m_treeData->m_acts_eta[
m_treeData->m_g4_steps] = actsParameters ? actsParameters->momentum().eta() : 0.;
337 m_treeData->m_acts_theta[
m_treeData->m_g4_steps] = actsParameters ? actsParameters->momentum().theta() : 0.;
338 m_treeData->m_acts_phi[
m_treeData->m_g4_steps] = actsParameters ? actsParameters->momentum().phi() : 0.;
356 float tActs = (actsParameters->position(gctx.
context()) - previousPos).
norm();
372 destinationSurfaceActs.reset();