49 return StatusCode::FAILURE;
54 return StatusCode::FAILURE;
57 return StatusCode::SUCCESS;
68 return StatusCode::FAILURE;
71 if(jetReadHandle->empty())
return StatusCode::SUCCESS;
76 std::optional<SG::ReadDecorHandle<xAOD::IParticleContainer, float>> wedgeZ;
83 ATH_MSG_ERROR(
"Failed to retrieve hits container with key " << hitsHandle.
key());
84 return StatusCode::FAILURE;
93 static const SG::AuxElement::ConstAccessor<int> bec(
"bec");
96 std::vector<Hit> hits;
97 hits.reserve(hitsHandle->size());
99 const int hit_bec = bec(*
hit);
103 const float hx =
x(*
hit);
104 const float hy =
y(*
hit);
105 hits.push_back({
hit, std::atan2(hy, hx),
z(*
hit), std::sqrt(hx*hx + hy*hy)});
111 [](
const Hit&
a,
const Hit& b) { return a.phi < b.phi; });
118 zed = (*wedgeZ)(*jet);
119 if(!std::isfinite(zed)) {
120 ATH_MSG_WARNING(
"Wedge z-centre is not finite, dropping hits for this jet.");
121 hitAssociation(*
jet) = {};
127 std::vector<ElementLink<xAOD::TrackMeasurementValidationContainer>> links;
136 hitAssociation(*
jet) = std::move(links);
139 return StatusCode::SUCCESS;
143 const std::vector<std::pair<float, const xAOD::TrackMeasurementValidation*>>
145 const std::vector<Hit>& hits,
147 const double eta =
jet->eta();
148 const double phi =
jet->phi();
150 std::vector<std::pair<float, const xAOD::TrackMeasurementValidation*>> ret;
155 const float halfWidth =
158 using HitItr = std::vector<Hit>::const_iterator;
159 const std::vector<std::pair<HitItr, HitItr>> ranges =
163 for(
const auto& [first, last] : ranges) {
164 for(HitItr it = first; it != last; ++it) {
166 const float dEta =
eta - std::asinh((
hit.z - zed) /
hit.r);
169 const float dR = std::sqrt(dEta * dEta + dPhi * dPhi);
172 ret.emplace_back(dR,
hit.original_hit);
183 for(
const auto& [first, last] : ranges) {
184 for(HitItr it = first; it != last; ++it) {
195 std::sort(ret.begin(), ret.end(), [](
const auto& h1,
const auto& h2) ->
bool { return h1.first < h2.first; });
196 ret.resize(std::min(
static_cast<unsigned int>(
m_maxHits),
static_cast<unsigned int>(ret.size())));
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_INFO(x,...)
#define ATH_MSG_FATAL(x,...)
#define CHECK(...)
Evaluate an expression and check for errors.
Handle class for reading a decoration on an object.
Handle class for reading from StoreGate.
Handle class for adding a decoration to an object.
An algorithm that can be simultaneously executed in multiple threads.
ElementLink implementation for ROOT usage.
virtual StatusCode execute(const EventContext &) const override
SG::ReadDecorHandleKey< xAOD::IParticleContainer > m_wedgeZKey
Gaudi::Property< bool > m_includeBarrel
Gaudi::Property< int > m_maxHits
Gaudi::Property< float > m_dEtaHitToVertex
Gaudi::Property< bool > m_includeEndcap
SG::ReadDecorHandleKey< xAOD::TrackMeasurementValidationContainer > m_hitsYRelToVertexKey
Gaudi::Property< bool > m_useDRCone
Gaudi::Property< float > m_dZHitToVertex
SG::ReadHandleKey< xAOD::TrackMeasurementValidationContainer > m_inputHitCollectionKey
SG::ReadHandleKey< xAOD::IParticleContainer > m_jetCollectionKey
Gaudi::Property< float > m_dRHitToJet
JetHitAssociationAlg(const std::string &name, ISvcLocator *pSvcLocator)
Gaudi::Property< float > m_dPhiHitToJet
SG::ReadDecorHandleKey< xAOD::TrackMeasurementValidationContainer > m_hitsXRelToVertexKey
const std::vector< std::pair< float, const xAOD::TrackMeasurementValidation * > > getJetHits(const xAOD::IParticle *jet, const std::vector< Hit > &hits, double zed) const
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_hitAssociationKey
virtual StatusCode initialize() override
SG::ReadDecorHandleKey< xAOD::TrackMeasurementValidationContainer > m_hitsZRelToVertexKey
Describes the Region of Ineterest geometry It has basically 9 parameters.
Handle class for reading a decoration on an object.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
Handle class for adding a decoration to an object.
Class providing the definition of the 4-vector interface.
constexpr T wrapToPi(T phi)
Wrap angle in radians to [-pi, pi].
std::vector< std::pair< typename std::vector< Hit >::const_iterator, typename std::vector< Hit >::const_iterator > > getPhiRanges(const std::vector< Hit > &hits, float phi, float halfWidth)
bool contains(const IRoiDescriptor &roi, double z0, double dzdr)
see whether a segment is contained within the roi in r-z
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
TrackMeasurementValidation_v1 TrackMeasurementValidation
Reference the current persistent version:
Helper for azimuthal angle calculations.