9#include "AthLinks/ElementLink.h"
47 return StatusCode::SUCCESS;
55 return StatusCode::SUCCESS;
66 if(isVtxDeco_available)
return;
69 std::vector<std::pair<const xAOD::Vertex*,float> > vxWithWeight;
78 for (
const auto *
const vtx : *vtxCont) {
82 const auto& trkLinks=vtx->trackParticleLinks();
83 const size_t nTrackLinks=trkLinks.size();
84 for (
unsigned i=0;i<nTrackLinks;++i) {
85 if (trkLinks[i].
isValid() && *(trkLinks[i]) == trk) {
86 vxWithWeight.emplace_back(vtx,vtx->trackWeights()[i]);
93 std::sort(vxWithWeight.begin(),vxWithWeight.end(),
94 [](std::pair<const xAOD::Vertex*,float>&
a, std::pair<const xAOD::Vertex*,float>& b){ return a.second > b.second; } );
98 std::vector<ElementLink<xAOD::VertexContainer>> AMVFVertices;
99 std::vector<float> AMVFWeights;
100 AMVFVertices.reserve(vxWithWeight.size());
101 AMVFWeights.reserve(vxWithWeight.size());
103 for (
const auto& p : vxWithWeight) {
104 AMVFVertices.emplace_back(p.first,*vtxCont,ctx);
105 AMVFWeights.emplace_back(p.second);
109 vtxDeco(*trk) = std::move(AMVFVertices);
110 wgtDeco(*trk) = std::move(AMVFWeights);
121 ATH_MSG_WARNING(
"Unable to retrieve xAOD::TrackParticleContainer, \"" <<
m_trkContKey.key() <<
"\", returning without applying decorations!");
128 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.
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".