ATLAS Offline Software
EMClusterTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "EMClusterTool.h"
7 #include "GaudiKernel/EventContext.h"
11 
14 
17 #include "StoreGate/WriteHandle.h"
18 
20  const std::string& name,
21  const IInterface* parent)
23 {
24  declareInterface<IEMClusterTool>(this);
25 }
26 
29 {
30 
31  ATH_MSG_DEBUG("Initializing " << name() << "...");
32 
34 
36  m_outputClusterContainerKey.key() + "_links";
38 
39  // Get the cluster correction tool
40  ATH_CHECK(m_MVACalibSvc.retrieve());
41 
42  ATH_MSG_DEBUG("Initialization successful");
43 
44  return StatusCode::SUCCESS;
45 }
46 
48 EMClusterTool::contExecute(const EventContext& ctx,
51 {
52 
53  // Create output cluster container and register in StoreGate
54  SG::WriteHandle<xAOD::CaloClusterContainer> outputClusterContainer(
56 
58 
59  SG::WriteHandle<CaloClusterCellLinkContainer> outputClusterContainerCellLink(
61 
62  ATH_CHECK(outputClusterContainerCellLink.record(
63  std::make_unique<CaloClusterCellLinkContainer>()));
64 
65  // Loop over electrons and create new clusters
66  if (electronContainer) {
67  for (auto electron : *electronContainer) {
68  setNewCluster(ctx, electron, outputClusterContainer.ptr());
69  }
70  }
71 
72  if (photonContainer) {
73  // Loop over photons and create new clusters
74  for (auto photon : *photonContainer) {
75  setNewCluster(ctx, photon, outputClusterContainer.ptr());
76  }
77  }
78 
80  ctx,
81  outputClusterContainer,
82  outputClusterContainerCellLink);
83 
84  return StatusCode::SUCCESS;
85 }
86 
87 void
89  const EventContext& ctx,
91  xAOD::CaloClusterContainer* outputClusterContainer) const
92 {
93  if (!eg) {
94  return;
95  }
96  if (!eg->caloCluster()) {
97  ATH_MSG_DEBUG("egamma object does not have a cluster associated");
98  return;
99  }
101  //create new cluster
102 xAOD::CaloCluster* cluster = outputClusterContainer->push_back(std::make_unique<xAOD::CaloCluster>());
103  //copy over
104  (*cluster)=*(eg->caloCluster());
105  //and do final calibration
106  if (m_MVACalibSvc->execute(*cluster, *eg).isFailure()) {
107  ATH_MSG_ERROR("Problem executing MVA cluster tool");
108  }
109  // Set the link to the new cluster
110  ClusterLink_t clusterLink(cluster, *outputClusterContainer, ctx);
111  const std::vector<ClusterLink_t> clusterLinks{ clusterLink };
112  eg->setCaloClusterLinks(clusterLinks);
113 }
114 
electronContainer
xAOD::ElectronContainer * electronContainer
Definition: TrigGlobEffCorrValidation.cxx:187
CaloClusterStoreHelper::finalizeClusters
static StatusCode finalizeClusters(SG::WriteHandle< CaloClusterCellLinkContainer > &h, xAOD::CaloClusterContainer *pClusterColl)
Finalize clusters (move CaloClusterCellLink to a separate container).
Definition: CaloClusterStoreHelper.cxx:64
CaloClusterStoreHelper::AddContainerWriteHandle
static StatusCode AddContainerWriteHandle(SG::WriteHandle< xAOD::CaloClusterContainer > &clusColl)
Creates a new xAOD::CaloClusterContainer in the given WriteHandle + CaloClusterAuxContainer and recor...
Definition: CaloClusterStoreHelper.cxx:53
ParticleTest.eg
eg
Definition: ParticleTest.py:29
EMClusterTool::setNewCluster
void setNewCluster(const EventContext &ctx, xAOD::Egamma *eg, xAOD::CaloClusterContainer *outputClusterContainer) const
Set new cluster to the egamma object, decorate the new cluster with a link to the old one.
Definition: EMClusterTool.cxx:88
xAOD::Egamma_v1
Definition: Egamma_v1.h:56
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
CaloClusterAuxContainer.h
EMClusterTool::m_MVACalibSvc
ServiceHandle< IegammaMVASvc > m_MVACalibSvc
Handle to the MVA calibration service.
Definition: EMClusterTool.h:86
EMClusterTool::initialize
virtual StatusCode initialize() override final
initialize method
Definition: EMClusterTool.cxx:28
CaloDetDescrManager.h
Definition of CaloDetDescrManager.
WriteHandle.h
Handle class for recording to StoreGate.
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
EgammaxAODHelpers.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ElectronContainer.h
EMClusterTool::m_outputClusterContainerKey
SG::WriteHandleKey< xAOD::CaloClusterContainer > m_outputClusterContainerKey
Key of the output cluster container.
Definition: EMClusterTool.h:67
CaloCluster.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
EMClusterTool::contExecute
virtual StatusCode contExecute(const EventContext &ctx, xAOD::ElectronContainer *electronContainer, xAOD::PhotonContainer *photonContainer) const override final
execute on container
Definition: EMClusterTool.cxx:48
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
photonContainer
xAOD::PhotonContainer * photonContainer
Definition: TrigGlobEffCorrValidation.cxx:189
EMClusterTool::EMClusterTool
EMClusterTool(const std::string &type, const std::string &name, const IInterface *parent)
constructor
Definition: EMClusterTool.cxx:19
EMClusterTool::m_outputClusterContainerCellLinkKey
SG::WriteHandleKey< CaloClusterCellLinkContainer > m_outputClusterContainerCellLinkKey
Key of the output cluster container cell links: name taken from containter name; only dummy configura...
Definition: EMClusterTool.h:77
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
CaloClusterStoreHelper.h
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
xAOD::photon
@ photon
Definition: TrackingPrimitives.h:199
EMClusterTool.h
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
xAOD::EgammaParameters::electron
@ electron
Definition: EgammaEnums.h:18
AthAlgTool
Definition: AthAlgTool.h:26
PhotonContainer.h