ATLAS Offline Software
TauTruthDecorationsAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 
8 
9 //
10 // includes
11 //
12 
17 
18 //
19 // method implementations
20 //
21 
22 namespace CP
23 {
24 
26  initialize ()
27  {
30  for (const auto& decorationName : m_doubleDecorations) {
32  ANA_CHECK( m_doubleWriteHandles.back().second->initialize(m_systematicsList, m_tauHandle));
33  }
34  for (const auto& decorationName : m_floatDecorations) {
36  ANA_CHECK( m_floatWriteHandles.back().second->initialize(m_systematicsList, m_tauHandle));
37  }
38  for (const auto& decorationName : m_intDecorations) {
39  m_intWriteHandles.push_back(std::make_pair(std::make_unique<SG::AuxElement::ConstAccessor<int>>(decorationName), std::make_unique<CP::SysWriteDecorHandle<int>>(m_prefix+decorationName, this)));
40  ANA_CHECK( m_intWriteHandles.back().second->initialize(m_systematicsList, m_tauHandle));
41  }
42  for (const auto& decorationName : m_charDecorations) {
44  ANA_CHECK( m_charWriteHandles.back().second->initialize(m_systematicsList, m_tauHandle));
45  }
49  return StatusCode::SUCCESS;
50  }
51 
52 
53 
55  execute ()
56  {
57  for (const auto& sys : m_systematicsList.systematicsVector())
58  {
59  const xAOD::TauJetContainer *taus = nullptr;
61  for (const xAOD::TauJet *tau : *taus)
62  {
63  const xAOD::TruthParticle* truthParticle = xAOD::TauHelpers::getTruthParticle(tau);
64  if (truthParticle == nullptr) continue;
65 
66  for (auto& [acc, writeHandle] : m_doubleWriteHandles) {
67  if (truthParticle == nullptr or !acc->isAvailable(*truthParticle)) {
68  writeHandle->set(*tau, -999., sys);
69  } else {
70  writeHandle->set(*tau, acc->operator()(*truthParticle), sys);
71  }
72  }
73 
74  for (auto& [acc, writeHandle] : m_floatWriteHandles) {
75  if (truthParticle == nullptr or !acc->isAvailable(*truthParticle)) {
76  writeHandle->set(*tau, -999., sys);
77  } else {
78  writeHandle->set(*tau, acc->operator()(*truthParticle), sys);
79  }
80  }
81 
82  for (auto& [acc, writeHandle] : m_intWriteHandles) {
83  if (truthParticle == nullptr or !acc->isAvailable(*truthParticle)) {
84  writeHandle->set(*tau, -999, sys);
85  } else {
86  writeHandle->set(*tau, acc->operator()(*truthParticle), sys);
87  }
88  }
89 
90  for (auto& [acc, writeHandle] : m_charWriteHandles) {
91  if (truthParticle == nullptr or !acc->isAvailable(*truthParticle)) {
92  writeHandle->set(*tau, 0, sys);
93  } else {
94  writeHandle->set(*tau, acc->operator()(*truthParticle), sys);
95  }
96  }
97 
100  }
101  }
102  return StatusCode::SUCCESS;
103  }
104 }
CP::SysWriteDecorHandle::set
void set(const SG::AuxElement &object, const T &value, const CP::SystematicSet &sys) const
set the object decoration for the given systematic
TauAnalysisTools::getTruthDecayMode
xAOD::TauJetParameters::DecayMode getTruthDecayMode(const xAOD::TruthParticle &xTruthTau)
Get the Truth Decay Mode from TruthTau particle.
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:223
CP::TauTruthDecorationsAlg::m_doubleDecorations
Gaudi::Property< std::vector< std::string > > m_doubleDecorations
the decoration for the tau scale factor
Definition: TauTruthDecorationsAlg.h:49
CP::TauTruthDecorationsAlg::m_prefix
Gaudi::Property< std::string > m_prefix
Definition: TauTruthDecorationsAlg.h:53
make_unique
std::unique_ptr< T > make_unique(Args &&... args)
Definition: SkimmingToolEXOT5.cxx:23
CP::TauTruthDecorationsAlg::initialize
StatusCode initialize() override
Definition: TauTruthDecorationsAlg.cxx:26
TruthParticleContainer.h
CP::TauTruthDecorationsAlg::m_tauHandle
SysReadHandle< xAOD::TauJetContainer > m_tauHandle
the tau collection we run on
Definition: TauTruthDecorationsAlg.h:39
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
CP::SysReadHandle::retrieve
::StatusCode retrieve(const T *&object, const CP::SystematicSet &sys) const
retrieve the object for the given name
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
CP::SysListHandle::systematicsVector
const std::vector< CP::SystematicSet > & systematicsVector() const
the list of systematics to loop over
Definition: SysListHandle.cxx:96
CP::TauTruthDecorationsAlg::m_floatDecorations
Gaudi::Property< std::vector< std::string > > m_floatDecorations
Definition: TauTruthDecorationsAlg.h:50
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
CP::TauTruthDecorationsAlg::m_charWriteHandles
std::vector< std::pair< std::unique_ptr< SG::AuxElement::ConstAccessor< char > >, std::unique_ptr< SysWriteDecorHandle< char > > > > m_charWriteHandles
Definition: TauTruthDecorationsAlg.h:59
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
CP::SysReadHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle)
initialize this handle
CP::SysListHandle::initialize
::StatusCode initialize()
intialize this property
Definition: SysListHandle.cxx:69
xAOD::TauHelpers::getTruthParticle
const xAOD::TruthParticle * getTruthParticle(const xAOD::IParticle *, bool debug=false)
return the truthParticle associated to the given IParticle (if any)
Definition: TauxAODHelpers.cxx:10
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CP::SysWriteDecorHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle, const ISysHandleBase &objectHandle)
initialize this handle
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:37
xAOD::TauJet_v3
Class describing a tau jet.
Definition: TauJet_v3.h:41
CP::TauTruthDecorationsAlg::execute
StatusCode execute() override
Definition: TauTruthDecorationsAlg.cxx:55
CP::TauTruthDecorationsAlg::m_intDecorations
Gaudi::Property< std::vector< std::string > > m_intDecorations
Definition: TauTruthDecorationsAlg.h:51
AthenaPoolTestRead.acc
acc
Definition: AthenaPoolTestRead.py:16
CP::TauTruthDecorationsAlg::m_intWriteHandles
std::vector< std::pair< std::unique_ptr< SG::AuxElement::ConstAccessor< int > >, std::unique_ptr< SysWriteDecorHandle< int > > > > m_intWriteHandles
Definition: TauTruthDecorationsAlg.h:58
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
CP::TauTruthDecorationsAlg::m_truthDecayModeDecoration
SysWriteDecorHandle< int > m_truthDecayModeDecoration
Definition: TauTruthDecorationsAlg.h:61
TauTruthDecorationsAlg.h
TauAnalysisTools::getTruthParticleType
TruthMatchedParticleType getTruthParticleType(const xAOD::TauJet &xTau)
return TauJet match type
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:572
CP::SysReadSelectionHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle, const ISysHandleBase &objectHandle)
initialize the accessor
Definition: SysReadSelectionHandle.cxx:34
CP::TauTruthDecorationsAlg::m_preselection
SysReadSelectionHandle m_preselection
the preselection we apply to our input
Definition: TauTruthDecorationsAlg.h:44
CP::TauTruthDecorationsAlg::m_truthParticleTypeDecoration
SysWriteDecorHandle< int > m_truthParticleTypeDecoration
Definition: TauTruthDecorationsAlg.h:63
CP::TauTruthDecorationsAlg::m_floatWriteHandles
std::vector< std::pair< std::unique_ptr< SG::AuxElement::ConstAccessor< float > >, std::unique_ptr< SysWriteDecorHandle< float > > > > m_floatWriteHandles
Definition: TauTruthDecorationsAlg.h:57
CP::TauTruthDecorationsAlg::m_systematicsList
SysListHandle m_systematicsList
the systematics list we run
Definition: TauTruthDecorationsAlg.h:35
CP::TauTruthDecorationsAlg::m_doubleWriteHandles
std::vector< std::pair< std::unique_ptr< SG::AuxElement::ConstAccessor< double > >, std::unique_ptr< SysWriteDecorHandle< float > > > > m_doubleWriteHandles
Definition: TauTruthDecorationsAlg.h:56
CP::SysWriteDecorHandle< float >
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
HelperFunctions.h
CP::TauTruthDecorationsAlg::m_charDecorations
Gaudi::Property< std::vector< std::string > > m_charDecorations
Definition: TauTruthDecorationsAlg.h:52
AuxElement.h
Base class for elements of a container that can have aux data.