diff --git a/FTagDumper/python/blocks/TruthTauMatcher.py b/FTagDumper/python/blocks/TruthTauMatcher.py index a395a09de094f22c1224ba424c52adc74148c5bd..e74cca76a7b7d5fc52c0c2edb057886d6ecb9050 100644 --- a/FTagDumper/python/blocks/TruthTauMatcher.py +++ b/FTagDumper/python/blocks/TruthTauMatcher.py @@ -55,9 +55,7 @@ class TruthTauMatcher(BaseBlock): particle_link_name: str = None def __post_init__(self): - if self.truth_tau_collection is None or isinstance( - self.truth_tau_collection, str - ): + if self.truth_tau_collection is None or isinstance(self.truth_tau_collection, str): self.truth_tau_collection = ["TruthTaus"] self.truth_tau_collection_name = self.truth_tau_collection[0] if self.reco_jet_collection is None: @@ -83,6 +81,7 @@ class TruthTauMatcher(BaseBlock): dpt_str = f"deltaPtTo{self.truth_tau_collection_name}" to_suffix = f"From{self.truth_tau_collection_name}" match_str = f"matchedTo{self.truth_tau_collection_name}" + isHadTau_str = f"isHadronicTauFrom{self.truth_tau_collection_name}" def to(f): return f + to_suffix @@ -101,6 +100,7 @@ class TruthTauMatcher(BaseBlock): dR=dr_str, dPt=dpt_str, match=match_str, + isHadTau=isHadTau_str, particleLink=self.particle_link_name, maxDeltaR=self.max_delta_R, minTruthTauPt=self.min_truth_tau_pT, diff --git a/FTagDumper/src/TruthTauMatcherAlg.cxx b/FTagDumper/src/TruthTauMatcherAlg.cxx index 2473f76a6537f10ec81f49fabf2f8168cc7e5588..52000934abdc492982244a39ecc2e845822a7b51 100644 --- a/FTagDumper/src/TruthTauMatcherAlg.cxx +++ b/FTagDumper/src/TruthTauMatcherAlg.cxx @@ -21,12 +21,12 @@ TruthTauMatcherAlg::TruthTauMatcherAlg(const std::string& name, ISvcLocator* pSv // Load the Aux variables for the truth taus namespace { - static const SG::AuxElement::ConstAccessor<char> acc_IsHadronicTau("IsHadronicTau"); static const SG::AuxElement::ConstAccessor<double> acc_pt_vis("pt_vis"); static const SG::AuxElement::ConstAccessor<double> acc_eta_vis("eta_vis"); static const SG::AuxElement::ConstAccessor<double> acc_phi_vis("phi_vis"); static const SG::AuxElement::ConstAccessor<double> acc_m_vis("m_vis"); static const SG::AuxElement::ConstAccessor<unsigned int> acc_classifierParticleType("classifierParticleType"); + static const SG::AuxElement::ConstAccessor<unsigned int> acc_classifierParticleOutcome("classifierParticleOutCome"); } StatusCode TruthTauMatcherAlg::initialize() { @@ -47,12 +47,14 @@ StatusCode TruthTauMatcherAlg::initialize() { m_drDecorator = recoJetsCollection + "." + m_dRKey; m_dPtDecorator = recoJetsCollection + "." + m_dPtKey; m_matchDecorator = recoJetsCollection + "." + m_matchKey; + m_isHadTauDecorator = recoJetsCollection + "." + m_isHadTauKey; ATH_CHECK(m_recoJets.initialize()); ATH_CHECK(m_truthTaus.initialize()); ATH_CHECK(m_drDecorator.initialize()); ATH_CHECK(m_dPtDecorator.initialize()); ATH_CHECK(m_matchDecorator.initialize()); + ATH_CHECK(m_isHadTauDecorator.initialize()); if (!m_linkKey.empty()) { m_linkDecorator = recoJetsCollection + "." + m_linkKey; ATH_CHECK(m_linkDecorator.initialize()); @@ -106,6 +108,7 @@ StatusCode TruthTauMatcherAlg::execute(const EventContext& cxt) const { SG::WriteDecorHandle<JC,float> drDecorator(m_drDecorator, cxt); SG::WriteDecorHandle<JC,float> dPtDecorator(m_dPtDecorator, cxt); SG::WriteDecorHandle<JC,char> matchDecorator(m_matchDecorator, cxt); + SG::WriteDecorHandle<JC,int> isHadTauDecorator(m_isHadTauDecorator, cxt); std::optional<SG::WriteDecorHandle<JC,IPLV>> linkDecorator; if (!m_linkDecorator.empty()) linkDecorator.emplace(m_linkDecorator, cxt); auto recoJets = getJetVector(recoJetGet); @@ -125,6 +128,15 @@ StatusCode TruthTauMatcherAlg::execute(const EventContext& cxt) const { truthTauVis.SetPtEtaPhiM(acc_pt_vis(*truthTau), acc_eta_vis(*truthTau), acc_phi_vis(*truthTau), acc_m_vis(*truthTau)); drDecorator(*recoJet) = recoJet->p4().DeltaR(truthTauVis); dPtDecorator(*recoJet) = recoJet->pt() - acc_pt_vis(*truthTau); + if ( + acc_classifierParticleOutcome(*truthTau) == 9 || + acc_classifierParticleOutcome(*truthTau) == 10 || + acc_classifierParticleOutcome(*truthTau) == 11 + ) { + isHadTauDecorator(*recoJet) = 1; + } else { + isHadTauDecorator(*recoJet) = 0; + } matchDecorator(*recoJet) = 1; matches.push_back({truthTau, recoJet}); if (linkDecorator) linkDecorator.value()(*recoJet) = { @@ -133,6 +145,7 @@ StatusCode TruthTauMatcherAlg::execute(const EventContext& cxt) const { } else { drDecorator(*recoJet) = NAN; dPtDecorator(*recoJet) = NAN; + isHadTauDecorator(*recoJet) = -1; matchDecorator(*recoJet) = 0; matches.push_back({nullptr, recoJet}); if (linkDecorator) linkDecorator.value()(*recoJet) = {}; diff --git a/FTagDumper/src/TruthTauMatcherAlg.h b/FTagDumper/src/TruthTauMatcherAlg.h index 7fe291a442484f8f556da3a0c8dd853fa0a14c2d..a195d554594f8ca5bf759cfde35da28dc03e6f22 100644 --- a/FTagDumper/src/TruthTauMatcherAlg.h +++ b/FTagDumper/src/TruthTauMatcherAlg.h @@ -46,6 +46,9 @@ private: this, "particleLink", "", "decorator for matched IParticle"}; Gaudi::Property<std::string> m_matchKey { this, "match", "jetIsMatched", "1 if matched, 0 if not"}; + Gaudi::Property<std::string> m_isHadTauKey { + this, "isHadTau", "isHadronicTau", "Status variable if the tau is hadronic or not" + }; // Matching logic configuration Gaudi::Property<float> m_maxDeltaR { this, "maxDeltaR", 0.3, @@ -54,12 +57,14 @@ private: Gaudi::Property<float> m_minTruthTauPt { this, "minTruthTauPt", 0, "Set minimum pT value for truth taus" }; + // Write decorators to store results SG::WriteDecorHandleKey<JC> m_drDecorator; SG::WriteDecorHandleKey<JC> m_dPtDecorator; SG::WriteDecorHandleKey<JC> m_linkDecorator; SG::WriteDecorHandleKey<JC> m_matchDecorator; + SG::WriteDecorHandleKey<JC> m_isHadTauDecorator; // Jet selection function using JV = std::vector<const xAOD::IParticle*>; diff --git a/configs/GN3_dev.json b/configs/GN3_dev.json index 7b6152b040c8e5387399091dceb7ec5c4c90d676..2db00f11fa373f387c405b446f6f4cfd5aed5d76 100644 --- a/configs/GN3_dev.json +++ b/configs/GN3_dev.json @@ -31,9 +31,14 @@ "n_b_tracks_ghost", "n_bc_tracks_ghost", "n_c_tracks_ghost", - "n_hf_tracks_ghost" + "n_hf_tracks_ghost", + "isHadronicTauFromTruthTaus" + ], + "uints": [ + "jetFoldHash", + "jetFoldHash_noHits", + "classifierParticleOutComeFromTruthTaus" ], - "uints": ["jetFoldHash", "jetFoldHash_noHits", "classifierParticleOutComeFromTruthTaus"], "floats": [ "ptFromTruthJet", "ptFromTruthDressedWZJet",