Rivet analyses

Search for new phenomena in monojet + missing transverse momentum events at 13 TeV (139 fb$^{-1}$)

Experiment: ATLAS (LHC)

Inspire ID: 1847779

Status: VALIDATED

Authors: - Tomasz Procter tomasz.procter@cern.ch (with agentic assistance, mainly Opus

References: - Phys.Rev.D 103 (2021) 112006 - DOI:10.1103/PhysRevD.103.112006 - arXiv: 2102.10874 - Expt page: ATLAS-EXOT-2018-06

Beams: p+ p+

Beam energies: (6500.0, 6500.0)GeV

Run details: - BSM signal (or SM V+jets/top/diboson background) events with an energetic jet and large missing transverse momentum. The cutflow objects d99/d100 apply the truth-MET>150/350 GeV generator filter internally, so unfiltered or filtered samples both work; supply the (filtered) cross-section.

Search for new phenomena in events with an energetic jet and large missing transverse momentum, using 139 fb$^{-1}$ of 13 TeV pp collisions. Events have $E_\mathrm{T}^\mathrm{miss} > 200$ GeV, a leading jet with $p_\mathrm{T} > 150$ GeV and $|\eta| < 2.4$, at most four jets with $p_\mathrm{T} > 30$ GeV and $|\eta| < 2.8$, $\Delta\phi(\text{jet}, p_\mathrm{T}^\mathrm{miss}) > 0.4$ (0.6 for $200 < E_\mathrm{T}^\mathrm{miss} \le 250$ GeV), and no electrons, muons, hadronic taus or photons. The signal region is binned in exclusive $E_\mathrm{T}^\mathrm{miss}$ ranges (EM0–EM12). The five control regions (W$\to\mu\nu$, W$\to e\nu$, top, Z$\to\mu\mu$, Z$\to ee$) are binned in the boson recoil $p_\mathrm{T}$. Objects are smeared with ATLAS Run-2 parametrisations; MET is the negative vector sum of the smeared hard objects. All outputs are expected events at 139 fb$^{-1}$.

Source code:

ATLAS_2021_I1847779.cc

// -*- C++ -*-
#include "Rivet/Analysis.hh"
#include "Rivet/Projections/FinalState.hh"
#include "Rivet/Projections/PromptFinalState.hh"
#include "Rivet/Projections/VisibleFinalState.hh"
#include "Rivet/Projections/InvisibleFinalState.hh"
#include "Rivet/Projections/LeptonFinder.hh"
#include "Rivet/Projections/FastJets.hh"
#include "Rivet/Projections/SmearedJets.hh"
#include "Rivet/Projections/SmearedParticles.hh"
#include "Rivet/Tools/ExptSmearingFunctions.hh"
#include "Rivet/Tools/ParticleSmearingFunctions.hh"

namespace Rivet {


  /// @brief Monojet search, full Run 2 (139 fb^-1)
  ///
  /// SR and five lepton CRs binned in E_T^miss / p_T^recoil (HepData d02-d07), plus the two
  /// published signal cutflows (d99: truth MET > 150 GeV, d100: truth MET > 350 GeV).
  ///
  /// Veto-object modelling beyond Rivet's standard efficiencies: truth-isolation
  /// proxies for Tight photon ID and for Loose ID of non-prompt baseline electrons; baseline e/mu from any
  /// origin (heavy-flavour decays included); a d0-significance cut on CR signal leptons; and a truth-environment
  /// proxy for FCTight isolation of CR signal electrons.
  class ATLAS_2021_I1847779 : public Analysis {
  public:

    RIVET_DEFAULT_ANALYSIS_CTOR(ATLAS_2021_I1847779);


    /// @name Analysis methods
    /// @{

    void init() {

      const FinalState fs(Cuts::abseta < 4.9);

      // Truth MET for the generator-filter row of the cutflows, as ATLAS's MissingEtFilter: prompt invisibles
      // incl. those from tau and muon decays (neutrinos from hadron decays excluded)
      declare(InvisibleFinalState(OnlyPrompt::YES, TauDecaysAs::PROMPT, MuDecaysAs::PROMPT), "Invisibles");

      // Jets: calorimeter jets, so muons and invisibles are not clustered; Medium JVT
      // (Run-1-vintage Rivet function, acts only for 20-60 GeV, |eta| < 2.4)
      FastJets fj(fs, JetAlg::ANTIKT, 0.4, JetMuons::NONE, JetInvisibles::NONE);
      declare(fj, "TruthJets");
      declare(SmearedJets(fj, _bTagEff, JET_CTAG_PERFECT,
                          JET_SMEAR_ATLAS_RUN2, ATLAS_JVT_EFF_MEDIUM), "Jets");

      // Dressed prompt leptons, incl. those from tau decays. The (double, Cut) constructor on purpose:
      // a Cut as first argument binds to the FinalState overload, which takes no lepton origin.
      const Cut ecut = Cuts::abspid == PID::ELECTRON && Cuts::pT > 5*GeV && Cuts::abseta < 2.6;
      const Cut mucut = Cuts::abspid == PID::MUON && Cuts::pT > 5*GeV && Cuts::abseta < 2.7;
      const LeptonFinder truthelectrons(0.1, ecut);
      const LeptonFinder truthmuons(0.1, mucut);
      declare(truthelectrons, "TruthElectrons");
      declare(truthmuons, "TruthMuons");

      // Veto-lepton candidates from any origin: baseline leptons carry no isolation and the OR only uses
      // jets with pT > 30 GeV, so non-prompt e/mu (heavy-flavour decays) can veto an event
      const LeptonFinder vetoelectrons(0.1, ecut, LeptonOrigin::ANY);
      const LeptonFinder vetomuons(0.1, mucut, LeptonOrigin::ANY);

      // Baseline (veto) electrons: reco x LooseAndBLayer LH ID, no isolation.
      // (The combined ELECTRON_EFF_ATLAS_RUN2_* functions are 0 below 10 GeV.)
      declare(SmearedParticles(vetoelectrons,
                               PARTICLE_EFF_PRODUCT(ELECTRON_RECOEFF_ATLAS_RUN2, ELECTRON_IDEFF_ATLAS_RUN2_LOOSE),
                               ELECTRON_SMEAR_ATLAS_RUN2), "Electrons");

      // Baseline (veto) muons: Medium reco x ID, no isolation (the MUON_EFF_ATLAS_RUN2_* functions
      // fold in loose isolation)
      declare(SmearedParticles(vetomuons, MUON_RECOIDEFF_ATLAS_RUN2_MEDIUM,
                               MUON_SMEAR_ATLAS_RUN2), "Muons");

      // Bare final-state e/mu: truth production vertices for the d0 significance of CR signal leptons
      declare(FinalState((Cuts::abspid == PID::ELECTRON || Cuts::abspid == PID::MUON) && Cuts::pT > 5*GeV), "BareLeptons");

      // Veto photons: prompt, Tight ID efficiency, isolation proxy
      declare(PromptFinalState(Cuts::abspid == PID::PHOTON && Cuts::pT > 8*GeV && Cuts::abseta < 2.5), "Photons");
      declare(VisibleFinalState(Cuts::abseta < 4.9), "Visible");

      // Histograms: count accumulators, converted to absolute-count estimates in finalize()
      // (HepData tables are events per bin, not densities). y01 = observed data in all six.
      for (const auto& reg : _regions) {
        book(_h[reg.first], "_" + mkAxisCode(reg.second, 1, 1), refData(reg.second, 1, 1));
        book(_e[reg.first], reg.second, 1, 1);
      }

      // Signal cutflows d99 (truth MET > 150) and d100 (truth MET > 350): hidden count
      // accumulators on the reference binning, converted to the reference type in finalize().
      // No data/background column exists: y01 (DMA_1_2000 / ADD) is an arbitrary choice.
      book(_cf150, "_cutflow150", refData<YODA::BinnedEstimate<string>>(99, 1, 1));
      book(_cf350, "_cutflow350", refData<YODA::BinnedEstimate<string>>(100, 1, 1));
      book(_cf150out, 99, 1, 1);
      book(_cf350out, 100, 1, 1);
      // Row labels from the reference binning (a booked object has no active pointer until
      // the first event)
      _labels150 = refData<YODA::BinnedEstimate<string>>(99, 1, 1).xEdges();
      _labels350 = refData<YODA::BinnedEstimate<string>>(100, 1, 1).xEdges();
      _checkCutflowLabels(_labels150, 22, "200", "$E_\\mathrm{T}^\\mathrm{miss} > $1200 GeV");
      _checkCutflowLabels(_labels350, 18, "400", "$E_\\mathrm{T}^\\mathrm{miss} > $1200 GeV");
    }


    void analyze(const Event& event) {

      // Truth MET for the cutflow generator-filter rows
      Vector3 ptinv;
      for (const Particle& p : apply<InvisibleFinalState>(event, "Invisibles").particles()) {
        ptinv += p.pTvec();
      }
      const double truthMET = ptinv.perp();

      // Baseline objects after efficiency and smearing; thresholds applied post-smearing
      Particles elecs = select(apply<ParticleFinder>(event, "Electrons").particlesByPt(),
                               Cuts::pT > 7*GeV && Cuts::abseta < 2.47);
      Particles muons = select(apply<ParticleFinder>(event, "Muons").particlesByPt(),
                               Cuts::pT > 7*GeV && Cuts::abseta < 2.5);

      // Prompt truth leptons: lepton-dressing photon exclusion and the prompt match below
      const Particles truthleps = apply<LeptonFinder>(event, "TruthElectrons").particles() +
                                  apply<LeptonFinder>(event, "TruthMuons").particles();
      const Particles& visible = apply<FinalState>(event, "Visible").particles();
      auto isPrompt = [&](const Particle& l) {
        return any(truthleps, [&](const Particle& t) {
          return t.abspid() == l.abspid() && deltaR(t, l) < 0.1;
        });
      };

      // Loose ID of non-prompt baseline electrons: truth-isolation proxy
      idiscard(elecs, [&](const Particle& e) { return !isPrompt(e) && !_electronHadIsolated(e, visible); });

      // Jets for the MET (pT > 20, |eta| < 4.5). Overlap removal acts only on jets with
      // pT > 30, |eta| < 2.8 (paper Sec. 4); the softer/forward ones enter the MET only.
      Jets jets, otherjets;
      for (const Jet& j : apply<JetFinder>(event, "Jets").jetsByPt(Cuts::pT > 20*GeV && Cuts::abseta < 4.5)) {
        if (j.pT() > 30*GeV && j.abseta() < 2.8) jets += j;
        else otherjets += j;
      }

      // Photons, excluding lepton-dressing photons (within dR < 0.1 of a truth dressed lepton)
      Particles photons;
      for (const Particle& y : apply<PromptFinalState>(event, "Photons").particles()) {
        if (any(truthleps, deltaRLess(y, 0.1))) continue;
        if (rand01() > PHOTON_EFF_ATLAS_RUN2_TIGHT(y)) continue;
        const Particle ysm = PHOTON_SMEAR_ATLAS_RUN2(y);
        if (ysm.pT() < 10*GeV || ysm.abseta() > 2.37) continue;
        if (!_photonIsolated(y, visible)) continue;
        photons += ysm;
      }

      // ---- Overlap removal (paper Sec. 4 order) ----
      // e-mu sharing a track: keep the muon (DeltaR proxy)
      idiscardIfAnyDeltaRLess(elecs, muons, 0.01);
      // e-jet: non-b jets within 0.2 of an electron removed; electron near a b-jet removed;
      // then electrons within 0.4 of any remaining jet removed
      idiscard(jets, [&](const Jet& j) { return !j.bTagged() && any(elecs, deltaRLess(j, 0.2)); });
      idiscard(elecs, [&](const Particle& e) {
        return any(jets, [&](const Jet& j) { return j.bTagged() && deltaR(e, j) < 0.2; });
      });
      idiscardIfAnyDeltaRLess(elecs, jets, 0.4);
      // mu-jet: non-b jets with < 3 tracks within 0.2 of a muon removed (standard ATLAS Run-2 radius;
      // the paper text says 0.4); then muons within 0.4 of a remaining jet removed
      idiscard(jets, [&](const Jet& j) {
        return !j.bTagged() && _nTracks(j) < 3 && any(muons, deltaRLess(j, 0.2));
      });
      idiscardIfAnyDeltaRLess(muons, jets, 0.4);
      // Hadronic taus: Loose tau ID on the jets surviving the lepton OR (efficiency for jets tagged with a
      // true hadronic tau, misID rate otherwise); the tau-jet step below then removes the tagged jet, so its
      // deposit is counted once (as a tau) in the MET
      Particles taus;
      for (const Jet& j : jets + otherjets) {
        if (rand01() < TAUJET_EFF_ATLAS_RUN2_LOOSE(j)) taus += Particle(PID::TAU, j.mom());
      }
      // taus: removed near e/mu; jets within 0.2 of a tau removed
      idiscardIfAnyDeltaRLess(taus, elecs + muons, 0.2);
      idiscardIfAnyDeltaRLess(jets, taus, 0.2);
      // photons: removed near e/mu; jets within 0.4 of a photon removed
      idiscardIfAnyDeltaRLess(photons, elecs + muons, 0.4);
      idiscardIfAnyDeltaRLess(jets, photons, 0.4);
      // Soft/forward jets that are the calorimeter image of a surviving e/tau/gamma are
      // dropped from the MET sum only, so one deposit is not counted twice
      idiscard(otherjets, [&](const Jet& j) {
        return any(elecs + taus + photons, deltaRLess(j, 0.2));
      });

      // MET: negative vector sum of e, mu, tau, gamma and jets (pT > 20, |eta| < 4.5) after OR
      Vector3 pmiss;
      for (const Jet& j : jets + otherjets) {
        pmiss -= j.pTvec();
      }
      for (const Particle& p : elecs + muons + taus + photons) {
        pmiss -= p.pTvec();
      }
      const double met = pmiss.perp();

      // Signal jets are the post-OR jets (pT > 30, |eta| < 2.8)
      const size_t nbjets = count(jets, hasBTag());
      const double ht = sum(jets, Kin::pT, 0.0);

      // Common jet pre-selection against a given recoil vector (paper Table 2)
      auto jetSel = [&](const Vector3& recoil) {
        if (jets.empty() || jets.size() > 4) return false;
        const double dphicut = (recoil.perp() > 200*GeV && recoil.perp() <= 250*GeV) ? 0.6 : 0.4;
        if (any(jets, [&](const Jet& j) { return deltaPhi(j.mom(), recoil) <= dphicut; })) return false;
        return jets[0].pT() > 150*GeV && jets[0].abseta() < 2.4;
      };
      auto fillRecoil = [&](const string& reg, double recoil) {
        _h[reg]->fill(min(recoil/GeV, 1299.)); //< last HepData bin includes overflow
      };

      const bool noTauGamma = taus.empty() && photons.empty();

      // ---- Signal cutflows (reporting chain, kept separate from the region logic) ----
      // Rows "Trigger", "Event cleaning" and "Lead. Jet quality requirements" have no truth
      // analogue and are pass-through.
      {
        const bool lepveto = elecs.empty() && muons.empty() && noTauGamma;
        const bool njets = !jets.empty() && jets.size() <= 4;
        const double dphicut = (met > 200*GeV && met <= 250*GeV) ? 0.6 : 0.4;
        const bool dphi = njets && !any(jets, [&](const Jet& j) { return deltaPhi(j.mom(), pmiss) <= dphicut; });
        const bool leadjet = njets && jets[0].pT() > 150*GeV && jets[0].abseta() < 2.4;
        // Rows: Total (filter), Trigger, Event cleaning, Lepton veto, N_jets, min dphi,
        // Lead. jet quality, Lead. jet pT/eta
        const vector<bool> chain = {true, true, true, lepveto, njets, dphi, true, leadjet};
        if (truthMET > 150*GeV) _fillCutflow(_cf150, _labels150, chain, met, 200*GeV, 9);
        if (truthMET > 350*GeV) _fillCutflow(_cf350, _labels350, chain, met, 400*GeV, 9);
      }

      // ---- Signal region ----
      if (elecs.empty() && muons.empty() && noTauGamma && met > 200*GeV && jetSel(pmiss)) fillRecoil("SR", met);

      // ---- Control regions (taus and photons vetoed everywhere) ----
      if (!noTauGamma) return;

      // Truth bare lepton behind a selected (dressed, smeared) lepton: nearest same-flavour one within 0.1
      const Particles& bare = apply<FinalState>(event, "BareLeptons").particles();
      auto bareMatch = [&](const Particle& l) -> const Particle* {
        const Particle* m = nullptr;
        for (const Particle& b : bare) {
          if (b.abspid() == l.abspid() && deltaR(b, l) < 0.1 && (!m || deltaR(b, l) < deltaR(*m, l))) m = &b;
        }
        return m;
      };

      auto passD0Sig = [&](const Particle& l, double maxsig) {
        const Particle* m = bareMatch(l);
        return !m || _d0Significance(*m, l.pT()) < maxsig;
      };

      // Signal-lepton tiers: d0/sigma(d0) < 3 (mu) / 5 (e) via passD0Sig; z0 always passes at truth level.
      // Signal isolation and impact-parameter cuts select prompt leptons, and the baseline admits non-prompt
      // ones, so a signal lepton must also match a prompt truth lepton.
      auto isSignalMuon = [&](const Particle& m) {
        return m.pT() > 10*GeV && isPrompt(m) && passD0Sig(m, 3);
      };
      auto isSignalElectron = [&](const Particle& e) {
        if (e.pT() < 30*GeV || !isPrompt(e) || !passD0Sig(e, 5)) return false;
        // Tight conditional on LooseAndBLayer (same source and binning)
        const double effL = ELECTRON_IDEFF_ATLAS_RUN2_LOOSE(e);
        const double effT = ELECTRON_IDEFF_ATLAS_RUN2_TIGHT(e);
        return effL > 0 && rand01() < min(1.0, effT/effL);
      };

      // One muon: CR1mu0b / CR1L1b
      if (muons.size() == 1 && elecs.empty() && isSignalMuon(muons[0])) {
        const Vector3 recoil = pmiss + muons[0].pTvec();
        if (recoil.perp() > 200*GeV && inRange(mT(muons[0], pmiss), 30*GeV, 100*GeV) && jetSel(recoil)) {
          fillRecoil(nbjets == 0 ? "CR1mu0b" : "CR1L1b", recoil.perp());
        }
      }

      // One electron: CR1e0b / CR1L1b (tight ID + FCTight isolation + crack veto)
      if (elecs.size() == 1 && muons.empty() && isSignalElectron(elecs[0])) {
        const Particle& e = elecs[0];
        const bool iso = rand01() < ELECTRON_ISOEFF_ATLAS_RUN2_FCTIGHT(e) && _electronEnvIsolated(e, visible);
        const Vector3 recoil = pmiss + e.pTvec();
        if (iso && !inRange(e.abseta(), 1.37, 1.52) && recoil.perp() > 200*GeV &&
            inRange(mT(e, pmiss), 30*GeV, 100*GeV) && met > 70*GeV && ht > 0 && met/GeV/sqrt(ht/GeV) > 5 &&
            jetSel(recoil)) {
          fillRecoil(nbjets == 0 ? "CR1e0b" : "CR1L1b", recoil.perp());
        }
      }

      // Two muons: CR2mu (b-jets: any; no charge requirement)
      if (muons.size() == 2 && elecs.empty() && isSignalMuon(muons[0]) && isSignalMuon(muons[1])) {
        const Vector3 recoil = pmiss + muons[0].pTvec() + muons[1].pTvec();
        const double mll = (muons[0].mom() + muons[1].mom()).mass();
        if (recoil.perp() > 200*GeV && inRange(mll, 66*GeV, 116*GeV) && jetSel(recoil)) fillRecoil("CR2mu", recoil.perp());
      }

      // Two electrons: CR2e (both signal-electron draws are always made)
      if (elecs.size() == 2 && muons.empty()) {
        const bool sig0 = isSignalElectron(elecs[0]);
        const bool sig1 = isSignalElectron(elecs[1]);
        const Vector3 recoil = pmiss + elecs[0].pTvec() + elecs[1].pTvec();
        const double mll = (elecs[0].mom() + elecs[1].mom()).mass();
        if (sig0 && sig1 && recoil.perp() > 200*GeV && inRange(mll, 66*GeV, 116*GeV) && jetSel(recoil)) {
          fillRecoil("CR2e", recoil.perp());
        }
      }
    }


    void finalize() {

      // All HepData objects are expected events at 139 fb^-1
      const double sf = crossSection()/femtobarn * 139.0 / sumOfWeights();
      for (const auto& reg : _regions) {
        scale(_h[reg.first], sf);
        barchart(_h[reg.first], _e[reg.first]);
      }
      scale(_cf150, sf);
      scale(_cf350, sf);
      barchart(_cf150, _cf150out);
      barchart(_cf350, _cf350out);
    }

    /// @}


  private:

    /// @name Jet helpers
    /// @{

    /// b-tagging, MV2c10 60% WP, from the paper's numbers (Sec. 4): eff_b = 60%, rejection 1500 (light),
    /// 35 (c), 180 (tau_had); pT > 30 GeV, |eta| < 2.5. Rivet has no 60% WP function. The 60% is a
    /// ttbar-averaged efficiency; its pT dependence is taken from Rivet's 77% WP function for the same tagger,
    /// JET_BTAG_ATLAS_RUN2_2016_MV2C10_77 (ATL-PHYS-PUB-2016-012), scaled by 0.60/0.77, since both WPs are
    /// defined by their ttbar-averaged efficiency. This assumes the 60% WP has the 77% WP's pT shape. Only that
    /// function's b-jet branch is used; the mistag rates here are the paper's, flat.
    static double _bTagEff(const Jet& j) {
      if (j.pT() < 30*GeV || j.abseta() > 2.5) return 0;
      if (j.bTagged(Cuts::pT > 5*GeV)) return JET_BTAG_ATLAS_RUN2_2016_MV2C10_77(j) * 0.60/0.77;
      if (j.cTagged(Cuts::pT > 5*GeV)) return 1/35.;
      if (j.tauTagged(Cuts::pT > 5*GeV)) return 1/180.;
      return 1/1500.;
    }

    /// Number of charged constituents with pT > 500 MeV in the tracker acceptance (jet "tracks").
    ///
    /// TODO: should we consider an nChargedTracks function (with a min pT and/or a function argument?)
    static size_t _nTracks(const Jet& j) {
      return j.particles(Cuts::charge3 != 0 && Cuts::pT > 0.5*GeV && Cuts::abseta < 2.5).size();
    }

    /// @}


    /// @name Truth-isolation proxies for object ID and isolation
    ///
    /// Rivet's efficiency functions depend on (pT, eta) only, measured on isolated objects; these cuts on the
    /// visible truth final state around the object model the loss of objects in hadronic activity.
    /// @{

    /// Tight photon ID: a prompt photon collinear with hadronic activity would fail Tight's shower-shape /
    /// hadronic-leakage cuts. Visible sum pT in DeltaR < 0.2 (excluding the photon) below 0.065 x pT(gamma),
    /// FixedCutTight's ETcone20 fraction as the scale.
    static bool _photonIsolated(const Particle& y, const Particles& visible) {
      const double iso = sumPt(select(visible, [&](const Particle& v) {
        return v.genParticle() != y.genParticle() && deltaR(v, y) < 0.2;
      }));
      return iso < 0.065*y.pT();
    }

    /// Loose electron ID, for non-prompt baseline electrons: one embedded in hadronic activity would fail
    /// Loose's shower-shape / hadronic-leakage cuts. Same cone and scale as _photonIsolated, hadrons only.
    static bool _electronHadIsolated(const Particle& e, const Particles& visible) {
      const double had = sumPt(select(visible, [&](const Particle& v) {
        return v.isHadron() && deltaR(v, e) < 0.2;
      }));
      return had < 0.065*e.pT();
    }

    /// FCTight electron isolation, applied on top of the (pT, eta) FCTight
    /// efficiency: that efficiency is measured on isolated electrons and is blind to nearby hadronic activity,
    /// e.g. a b-jet next to the electron in a boosted top decay. Track ptvarcone20 (charged, pT > 1 GeV,
    /// dR < min(0.2, 10 GeV/pT)) and calorimeter topoetcone20 (visible, dR < 0.2, dressing photons within
    /// dR < 0.1 excluded), each < 0.06 pT(e). Isolated electrons pass it almost always.
    static bool _electronEnvIsolated(const Particle& e, const Particles& visible) {
      const double rtrk = min(0.2, 10*GeV/e.pT());
      double trk = 0, calo = 0;
      for (const Particle& v : visible) {
        const double dr = deltaR(v, e);
        if (dr > 0.2) continue;
        if (v.abspid() == PID::ELECTRON && dr < 0.01) continue;
        if (v.abspid() == PID::PHOTON && dr < 0.1) continue;
        calo += v.pT();
        if (v.isCharged() && v.pT() > 1*GeV && dr < rtrk) trk += v.pT();
      }
      return trk < 0.06*e.pT() && calo < 0.06*e.pT();
    }

    /// @}


    /// @name Transverse impact-parameter significance of signal leptons
    /// @{

    /// Intrinsic transverse impact-parameter resolution of a track vs pT, |eta| < 0.8, 2018 data:
    /// ATLAS, "Track and Vertex Reconstruction with the ATLAS Inner Detector", arXiv:2605.07585,
    /// Fig. 21a (digitised). Log-pT interpolation, clamped at the ends; used at all eta.
    static double _sigmaD0(double pt) {
      static const vector<double> pts = {0.62, 0.87, 1.11, 1.36, 1.74, 2.23, 2.73, 3.23, 3.73, 4.48, 5.48,
        6.48, 7.48, 8.48, 9.48, 10.98, 12.98, 14.99, 16.99, 19.00, 22.01, 26.03, 30.05, 34.06, 38.09, 42.61,
        47.65, 52.68, 57.71, 65.27, 75.35, 90.47, 125.8, 201.6, 328.1};
      static const vector<double> sigmas = {100.1, 75.7, 62.0, 53.2, 45.0, 37.6, 32.8, 29.5, 26.8, 24.0, 21.2,
        19.3, 18.0, 17.0, 16.1, 15.2, 14.4, 13.8, 13.4, 12.9, 12.3, 12.0, 11.7, 11.6, 11.4, 11.3,
        11.2, 11.2, 11.1, 11.6, 11.2, 11.3, 11.4, 11.3, 11.4};
      const double x = pt/GeV;
      double rtn = sigmas.back();
      if (x <= pts.front()) rtn = sigmas.front();
      else if (x < pts.back()) {
        const size_t i = std::upper_bound(pts.begin(), pts.end(), x) - pts.begin();
        const double f = log(x/pts[i-1]) / log(pts[i]/pts[i-1]);
        rtn = sigmas[i-1] + f*(sigmas[i] - sigmas[i-1]);
      }
      return rtn * 1e-3*mm;
    }

    /// d0 significance w.r.t. the beamline: the truth d0 of @a truth (the bare lepton behind a reconstructed
    /// one of transverse momentum @a pt) smeared by the track resolution and by the ~10 um transverse
    /// beamspot (arXiv:2605.07585, Sec. 6.3), both in the denominator
    static double _d0Significance(const Particle& truth, double pt) {
      const double strk = _sigmaD0(pt);
      const double sbs = 10e-3*mm;
      const double d0 = truth.impactParam() + randnorm(0, strk) + randnorm(0, sbs);
      return fabs(d0) / sqrt(sqr(strk) + sqr(sbs));
    }

    /// @}


    /// @name Cutflow helpers
    /// @{

    /// Fill a published cutflow by its own row labels: the sequential pre-selection rows of
    /// @a chain, then the MET threshold row, then the exclusive MET bin (from label @a ibin0)
    void _fillCutflow(BinnedHistoPtr<string>& cf, const vector<string>& labels,
                      const vector<bool>& chain, double met, double metcut, size_t ibin0) {
      for (size_t i = 0; i < chain.size(); ++i) {
        if (!chain[i]) return;
        cf->fill(labels[i]);
      }
      if (met <= metcut) return;
      cf->fill(labels[chain.size()]);
      // Exclusive bins (lo, hi], last one open-ended
      size_t ib = 0;
      while (ib + 1 < _emEdges.size() && met/GeV > _emEdges[ib+1]) {
        ++ib;
      }
      const size_t ifirst = std::find(_emEdges.begin(), _emEdges.end(), metcut/GeV) - _emEdges.begin();
      cf->fill(labels[ibin0 + ib - ifirst]);
    }

    /// Fail loudly if the record's row labels ever change meaning or order
    void _checkCutflowLabels(const vector<string>& labels, size_t n, const string& metcut,
                             const string& lastlabel) const {
      auto has = [&](size_t i, const string& s) { return i < labels.size() && labels[i].find(s) != string::npos; };
      const bool ok = labels.size() == n && has(0, "Total evts") && has(1, "Trigger") &&
        has(2, "Event cleaning") && has(3, "Lepton veto") && has(4, "N_\\mathrm{jets}") &&
        has(5, "Delta\\Phi") && has(6, "Lead. Jet quality") && has(7, "Lead. Jet $p_\\mathrm{T}>150") &&
        has(8, metcut) && has(9, metcut) && labels.back() == lastlabel;
      if (!ok) throw UserError("ATLAS_2021_I1847779: unexpected cutflow row labels in reference data");
    }

    /// @}


    const vector<pair<string, unsigned int>> _regions = {
      {"CR1mu0b", 2}, {"CR1e0b", 3}, {"CR1L1b", 4}, {"CR2mu", 5}, {"CR2e", 6}, {"SR", 7}};
    const vector<double> _emEdges = {200, 250, 300, 350, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200};

    map<string, Histo1DPtr> _h;
    map<string, Estimate1DPtr> _e;
    BinnedHistoPtr<string> _cf150, _cf350;
    BinnedEstimatePtr<string> _cf150out, _cf350out;
    vector<string> _labels150, _labels350;

  };


  RIVET_DECLARE_PLUGIN(ATLAS_2021_I1847779);

}