|
ATLAS Offline Software
|
Go to the documentation of this file.
87 bool isSupportedLabel =
false;
88 isSupportedLabel = isSupportedLabel || (
m_truthLabelName==
"R10TruthLabel_R21Consolidated");
89 isSupportedLabel = isSupportedLabel || (
m_truthLabelName==
"R10TruthLabel_R21Precision");
90 isSupportedLabel = isSupportedLabel || (
m_truthLabelName==
"R10TruthLabel_R21Precision_2022v1");
91 isSupportedLabel = isSupportedLabel || (
m_truthLabelName==
"R10TruthLabel_R22v1");
92 isSupportedLabel = isSupportedLabel || (
m_truthLabelName==
"R10WZTruthLabel_R22v1");
94 if(!isSupportedLabel) {
96 return StatusCode::FAILURE;
154 return StatusCode::SUCCESS;
196 auto maybeInit = [&] (
auto&
h,
199 if (!
k.key().empty())
h.emplace (
k, ctx);
223 const std::vector<std::pair<TLorentzVector,int> >& tlv_truthParts,
224 const EventContext& ctx)
const {
230 bool matchTop =
false;
238 for (
auto tlv_truth : tlv_truthParts) {
239 float dR = tlv_truth.first.DeltaR(
jet.p4());
242 if ( std::abs(tlv_truth.second) == 23 && !matchZ ) {
247 if ( std::abs(tlv_truth.second) == 24 && !matchW ) {
252 if ( std::abs(tlv_truth.second) == 25 && !matchH ) {
257 if ( std::abs(tlv_truth.second) == 6 && !matchTop ) {
266 (*
dh.dRWHandle)(
jet) = dR_W;
267 (*
dh.dRZHandle)(
jet) = dR_Z;
268 (*
dh.dRHHandle)(
jet) = dR_H;
269 (*
dh.dRTopHandle)(
jet) = dR_Top;
271 return getLabel(
dh,
jet, matchH, matchW, matchZ, matchTop, ctx );
277 const EventContext& ctx )
const
283 bool matchTop =
false;
313 return getLabel(
dh,
jet, matchH, matchW, matchZ, matchTop, ctx );
318 const EventContext& ctx = Gaudi::Hive::currentContext();
332 return StatusCode::SUCCESS;
337 const EventContext& ctx)
const {
352 if ( element_link.
isValid() ) {
356 ATH_MSG_ERROR(
"Unable to get a link to the parent jet! Returning a NULL pointer.");
357 return StatusCode::FAILURE;
363 const xAOD::Jet* matchTruthJet =
nullptr;
364 float dRminGroomed = 9999;
365 const xAOD::Jet* matchTruthGroomedJet =
nullptr;
369 if(
jet->numConstituents() > 0){
370 for (
const xAOD::Jet* truthJet : *truthJets ) {
371 float dR =
jet->p4().DeltaR( truthJet->p4() );
373 if (
parent ) dR =
parent->p4().DeltaR( truthJet->p4() );
378 matchTruthJet = truthJet;
385 float dR_truthJet_W = 9999;
386 float dR_truthJet_Z = 9999;
387 float dR_truthJet_Top = 9999;
388 float dR_truthJet_H = 9999;
390 float truthJetSplit12 = -9999;
391 float truthJetSplit23 = -9999;
392 float truthJetMass = -9999;
393 float truthJetPt = -9999;
395 if ( matchTruthJet ) {
399 label = labelAcc(*matchTruthJet);
401 if(
dh.dRWHandle->isAvailable()) dR_truthJet_W = (*
dh.dRWHandle)(*matchTruthJet);
402 if(
dh.dRZHandle->isAvailable()) dR_truthJet_Z = (*
dh.dRZHandle)(*matchTruthJet);
403 if(
dh.dRHHandle->isAvailable()) dR_truthJet_H = (*
dh.dRHHandle)(*matchTruthJet);
404 if(
dh.dRTopHandle->isAvailable()) dR_truthJet_Top = (*
dh.dRTopHandle)(*matchTruthJet);
408 if(split23Handle.
isAvailable()) truthJetSplit23 = split23Handle(*matchTruthJet);
412 if(split23Handle.
isAvailable()) truthJetSplit23 = split23Handle(*matchTruthJet);
414 if(split12Handle.
isAvailable()) truthJetSplit12 = split12Handle(*matchTruthJet);
416 if(nbAcc.
isAvailable(*matchTruthJet)) truthJetNB = nbAcc (*matchTruthJet);
417 truthJetMass = matchTruthJet->
m();
418 truthJetPt = matchTruthJet->
pt();
422 float truthGroomedJetMass = -9999;
423 float truthGroomedJetPt = -9999;
425 if ( matchTruthJet ) {
426 for (
const xAOD::Jet* truthGroomedJet : *truthGroomedJets ) {
428 if ( !element_link.
isValid() ) {
continue; }
429 if ( matchTruthJet == *element_link ) {
430 matchTruthGroomedJet = truthGroomedJet;
436 if ( !matchTruthGroomedJet ) {
437 for (
const xAOD::Jet* truthGroomedJet : *truthGroomedJets ) {
438 float dR =
jet->p4().DeltaR( truthGroomedJet->p4() );
441 if ( dR < dRminGroomed ) {
443 matchTruthGroomedJet = truthGroomedJet;
448 if ( matchTruthGroomedJet ) {
449 truthGroomedJetMass = matchTruthGroomedJet->
m();
450 truthGroomedJetPt = matchTruthGroomedJet->
pt();
459 (*
dh.dRWRecoHandle)(*
jet) = dR_truthJet_W;
460 (*
dh.dRZRecoHandle)(*
jet) = dR_truthJet_Z;
461 (*
dh.dRHRecoHandle)(*
jet) = dR_truthJet_H;
462 (*
dh.dRTopRecoHandle)(*
jet) = dR_truthJet_Top;
465 (*
dh.split23Handle)(*
jet) = truthJetSplit23;
469 (*
dh.split23Handle)(*
jet) = truthJetSplit23;
470 (*
dh.split12Handle)(*
jet) = truthJetSplit12;
473 (*
dh.nbRecoHandle)(*
jet) = truthJetNB;
474 (*
dh.truthMassHandle)(*
jet) = truthJetMass;
475 (*
dh.truthPtHandle)(*
jet) = truthJetPt;
478 (*
dh.truthGroomedMassHandle)(*
jet) = truthGroomedJetMass;
479 (*
dh.truthGroomedPtHandle)(*
jet) = truthGroomedJetPt;
483 return StatusCode::SUCCESS;
487 const EventContext& ctx)
const {
494 ATH_MSG_ERROR(
"No truth jet container retrieved. Please make sure you are using a supported TruthLabelName.");
495 return StatusCode::FAILURE;
504 const EventContext& ctx)
const
507 if ( !(truthJets.
size()) )
return StatusCode::SUCCESS;
510 if(
dh.labelHandle->isAvailable()){
513 return StatusCode::SUCCESS;
517 int channelNumber = -999;
523 return StatusCode::FAILURE;
527 std::vector<std::pair<TLorentzVector,int> > tlv_truthParts;
534 if ( channelNumber < 0 ) {
536 return StatusCode::FAILURE;
543 ATH_MSG_ERROR(
"Cannot apply truth labels to Sherpa 2.2.1 samples using TRUTH3 containers");
544 return StatusCode::FAILURE;
551 if(!truthPartsBoson.
isValid()){
553 return StatusCode::FAILURE;
559 return StatusCode::FAILURE;
562 getTLVs(tlv_truthParts, truthPartsBoson.
cptr(), truthPartsTop.
cptr(), isSherpa);
570 return StatusCode::FAILURE;
573 getTLVs(tlv_truthParts, truthParts.
cptr(), truthParts.
cptr(), isSherpa);
587 ATH_MSG_DEBUG(
"Getting truth label using ghost-association");
594 return StatusCode::SUCCESS;
603 int countStatus3 = 0;
606 TLorentzVector
p1(0,0,0,0);
607 TLorentzVector
p2(0,0,0,0);
610 TLorentzVector WZCand(0,0,0,0);
613 bool isWPCand =
false;
614 bool isWMCand =
false;
615 bool isZCand =
false;
618 bool inMassWindow =
false;
620 for (
unsigned int ipart = 0; ipart < truthBosons->
size(); ipart++ ){
628 if ( std::abs(
part1->pdgId()) > 5 )
continue;
632 if ( countStatus3 > 3 )
continue;
637 for (
unsigned int jpart = ipart+1; jpart < truthBosons->
size(); jpart++ ) {
645 if ( std::abs(
part2->pdgId()) > 5 )
continue;
654 else if (
part1->pdgId() == 2 ||
part1->pdgId() == 4 ||
part2->pdgId() == 2 ||
part2->pdgId() == 4 ) {
670 if ( 60000 < WZCand.M() && WZCand.M() < 140000. ) {
677 if ( inMassWindow && (isWPCand || isWMCand || isZCand) ) {
678 std::pair<TLorentzVector,int>
WZ;
680 WZ = std::make_pair(WZCand,23);
683 WZ = std::make_pair(WZCand,24);
686 WZ = std::make_pair(WZCand,-24);
697 tlvs.push_back(std::make_pair(
part->p4(),
part->pdgId()));
704 tlvs.push_back(std::make_pair(
part->p4(),
part->pdgId()));
710 if ( std::abs(
tp->pdgId()) != pdgId )
return false;
711 for (
unsigned int iChild = 0; iChild <
tp->nChildren(); iChild++ ) {
713 if ( !child )
continue;
714 if ( child->
pdgId() ==
tp->pdgId() )
return false;
724 float split12 = -999.0;
727 const float c0 = 55.25;
728 const float c1 = -2.34e-3;
742 float split23 = -999.0;
749 const float c0 = 3.3;
750 const float c1 = -6.98e-4;
763 if( !
jet.getAttribute<
int>( collection+
"Count", nMatchPart ) ){
765 std::vector<const xAOD::TruthParticle*> ghostParts;
767 ATH_MSG_ERROR( collection +
" cannot be retrieved! Truth label definition might be wrong" );
769 nMatchPart = ghostParts.size();
781 const EventContext& ctx)
const {
785 (*
dh.nbHandle)(
jet) = nMatchB;
790 bool is_tautauEl =
false;
791 bool is_tautauMu =
false;
792 bool is_tautauHad =
false;
799 is_bb = ( nMatchB > 1 );
808 is_bb = ( nMatchB > 1 );
818 is_bb = ( nMatchB > 1 );
827 int extended_GA_label = -1;
828 if (not
jet.getAttribute(
"HadronGhostExtendedTruthLabelID", extended_GA_label)) {
834 is_bb = ( extended_GA_label == 55 );
835 is_cc = ( extended_GA_label == 44 );
836 is_tautauEl = ( extended_GA_label == 151511 );
837 is_tautauMu = ( extended_GA_label == 151513 );
838 is_tautauHad = ( extended_GA_label == 1515 );
857 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)
Identify if the particle is physical, i.e. is stable or decayed.
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.