![Logo](../../ATLAS-Logo-Square-Blue-RGB.png) |
ATLAS Offline Software
|
Go to the documentation of this file.
74 bool isSupportedLabel =
false;
75 isSupportedLabel = isSupportedLabel || (
m_truthLabelName==
"R10TruthLabel_R21Consolidated");
76 isSupportedLabel = isSupportedLabel || (
m_truthLabelName==
"R10TruthLabel_R21Precision");
77 isSupportedLabel = isSupportedLabel || (
m_truthLabelName==
"R10TruthLabel_R21Precision_2022v1");
78 isSupportedLabel = isSupportedLabel || (
m_truthLabelName==
"R10TruthLabel_R22v1");
80 if(!isSupportedLabel) {
82 return StatusCode::FAILURE;
140 return StatusCode::SUCCESS;
182 auto maybeInit = [&] (
auto&
h,
185 if (!
k.key().empty())
h.emplace (
k, ctx);
209 const std::vector<std::pair<TLorentzVector,int> >& tlv_truthParts,
210 const EventContext& ctx)
const {
216 bool matchTop =
false;
224 for (
auto tlv_truth : tlv_truthParts) {
225 float dR = tlv_truth.first.DeltaR(
jet.p4());
228 if ( std::abs(tlv_truth.second) == 23 && !matchZ ) {
233 if ( std::abs(tlv_truth.second) == 24 && !matchW ) {
238 if ( std::abs(tlv_truth.second) == 25 && !matchH ) {
243 if ( std::abs(tlv_truth.second) == 6 && !matchTop ) {
252 (*
dh.dRWHandle)(
jet) = dR_W;
253 (*
dh.dRZHandle)(
jet) = dR_Z;
254 (*
dh.dRHHandle)(
jet) = dR_H;
255 (*
dh.dRTopHandle)(
jet) = dR_Top;
257 return getLabel(
dh,
jet, matchH, matchW, matchZ, matchTop, ctx );
263 const EventContext& ctx )
const
269 bool matchTop =
false;
299 return getLabel(
dh,
jet, matchH, matchW, matchZ, matchTop, ctx );
304 const EventContext& ctx = Gaudi::Hive::currentContext();
318 return StatusCode::SUCCESS;
323 const EventContext& ctx)
const {
338 if ( element_link.
isValid() ) {
342 ATH_MSG_ERROR(
"Unable to get a link to the parent jet! Returning a NULL pointer.");
343 return StatusCode::FAILURE;
349 const xAOD::Jet* matchTruthJet =
nullptr;
350 float dRminGroomed = 9999;
351 const xAOD::Jet* matchTruthGroomedJet =
nullptr;
355 if(
jet->numConstituents() > 0){
356 for (
const xAOD::Jet* truthJet : *truthJets ) {
357 float dR =
jet->p4().DeltaR( truthJet->p4() );
359 if (
parent ) dR =
parent->p4().DeltaR( truthJet->p4() );
364 matchTruthJet = truthJet;
371 float dR_truthJet_W = 9999;
372 float dR_truthJet_Z = 9999;
373 float dR_truthJet_Top = 9999;
374 float dR_truthJet_H = 9999;
376 float truthJetSplit12 = -9999;
377 float truthJetSplit23 = -9999;
378 float truthJetMass = -9999;
379 float truthJetPt = -9999;
381 if ( matchTruthJet ) {
383 label = (*
dh.labelHandle)(*matchTruthJet);
385 if(
dh.dRWHandle->isAvailable()) dR_truthJet_W = (*
dh.dRWHandle)(*matchTruthJet);
386 if(
dh.dRZHandle->isAvailable()) dR_truthJet_Z = (*
dh.dRZHandle)(*matchTruthJet);
387 if(
dh.dRHHandle->isAvailable()) dR_truthJet_H = (*
dh.dRHHandle)(*matchTruthJet);
388 if(
dh.dRTopHandle->isAvailable()) dR_truthJet_Top = (*
dh.dRTopHandle)(*matchTruthJet);
392 if(split23Handle.
isAvailable()) truthJetSplit23 = split23Handle(*matchTruthJet);
396 if(split23Handle.
isAvailable()) truthJetSplit23 = split23Handle(*matchTruthJet);
398 if(split12Handle.
isAvailable()) truthJetSplit12 = split12Handle(*matchTruthJet);
400 if(nbAcc.
isAvailable(*matchTruthJet)) truthJetNB = nbAcc (*matchTruthJet);
401 truthJetMass = matchTruthJet->
m();
402 truthJetPt = matchTruthJet->
pt();
406 float truthGroomedJetMass = -9999;
407 float truthGroomedJetPt = -9999;
409 if ( matchTruthJet ) {
410 for (
const xAOD::Jet* truthGroomedJet : *truthGroomedJets ) {
412 if ( !element_link.
isValid() ) {
continue; }
413 if ( matchTruthJet == *element_link ) {
414 matchTruthGroomedJet = truthGroomedJet;
420 if ( !matchTruthGroomedJet ) {
421 for (
const xAOD::Jet* truthGroomedJet : *truthGroomedJets ) {
422 float dR =
jet->p4().DeltaR( truthGroomedJet->p4() );
425 if ( dR < dRminGroomed ) {
427 matchTruthGroomedJet = truthGroomedJet;
432 if ( matchTruthGroomedJet ) {
433 truthGroomedJetMass = matchTruthGroomedJet->
m();
434 truthGroomedJetPt = matchTruthGroomedJet->
pt();
443 (*
dh.dRWRecoHandle)(*
jet) = dR_truthJet_W;
444 (*
dh.dRZRecoHandle)(*
jet) = dR_truthJet_Z;
445 (*
dh.dRHRecoHandle)(*
jet) = dR_truthJet_H;
446 (*
dh.dRTopRecoHandle)(*
jet) = dR_truthJet_Top;
449 (*
dh.split23Handle)(*
jet) = truthJetSplit23;
453 (*
dh.split23Handle)(*
jet) = truthJetSplit23;
454 (*
dh.split12Handle)(*
jet) = truthJetSplit12;
457 (*
dh.nbRecoHandle)(*
jet) = truthJetNB;
458 (*
dh.truthMassHandle)(*
jet) = truthJetMass;
459 (*
dh.truthPtHandle)(*
jet) = truthJetPt;
462 (*
dh.truthGroomedMassHandle)(*
jet) = truthGroomedJetMass;
463 (*
dh.truthGroomedPtHandle)(*
jet) = truthGroomedJetPt;
467 return StatusCode::SUCCESS;
471 const EventContext& ctx)
const {
478 ATH_MSG_ERROR(
"No truth jet container retrieved. Please make sure you are using a supported TruthLabelName.");
479 return StatusCode::FAILURE;
488 const EventContext& ctx)
const
491 if ( !(truthJets.
size()) )
return StatusCode::SUCCESS;
494 if(
dh.labelHandle->isAvailable()){
496 return StatusCode::SUCCESS;
500 int channelNumber = -999;
506 return StatusCode::FAILURE;
510 std::vector<std::pair<TLorentzVector,int> > tlv_truthParts;
517 if ( channelNumber < 0 ) {
519 return StatusCode::FAILURE;
526 ATH_MSG_ERROR(
"Cannot apply truth labels to Sherpa 2.2.1 samples using TRUTH3 containers");
527 return StatusCode::FAILURE;
534 if(!truthPartsBoson.
isValid()){
536 return StatusCode::FAILURE;
542 return StatusCode::FAILURE;
545 getTLVs(tlv_truthParts, truthPartsBoson.
cptr(), truthPartsTop.
cptr(), isSherpa);
553 return StatusCode::FAILURE;
556 getTLVs(tlv_truthParts, truthParts.
cptr(), truthParts.
cptr(), isSherpa);
570 ATH_MSG_DEBUG(
"Getting truth label using ghost-association");
577 return StatusCode::SUCCESS;
586 int countStatus3 = 0;
589 TLorentzVector p1(0,0,0,0);
590 TLorentzVector p2(0,0,0,0);
593 TLorentzVector WZCand(0,0,0,0);
596 bool isWPCand =
false;
597 bool isWMCand =
false;
598 bool isZCand =
false;
601 bool inMassWindow =
false;
603 for (
unsigned int ipart = 0; ipart < truthBosons->
size(); ipart++ ){
611 if ( std::abs(
part1->pdgId()) > 5 )
continue;
615 if ( countStatus3 > 3 )
continue;
620 for (
unsigned int jpart = ipart+1; jpart < truthBosons->
size(); jpart++ ) {
628 if ( std::abs(
part2->pdgId()) > 5 )
continue;
637 else if (
part1->pdgId() == 2 ||
part1->pdgId() == 4 ||
part2->pdgId() == 2 ||
part2->pdgId() == 4 ) {
653 if ( 60000 < WZCand.M() && WZCand.M() < 140000. ) {
660 if ( inMassWindow && (isWPCand || isWMCand || isZCand) ) {
661 std::pair<TLorentzVector,int>
WZ;
663 WZ = std::make_pair(WZCand,23);
666 WZ = std::make_pair(WZCand,24);
669 WZ = std::make_pair(WZCand,-24);
680 tlvs.push_back(std::make_pair(
part->p4(),
part->pdgId()));
687 tlvs.push_back(std::make_pair(
part->p4(),
part->pdgId()));
693 if ( std::abs(
tp->pdgId()) !=
pdgId )
return false;
694 for (
unsigned int iChild = 0; iChild <
tp->nChildren(); iChild++ ) {
696 if ( !child )
continue;
697 if ( child->
pdgId() ==
tp->pdgId() )
return false;
707 float split12 = -999.0;
710 const float c0 = 55.25;
711 const float c1 = -2.34e-3;
725 float split23 = -999.0;
731 const float c0 = 3.3;
732 const float c1 = -6.98e-4;
745 if( !
jet.getAttribute<
int>( collection+
"Count", nMatchPart ) ){
747 std::vector<const xAOD::TruthParticle*> ghostParts;
749 ATH_MSG_ERROR( collection +
" cannot be retrieved! Truth label definition might be wrong" );
751 nMatchPart = ghostParts.size();
763 const EventContext& ctx)
const {
767 (*
dh.nbHandle)(
jet) = nMatchB;
772 bool is_tautauEl =
false;
773 bool is_tautauMu =
false;
774 bool is_tautauHad =
false;
781 is_bb = ( nMatchB > 1 );
790 is_bb = ( nMatchB > 1 );
800 is_bb = ( nMatchB > 1 );
809 int extended_GA_label = -1;
810 if (not
jet.getAttribute(
"HadronGhostExtendedTruthLabelID", extended_GA_label)) {
816 is_bb = ( extended_GA_label == 55 );
817 is_cc = ( extended_GA_label == 44 );
818 is_tautauEl = ( extended_GA_label == 151511 );
819 is_tautauMu = ( extended_GA_label == 151513 );
820 is_tautauHad = ( extended_GA_label == 1515 );
839 if( !(matchTop || matchW || matchZ || matchH) ) {
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
const_pointer_type cptr()
Dereference the pointer.
Helper class to provide type-safe access to aux data.
Helper class to provide constant type-safe access to aux data.
const std::string & key() const
Return the StoreGate ID for the referenced object.
bool isValid() const
Test to see if the link can be dereferenced.
uint32_t mcChannelNumber() const
The MC generator's channel number.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
bool isPhysical(const T &p)
Handle class for reading a decoration on an object.
::StatusCode StatusCode
StatusCode definition for legacy code.
Class describing a truth particle in the MC record.
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
ElementLink implementation for ROOT usage.
std::string to_string(const DetectorType &type)
virtual double m() const
The invariant mass of the particle.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
int enumToInt(const TypeEnum type)
const T * at(size_type n) const
Access an element, as an rvalue.
Helper class to provide constant type-safe access to aux data.
int pdgId() const
PDG ID code.
virtual double pt() const
The transverse momentum ( ) of the particle.
bool isAvailable()
Test to see if this variable exists in the store, for the referenced object.
size_type size() const noexcept
Returns the number of elements in the collection.