ATLAS Offline Software
TrkExtrapolator.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // class header include
6 #include "TrkExtrapolator.h"
7 
8 
10 
14 
15 
17 ISF::TrkExtrapolator::TrkExtrapolator(const std::string& t, const std::string& n, const IInterface* p)
18  : base_class(t,n,p),
19  m_extrapolator("Trk::Extrapolator/AtlasExtrapolator"),
20  m_trackingVolumeName(""),
21  m_trackingVolume(0),
22  m_pdgToParticleHypothesis(new Trk::PdgToParticleHypothesis())
23 {
24  declareProperty( "TrackingVolumeName",
26  "Name of the TrackingVolume within which the extrapolation is to be carried out");
27  declareProperty( "Extrapolator",
29  "Extrapolator used for track extrapolation" );
30 }
31 
34 {
35  delete m_pdgToParticleHypothesis;
36 }
37 
38 
41 {
42  ATH_MSG_VERBOSE("initialize() begin");
43 
44  StatusCode sc = m_extrapolator.retrieve();
45  if (sc.isFailure()){
46  ATH_MSG_FATAL( "Could not retrieve " << m_extrapolator );
47  return StatusCode::FAILURE;
48  }
49  // initialize the TrackingGeometryReadKey
50  ATH_CHECK(m_trackingGeometryReadKey.initialize());
51 
52  ATH_MSG_VERBOSE("initialize() successful");
53  return StatusCode::SUCCESS;
54 }
55 
58 {
59  ATH_MSG_VERBOSE("finalize() begin");
60 
61  ATH_MSG_VERBOSE("finalize() successful");
62  return StatusCode::SUCCESS;
63 }
64 
67 
68  const EventContext& ctx = Gaudi::Hive::currentContext();
69  if( m_extrapolator.empty() ) {
70  ATH_MSG_ERROR( "Problem with extrapolator!" );
71  return 0;
72  }
73 
74  if ( !m_trackingVolume.get() ) {
75  // ------------------------------- get the trackingGeometry at first place
76  SG::ReadCondHandle<Trk::TrackingGeometry> readHandle{m_trackingGeometryReadKey};
77  if (!readHandle.isValid() || *readHandle == nullptr) {
78  ATH_MSG_ERROR("Problem with TrackingGeometry '" << m_trackingGeometryReadKey.fullKey() << "' from CondStore.");
79  return 0;
80  }
81 
82  const Trk::TrackingGeometry* trackingGeometry = *readHandle;
83  const Trk::TrackingVolume* trackingVolume = trackingGeometry->trackingVolume( m_trackingVolumeName);
84  if (!trackingVolume) {
85  ATH_MSG_FATAL("Failed to retrieve TrackingVolume: " << m_trackingVolumeName);
86  return 0;
87  }
88  m_trackingVolume.set(trackingVolume);
89  }
90 
91  // create objects from ISFParticle needed for extrapolation
92  Trk::CurvilinearParameters par(particle.position(),particle.momentum(),particle.charge());
93 
94  int absPdg = abs(particle.pdgCode());
95  //bool photon = (absPdg == 22);
96  //bool geantino = (absPdg == 999);
97  //bool charged = photon || geantino ? false : (particle.charge()*particle.charge() > 0) ;
98 
99  Trk::ParticleHypothesis particleHypo =
100  m_pdgToParticleHypothesis->convert(particle.pdgCode(),particle.charge());
101  if ( absPdg == 999 ) particleHypo = Trk::geantino;
102 
103  // extrapolate to calorimeter entry
104  const Trk::TrackParameters* extrapolatedPars = m_extrapolator->extrapolateToVolume(ctx,
105  par,
106  *m_trackingVolume.get(),
108  particleHypo).release();
109 
110  // create a new ISF particle representing the given particle at the extrapolated position
111  ISFParticle *extrapolatedParticle = new ISFParticle( extrapolatedPars->position(),
112  extrapolatedPars->momentum(),
113  particle.mass(),
114  particle.charge(),
115  particle.pdgCode(),
116  particle.status(),
117  particle.timeStamp(),
118  particle,
119  particle.id() // FIXME should this be undefined instead?
120  );
121 
122  // cleanup
123  delete extrapolatedPars;
124 
125  return extrapolatedParticle;
126 }
127 
ISF::TrkExtrapolator::finalize
virtual StatusCode finalize() override
Athena AlgTool finalization.
Definition: TrkExtrapolator.cxx:57
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
TrackParameters.h
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
Trk::ParametersBase::position
const Amg::Vector3D & position() const
Access method for the position.
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
ISF::ISFParticle
Definition: ISFParticle.h:42
IExtrapolator.h
Trk::alongMomentum
@ alongMomentum
Definition: PropDirection.h:20
ISF::TrkExtrapolator::m_extrapolator
ToolHandle< Trk::IExtrapolator > m_extrapolator
extrapolation to calo entry
Definition: TrkExtrapolator.h:69
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
ISF::TrkExtrapolator::extrapolate
virtual ISF::ISFParticle * extrapolate(const ISF::ISFParticle &particle) const override
Extrapolate the given ISFParticle.
Definition: TrkExtrapolator.cxx:66
PdgToParticleHypothesis.h
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
Trk::ParticleHypothesis
ParticleHypothesis
Definition: ParticleHypothesis.h:25
ISF::TrkExtrapolator::TrkExtrapolator
TrkExtrapolator(const std::string &t, const std::string &n, const IInterface *p)
Constructor with parameters.
Definition: TrkExtrapolator.cxx:17
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
beamspotman.n
n
Definition: beamspotman.py:731
Trk::TrackingGeometry
Definition: TrackingGeometry.h:67
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Trk::geantino
@ geantino
Definition: ParticleHypothesis.h:26
ISF::TrkExtrapolator::m_trackingVolumeName
std::string m_trackingVolumeName
name of the volume within the extrapolation is carried out
Definition: TrkExtrapolator.h:71
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Trk::ParametersBase
Definition: ParametersBase.h:55
Trk::CurvilinearParametersT
Definition: CurvilinearParametersT.h:48
ISF::TrkExtrapolator::initialize
virtual StatusCode initialize() override
Athena AlgTool initialization.
Definition: TrkExtrapolator.cxx:40
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:29
Trk::ParametersBase::momentum
const Amg::Vector3D & momentum() const
Access method for the momentum.
Trk::TrackingGeometry::trackingVolume
const TrackingVolume * trackingVolume(const std::string &name) const
return the tracking Volume by name, 0 if it doesn't exist
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
TrackingGeometry.h
TrkExtrapolator.h
Trk::TrackingVolume
Definition: TrackingVolume.h:121
ISF::TrkExtrapolator::~TrkExtrapolator
~TrkExtrapolator()
Destructor.
Definition: TrkExtrapolator.cxx:33