ATLAS Offline Software
PFlowCalibPFODecoratorAlgorithm.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 //Core classes
9 
11 
13 
15 
16  ATH_CHECK(m_truthAttributerTool.retrieve());
17 
18  return StatusCode::SUCCESS;
19 }
20 
22  SG::WriteDecorHandle<xAOD::FlowElementContainer, std::vector< std::pair<unsigned int, double> > >& pfoWriteDecorHandle,
23  SG::ReadHandle<std::map<Identifier,std::vector<const CaloCalibrationHit*> > >& CalibHitReadHandle)const
24 {
25 
26  StatusCode sc;
27  for (auto thisFE : *pfoWriteDecorHandle){
28  // retrieve calo cluster, first as the iparticle we retrieve then cast to calocluster ptr
29  const xAOD::IParticle* FE_Iparticle=thisFE->otherObjects().at(0);
30  const xAOD::CaloCluster* thisCaloCluster = dynamic_cast<const xAOD::CaloCluster*>(FE_Iparticle);
31  if (not thisCaloCluster){
32  ATH_MSG_ERROR("Dynamic cast failed in PFlowCalibPFODecoratorAlgorithm::LinkCalibHitPFO");
33  return StatusCode::FAILURE;
34  }
35  std::vector<std::pair<unsigned int, double > > newBarCodeTruthPairs;
36  sc = m_truthAttributerTool->calculateTruthEnergies(*thisCaloCluster, m_numTruthParticles, *CalibHitReadHandle, newBarCodeTruthPairs);
37  if (sc == StatusCode::FAILURE) return sc;
38 
39  for (const auto& thisPair : newBarCodeTruthPairs) ATH_MSG_DEBUG("Cluster Final loop: Particle with barcode " << thisPair.first << " has truth energy of " << thisPair.second << " for cluster with e, eta " << thisCaloCluster->e() << " and " << thisCaloCluster->eta());
40 
41  pfoWriteDecorHandle(*thisFE) = newBarCodeTruthPairs;
42  }
43  return StatusCode::SUCCESS;
44 }
45 
47 
49  if(!mapIdentifierToCalibHitsReadHandle.isValid()){
50  ATH_MSG_WARNING("Could not retrieve map between Identifier and calibraiton hits from Storegate");
51  return StatusCode::FAILURE;
52  }
53 
54  // pfo linker alg
56 
58  pfoWriteDecorHandleNLeadingTruthParticles,
59  mapIdentifierToCalibHitsReadHandle)); // end of check block
60 
61  return StatusCode::SUCCESS;
62 }
63 
65  return StatusCode::SUCCESS;
66 }
67 
68 
PFlowCalibPFODecoratorAlgorithm::LinkCalibHitPFO
StatusCode LinkCalibHitPFO(SG::WriteDecorHandle< xAOD::FlowElementContainer, std::vector< std::pair< unsigned int, double > > > &pfoWriteDecorHandle, SG::ReadHandle< std::map< Identifier, std::vector< const CaloCalibrationHit * > > > &CalibHitHandle) const
Definition: PFlowCalibPFODecoratorAlgorithm.cxx:21
PFlowCalibPFODecoratorAlgorithm::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: PFlowCalibPFODecoratorAlgorithm.cxx:46
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
PFlowCalibPFODecoratorAlgorithm::m_mapIdentifierToCalibHitsReadHandleKey
SG::ReadHandleKey< std::map< Identifier, std::vector< const CaloCalibrationHit * > > > m_mapIdentifierToCalibHitsReadHandleKey
ReadHandleKey for the map between Identifiers and sets of calibration hits.
Definition: PFlowCalibPFODecoratorAlgorithm.h:49
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:40
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
PFlowCalibPFODecoratorAlgorithm::m_truthAttributerTool
ToolHandle< ICaloCalibClusterTruthAttributerTool > m_truthAttributerTool
ToolHandle to a tool to create the calibration hit truth information that we need for the decoration.
Definition: PFlowCalibPFODecoratorAlgorithm.h:55
PFlowCalibPFODecoratorAlgorithm::m_pfoWriteDecorHandleKeyNLeadingTruthParticles
SG::WriteDecorHandleKey< xAOD::FlowElementContainer > m_pfoWriteDecorHandleKeyNLeadingTruthParticles
Write handle key to decorate PFO with threeN leading truth particle barcode and energy.
Definition: PFlowCalibPFODecoratorAlgorithm.h:52
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
PFlowCalibPFODecoratorAlgorithm::m_numTruthParticles
Gaudi::Property< unsigned int > m_numTruthParticles
Allow user to set the number of truth particles per clusterCaloCluster or PFO, in descending pt order...
Definition: PFlowCalibPFODecoratorAlgorithm.h:58
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
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
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:99
WriteDecorHandle.h
Handle class for adding a decoration to an object.
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
PFlowCalibPFODecoratorAlgorithm.h
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
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
PFlowCalibPFODecoratorAlgorithm::initialize
virtual StatusCode initialize() override
Definition: PFlowCalibPFODecoratorAlgorithm.cxx:10
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
PFlowCalibPFODecoratorAlgorithm::finalize
virtual StatusCode finalize() override
Definition: PFlowCalibPFODecoratorAlgorithm.cxx:64