ATLAS Offline Software
Loading...
Searching...
No Matches
PFSimulateTruthShowerTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
5
6#include "eflowRecCluster.h"
7#include "eflowRecTrack.h"
9
11
13 const std::string& name,
14 const IInterface* parent) :
15 AthAlgTool(type, name, parent){}
16
18
21
22 return StatusCode::SUCCESS;
23}
24
26 return StatusCode::SUCCESS;
27}
28
30
32 if (!tileActiveCaloCalibrationHitReadHandle.isValid()){
33 ATH_MSG_WARNING("TileActiveCaloCalibrationHitReadHandle is not valid");
34 return;
35 }
36
38 if (!lArActiveCaloCalibrationHitReadHandle.isValid()){
39 ATH_MSG_WARNING("lArActiveCaloCalibrationHitReadHandle is not valid");
40 return;
41 }
42
43 for (unsigned int trackCounter = 0; trackCounter < thisEFlowCaloObject.nTracks();trackCounter++){
44
45 eflowRecTrack* thisTrack = thisEFlowCaloObject.efRecTrack(trackCounter);
46
48
49 const static SG::Accessor<TruthLink> truthLinkAccessor("truthParticleLink");
50 //if truthLink not valid don't print a WARNING because this is an expected condition as discussed here:
51 //https://indico.cern.ch/event/795039/contributions/3391771/attachments/1857138/3050771/TruthTrackFTAGWS.pdf
52 TruthLink truthLink = truthLinkAccessor(*(thisTrack->getTrack()));
53
54 if (!truthLink.isValid()) continue;
55
56 //get uniqueID of particle
57 const int uniqueID = (*truthLink)->uid();
58
59 std::map<Identifier,double> identifierToTruthEnergyMap;
60
61 for (auto thisCalibHit : *tileActiveCaloCalibrationHitReadHandle) this->fillMap(identifierToTruthEnergyMap,uniqueID,*thisCalibHit);
62 for (auto thisCalibHit : *lArActiveCaloCalibrationHitReadHandle) this->fillMap(identifierToTruthEnergyMap,uniqueID,*thisCalibHit);
63
64 //find the matched clusters
65 for (auto thisLink : thisTrack->getClusterMatches()){
66 for (auto thisCell : *(thisLink->getCluster()->getCluster()->getOwnCellLinks())){
67 //look up the truth energy for this cell
68 if (identifierToTruthEnergyMap.count(thisCell->ID()) == 0) continue;
69 double truthEnergy = identifierToTruthEnergyMap[thisCell->ID()];
70 thisTrack->insertTruthEnergyPair(thisCell,truthEnergy);
71 }//cell loop
72 }//matched cluster loop
73 }//track loop
74}
75
76void PFSimulateTruthShowerTool::fillMap(std::map<Identifier,double>& identifierToTruthEnergyMap, int uniqueID, const CaloCalibrationHit& thisCalibHit) const{
77 if (HepMC::uniqueID(thisCalibHit) == uniqueID) {
78 Identifier thisIdentifier = thisCalibHit.cellID();
79 unsigned int count = identifierToTruthEnergyMap.count(thisIdentifier);
80 if (0 == count) identifierToTruthEnergyMap[thisIdentifier] = thisCalibHit.energyEM() + thisCalibHit.energyNonEM();
81 else identifierToTruthEnergyMap[thisIdentifier] += (thisCalibHit.energyEM() + thisCalibHit.energyNonEM());
82 }
83}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
ElementLink< xAOD::TruthParticleContainer > TruthLink
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Class to store calorimeter calibration hit.
double energyNonEM() const
Identifier cellID() const
void fillMap(std::map< Identifier, double > &identifierToTruthEnergyMap, int uniqueID, const CaloCalibrationHit &thisCalibHit) const
PFSimulateTruthShowerTool(const std::string &type, const std::string &name, const IInterface *parent)
void simulateShower(eflowCaloObject &thisEFlowCaloObject) const
SG::ReadHandleKey< CaloCalibrationHitContainer > m_lArActiveCaloCalibrationHitReadHandleKey
ReadHandleKey for Active LAr Calibration Hits.
SG::ReadHandleKey< CaloCalibrationHitContainer > m_tileActiveCaloCalibrationHitReadHandleKey
ReadHandleKey for Active Tile Calibration Hits.
Helper class to provide type-safe access to aux data.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
An internal EDM object which stores information about systems of associated tracks and calorimeter cl...
const eflowRecTrack * efRecTrack(int i) const
unsigned nTracks() const
This class extends the information about a xAOD::Track.
const std::vector< eflowTrackClusterLink * > & getClusterMatches() const
const xAOD::TrackParticle * getTrack() const
void insertTruthEnergyPair(const CaloCell *cell, double truthEnergy)
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:148
int uniqueID(const T &p)