ATLAS Offline Software
Loading...
Searching...
No Matches
ExtendTrackToLayerTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
7
9{
10}
11
13{
14 ATH_MSG_DEBUG("Initialize " << name());
15 CHECK(m_extensionTool.retrieve());
16
17 if (m_caloLayerNames.value().size() == 0)
18 {
19 ATH_MSG_ERROR("No layers requested, tool would not do anything!");
20 return StatusCode::FAILURE;
21 }
22
23 std::map<std::string, CaloSampling::CaloSample> samplings;
24 for (unsigned int ii = 0; ii < CaloSampling::getNumberOfSamplings(); ++ii)
25 samplings[CaloSampling::getSamplingName(ii)] = static_cast<CaloSampling::CaloSample>(ii);
26 m_caloLayers.reserve(m_caloLayerNames.value().size());
27 for (const std::string &name : m_caloLayerNames.value())
28 {
29 auto itr = samplings.find(name);
30 if (itr == samplings.end())
31 {
32 ATH_MSG_ERROR("Unknown sampling '" << name << "' requested!");
33 return StatusCode::FAILURE;
34 }
35 }
36 return StatusCode::SUCCESS;
37}
38
40 const EventContext &ctx,
41 const xAOD::TrackParticle &track) const
42{
43 std::unique_ptr<Trk::CaloExtension> extension = m_extensionTool->caloExtension(
44 ctx, track);
45 if (!extension)
46 // This means that track wasn't extrapolated into the calorimeter
47 return TrackExtension{};
48 // Get the eta-phi entry positions of the intersections of this track with the
49 // calorimeter
52 // Go through the layers we requested in order
53 bool isCrossed;
54 double eta;
55 double phi;
57 {
58 std::tie(isCrossed, eta, phi) = result[layer];
59 // Return the first that is crossed
60 if (isCrossed)
61 return TrackExtension{eta, phi};
62 }
63 // If we got here, it crossed no layer that we're interested in, return an
64 // invalid extension
65 return TrackExtension{};
66}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
static std::string getSamplingName(CaloSample theSample)
Returns a string (name) for each CaloSampling.
static constexpr unsigned int getNumberOfSamplings()
Get number of available samplings.
ToolHandle< Trk::IParticleCaloExtensionTool > m_extensionTool
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
std::vector< CaloSampling::CaloSample > m_caloLayers
The calo layer enums.
Gaudi::Property< std::vector< std::string > > m_caloLayerNames
ExtendTrackToLayerTool(const std::string &name)
virtual TrackExtension extendTrack(const EventContext &ctx, const xAOD::TrackParticle &track) const override
Extend the track to a given layer.
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
void entryEtaPhiHashLookupVector(const Trk::CaloExtension &extension, EtaPhiHashLookupVector &result)
std::vector< std::tuple< bool, double, double > > EtaPhiHashLookupVector
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Helper struct to hold track extrapolation information.