ATLAS Offline Software
LinkCounterAlg.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
6 
7 #include "StoreGate/ReadDecorHandle.h"
8 #include "StoreGate/WriteDecorHandle.h"
9 #include "AthLinks/ElementLink.h"
10 
11 
12 namespace FlavorTagDiscriminants {
13 
14  template <typename T, typename C>
15  StatusCode LinkCounterAlg<T,C>::initialize()
16  {
17  if (m_links.empty()) {
18  ATH_MSG_ERROR("link not specified");
19  return StatusCode::FAILURE;
20  }
21  ATH_CHECK(m_links.initialize());
22  ATH_CHECK(m_flag.initialize());
23  return StatusCode::SUCCESS;
24  }
25 
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;
34  }
35  return StatusCode::SUCCESS;
36  }
37 
38 } // end namespace FlavorTagDiscriminants