ATLAS Offline Software
TruthCaloShowerDecorator.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
8 #include "xAODEgamma/Electron.h"
12 
13 namespace DerivationFramework {
14 
16  const std::string& n,
17  const IInterface* p)
18  : base_class(t, n, p)
19 {
20 }
21 
24 {
25  ATH_MSG_DEBUG("Initializing " << name() << "...");
26 
27  if (m_calibhitToCaloCellTool.retrieve().isFailure()) {
28  ATH_MSG_FATAL("Failed to retrieve tool " << m_calibhitToCaloCellTool);
29  return StatusCode::FAILURE;
30  }
31  ATH_MSG_INFO("Retrieved tool " << m_calibhitToCaloCellTool);
32 
37 
38  const std::string baseName = m_truthParticleContainerName.key();
39  m_linkDecoratorClusterEtot = baseName + ".truthLArClusterEtotLink";
40  m_linkDecoratorClusterEvis = baseName + ".truthLArClusterEvisLink";
41  m_linkDecoratorClusterEem = baseName + ".truthLArClusterEemLink";
42 
46 
47  return StatusCode::SUCCESS;
48 }
49 
52 {
53  return StatusCode::SUCCESS;
54 }
55 
58 {
59  const EventContext& ctx = Gaudi::Hive::currentContext();
60 
61  SG::ReadHandle<xAOD::TruthParticleContainer> truthPartContainerReadHandle{
63  };
64  const xAOD::TruthParticleContainer* truthPartContainer =
65  truthPartContainerReadHandle.ptr();
66 
67  // create truth clusters
68  ATH_MSG_DEBUG("Creating truth clusters");
70  ->processCalibHitsFromParticle()
71  .isSuccess()) {
72  ATH_MSG_FATAL("Tool " << m_calibhitToCaloCellTool << " failed.");
73  return StatusCode::FAILURE;
74  }
75 
76  ATH_MSG_DEBUG("Retrieving truth clusters");
78  truthClusterContainerEtotReadHandle{ m_truthClusterContainerEtot, ctx };
80  truthClusterContainerEvisReadHandle{ m_truthClusterContainerEvis, ctx };
81  SG::ReadHandle<xAOD::CaloClusterContainer> truthClusterContainerEemReadHandle{
83  };
84  const xAOD::CaloClusterContainer* truthClusterContainerEtot =
85  truthClusterContainerEtotReadHandle.ptr();
86  const xAOD::CaloClusterContainer* truthClusterContainerEvis =
87  truthClusterContainerEvisReadHandle.ptr();
88  const xAOD::CaloClusterContainer* truthClusterContainerEem =
89  truthClusterContainerEemReadHandle.ptr();
90 
91  if (!truthClusterContainerEtot || !truthClusterContainerEvis ||
92  !truthClusterContainerEem) {
93  ATH_MSG_ERROR("Failed to retrieve truth cluster container");
94  return StatusCode::FAILURE;
95  }
96 
99  linkDecoratorClusterEtot(m_linkDecoratorClusterEtot, ctx);
102  linkDecoratorClusterEvis(m_linkDecoratorClusterEvis, ctx);
105  linkDecoratorClusterEem(m_linkDecoratorClusterEem, ctx);
106 
108  *truthClusterContainerEtot, 0);
110  *truthClusterContainerEvis, 0);
112  *truthClusterContainerEem, 0);
113 
114  ATH_MSG_DEBUG("Decorating truth parts with truth cluster energy");
115  for (const auto* const truthPart : *truthPartContainer) {
116  if (!truthPart) continue;
117  if (!MC::isSingleParticle(truthPart)) continue;
118  linkDecoratorClusterEtot(*truthPart) = truthClusterEtot;
119  linkDecoratorClusterEvis(*truthPart) = truthClusterEvis;
120  linkDecoratorClusterEem(*truthPart) = truthClusterEem;
121  }
122  return StatusCode::SUCCESS;
123 }
124 }
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
DerivationFramework::TruthCaloShowerDecorator::m_linkDecoratorClusterEem
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_linkDecoratorClusterEem
Definition: TruthCaloShowerDecorator.h:60
DerivationFramework::TruthCaloShowerDecorator::finalize
StatusCode finalize()
Definition: TruthCaloShowerDecorator.cxx:51
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
DerivationFramework::TruthCaloShowerDecorator::m_linkDecoratorClusterEvis
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_linkDecoratorClusterEvis
Definition: TruthCaloShowerDecorator.h:58
CalibHitToCaloCellTool.h
Convert energy deposits from calibration hits to CaloCell, xAOD::CaloCluster.
SG::ReadHandle< xAOD::TruthParticleContainer >
DerivationFramework::TruthCaloShowerDecorator::m_linkDecoratorClusterEtot
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_linkDecoratorClusterEtot
Definition: TruthCaloShowerDecorator.h:56
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
DerivationFramework::TruthCaloShowerDecorator::m_truthClusterContainerEvis
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_truthClusterContainerEvis
Definition: TruthCaloShowerDecorator.h:47
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
DerivationFramework::TruthCaloShowerDecorator::m_truthClusterContainerEtot
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_truthClusterContainerEtot
Definition: TruthCaloShowerDecorator.h:44
ElectronContainer.h
beamspotman.n
n
Definition: beamspotman.py:729
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TruthCaloShowerDecorator.h
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
DerivationFramework::TruthCaloShowerDecorator::m_truthClusterContainerEem
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_truthClusterContainerEem
Definition: TruthCaloShowerDecorator.h:50
DerivationFramework::TruthCaloShowerDecorator::TruthCaloShowerDecorator
TruthCaloShowerDecorator(const std::string &t, const std::string &n, const IInterface *p)
Definition: TruthCaloShowerDecorator.cxx:15
DerivationFramework::TruthCaloShowerDecorator::addBranches
virtual StatusCode addBranches() const
Definition: TruthCaloShowerDecorator.cxx:57
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DerivationFramework
THE reconstruction tool.
Definition: ParticleSortingAlg.h:24
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
MC::isSingleParticle
bool isSingleParticle(const T &p)
Identify a particlegun particle.
Definition: HepMCHelpers.h:74
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
DerivationFramework::TruthCaloShowerDecorator::m_calibhitToCaloCellTool
ToolHandle< CalibHitToCaloCellTool > m_calibhitToCaloCellTool
Definition: TruthCaloShowerDecorator.h:62
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
xAOD::TruthParticleContainer
TruthParticleContainer_v1 TruthParticleContainer
Declare the latest version of the truth particle container.
Definition: Event/xAOD/xAODTruth/xAODTruth/TruthParticleContainer.h:17
DerivationFramework::TruthCaloShowerDecorator::initialize
StatusCode initialize()
Definition: TruthCaloShowerDecorator.cxx:23
SG::WriteDecorHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
DerivationFramework::TruthCaloShowerDecorator::m_truthParticleContainerName
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthParticleContainerName
SG key of the truth particle container.
Definition: TruthCaloShowerDecorator.h:36
Electron.h
TruthParticle.h
EgammaTruthxAODHelpers.h
HepMCHelpers.h