ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
DerivationFramework
DerivationFrameworkTau
src
DiTauIDDecoratorWrapper.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
DerivationFrameworkTau/DiTauIDDecoratorWrapper.h
"
6
#include "
StoreGate/ReadHandle.h
"
7
#include "
xAODCore/ShallowCopy.h
"
8
9
namespace
DerivationFramework
{
10
11
StatusCode
DiTauIDDecoratorWrapper::initialize
()
12
{
13
ATH_CHECK
(
m_tDiTauOnnxDiscriminantTool
.retrieve() );
14
ATH_CHECK
(
m_tDiTauWPDecoratorTool
.retrieve() );
15
16
if
(
m_WPCuts
.size() !=
m_WPDecorKeys
.size() ) {
17
ATH_MSG_ERROR
(
"Size mismatch between m_WPDecorKeys and m_WPCuts! Please check the configuration."
);
18
return
StatusCode::FAILURE;
19
}
20
21
// initialize read/write handle keys
22
ATH_CHECK
(
m_ditauContainerKey
.initialize() );
23
ATH_CHECK
(
m_scoreDecorKey
.initialize() );
24
ATH_CHECK
(
m_WPDecorKeys
.initialize() );
25
26
return
StatusCode::SUCCESS;
27
}
28
29
StatusCode
DiTauIDDecoratorWrapper::addBranches
(
const
EventContext& ctx)
const
30
{
31
32
// retrieve ditau container
33
SG::ReadHandle<xAOD::DiTauJetContainer>
ditauJetsReadHandle(
m_ditauContainerKey
, ctx);
34
if
(!ditauJetsReadHandle.
isValid
()) {
35
ATH_MSG_ERROR
(
"Could not retrieve DiTauJetContainer with key "
<< ditauJetsReadHandle.
key
());
36
return
StatusCode::FAILURE;
37
}
38
const
xAOD::DiTauJetContainer
* ditauContainer = ditauJetsReadHandle.
cptr
();
39
40
SG::WriteDecorHandle<xAOD::DiTauJetContainer, float>
scoreDecor(
m_scoreDecorKey
, ctx);
41
42
std::vector<SG::WriteDecorHandle<xAOD::DiTauJetContainer, char> > WPDecors;
43
WPDecors.reserve (
m_WPDecorKeys
.size());
44
for
(
const
SG::WriteDecorHandleKey<xAOD::DiTauJetContainer>
& k :
m_WPDecorKeys
) {
45
WPDecors.emplace_back (k, ctx);
46
}
47
48
// create shallow copy
49
auto
shallowCopy =
xAOD::shallowCopy
(*ditauContainer, ctx);
50
51
for
(
auto
ditau : *shallowCopy.first) {
52
53
float
score =
m_tDiTauOnnxDiscriminantTool
->GetDiTauObjOnnxScore(*ditau);
54
55
// copy over the relevant decorations (scores and working points)
56
const
xAOD::DiTauJet
* xDiTau = ditauContainer->
at
(ditau->index());
57
scoreDecor(*xDiTau) = score;
58
59
int
i=0;
60
for
(
SG::WriteDecorHandle<xAOD::DiTauJetContainer, char>
& dec : WPDecors) {
61
bool
decision =
m_tDiTauWPDecoratorTool
->passOmniWP(score,
m_WPCuts
.value().at(i));
62
dec(*xDiTau) = decision;
63
i++;
64
}
65
}
66
67
return
StatusCode::SUCCESS;
68
}
69
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
DiTauIDDecoratorWrapper.h
ShallowCopy.h
ReadHandle.h
Handle class for reading from StoreGate.
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
DerivationFramework::DiTauIDDecoratorWrapper::m_ditauContainerKey
SG::ReadHandleKey< xAOD::DiTauJetContainer > m_ditauContainerKey
Definition
DiTauIDDecoratorWrapper.h:33
DerivationFramework::DiTauIDDecoratorWrapper::m_WPCuts
Gaudi::Property< std::vector< float > > m_WPCuts
Definition
DiTauIDDecoratorWrapper.h:42
DerivationFramework::DiTauIDDecoratorWrapper::m_tDiTauWPDecoratorTool
ToolHandle< DiTauWPDecorator > m_tDiTauWPDecoratorTool
Definition
DiTauIDDecoratorWrapper.h:38
DerivationFramework::DiTauIDDecoratorWrapper::addBranches
virtual StatusCode addBranches(const EventContext &ctx) const override
Definition
DiTauIDDecoratorWrapper.cxx:29
DerivationFramework::DiTauIDDecoratorWrapper::m_scoreDecorKey
SG::WriteDecorHandleKey< xAOD::DiTauJetContainer > m_scoreDecorKey
Definition
DiTauIDDecoratorWrapper.h:34
DerivationFramework::DiTauIDDecoratorWrapper::m_tDiTauOnnxDiscriminantTool
ToolHandle< DiTauOnnxDiscriminantTool > m_tDiTauOnnxDiscriminantTool
Definition
DiTauIDDecoratorWrapper.h:37
DerivationFramework::DiTauIDDecoratorWrapper::initialize
virtual StatusCode initialize() override
Definition
DiTauIDDecoratorWrapper.cxx:11
DerivationFramework::DiTauIDDecoratorWrapper::m_WPDecorKeys
SG::WriteDecorHandleKeyArray< xAOD::DiTauJetContainer > m_WPDecorKeys
Definition
DiTauIDDecoratorWrapper.h:35
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
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
SG::WriteDecorHandleKey
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
Definition
StoreGate/StoreGate/WriteDecorHandleKey.h:90
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition
StoreGate/StoreGate/WriteDecorHandle.h:100
DerivationFramework
THE reconstruction tool.
Definition
CascadeTools.h:16
xAOD::DiTauJetContainer
DiTauJetContainer_v1 DiTauJetContainer
Definition of the current DiTauJet container version.
Definition
DiTauJetContainer.h:17
xAOD::shallowCopy
ShallowCopyResult_t< T > shallowCopy(const T &cont, const EventContext &ctx)
Create a shallow copy of an existing container.
xAOD::DiTauJet
DiTauJet_v1 DiTauJet
Definition of the current version.
Definition
DiTauJet.h:17
Generated on
for ATLAS Offline Software by
1.17.0