93 std::vector<const xAOD::TruthParticle*> vTruthMatch;
94 std::vector<TruthMatchedParticleType> vTruthMatchedParticleType;
95 std::vector<const xAOD::Jet*> vTruthJetMatch;
108 while (xDiTau.
subjetPt(n_subjets) > 0. )
113 n_subjets = accNSubjets(xDiTau);
117 for (
int i = 0; i < n_subjets; ++i)
122 vTruthMatch.push_back(xTruthMatch);
123 vTruthMatchedParticleType.push_back(eTruthMatchedParticleType);
125 const xAOD::Jet* xTruthJetMatch =
nullptr;
126 vTruthJetMatch.push_back(xTruthJetMatch);
130 for (
int i = 0; i < n_subjets; ++i)
132 TLorentzVector vSubjetTLV;
133 vSubjetTLV.SetPtEtaPhiE(xDiTau.
subjetPt(i),
140 vTruthJetMatch.at(i),
141 vTruthMatchedParticleType.at(i)).isFailure() )
143 ATH_MSG_WARNING(
"There was a failure in matching truth taus with subjet " << i);
144 return StatusCode::FAILURE;
146 if (vTruthMatch.at(i) && vTruthMatchedParticleType.at(i) ==
TruthHadronicTau)
148 xRemainingTruthTaus.
erase( std::find(xRemainingTruthTaus.
begin(),
149 xRemainingTruthTaus.
end(),
150 vTruthMatch.at(i)) );
155 std::vector< ElementLink < xAOD::JetContainer > > vTruthJetLinks;
156 for (
int i = 0; i < n_subjets; ++i)
158 const xAOD::Jet* xTruthJetMatch = vTruthJetMatch.at(i);
160 ElementLink < xAOD::JetContainer > lTruthParticleLink(xTruthJetMatch, *
m_truthTausEvent.m_xTruthJetContainerConst);
161 vTruthJetLinks.push_back(lTruthParticleLink);
165 ElementLink < xAOD::JetContainer > lTruthParticleLink;
166 vTruthJetLinks.push_back(lTruthParticleLink);
170 decTruthJetLinks (
"truthJetLinks");
171 decTruthJetLinks(xDiTau) = std::move(vTruthJetLinks);
174 bool bTruthMatched =
true;
177 std::vector< ElementLink < xAOD::TruthParticleContainer > > vTruthLinks;
178 for (
int i = 0; i < n_subjets; ++i)
186 ElementLink < xAOD::TruthParticleContainer > lTruthParticleLink(xTruthMatch, xTruthTauContainer);
187 vTruthLinks.push_back(lTruthParticleLink);
189 else if (eTruthMatchedParticleType ==
TruthMuon)
191 ElementLink <xAOD::TruthParticleContainer> lTruthParticleLink(xTruthMatch, *
m_truthTausEvent.m_xTruthMuonContainerConst);
192 vTruthLinks.push_back(lTruthParticleLink);
196 ElementLink <xAOD::TruthParticleContainer> lTruthParticleLink(xTruthMatch, *
m_truthTausEvent.m_xTruthElectronContainerConst);
197 vTruthLinks.push_back(lTruthParticleLink);
202 ElementLink < xAOD::TruthParticleContainer > lTruthParticleLink;
203 vTruthLinks.push_back(lTruthParticleLink);
206 if (i == 0 || i == 1) bTruthMatched =
false;
211 decTruthParticleLinks (
"truthParticleLinks");
212 decTruthParticleLinks(xDiTau) = vTruthLinks;
216 decTruthTaus (
"TruthTaus");
217 decTruthTaus(xDiTau) = vTruthLinks;
234 if ( n_subjets < 2) {
235 decIsTruthMatched(xDiTau) = (char)
false;
236 decIsTruthHadronic(xDiTau) = (char)
false;
237 decTruthLeadPt(xDiTau) = -1234.;
238 decTruthLeadEta(xDiTau) = -1234.;
239 decTruthLeadPhi(xDiTau) = -1234.;
240 decTruthLeadM(xDiTau) = -1234.;
241 decTruthLeadPdgID(xDiTau) = -1234.;
242 decTruthSubleadPt(xDiTau) = -1234.;
243 decTruthSubleadEta(xDiTau) = -1234.;
244 decTruthSubleadPhi(xDiTau) = -1234.;
245 decTruthSubleadM(xDiTau) = -1234.;
246 decTruthSubleadPdgID(xDiTau) = -1234.;
247 decTruthDeltaR(xDiTau) = -1234.;
248 decTruthMass(xDiTau) = -1234.;
249 return StatusCode::SUCCESS;
252 decIsTruthMatched(xDiTau) = (char)bTruthMatched;
256 decIsTruthHadronic(xDiTau) = (char)(vTruthMatchedParticleType[0]==
TruthHadronicTau
260 decIsTruthHadronic(xDiTau) = (char)
false;
262 if (accIsTruthHadronic(xDiTau))
264 TLorentzVector tlvTruthTau1;
265 TLorentzVector tlvTruthTau2;
266 tlvTruthTau1.SetPtEtaPhiM(
m_accPtVis(*(*vTruthLinks.at(0))),
270 tlvTruthTau2.SetPtEtaPhiM(
m_accPtVis(*(*vTruthLinks.at(1))),
275 decTruthLeadPt(xDiTau) = std::max(tlvTruthTau1.Pt(), tlvTruthTau2.Pt());
276 decTruthLeadEta(xDiTau) = (tlvTruthTau1.Pt() > tlvTruthTau2.Pt()) ? tlvTruthTau1.Eta() : tlvTruthTau2.Eta();
277 decTruthLeadPhi(xDiTau) = (tlvTruthTau1.Pt() > tlvTruthTau2.Pt()) ? tlvTruthTau1.Phi() : tlvTruthTau2.Phi();
278 decTruthLeadM(xDiTau) = (tlvTruthTau1.Pt() > tlvTruthTau2.Pt()) ? tlvTruthTau1.M() : tlvTruthTau2.M();
279 decTruthLeadPdgID(xDiTau) = (*vTruthLinks.at(0))->pdgId();
280 decTruthSubleadPt(xDiTau) = std::min(tlvTruthTau1.Pt(), tlvTruthTau2.Pt());
281 decTruthSubleadEta(xDiTau) = (tlvTruthTau1.Pt() > tlvTruthTau2.Pt()) ? tlvTruthTau2.Eta() : tlvTruthTau1.Eta();
282 decTruthSubleadPhi(xDiTau) = (tlvTruthTau1.Pt() > tlvTruthTau2.Pt()) ? tlvTruthTau2.Phi() : tlvTruthTau1.Phi();
283 decTruthSubleadM(xDiTau) = (tlvTruthTau1.Pt() > tlvTruthTau2.Pt()) ? tlvTruthTau2.M() : tlvTruthTau1.M();
284 decTruthSubleadPdgID(xDiTau) = (*vTruthLinks.at(1))->pdgId();
285 decTruthDeltaR(xDiTau) = tlvTruthTau1.DeltaR(tlvTruthTau2);
286 decTruthMass(xDiTau) = (tlvTruthTau1 + tlvTruthTau2).M();
290 decTruthLeadPt(xDiTau) = -1234.;
291 decTruthLeadEta(xDiTau) = -1234.;
292 decTruthLeadPhi(xDiTau) = -1234.;
293 decTruthLeadM(xDiTau) = -1234.;
294 decTruthLeadPdgID(xDiTau) = -1234.;
295 decTruthSubleadPt(xDiTau) = -1234.;
296 decTruthSubleadEta(xDiTau) = -1234.;
297 decTruthSubleadPhi(xDiTau) = -1234.;
298 decTruthSubleadM(xDiTau) = -1234.;
299 decTruthSubleadPdgID(xDiTau) = -1234.;
300 decTruthDeltaR(xDiTau) = -1234.;
301 decTruthMass(xDiTau) = -1234.;
304 return StatusCode::SUCCESS;
313 for (
auto xTruthTauIt : xTruthTauContainer)
315 TLorentzVector vTruthVisTLV;
316 vTruthVisTLV.SetPtEtaPhiM(
m_accPtVis(*xTruthTauIt),
323 if (
static_cast<bool>(accIsHadronicTau(*xTruthTauIt)))
328 xTruthMatch = xTruthTauIt;
338 if (vSubjetTLV.DeltaR(xTruthMuonIt->p4()) <=
m_dMaxDeltaR)
340 if (xTruthMuonIt->pt()<dPtMax)
344 xTruthMatch = xTruthMuonIt;
345 dPtMax = xTruthMuonIt->
pt();
353 for (
auto xTruthElectronIt : *
m_truthTausEvent.m_xTruthElectronContainerConst)
355 if (vSubjetTLV.DeltaR(xTruthElectronIt->p4()) <=
m_dMaxDeltaR)
357 if (xTruthElectronIt->pt()<dPtMax)
360 xTruthMatch = xTruthElectronIt;
361 dPtMax = xTruthElectronIt->
pt();
371 if (vSubjetTLV.DeltaR(xTruthJetIt->p4()) <=
m_dMaxDeltaR)
373 if (xTruthJetIt->pt()<dPtMax)
375 xTruthJetMatch = xTruthJetIt;
376 dPtMax = xTruthJetIt->
pt();
381 return StatusCode::SUCCESS;
virtual double pt() const override final
The transverse momentum ( ) of the particle.