Rivet tutorials
Detector emulation by “smearing”
By design, Rivet is a package to analyse simulated collision events, with the HepMC event-graph as the core input object. This works perfectly for experimental analyses in which detector-reconstruction biases and inefficiencies have been “unfolded” from the reference data, for direct comparison with an MC-truth fiducial selection. But many analyses, particularly searches for new physics, are performed at reconstruction level for simplicity and speed.
The reinterpretation of these analyses is also an important use-case for Rivet, e.g. in the majority of phenomenology studies where a fully-detailed detector material, electronics, and reconstruction suite is not available, or is too computationally expensive to be tractable. For these, Rivet’s projection system provides an efficient way to emulate detector effects by “smearing” of physics-object positions and momenta, and application of imperfect efficiencies to object finding and labelling.
Detector emulation in Rivet

The image above illustrates the rationale behind this approach: as experimental reconstruction algorithms and calibrations are designed to produce physics objects as close as possible to the real/truth-level inputs to full simulation, the reconstruction step is approximately an inversion of the simulation (particle-transport, secondary interactions, and energy deposition) and digitization.
Full simulation, while the gold standard for precision modelling, especially as it runs the same reconstruction as used on real data, is a very expensive way to make a nearly-closing round-trip. As the remaining difference between objects at truth and reco levels is relatively small, compared to how different they are at the digitization stage, a reasonably modelling of the non-closure can often be obtained by simple parametrisations of resolutions, biases, and object-identification inefficiencies and mislabellings.
These smearing and efficiency functions are currently implemented as three types of modifier projection, used to wrap truth-level projections and change their outputs to include reco-level biases:
SmearedParticles: wrapsParticleFinderprojections, includingFinalStates.SmearedJets: wrapsJetFinderprojections, includingFastJets.SmearedMET: wraps theMissingMomentumprojection.
All three wrapper projections can be configured with user-specified chains of smearing and efficiency functions, which are included in projection-caching equivalence comparisons in the usual way.
Unlike many such smearing-oriented approaches, e.g. the popular Delphes fast-simulation tool, as it is configured by wrapping of object finders at the analysis level, the Rivet detector-emulation system allows for multiple detector biases to be emulated, on a per-analysis basis, in a single run on input truth-level events.
Smearing and efficiency functors
The key to flexible smearing and efficiency parametrisation in Rivet
is functors. A functor in C++ is any object that behaves like a
function, i.e. it can be called using parentheses around a list of
arguments, like my_functor(arg1, arg2). A normal function is a
functor; a lambda function [](const Type1&, const Type2&) is a
functor; any object of a class that implements operator(),
e.g. operator() (const Type1&, const Type2&), is a functor. If you
prefer, “function object” is clearer.
You can provide a list of such functors to Rivet’s smearing wrappers
at construction time, and they will be stored and called in order each
time they meet one of the physics objects handled by that projection.
The SmearedParticles and SmearedJets projections can take either
smearing functions that map a Particle to a new (modified)
Particle or a Jet to a modified Jet respectively, or
efficiency functions that respectively map a Particle to a
reconstruction-efficiency double, or map a Jet to a set of
flavour-tagging efficiencies. So, to make an unrealistic example of a
charged-particle finder that always reconstructs with twice the
momentum but loses half the particles,
FinalState fs(Cuts::abscharge > 0);
SmearedParticles(fs,
[](const Particle& p){ return Particle(p.pid(),
P4::mkXYZM(2*p.px(), 2*p.py(), 2*p.pz(), p.mass())); },
[](const Particle& p){ return 0.5; })
or for a smeared jet with a b-tag efficiency of 77%, and c- and light b-mistag rates of 1/5 and 1/100, and jet-energy resolution of 5%:
FastJets fj(fs, JetAlg::ANTIKT, 0.4);
SmearedJets(fj,
[](const Jet& j){ return j.bTagged() ? 0.77 : j.cTagged() ? 1/5. : 1/100.; },
[](const Jet& j){ return Jet(P4_SMEAR_E_GAUSS(j.mom(), 0.05*j.E(), j.particles()); )})
Note that the smearing functions that map from the truth object to a
new version of the same type can change anything within that type: the
momentum, the vertex locations, the particle ID(s), the jet
constituents, the jet flavour-tags, etc. etc. This system is very
general: in its current for the one thing it can’t do is confuse a
Particle for a Jet or vice-versa (which would be useful for
electron/jet misidentification, but this can be handled more manually
in the analysis code: the projections can’t do everything!)
Finally there is the SmearedMET wrapper. This one takes a special
kind of functor, which maps a (Vector3, double) pair of arguments to
a special METSmearParams data structure used to perform the smearing.
The input pair of arguments represent the truth missing-momentum vector
and the event scalar-sum of particle pT/energy respectively. This one
is a bit specialised so we won’t cover it in detail here, other than to
note that it’s the same general mechanism via user- or pre-defined functors.
Smearing helper functions
This last example, you’ll note, is using a predefined helper function
P4_SMEAR_E_GAUSS, which takes some of the boring coding out of
smearing the jet energy by a Gaussian of the given width and making
the momentum object consistent. There are lots of such helper
functions in the
Rivet/Tools/MomentumSmearingFunctions.hh,
Rivet/Tools/ParticleSmearingFunctions.hh, and
Rivet/Tools/JetSmearingFunctions.hh headers.
For example, to simplify b-tagging efficiencies: JET_BTAG_EFFS(0.77,
1/5., 1/100.) returns a functor that does the same as the nested
ternary expression above. And there are whole families of pre-coded
experimental resolution and efficiency functors in
Rivet/Tools/ExptSmearingFunctions.hh, e.g. JET_SMEAR_ATLAS_RUN2.
Take a look, have a play, and let the developers know if you have
a need for more functors, corrections, or extensions to the system!
MET significance
Many searches cut on a missing-momentum significance rather than (or as well as) the MET itself, to tell genuine invisible particles apart from fake MET due to mismeasured jets and leptons. This isn’t strictly smearing, but it uses similar resolution parametrisations. There are three implementations, so check which one your paper means and which works best in the context of your analysis:
- A simple ratio like
MET/sqrt(HT). This needs no special machinery: just compute it in your analysis from your smeared objects. Some analyses genuinely mean this object when they say “MET significance”, and in to first order it is also often a reasonable approximation of the more complex definitions below. - The event-based significance from
SmearedMET::missingPtSignf(), described above, with the resolution taken from the MET-smearing parametrisation, e.g.MET_SMEARPARAMS_ATLAS_RUN2as a function of the event’s scalar sum. For most applications, this lacks the simplicity of the approach above without gaining the performance improvements of the approach below. - The full object-based significance used by most ATLAS Run 2 searches (described in ATLAS-CONF-2018-038). Each reconstructed object’s resolution in pT and phi is rotated into the MET direction and summed into a covariance matrix, together with a “soft term” for everything else, and the significance is the MET divided by the resolution along its own direction, corrected for the correlation with the perpendicular one.
The last of these is provided by the ObjectBasedMET calculator in
Rivet/Tools/ObjectBasedMET.hh.
It isn’t a projection: you build it once and then call it on each
event’s objects:
// In init(): ATLAS Run 2 resolutions for jets, electrons, and muons
_metsig = ATLAS_RUN2_DEFAULT_METSIG();
// In analyze(): the reco-level MET vector and the objects that make it up
const double S = _metsig.sig(vmet, jets, electrons, muons);
where _metsig is an ObjectBasedMET member of your analysis. A few
things to watch out for:
- The objects should be your reco-level (smeared) ones, after overlap
removal (though pay attention for what the papers says e.g. about
baseline ve signal leptons), and the same set that your MET vector
is built from. Any momentum in the MET that isn’t passed to
sig()ends up in the soft term, which by default has a flat 10 GeV resolution. - Photon and tau resolution functors exist, but aren’t in the default
set as they haven’t been validated yet. Photons or taus passed to
sig()without having been included in the constructor are ignored, with a warning. If you use them and they work, we’d love to here about it! - Custom resolution functors and soft-term treatments can be plugged in
via the
makeObjectBasedMET<...>()template function: see theEXAMPLE_METSIGanalysis for the options.