2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
7 #include "StoreGate/ReadDecorHandle.h"
8 #include "StoreGate/WriteDecorHandle.h"
9 #include "AthLinks/ElementLink.h"
12 namespace FlavorTagDiscriminants {
14 template <typename T, typename C>
15 StatusCode LinkCounterAlg<T,C>::initialize()
17 if (m_links.empty()) {
18 ATH_MSG_ERROR("link not specified");
19 return StatusCode::FAILURE;
21 ATH_CHECK(m_links.initialize());
22 ATH_CHECK(m_flag.initialize());
23 return StatusCode::SUCCESS;
26 template <typename T, typename C>
27 StatusCode LinkCounterAlg<T,C>::execute(const EventContext& cxt) const {
28 using TV = std::vector<ElementLink<T>>;
29 SG::ReadDecorHandle<C, TV> links_handle(m_links, cxt);
30 SG::WriteDecorHandle<C, char> flag_handle(m_flag, cxt);
31 for (const auto* jet: *links_handle) {
32 const auto& links = links_handle(*jet);
33 flag_handle(*jet) = (links.size() >= m_minimumLinks) ? 1 : 0;
35 return StatusCode::SUCCESS;
38 } // end namespace FlavorTagDiscriminants