ATLAS Offline Software
Loading...
Searching...
No Matches
PFSimulateTruthShowerTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
5
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
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 uniqueID of particle
45 const int uniqueID = (*truthLink)->uid();
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,uniqueID,*thisCalibHit);
62 for (auto thisCalibHit : *lArActiveCaloCalibrationHitReadHandle) this->fillMap(identifierToTruthEnergyMap,uniqueID,*thisCalibHit);
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
79void PFSimulateTruthShowerTool::fillMap(std::map<Identifier,double>& identifierToTruthEnergyMap, int uniqueID, const CaloCalibrationHit& thisCalibHit) const{
80 if (HepMC::uniqueID(thisCalibHit) == uniqueID) {
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}
#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.
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
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:146
int uniqueID(const T &p)