49 {
50
51
53 if (!
parts.isValid()) {
55 return StatusCode::FAILURE;
56 }
57 SG::ReadHandle<xAOD::TruthEventContainer> tec{
m_truthSGKey, ctx};
60 return StatusCode::FAILURE;
61 }
64 ATH_MSG_DEBUG(
"No truth pileup collection with name " <<
m_truthPileupSGKey.fullKey() <<
" found in StoreGate. Pile-up information will not be filled");
65 }
66
67 SG::ReadHandle<xAOD::TruthParticleContainer> truthMuons{
m_truthMuonSGKey, ctx};
70 return StatusCode::FAILURE;
71 }
72
73
74
75 for (const xAOD::IParticle* part : *parts) {
77 float minDR{FLT_MAX};
80 if (dR > minDR) continue;
81 closest = muTruth;
82 minDR = dR;
83 }
84
86 for (size_t parti = 0; parti < event->nTruthParticles(); parti++) {
90 continue;
92 if (dR > minDR) continue;
93 closest = tpart;
94 minDR = dR;
95 }
96 }
97
98 decorator_dR(*part) = closest ? std::sqrt(minDR) : -1;
99
100 int newType{-1}, newOrigin{-1};
101 if (closest && closest->
isMuon()) {
102 newType = acc_tT(*closest);
103 newOrigin = acc_tO(*closest);
104 } else if (closest) {
107 newOrigin =
res.second;
108 }
109 decorator_type(*part) = newType;
110 decorator_origin(*part) = newOrigin;
111
112 decorator_pu_dR(*part) = -1;
113 decorator_pu_type(*part) = -1;
114 decorator_pu_origin(*part) = -1;
115
116 minDR = FLT_MAX;
117
120 for (auto event : *tpec) {
121 for (size_t parti = 0; parti < event->nTruthParticles(); parti++) {
125 continue;
127 if (dR > minDR) continue;
128 closestPileup = tpart;
129 minDR = dR;
130 }
131 }
132 decorator_pu_dR(*part) = (closestPileup ? std::sqrt(minDR) : -1);
133 int newPileupType{-1}, newPileupOrigin{-1};
134 if (closestPileup) {
136 newPileupType =
res.first;
137 newPileupOrigin =
res.second;
138 }
139 decorator_pu_type(*part) = newPileupType;
140 decorator_pu_origin(*part) = newPileupOrigin;
141 }
142 }
143
144 return StatusCode::SUCCESS;
145}
std::pair< std::vector< unsigned int >, bool > res
ToolHandle< IMCTruthClassifier > m_mcTruthClassifier
Gaudi::Property< float > m_minPt
SG::ReadHandleKey< xAOD::TruthPileupEventContainer > m_truthPileupSGKey
SG::ReadHandleKey< xAOD::TruthEventContainer > m_truthSGKey
SG::ReadHandleKey< xAOD::IParticleContainer > m_containerKey
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthMuonSGKey
virtual bool isValid() override final
Can the handle be successfully dereferenced?
virtual double pt() const override final
The transverse momentum ( ) of the particle.
double charge() const
Physical charge.
bool isMuon() const
Whether the particle is a muon (or antimuon)
bool is_simulation_particle(const T &p)
Method to establish if a particle (or barcode) was created during the simulation (TODO update to be s...
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
double deltaR2(double rapidity1, double phi1, double rapidity2, double phi2)
from bare rapidity,phi
TruthEvent_v1 TruthEvent
Typedef to implementation.
TruthParticle_v1 TruthParticle
Typedef to implementation.