ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
eflowRec
src
PFSimulateTruthShowerTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
#include "
PFSimulateTruthShowerTool.h
"
5
6
#include "
eflowRecCluster.h
"
7
#include "
eflowRecTrack.h
"
8
#include "
eflowTrackClusterLink.h
"
9
10
#include "
xAODTruth/TruthParticleContainer.h
"
11
12
PFSimulateTruthShowerTool::PFSimulateTruthShowerTool
(
const
std::string&
type
,
13
const
std::string& name,
14
const
IInterface* parent) :
15
AthAlgTool
(
type
, name, parent){}
16
17
StatusCode
PFSimulateTruthShowerTool::initialize
(){
18
19
ATH_CHECK
(
m_tileActiveCaloCalibrationHitReadHandleKey
.initialize());
20
ATH_CHECK
(
m_lArActiveCaloCalibrationHitReadHandleKey
.initialize());
21
22
return
StatusCode::SUCCESS;
23
}
24
25
StatusCode
PFSimulateTruthShowerTool::finalize
(){
26
return
StatusCode::SUCCESS;
27
}
28
29
void
PFSimulateTruthShowerTool::simulateShower
(
eflowCaloObject
& thisEFlowCaloObject)
const
{
30
31
SG::ReadHandle<CaloCalibrationHitContainer>
tileActiveCaloCalibrationHitReadHandle(
m_tileActiveCaloCalibrationHitReadHandleKey
);
32
if
(!tileActiveCaloCalibrationHitReadHandle.
isValid
()){
33
ATH_MSG_WARNING
(
"TileActiveCaloCalibrationHitReadHandle is not valid"
);
34
return
;
35
}
36
37
SG::ReadHandle<CaloCalibrationHitContainer>
lArActiveCaloCalibrationHitReadHandle(
m_lArActiveCaloCalibrationHitReadHandleKey
);
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
47
typedef
ElementLink<xAOD::TruthParticleContainer>
TruthLink
;
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
76
void
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
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
TruthParticleContainer.h
PFSimulateTruthShowerTool.h
TruthLink
ElementLink< xAOD::TruthParticleContainer > TruthLink
Definition
TruthRelatedMuonPlotOrganizer.cxx:13
AthAlgTool::AthAlgTool
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Definition
AthAlgTool.cxx:16
CaloCalibrationHit
Class to store calorimeter calibration hit.
Definition
CaloCalibrationHit.h:24
CaloCalibrationHit::energyNonEM
double energyNonEM() const
Definition
CaloCalibrationHit.h:134
CaloCalibrationHit::cellID
Identifier cellID() const
Definition
CaloCalibrationHit.h:128
CaloCalibrationHit::energyEM
double energyEM() const
Definition
CaloCalibrationHit.h:131
ElementLink
ElementLink implementation for ROOT usage.
Definition
A/AthLinks/ElementLink.h:40
ElementLink::isValid
bool isValid() const
Check if the element can be found.
PFSimulateTruthShowerTool::finalize
StatusCode finalize()
Definition
PFSimulateTruthShowerTool.cxx:25
PFSimulateTruthShowerTool::fillMap
void fillMap(std::map< Identifier, double > &identifierToTruthEnergyMap, int uniqueID, const CaloCalibrationHit &thisCalibHit) const
Definition
PFSimulateTruthShowerTool.cxx:76
PFSimulateTruthShowerTool::PFSimulateTruthShowerTool
PFSimulateTruthShowerTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition
PFSimulateTruthShowerTool.cxx:12
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
PFSimulateTruthShowerTool::initialize
StatusCode initialize()
Definition
PFSimulateTruthShowerTool.cxx:17
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:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
eflowCaloObject
An internal EDM object which stores information about systems of associated tracks and calorimeter cl...
Definition
eflowCaloObject.h:35
eflowCaloObject::efRecTrack
const eflowRecTrack * efRecTrack(int i) const
Definition
eflowCaloObject.h:53
eflowCaloObject::nTracks
unsigned nTracks() const
Definition
eflowCaloObject.h:55
eflowRecTrack
This class extends the information about a xAOD::Track.
Definition
eflowRecTrack.h:49
eflowRecTrack::getClusterMatches
const std::vector< eflowTrackClusterLink * > & getClusterMatches() const
Definition
eflowRecTrack.h:71
eflowRecTrack::getTrack
const xAOD::TrackParticle * getTrack() const
Definition
eflowRecTrack.h:58
eflowRecTrack::insertTruthEnergyPair
void insertTruthEnergyPair(const CaloCell *cell, double truthEnergy)
Definition
eflowRecTrack.cxx:89
eflowRecCluster.h
eflowRecTrack.h
eflowTrackClusterLink.h
count
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
Definition
hcg.cxx:148
HepMC::uniqueID
int uniqueID(const T &p)
Definition
MagicNumbers.h:89
Identifier
Definition
IdentifierFieldParser.cxx:14
type
Generated on
for ATLAS Offline Software by
1.17.0