ATLAS Offline Software
Loading...
Searching...
No Matches
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
8
9namespace DerivationFramework {
10
12 {
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
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
41
42 std::vector<SG::WriteDecorHandle<xAOD::DiTauJetContainer, char> > WPDecors;
43 WPDecors.reserve (m_WPDecorKeys.size());
45 WPDecors.emplace_back (k, ctx);
46 }
47
48 // create shallow copy
49 auto shallowCopy = xAOD::shallowCopyContainer (*ditauContainer);
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;
61 bool decision = m_tDiTauWPDecoratorTool->passOmniWP(score, m_WPCuts.value().at(i));
62 dec(*xDiTau) = decision;
63 i++;
64 }
65 }
66
67 delete shallowCopy.first;
68 delete shallowCopy.second;
69
70 return StatusCode::SUCCESS;
71 }
72}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
Handle class for reading from StoreGate.
const T * at(size_type n) const
Access an element, as an rvalue.
SG::ReadHandleKey< xAOD::DiTauJetContainer > m_ditauContainerKey
Gaudi::Property< std::vector< float > > m_WPCuts
ToolHandle< DiTauWPDecorator > m_tDiTauWPDecoratorTool
virtual StatusCode addBranches(const EventContext &ctx) const override
SG::WriteDecorHandleKey< xAOD::DiTauJetContainer > m_scoreDecorKey
ToolHandle< DiTauOnnxDiscriminantTool > m_tDiTauOnnxDiscriminantTool
SG::WriteDecorHandleKeyArray< xAOD::DiTauJetContainer > m_WPDecorKeys
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
Handle class for adding a decoration to an object.
THE reconstruction tool.
std::pair< std::unique_ptr< T >, std::unique_ptr< ShallowAuxContainer > > shallowCopyContainer(const T &cont, const EventContext &ctx)
Function making a shallow copy of a constant container.
DiTauJetContainer_v1 DiTauJetContainer
Definition of the current DiTauJet container version.
DiTauJet_v1 DiTauJet
Definition of the current version.
Definition DiTauJet.h:17