ATLAS Offline Software
DiTauIDDecoratorWrapper.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "StoreGate/ReadHandle.h"
7 #include "xAODCore/ShallowCopy.h"
8 
9 namespace DerivationFramework {
10 
12  {
14 
15  // declare decorations to the scheduler
16  m_scoreDecorKey = m_ditauContainerKey.key() + ".omni_score";
17 
18  // initialize read/write handle keys
19  ATH_CHECK( m_ditauContainerKey.initialize() );
20  ATH_CHECK( m_scoreDecorKey.initialize() );
21 
22  return StatusCode::SUCCESS;
23  }
24 
26  {
27  const EventContext& ctx = Gaudi::Hive::currentContext();
28 
29  // retrieve ditau container
31  if (!ditauJetsReadHandle.isValid()) {
32  ATH_MSG_ERROR ("Could not retrieve DiTauJetContainer with key " << ditauJetsReadHandle.key());
33  return StatusCode::FAILURE;
34  }
35  const xAOD::DiTauJetContainer* ditauContainer = ditauJetsReadHandle.cptr();
36 
38 
39  // create shallow copy
40  auto shallowCopy = xAOD::shallowCopyContainer (*ditauContainer);
41 
42  for (auto ditau : *shallowCopy.first) {
43 
44  float score = m_tDiTauOnnxDiscriminantTool->GetDiTauObjOnnxScore(*ditau);
45 
46  // copy over the relevant decorations (scores and working points)
47  const xAOD::DiTauJet* xDiTau = ditauContainer->at(ditau->index());
48  scoreDecor(*xDiTau) = score;
49  }
50 
51  delete shallowCopy.first;
52  delete shallowCopy.second;
53 
54  return StatusCode::SUCCESS;
55  }
56 }
ShallowCopy.h
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
DiTauIDDecoratorWrapper.h
DerivationFramework::DiTauIDDecoratorWrapper::m_scoreDecorKey
SG::WriteDecorHandleKey< xAOD::DiTauJetContainer > m_scoreDecorKey
Definition: DiTauIDDecoratorWrapper.h:33
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DerivationFramework::DiTauIDDecoratorWrapper::m_ditauContainerKey
SG::ReadHandleKey< xAOD::DiTauJetContainer > m_ditauContainerKey
Definition: DiTauIDDecoratorWrapper.h:32
DerivationFramework
THE reconstruction tool.
Definition: ParticleSortingAlg.h:24
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
DerivationFramework::DiTauIDDecoratorWrapper::addBranches
virtual StatusCode addBranches() const override
Definition: DiTauIDDecoratorWrapper.cxx:25
SG::VarHandleBase::key
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:64
xAOD::shallowCopyContainer
std::pair< std::unique_ptr< T >, std::unique_ptr< ShallowAuxContainer > > shallowCopyContainer(const T &cont, [[maybe_unused]] const EventContext &ctx)
Function making a shallow copy of a constant container.
Definition: ShallowCopy.h:110
xAOD::score
@ score
Definition: TrackingPrimitives.h:514
DerivationFramework::DiTauIDDecoratorWrapper::m_tDiTauOnnxDiscriminantTool
ToolHandle< DiTauOnnxDiscriminantTool > m_tDiTauOnnxDiscriminantTool
Definition: DiTauIDDecoratorWrapper.h:35
xAOD::DiTauJet_v1
Definition: DiTauJet_v1.h:31
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
ReadHandle.h
Handle class for reading from StoreGate.
DerivationFramework::DiTauIDDecoratorWrapper::initialize
virtual StatusCode initialize() override
Definition: DiTauIDDecoratorWrapper.cxx:11