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 
25  StatusCode DiTauIDDecoratorWrapper::addBranches(const EventContext& ctx) const
26  {
27 
28  // retrieve ditau container
30  if (!ditauJetsReadHandle.isValid()) {
31  ATH_MSG_ERROR ("Could not retrieve DiTauJetContainer with key " << ditauJetsReadHandle.key());
32  return StatusCode::FAILURE;
33  }
34  const xAOD::DiTauJetContainer* ditauContainer = ditauJetsReadHandle.cptr();
35 
37 
38  // create shallow copy
39  auto shallowCopy = xAOD::shallowCopyContainer (*ditauContainer);
40 
41  for (auto ditau : *shallowCopy.first) {
42 
43  float score = m_tDiTauOnnxDiscriminantTool->GetDiTauObjOnnxScore(*ditau);
44 
45  // copy over the relevant decorations (scores and working points)
46  const xAOD::DiTauJet* xDiTau = ditauContainer->at(ditau->index());
47  scoreDecor(*xDiTau) = score;
48  }
49 
50  delete shallowCopy.first;
51  delete shallowCopy.second;
52 
53  return StatusCode::SUCCESS;
54  }
55 }
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:795
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
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
DerivationFramework::DiTauIDDecoratorWrapper::addBranches
virtual StatusCode addBranches(const EventContext &ctx) const override
Definition: DiTauIDDecoratorWrapper.cxx:25