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;
378 if (
jet->numConstituents() > 0) {
379 for (
const xAOD::Jet* truthJet : *truthJets) {
381 float dR =
jet->p4().DeltaR(truthJet->p4(),
true);
383 if (parent) dR = parent->p4().DeltaR(truthJet->p4(),
true);
387 float ghostTruthPt = accGhostTruthPt(*
jet);
388 float ghostPtFraction = (ghostTruthPt / (truthJet->pt()));
391 sumPtMatchedHSJets += truthJet->pt();
392 if (std::abs(1 - ghostPtFraction) < std::abs(1 - ghostFracNominal)) {
393 matchTruthJet = truthJet;
394 ghostFracNominal = ghostPtFraction;
401 sumPtMatchedHSJets += truthJet->pt();
404 matchTruthJet = truthJet;
410 for (
const xAOD::Jet* ootJet : *outOfTimeTruthJets) {
411 float dR =
jet->p4().DeltaR(ootJet->p4(),
true);
413 float ghostTruthPt = accGhostTruthPt(*
jet);
414 float ghostPtFraction = (ghostTruthPt / (ootJet->pt()));
416 nMatchedOOTJets += 1;
417 sumPtMatchedOOTJets += ootJet->pt();
418 if (std::abs(1 - ghostPtFraction) < std::abs(1 - ghostFracNominal)) {
419 oot_matchTruthJet = ootJet;
425 nMatchedOOTJets += 1;
426 sumPtMatchedOOTJets += ootJet->pt();
427 if (dR < oot_dRmin) {
429 oot_matchTruthJet = ootJet;
434 for (
const xAOD::Jet* itJet : *inTimeTruthJets) {
435 float dR =
jet->p4().DeltaR(itJet->p4(),
true);
437 float ghostTruthPt = accGhostTruthPt(*
jet);
438 float ghostPtFraction = (ghostTruthPt / (itJet->pt()));
441 sumPtMatchedITJets += itJet->pt();
442 if (std::abs(1 - ghostPtFraction) < std::abs(1 - ghostFracNominal)) {
443 it_matchTruthJet = itJet;
450 sumPtMatchedITJets += itJet->pt();
453 it_matchTruthJet = itJet;
472 int nMatchedPUJets = nMatchedOOTJets + nMatchedITJets;
474 float totalMatchedpT = sumPtMatchedHSJets + sumPtMatchedOOTJets + sumPtMatchedITJets;
477 bestHSpT = matchTruthJet->
pt();
478 bestHSpTRatio = bestHSpT / totalMatchedpT;
480 if (oot_matchTruthJet) {
481 bestOOTpT = oot_matchTruthJet->
pt();
482 bestOOTpTRatio = bestOOTpT / totalMatchedpT;
484 if (it_matchTruthJet) {
485 bestITpT = it_matchTruthJet->
pt();
486 bestITpTRatio = bestITpT / totalMatchedpT;
489 if (bestHSpTRatio >= 0.9) {
492 else if (bestITpTRatio >= 0.9) {
495 else if (bestOOTpTRatio >= 0.9) {
498 else if (nMatchedPUJets == 0 && nMatchedHSJets > 1) {
501 else if (nMatchedPUJets > 0 && nMatchedHSJets > 0) {
504 else if (nMatchedPUJets > 1) {
517 float truthJetSplit12 = -9999;
518 float truthJetSplit23 = -9999;
522 float truthJetMass = -9999;
523 float truthJetPt = -9999;
524 float truthJetRapidity = -9;
525 float truthJetPhi = -9999;
533 matchTruthJet = it_matchTruthJet;
534 truthJetCont = inTimeTruthJets.
cptr();
538 matchTruthJet = oot_matchTruthJet;
539 truthJetCont = outOfTimeTruthJets.
cptr();
543 if (bestITpTRatio >= bestOOTpTRatio) {
544 matchTruthJet = it_matchTruthJet;
545 truthJetCont = inTimeTruthJets.
cptr();
548 matchTruthJet = oot_matchTruthJet;
549 truthJetCont = outOfTimeTruthJets.
cptr();
556 if ( matchTruthJet ) {
563 label = labelAcc(*matchTruthJet);
566 if (split23Handle.
isAvailable()) truthJetSplit23 = split23Handle(*matchTruthJet);
568 if (split12Handle.
isAvailable()) truthJetSplit12 = split12Handle(*matchTruthJet);
570 if (nbAcc.isAvailable(*matchTruthJet)) truthJetNB = nbAcc(*matchTruthJet);
572 ATH_MSG_VERBOSE(
"For reco jet " <<
jet->index() <<
", matched truth jet index " << matchTruthJet->index());
574 truthJetMass = matchTruthJet->
m();
575 truthJetPt = matchTruthJet->
pt();
576 truthJetRapidity = matchTruthJet->
rapidity();
577 truthJetPhi = matchTruthJet->
phi();
582 float truthGroomedJetMass = -9999;
583 float truthGroomedJetPt = -9999;
585 if ( matchTruthJet ) {
586 for (
const xAOD::Jet* truthGroomedJet : *truthGroomedJets ) {
588 if ( !element_link.
isValid() ) {
continue; }
589 if ( matchTruthJet == *element_link ) {
590 matchTruthGroomedJet = truthGroomedJet;
596 if ( !matchTruthGroomedJet && parent !=
nullptr) {
597 for (
const xAOD::Jet* truthGroomedJet : *truthGroomedJets ) {
598 float dR = parent->p4().DeltaR(truthGroomedJet->p4(),
true);
601 if ( dR < dRminGroomed ) {
603 matchTruthGroomedJet = truthGroomedJet;
608 if ( matchTruthGroomedJet ) {
609 truthGroomedJetMass = matchTruthGroomedJet->
m();
610 truthGroomedJetPt = matchTruthGroomedJet->
pt();
646 return StatusCode::SUCCESS;
650 const EventContext& ctx)
const {
657 ATH_MSG_ERROR(
"No truth jet container retrieved. Please make sure you are using a supported TruthLabelName.");
658 return StatusCode::FAILURE;
667 const EventContext& ctx)
const
670 if ( !(truthJets.
size()) )
return StatusCode::SUCCESS;
676 return StatusCode::SUCCESS;
683 return StatusCode::FAILURE;
690 ATH_MSG_DEBUG(
"Getting truth label using ghost-association");
696 return StatusCode::SUCCESS;
704 float split12 = -999.0;
707 const float c0 = 55.25;
708 const float c1 = -2.34e-3;
710 split12 = c0 * std::exp( c1 * pt );
722 float split23 = -999.0;
728 const float c0 = 3.3;
729 const float c1 = -6.98e-4;
731 split23 = std::exp( c0 + c1 * pt );
742 if( !
jet.getAttribute<
int>( collection+
"Count", nMatchPart ) ){
744 std::vector<const xAOD::TruthParticle*> ghostParts;
746 ATH_MSG_ERROR( collection +
" cannot be retrieved! Truth label definition might be wrong" );
748 nMatchPart = ghostParts.size();
760 const EventContext& ctx)
const {
769 bool is_tautauEl =
false;
770 bool is_tautauMu =
false;
771 bool is_tautauHad =
false;
780 is_bb = ( nMatchB > 1 );
789 int extended_GA_label = -1;
790 if (not
jet.getAttribute(
"HadronGhostExtendedTruthLabelID", extended_GA_label)) {
796 is_bb = ( extended_GA_label == 55 );
797 is_cc = ( extended_GA_label == 44 );
798 is_tautauEl = ( extended_GA_label == 151511 );
799 is_tautauMu = ( extended_GA_label == 151513 );
800 is_tautauHad = ( extended_GA_label == 1515 );
819 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_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
#define ATH_MSG_INFO(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?
const_pointer_type cptr()
Dereference the pointer.
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".