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")
39 if (name ==
"R4OutOfTimeTruthLabel")
55 return StatusCode::FAILURE;
117 return StatusCode::FAILURE;
194 return StatusCode::SUCCESS;
214 auto maybeInit = [&] (
auto&
h,
217 if (!k.key().empty())
h.emplace (k, ctx);
220 maybeInit (
nbHandle, tool.m_NB_truthKey);
244 const EventContext& ctx )
const
250 bool matchTop =
false;
280 return getLabel( dh,
jet, matchH, matchW, matchZ, matchTop, ctx );
285 const EventContext& ctx = Gaudi::Hive::currentContext();
303 return StatusCode::SUCCESS;
308 const EventContext& ctx)
const {
312 bool usePileupJets =
true;
320 if (!inTimeTruthJets.
isValid() || !outOfTimeTruthJets.
isValid()) {
322 usePileupJets =
false;
340 if ( element_link.
isValid() ) {
341 parent = *element_link;
344 ATH_MSG_ERROR(
"Unable to get a link to the parent jet! Returning a NULL pointer.");
345 return StatusCode::FAILURE;
350 float oot_dRmin = 9999;
351 float it_dRmin = 9999;
352 float ghostFracNominal = 9;
353 const xAOD::Jet* matchTruthJet =
nullptr;
354 const xAOD::Jet* oot_matchTruthJet =
nullptr;
355 const xAOD::Jet* it_matchTruthJet =
nullptr;
357 float dRminGroomed = 9999;
358 const xAOD::Jet* matchTruthGroomedJet =
nullptr;
360 float sumPtMatchedHSJets = 0;
361 float sumPtMatchedOOTJets = 0;
362 float sumPtMatchedITJets = 0;
363 float bestHSpT = -9999;
364 float bestOOTpT = -9999;
365 float bestITpT = -9999;
366 float bestHSpTRatio = -9;
367 float bestOOTpTRatio = -9;
368 float bestITpTRatio = -9;
369 int nMatchedHSJets = 0;
370 int nMatchedOOTJets = 0;
371 int nMatchedITJets = 0;
376 if (
jet->numConstituents() > 0) {
379 float ghostTruthPt = accGhostTruthPt(*
jet);
380 for (
const xAOD::Jet* truthJet : *truthJets) {
382 float dR =
jet->p4().DeltaR(truthJet->p4(),
true);
384 if (parent) dR = parent->p4().DeltaR(truthJet->p4(),
true);
386 float ghostPtFraction = (ghostTruthPt / (truthJet->pt()));
390 sumPtMatchedHSJets += truthJet->pt();
391 if (std::abs(1 - ghostPtFraction) < std::abs(1 - ghostFracNominal)) {
392 matchTruthJet = truthJet;
393 ghostFracNominal = ghostPtFraction;
400 sumPtMatchedHSJets += truthJet->pt();
403 matchTruthJet = truthJet;
409 for (
const xAOD::Jet* ootJet : *outOfTimeTruthJets) {
410 float dR =
jet->p4().DeltaR(ootJet->p4(),
true);
411 float ghostPtFraction = (ghostTruthPt / (ootJet->pt()));
414 nMatchedOOTJets += 1;
415 sumPtMatchedOOTJets += ootJet->pt();
416 if (std::abs(1 - ghostPtFraction) < std::abs(1 - ghostFracNominal)) {
417 oot_matchTruthJet = ootJet;
423 nMatchedOOTJets += 1;
424 sumPtMatchedOOTJets += ootJet->pt();
425 if (dR < oot_dRmin) {
427 oot_matchTruthJet = ootJet;
432 for (
const xAOD::Jet* itJet : *inTimeTruthJets) {
433 float dR =
jet->p4().DeltaR(itJet->p4(),
true);
434 float ghostPtFraction = (ghostTruthPt / (itJet->pt()));
438 sumPtMatchedITJets += itJet->pt();
439 if (std::abs(1 - ghostPtFraction) < std::abs(1 - ghostFracNominal)) {
440 it_matchTruthJet = itJet;
447 sumPtMatchedITJets += itJet->pt();
450 it_matchTruthJet = itJet;
469 int nMatchedPUJets = nMatchedOOTJets + nMatchedITJets;
471 float totalMatchedpT = sumPtMatchedHSJets + sumPtMatchedOOTJets + sumPtMatchedITJets;
474 bestHSpT = matchTruthJet->
pt();
475 bestHSpTRatio = bestHSpT / totalMatchedpT;
477 if (oot_matchTruthJet) {
478 bestOOTpT = oot_matchTruthJet->
pt();
479 bestOOTpTRatio = bestOOTpT / totalMatchedpT;
481 if (it_matchTruthJet) {
482 bestITpT = it_matchTruthJet->
pt();
483 bestITpTRatio = bestITpT / totalMatchedpT;
486 if (bestHSpTRatio >= 0.9) {
489 else if (bestITpTRatio >= 0.9) {
492 else if (bestOOTpTRatio >= 0.9) {
495 else if (nMatchedPUJets == 0 && nMatchedHSJets > 1) {
498 else if (nMatchedPUJets > 0 && nMatchedHSJets > 0) {
501 else if (nMatchedPUJets > 1) {
514 float truthJetSplit12 = -9999;
515 float truthJetSplit23 = -9999;
519 float truthJetMass = -9999;
520 float truthJetPt = -9999;
521 float truthJetRapidity = -9;
522 float truthJetPhi = -9999;
527 matchTruthJet = it_matchTruthJet;
530 matchTruthJet = oot_matchTruthJet;
533 if (bestITpTRatio >= bestOOTpTRatio) {
534 matchTruthJet = it_matchTruthJet;
537 matchTruthJet = oot_matchTruthJet;
541 if ( matchTruthJet ) {
548 label = labelAcc(*matchTruthJet);
551 if (split23Handle.
isAvailable()) truthJetSplit23 = split23Handle(*matchTruthJet);
553 if (split12Handle.
isAvailable()) truthJetSplit12 = split12Handle(*matchTruthJet);
555 if (nbAcc.isAvailable(*matchTruthJet)) truthJetNB = nbAcc(*matchTruthJet);
558 truthJetMass = matchTruthJet->
m();
559 truthJetPt = matchTruthJet->
pt();
560 truthJetRapidity = matchTruthJet->
rapidity();
561 truthJetPhi = matchTruthJet->
phi();
566 float truthGroomedJetMass = -9999;
567 float truthGroomedJetPt = -9999;
569 if ( matchTruthJet ) {
570 for (
const xAOD::Jet* truthGroomedJet : *truthGroomedJets ) {
572 if ( !element_link.
isValid() ) {
continue; }
573 if ( matchTruthJet == *element_link ) {
574 matchTruthGroomedJet = truthGroomedJet;
580 if ( !matchTruthGroomedJet && parent !=
nullptr) {
581 for (
const xAOD::Jet* truthGroomedJet : *truthGroomedJets ) {
582 float dR = parent->p4().DeltaR(truthGroomedJet->p4(),
true);
585 if ( dR < dRminGroomed ) {
587 matchTruthGroomedJet = truthGroomedJet;
592 if ( matchTruthGroomedJet ) {
593 truthGroomedJetMass = matchTruthGroomedJet->
m();
594 truthGroomedJetPt = matchTruthGroomedJet->
pt();
630 return StatusCode::SUCCESS;
634 const EventContext& ctx)
const {
641 ATH_MSG_ERROR(
"No truth jet container retrieved. Please make sure you are using a supported TruthLabelName.");
642 return StatusCode::FAILURE;
651 const EventContext& ctx)
const
654 if ( !(truthJets.
size()) )
return StatusCode::SUCCESS;
660 return StatusCode::SUCCESS;
667 return StatusCode::FAILURE;
674 ATH_MSG_DEBUG(
"Getting truth label using ghost-association");
680 return StatusCode::SUCCESS;
688 float split12 = -999.0;
691 const float c0 = 55.25;
692 const float c1 = -2.34e-3;
694 split12 = c0 * std::exp( c1 * pt );
706 float split23 = -999.0;
712 const float c0 = 3.3;
713 const float c1 = -6.98e-4;
715 split23 = std::exp( c0 + c1 * pt );
726 if( !
jet.getAttribute<
int>( collection+
"Count", nMatchPart ) ){
728 std::vector<const xAOD::TruthParticle*> ghostParts;
730 ATH_MSG_ERROR( collection +
" cannot be retrieved! Truth label definition might be wrong" );
732 nMatchPart = ghostParts.size();
744 const EventContext& ctx)
const {
753 bool is_tautauEl =
false;
754 bool is_tautauMu =
false;
755 bool is_tautauHad =
false;
764 is_bb = ( nMatchB > 1 );
773 int extended_GA_label = -1;
774 if (not
jet.getAttribute(
"HadronGhostExtendedTruthLabelID", extended_GA_label)) {
780 is_bb = ( extended_GA_label == 55 );
781 is_cc = ( extended_GA_label == 44 );
782 is_tautauEl = ( extended_GA_label == 151511 );
783 is_tautauMu = ( extended_GA_label == 151513 );
784 is_tautauHad = ( extended_GA_label == 1515 );
803 if( !(matchTop || matchW || matchZ || matchH) ) {
Scalar deltaR(const MatrixBase< Derived > &vec) const
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
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 rapidity() const
The true rapidity (y) of the particle.
virtual double m() const
The invariant mass 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())
int enumToInt(const TypeEnum type)
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".