ATLAS Offline Software
PFSimulateTruthShowerTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
5 
9 
11 
13  const std::string& name,
14  const IInterface* parent) :
16 
18 
21 
22  return StatusCode::SUCCESS;
23 }
24 
26  return StatusCode::SUCCESS;
27 }
28 
30 
31  for (unsigned int trackCounter = 0; trackCounter < thisEFlowCaloObject.nTracks();trackCounter++){
32 
33  eflowRecTrack* thisTrack = thisEFlowCaloObject.efRecTrack(trackCounter);
34 
36 
37  const static SG::AuxElement::Accessor<TruthLink> truthLinkAccessor("truthParticleLink");
38  //if truthLink not valid don't print a WARNING because this is an expected condition as discussed here:
39  //https://indico.cern.ch/event/795039/contributions/3391771/attachments/1857138/3050771/TruthTrackFTAGWS.pdf
40  TruthLink truthLink = truthLinkAccessor(*(thisTrack->getTrack()));
41 
42  if (!truthLink.isValid()) continue;
43 
44  //get barcode of particle
45  const int barcode = (*truthLink)->barcode(); // FIXME barcode-based
46 
48  if (!tileActiveCaloCalibrationHitReadHandle.isValid()){
49  ATH_MSG_WARNING("TileActiveCaloCalibrationHitReadHandle is not valid");
50  return;
51  }
52 
54  if (!lArActiveCaloCalibrationHitReadHandle.isValid()){
55  ATH_MSG_WARNING("lArActiveCaloCalibrationHitReadHandle is not valid");
56  return;
57  }
58 
59  std::map<Identifier,double> identifierToTruthEnergyMap;
60 
61  for (auto thisCalibHit : *tileActiveCaloCalibrationHitReadHandle) this->fillMap(identifierToTruthEnergyMap,barcode,*thisCalibHit); // FIXME barcode-based
62  for (auto thisCalibHit : *lArActiveCaloCalibrationHitReadHandle) this->fillMap(identifierToTruthEnergyMap,barcode,*thisCalibHit); // FIXME barcode-based
63 
64  //find the matched clusters
65  std::vector<eflowRecCluster*> matchedClusters;
66  for (auto thisLink : thisTrack->getClusterMatches()) matchedClusters.push_back(thisLink->getCluster());
67 
68  for (auto thisLink : thisTrack->getClusterMatches()){
69  for (auto thisCell : *(thisLink->getCluster()->getCluster()->getOwnCellLinks())){
70  //look up the truth energy for this cell
71  if (identifierToTruthEnergyMap.count(thisCell->ID()) == 0) continue;
72  double truthEnergy = identifierToTruthEnergyMap[thisCell->ID()];
73  thisTrack->insertTruthEnergyPair(thisCell,truthEnergy);
74  }//cell loop
75  }//matched cluster loop
76  }//track loop
77 }
78 
79 void PFSimulateTruthShowerTool::fillMap(std::map<Identifier,double>& identifierToTruthEnergyMap, int barcode, const CaloCalibrationHit& thisCalibHit) const{
80  if (HepMC::barcode(thisCalibHit) == barcode) { // FIXME barcode-based until xAOD::TruthParticle supports id rather than barcode
81  Identifier thisIdentifier = thisCalibHit.cellID();
82  unsigned int count = identifierToTruthEnergyMap.count(thisIdentifier);
83  if (0 == count) identifierToTruthEnergyMap[thisIdentifier] = thisCalibHit.energyEM() + thisCalibHit.energyNonEM();
84  else identifierToTruthEnergyMap[thisIdentifier] += (thisCalibHit.energyEM() + thisCalibHit.energyNonEM());
85  }
86 }
PFSimulateTruthShowerTool::initialize
StatusCode initialize()
Definition: PFSimulateTruthShowerTool.cxx:17
CaloCalibrationHit::energyNonEM
double energyNonEM() const
Definition: CaloCalibrationHit.h:124
PFSimulateTruthShowerTool::m_tileActiveCaloCalibrationHitReadHandleKey
SG::ReadHandleKey< CaloCalibrationHitContainer > m_tileActiveCaloCalibrationHitReadHandleKey
ReadHandleKey for Active Tile Calibration Hits.
Definition: PFSimulateTruthShowerTool.h:32
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:68
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
TruthParticleContainer.h
TruthLink
ElementLink< xAOD::TruthParticleContainer > TruthLink
Definition: TruthRelatedMuonPlotOrganizer.cxx:12
CaloCalibrationHit::energyEM
double energyEM() const
Definition: CaloCalibrationHit.h:121
eflowCaloObject
An internal EDM object which stores information about systems of associated tracks and calorimeter cl...
Definition: eflowCaloObject.h:34
eflowRecTrack::insertTruthEnergyPair
void insertTruthEnergyPair(const CaloCell *cell, double truthEnergy)
Definition: eflowRecTrack.cxx:90
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
eflowRecTrack
This class extends the information about a xAOD::Track.
Definition: eflowRecTrack.h:46
PFSimulateTruthShowerTool::finalize
StatusCode finalize()
Definition: PFSimulateTruthShowerTool.cxx:25
eflowRecTrack::getClusterMatches
const std::vector< eflowTrackClusterLink * > & getClusterMatches() const
Definition: eflowRecTrack.h:67
eflowRecTrack.h
eflowCaloObject::efRecTrack
const eflowRecTrack * efRecTrack(int i) const
Definition: eflowCaloObject.h:52
PFSimulateTruthShowerTool::simulateShower
void simulateShower(eflowCaloObject &thisEFlowCaloObject) const
Definition: PFSimulateTruthShowerTool.cxx:29
PFSimulateTruthShowerTool::m_lArActiveCaloCalibrationHitReadHandleKey
SG::ReadHandleKey< CaloCalibrationHitContainer > m_lArActiveCaloCalibrationHitReadHandleKey
ReadHandleKey for Active LAr Calibration Hits.
Definition: PFSimulateTruthShowerTool.h:35
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
eflowCaloObject::nTracks
unsigned nTracks() const
Definition: eflowCaloObject.h:54
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
eflowRecCluster.h
CaloCalibrationHit::cellID
Identifier cellID() const
Definition: CaloCalibrationHit.h:118
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
PFSimulateTruthShowerTool::PFSimulateTruthShowerTool
PFSimulateTruthShowerTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: PFSimulateTruthShowerTool.cxx:12
CaloCalibrationHit
Class to store calorimeter calibration hit.
Definition: CaloCalibrationHit.h:23
eflowRecTrack::getTrack
const xAOD::TrackParticle * getTrack() const
Definition: eflowRecTrack.h:54
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
PFSimulateTruthShowerTool::fillMap
void fillMap(std::map< Identifier, double > &identifierToTruthEnergyMap, int barcode, const CaloCalibrationHit &thisCalibHit) const
Definition: PFSimulateTruthShowerTool.cxx:79
AthAlgTool
Definition: AthAlgTool.h:26
PFSimulateTruthShowerTool.h
Identifier
Definition: IdentifierFieldParser.cxx:14