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"
28 #include "Acts/Surfaces/CurvilinearSurface.hpp"
32 #include "Acts/Geometry/GeometryContext.hpp"
33 #include "Acts/Geometry/TrackingGeometry.hpp"
38 m_extrapolationEngine(
""),
39 m_actsExtrapolator(
""),
40 m_extrapolateDirectly(true),
41 m_extrapolateIncrementally(true),
42 m_parameterCache(nullptr),
43 m_actsParameterCache(std::nullopt),
45 m_tX0NonSensitiveCache(0.),
46 m_tNonSensitiveCache(0.),
49 m_validationTreeName(
"G4Follower_"+
n),
50 m_validationTreeDescription(
"Output of the G4Follower_"),
51 m_validationTreeFolder(
"/val/G4Follower_"+
n),
52 m_validationTree(nullptr)
77 return StatusCode::FAILURE;
82 return StatusCode::FAILURE;
141 SmartIF<ITHistSvc> tHistSvc{service(
"THistSvc")};
143 ATH_MSG_ERROR(
"Could not find Hist Service -> Switching ValidationMode Off !" );
147 ATH_MSG_ERROR(
"Could not register the validation Tree -> Switching ValidationMode Off !" );
152 return StatusCode::SUCCESS;
157 return StatusCode::SUCCESS;
180 const G4ThreeVector&
mom,
182 float t,
float X0,
bool isSensitive)
185 const EventContext &ctx = Gaudi::Hive::currentContext();
187 auto trackingGeometry =
m_actsExtrapolator->trackingGeometryTool()->trackingGeometry();
196 ATH_MSG_INFO(
"Initial step ... preparing event cache.");
211 std::shared_ptr<Acts::PerigeeSurface> surface =
212 Acts::Surface::makeShared<Acts::PerigeeSurface>(
218 Acts::Vector4 actsStart(
pos.x(),
pos.y(),
pos.z(),0);
219 Acts::Vector3
dir = nmom.normalized();
222 Acts::AnyCharge{
static_cast<float>(
charge)}};
224 surface, gctx.
context(), actsStart,
dir,
charge/(
mom.mag()/1000), std::nullopt, hypothesis)
229 float tX0 =
X0 > 10
e-5 ?
t/
X0 : 0.;
263 if(eCodeSteps.code != 2 ){
264 ATH_MSG_ERROR(
"Error in the Extrapolator Engine, skip the current step");
269 auto destinationSurfaceActs = Acts::CurvilinearSurface(destinationSurface.
center(), destinationSurface.
normal()).planeSurface();
270 std::optional<Acts::BoundTrackParameters> actsParameters =
m_actsExtrapolator->propagate(ctx,
272 *destinationSurfaceActs,
273 Acts::Direction::Forward,
278 *destinationSurfaceActs,
279 Acts::Direction::Forward,
282 if(not actsParameters.has_value()){
283 ATH_MSG_ERROR(
"Error in the Acts extrapolation, skip the current step");
286 int volID = trackingGeometry->lowestTrackingVolume(gctx.
context(), actsParameters->position(gctx.
context()))->geometryId().volume();
327 float tATLAS = (trkParameters->
position() - previousPos).
norm();
336 m_treeData->m_acts_pt[
m_treeData->m_g4_steps] = actsParameters ? actsParameters->transverseMomentum()*1000 : 0.;
337 m_treeData->m_acts_eta[
m_treeData->m_g4_steps] = actsParameters ? actsParameters->momentum().eta() : 0.;
338 m_treeData->m_acts_theta[
m_treeData->m_g4_steps] = actsParameters ? actsParameters->momentum().theta() : 0.;
339 m_treeData->m_acts_phi[
m_treeData->m_g4_steps] = actsParameters ? actsParameters->momentum().phi() : 0.;
357 float tActs = (actsParameters->position(gctx.
context()) - previousPos).
norm();
373 destinationSurfaceActs.reset();