ATLAS Offline Software
TauxAODHelpers.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 #include "AthContainers/ConstAccessor.h"
6 
7 template<class T>
8 const T* xAOD::TauHelpers::getLink(const xAOD::IParticle* particle, const std::string& name, bool debug)
9 {
10  if (!particle) return 0;
11  typedef ElementLink< DataVector<T> > Link_t;
12 
13  static const SG::ConstAccessor< Link_t > acc( name );
14  if (!acc.isAvailable( *particle ) )
15  {
16  if (debug) std::cerr<< "Link not available" << std::endl;
17  return 0;
18  }
19  const Link_t link = acc( *particle );
20  if (!link.isValid())
21  {
22  if (debug) std::cerr << "Invalid link" << std::endl;
23  return 0;
24  }
25  return *link;
26 }
27