diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTop/DerivationFrameworkTop/ExKtbbAugmentation.h b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTop/DerivationFrameworkTop/ExKtbbAugmentation.h index 309a052f451f1421d60c542fc0e74860413798a3..247c81f090890edfc4c57fb7db94987325edf8e4 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTop/DerivationFrameworkTop/ExKtbbAugmentation.h +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTop/DerivationFrameworkTop/ExKtbbAugmentation.h @@ -31,8 +31,9 @@ namespace DerivationFramework { StatusCode initialize(); StatusCode finalize(); virtual StatusCode addBranches() const; - - private: + int getDeXTerLabel(const int ghostBFinalCount,const int ghostCFinalCount) const; + + private: std::string m_eventInfoName; std::string m_secvtxName; std::string m_largeJetCollectionName; @@ -73,6 +74,9 @@ namespace DerivationFramework { const SG::AuxElement::Decorator<float> jet_dexter_pb_negtrksflip_svmassflip; const SG::AuxElement::Decorator<float> jet_dexter_pl_negtrksflip_svmassflip; const SG::AuxElement::Decorator<int> smalljet_largeJetLabel; + const SG::AuxElement::Decorator<int> jet_dexter_ghostBhadronCount; + const SG::AuxElement::Decorator<int> jet_dexter_ghostChadronCount; + const SG::AuxElement::Decorator<int> jet_dexter_TruthLabel; }; /// class diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTop/python/TOPQCommonExtraContent.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTop/python/TOPQCommonExtraContent.py index fa3ee0f2e87f6d6711be8aec52f04db9dccec10b..aad23b6a7c4213a979a5c40e9fd231dd2d5641f1 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTop/python/TOPQCommonExtraContent.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTop/python/TOPQCommonExtraContent.py @@ -198,6 +198,9 @@ TOPQExtraVariables_AntiKt8EMPFlowJets_ForTOPQ1 = ["AntiKt8EMPFlowJets + "ExKtbb_dexter_pbb_negtrksflip_svmassflip." + "ExKtbb_dexter_pb_negtrksflip_svmassflip." + "ExKtbb_dexter_pl_negtrksflip_svmassflip." + + "dexter_GhostBHadronsCount." + + "dexter_GhostCHadronsCount." + + "dexter_TruthLabel." ] TOPQExtraVariables_AntiKt8EMPFlowExKt2GASubJets_ForTOPQ1 = ["AntiKt8EMPFlowExKt2GASubJets." + "AlgorithmType." diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTop/src/ExKtbbAugmentation.cxx b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTop/src/ExKtbbAugmentation.cxx index bd8de14a1fe0e814f0073f22bfec28ad76be1eb8..844c8bb89aad3221ce97a905ccbbc7631f95e395 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTop/src/ExKtbbAugmentation.cxx +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTop/src/ExKtbbAugmentation.cxx @@ -9,6 +9,7 @@ #include "xAODTracking/VertexContainer.h" #include "xAODTracking/VertexAuxContainer.h" #include "FlavorTagDiscriminants/BTagTrackAugmenter.h" +#include "ParticleJetTools/ParticleJetLabelCommon.h" namespace DerivationFramework { @@ -44,7 +45,10 @@ ExKtbbAugmentation::ExKtbbAugmentation(const std::string& t, const std::string& jet_dexter_pbb_negtrksflip_svmassflip("ExKtbb_dexter_pbb_negtrksflip_svmassflip"), jet_dexter_pb_negtrksflip_svmassflip("ExKtbb_dexter_pb_negtrksflip_svmassflip"), jet_dexter_pl_negtrksflip_svmassflip("ExKtbb_dexter_pl_negtrksflip_svmassflip"), - smalljet_largeJetLabel("LargeJetLabel") + smalljet_largeJetLabel("LargeJetLabel"), + jet_dexter_ghostBhadronCount("dexter_GhostBHadronsCount"), + jet_dexter_ghostChadronCount("dexter_GhostCHadronsCount"), + jet_dexter_TruthLabel("dexter_TruthLabel") { declareInterface<DerivationFramework::IAugmentationTool>(this); @@ -83,6 +87,33 @@ StatusCode ExKtbbAugmentation::finalize(){ } +int ExKtbbAugmentation::getDeXTerLabel(const int ghostBFinalCount,const int ghostCFinalCount) const +{ + + int jet_flavor = 0; + // jet flavor label + // 55 - bb: nb >= 2 bb bbb bbc bbl... + // 54 - bc: nb = 1 && nc >= 1 bc bcc bcl + // 5 - b : nb = 1 && nc = 0 b bl bll + // 44 - cc: nb = 0 && nc >= 2 cc ccc ccl... + // 4 - c : nb = 0 && nc = 1 c cl cll + // 0 - l : nb = 0 && nc = 0 light + if (ghostBFinalCount >= 2) + jet_flavor = 55; + else if (ghostBFinalCount == 1 && ghostCFinalCount >= 1) + jet_flavor = 54; + else if (ghostBFinalCount == 1 && ghostCFinalCount == 0) + jet_flavor = 5; + else if (ghostBFinalCount == 0 && ghostCFinalCount >= 2) + jet_flavor = 44; + else if (ghostBFinalCount == 0 && ghostCFinalCount == 1) + jet_flavor = 4; + else if (ghostBFinalCount == 0 && ghostCFinalCount == 0) + jet_flavor = 0; + + return jet_flavor; +} + StatusCode ExKtbbAugmentation::addBranches() const{ @@ -129,6 +160,9 @@ StatusCode ExKtbbAugmentation::addBranches() const{ for (const auto jet : *jets) { + std::vector<const xAOD::TruthParticle *> jetlabelpartsb; + std::vector<const xAOD::TruthParticle *> jetlabelpartsc; + auto constVector = jet->constituentLinks(); for (auto constituent : constVector) smalljet_largeJetLabel(*smalljets->at(constituent.index())) = jet->index(); @@ -149,6 +183,23 @@ StatusCode ExKtbbAugmentation::addBranches() const{ ATH_MSG_ERROR("Empty pointer to track subjet! You will crash soon..."); return StatusCode::FAILURE; } else { + // Add Truth hadron labeling to jets + const auto& b_links = subjet->auxdata<std::vector<ElementLink<xAOD::IParticleContainer> > >("GhostBHadronsFinal"); + const auto& c_links = subjet->auxdata<std::vector<ElementLink<xAOD::IParticleContainer> > >("GhostCHadronsFinal"); + for (const auto &b_el : b_links) + { + const auto *bhadron = dynamic_cast<const xAOD::TruthParticle *>(*b_el); + if (bhadron->p4().DeltaR(subjet->p4()) < 0.3) + jetlabelpartsb.push_back(bhadron); + } + for (const auto &c_el : c_links) + { + const auto *chadron = dynamic_cast<const xAOD::TruthParticle *>(*c_el); + if (chadron->p4().DeltaR(subjet->p4()) < 0.3) + jetlabelpartsc.push_back(chadron); + } + + // For track sd0 auto constVector = subjet->getConstituents(); std::vector<double> sd0; for (const auto constituent : constVector) { @@ -187,6 +238,18 @@ StatusCode ExKtbbAugmentation::addBranches() const{ } } + using ParticleJetTools::childrenRemoved; + childrenRemoved(jetlabelpartsb, jetlabelpartsb); + childrenRemoved(jetlabelpartsb, jetlabelpartsc); + childrenRemoved(jetlabelpartsc, jetlabelpartsc); + int ghostBTotalCount = jetlabelpartsb.size(); + int ghostCTotalCount = jetlabelpartsc.size(); + + jet_dexter_ghostBhadronCount(*jet) = ghostBTotalCount; + jet_dexter_ghostChadronCount(*jet) = ghostCTotalCount; + + jet_dexter_TruthLabel(*jet) = getDeXTerLabel(ghostBTotalCount, ghostCTotalCount); + ATH_MSG_VERBOSE("Adding DexTer scores to AntiKt8 jets"); m_dexter->setProperty("negativeTagMode", "");