9#include "AthLinks/ElementLink.h"
57 return StatusCode::SUCCESS;
65 return StatusCode::SUCCESS;
76 if(isVtxDeco_available)
return;
79 std::vector<std::pair<const xAOD::Vertex*,float> > vxWithWeight;
88 for (
const auto *
const vtx : *vtxCont) {
92 const auto& trkLinks=vtx->trackParticleLinks();
93 const size_t nTrackLinks=trkLinks.size();
94 for (
unsigned i=0;i<nTrackLinks;++i) {
95 if (trkLinks[i].
isValid() && *(trkLinks[i]) == trk) {
96 vxWithWeight.emplace_back(vtx,vtx->trackWeights()[i]);
103 std::sort(vxWithWeight.begin(),vxWithWeight.end(),
104 [](std::pair<const xAOD::Vertex*,float>&
a, std::pair<const xAOD::Vertex*,float>& b){ return a.second > b.second; } );
108 std::vector<ElementLink<xAOD::VertexContainer>> AMVFVertices;
109 std::vector<float> AMVFWeights;
110 AMVFVertices.reserve(vxWithWeight.size());
111 AMVFWeights.reserve(vxWithWeight.size());
113 for (
const auto& p : vxWithWeight) {
114 AMVFVertices.emplace_back(p.first,*vtxCont,ctx);
115 AMVFWeights.emplace_back(p.second);
119 vtxDeco(*trk) = std::move(AMVFVertices);
120 wgtDeco(*trk) = std::move(AMVFWeights);
131 ATH_MSG_WARNING(
"Unable to retrieve xAOD::TrackParticleContainer, \"" <<
m_trkContKey.key() <<
"\", returning without applying decorations!");
138 ATH_MSG_WARNING(
"Unable to retrieve xAOD::VertexContainer, \"" <<
m_vtxContKey.key() <<
"\", returning without applying decorations!");
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type get() const
Dereference the pointer, but don't cache anything.
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
Handle class for adding a decoration to an object.
bool isAvailable()
Test to see if this variable exists in the store, for the referenced object.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".