21 if (name ==
"R10TruthLabel_R21Precision_2022v1")
24 if (name ==
"R10TruthLabel_R22v1")
27 if (name ==
"R10WZTruthLabel_R22v1")
30 if (name ==
"R4TruthLabel")
33 if (name ==
"R4TruthDressedWZLabel")
36 if (name ==
"R4InTimeTruthLabel")
52 return StatusCode::FAILURE;
110 return StatusCode::FAILURE;
168 return StatusCode::SUCCESS;
188 auto maybeInit = [&] (
auto&
h,
191 if (!k.key().empty())
h.emplace (k, ctx);
194 maybeInit (
nbHandle, tool.m_NB_truthKey);
214 const EventContext& ctx )
const
220 bool matchTop =
false;
250 return getLabel( dh,
jet, matchH, matchW, matchZ, matchTop, ctx );
255 const EventContext& ctx = Gaudi::Hive::currentContext();
273 return StatusCode::SUCCESS;
278 const EventContext& ctx)
const {
293 if ( element_link.
isValid() ) {
294 parent = *element_link;
297 ATH_MSG_ERROR(
"Unable to get a link to the parent jet! Returning a NULL pointer.");
298 return StatusCode::FAILURE;
303 float ghostFracNominal = 9999;
304 const xAOD::Jet* matchTruthJet =
nullptr;
305 float dRminGroomed = 9999;
306 const xAOD::Jet* matchTruthGroomedJet =
nullptr;
310 if(
jet->numConstituents() > 0){
311 for (
const xAOD::Jet* truthJet : *truthJets ) {
314 float dR =
jet->p4().DeltaR(truthJet->p4());
316 if (parent) dR = parent->p4().DeltaR(truthJet->p4());
320 float ghostTruthPt = accGhostTruthPt(*
jet);
321 float ghostPtFraction = (ghostTruthPt / (truthJet->pt()));
324 if (std::abs(1 - ghostPtFraction) < std::abs(1 - ghostFracNominal)) {
325 matchTruthJet = truthJet;
326 ghostFracNominal = ghostPtFraction;
335 matchTruthJet = truthJet;
346 float truthJetSplit12 = -9999;
347 float truthJetSplit23 = -9999;
351 float truthJetMass = -9999;
352 float truthJetPt = -9999;
353 float truthJetEta = -9999;
354 float truthJetPhi = -9999;
356 float ghostFrac = -2;
358 if ( matchTruthJet ) {
364 label = labelAcc(*matchTruthJet);
367 if (split23Handle.
isAvailable()) truthJetSplit23 = split23Handle(*matchTruthJet);
369 if (split12Handle.
isAvailable()) truthJetSplit12 = split12Handle(*matchTruthJet);
371 if (nbAcc.isAvailable(*matchTruthJet)) truthJetNB = nbAcc(*matchTruthJet);
374 truthJetMass = matchTruthJet->
m();
375 truthJetPt = matchTruthJet->
pt();
376 truthJetEta = matchTruthJet->
eta();
377 truthJetPhi = matchTruthJet->
phi();
378 ghostFrac = ghostFracNominal;
383 float truthGroomedJetMass = -9999;
384 float truthGroomedJetPt = -9999;
386 if ( matchTruthJet ) {
387 for (
const xAOD::Jet* truthGroomedJet : *truthGroomedJets ) {
389 if ( !element_link.
isValid() ) {
continue; }
390 if ( matchTruthJet == *element_link ) {
391 matchTruthGroomedJet = truthGroomedJet;
397 if ( !matchTruthGroomedJet && parent !=
nullptr) {
398 for (
const xAOD::Jet* truthGroomedJet : *truthGroomedJets ) {
399 float dR = parent->p4().DeltaR(truthGroomedJet->p4());
402 if ( dR < dRminGroomed ) {
404 matchTruthGroomedJet = truthGroomedJet;
409 if ( matchTruthGroomedJet ) {
410 truthGroomedJetMass = matchTruthGroomedJet->
m();
411 truthGroomedJetPt = matchTruthGroomedJet->
pt();
441 return StatusCode::SUCCESS;
445 const EventContext& ctx)
const {
452 ATH_MSG_ERROR(
"No truth jet container retrieved. Please make sure you are using a supported TruthLabelName.");
453 return StatusCode::FAILURE;
462 const EventContext& ctx)
const
465 if ( !(truthJets.
size()) )
return StatusCode::SUCCESS;
471 return StatusCode::SUCCESS;
478 return StatusCode::FAILURE;
485 ATH_MSG_DEBUG(
"Getting truth label using ghost-association");
491 return StatusCode::SUCCESS;
499 float split12 = -999.0;
502 const float c0 = 55.25;
503 const float c1 = -2.34e-3;
505 split12 = c0 * std::exp( c1 * pt );
517 float split23 = -999.0;
523 const float c0 = 3.3;
524 const float c1 = -6.98e-4;
526 split23 = std::exp( c0 + c1 * pt );
537 if( !
jet.getAttribute<
int>( collection+
"Count", nMatchPart ) ){
539 std::vector<const xAOD::TruthParticle*> ghostParts;
541 ATH_MSG_ERROR( collection +
" cannot be retrieved! Truth label definition might be wrong" );
543 nMatchPart = ghostParts.size();
555 const EventContext& ctx)
const {
564 bool is_tautauEl =
false;
565 bool is_tautauMu =
false;
566 bool is_tautauHad =
false;
575 is_bb = ( nMatchB > 1 );
584 int extended_GA_label = -1;
585 if (not
jet.getAttribute(
"HadronGhostExtendedTruthLabelID", extended_GA_label)) {
591 is_bb = ( extended_GA_label == 55 );
592 is_cc = ( extended_GA_label == 44 );
593 is_tautauEl = ( extended_GA_label == 151511 );
594 is_tautauMu = ( extended_GA_label == 151513 );
595 is_tautauHad = ( extended_GA_label == 1515 );
614 if( !(matchTop || matchW || matchZ || matchH) ) {
Scalar deltaR(const MatrixBase< Derived > &vec) const
#define ATH_CHECK
Evaluate an expression and check for errors.
Helper class to provide constant type-safe access to aux data.
ATLAS-specific HepMC functions.
Header file for AthHistogramAlgorithm.
size_type size() const noexcept
Returns the number of elements in the collection.
ElementLink implementation for ROOT usage.
bool isValid() const
Check if the element can be found.
Helper class to provide constant type-safe access to aux data.
Handle class for reading a decoration on an object.
bool isAvailable()
Test to see if this variable exists in the store, for the referenced object.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
virtual double phi() const
The azimuthal angle ( ) of the particle.
virtual double pt() const
The transverse momentum ( ) of the particle.
virtual double m() const
The invariant mass of the particle.
virtual double eta() const
The pseudorapidity ( ) of the particle.
std::string label(const std::string &format, int i)
int enumToInt(const TypeEnum type)
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Jet_v1 Jet
Definition of the current "jet version".
TruthParticle_v1 TruthParticle
Typedef to implementation.
JetContainer_v1 JetContainer
Definition of the current "jet container version".