2 #ifndef RIVET_SmearedJets_HH 3 #define RIVET_SmearedJets_HH 5 #include "Rivet/Jet.hh" 6 #include "Rivet/Particle.hh" 7 #include "Rivet/Projection.hh" 8 #include "Rivet/Projections/JetAlg.hh" 9 #include "Rivet/Tools/SmearingFunctions.hh" 56 const initializer_list<JetEffSmearFn>& effSmearFns={})
57 :
SmearedJets(ja, vector<JetEffSmearFn>{effSmearFns}, bTagEffFn, cTagEffFn)
66 const vector<JetEffSmearFn>& effSmearFns={})
67 :
SmearedJets(ja, effSmearFns, bTagEffFn, cTagEffFn)
75 const initializer_list<JetEffSmearFn>& effSmearFns,
85 const vector<JetEffSmearFn>& effSmearFns,
88 : _detFns(effSmearFns), _bTagEffFn(bTagEffFn), _cTagEffFn(cTagEffFn)
104 :
SmearedJets(ja, {jetEffFn,smearFn}, bTagEffFn, cTagEffFn)
122 const CmpState teq =
mkPCmp(p,
"TruthJets");
123 if (teq != CmpState::EQ)
return teq;
127 const CmpState nfeq =
cmp(_detFns.size(), other._detFns.
size());
128 if (nfeq != CmpState::EQ)
return nfeq;
129 for (
size_t i = 0; i < _detFns.size(); ++i) {
130 const CmpState feq = _detFns[i].cmp(other._detFns[i]);
131 if (feq != CmpState::EQ)
return feq;
142 const Jets& truthjets = apply<JetAlg>(e,
"TruthJets").
jetsByPt();
143 _recojets.clear(); _recojets.reserve(truthjets.size());
145 for (
const Jet& j : truthjets) {
148 MSG_DEBUG(
"Truth jet: " <<
"mom=" << jdet.
mom()/GeV <<
" GeV, pT=" << jdet.
pT()/GeV <<
", eta=" << jdet.
eta());
151 std::tie(jdet, jeff) = fn(jdet);
153 if (jdet.
particles().empty() && !j.particles().empty()) jdet.
particles() = j.particles();
154 if (jdet.
tags().empty() && !j.tags().empty()) jdet.
tags() = j.tags();
155 MSG_DEBUG(
" ->" <<
"mom=" << jdet.
mom()/GeV <<
" GeV, pT=" << jdet.
pT()/GeV <<
", eta=" << jdet.
eta());
161 if (jeff <= 0) { keep =
false;
break; }
162 if (jeff < 1 &&
rand01() > jeff) { keep =
false;
break; }
164 if (keep) _recojets.push_back(jdet);
167 for (
Jet& j : _recojets) {
169 const double beff = _bTagEffFn ? _bTagEffFn(j) : j.bTagged();
170 const bool btag = beff == 1 || (beff != 0 &&
rand01() < beff);
172 if (!btag && j.bTagged()) j.tags().erase(std::remove_if(j.tags().begin(), j.tags().end(), hasBottom), j.tags().end());
173 if (btag && !j.bTagged()) j.tags().push_back(
Particle(PID::BQUARK, j.mom()));
175 const double ceff = _cTagEffFn ? _cTagEffFn(j) : j.cTagged();
176 const bool ctag = ceff == 1 || (ceff != 0 &&
rand01() < beff);
178 if (!ctag && j.cTagged()) j.tags().erase(std::remove_if(j.tags().begin(), j.tags().end(), hasCharm), j.tags().end());
179 if (ctag && !j.cTagged()) j.tags().push_back(
Particle(PID::CQUARK, j.mom()));
185 Jets _jets()
const {
return _recojets; }
189 return getProjection<JetAlg>(
"TruthJets").
jetsByPt();
202 vector<JetEffSmearFn> _detFns;
void setName(const std::string &name)
Used by derived classes to set their name.
Definition: Projection.hh:142
Definition: MC_Cent_pPb.hh:10
void reset()
Reset the projection. Smearing functions will be unchanged.
Definition: SmearedJets.hh:193
function< double(const Jet &)> JetEffFn
Typedef for Jet efficiency functions/functors.
Definition: JetSmearingFunctions.hh:23
CmpState compare(const Projection &p) const
Compare to another SmearedJets.
Definition: SmearedJets.hh:120
Functor for simultaneous efficiency-filtering and smearing of Jets.
Definition: JetSmearingFunctions.hh:94
const FourMomentum & mom() const
Get equivalent single momentum four-vector (const) (alias).
Definition: ParticleBase.hh:39
Particles & particles()
Get the particles in this jet.
Definition: Jet.hh:47
SmearedJets(const JetAlg &ja, const JetSmearFn &smearFn, const JetEffFn &bTagEffFn=JET_BTAG_PERFECT, const JetEffFn &cTagEffFn=JET_CTAG_PERFECT)
Constructor with a reco efficiency and optional tagging efficiencies.
Definition: SmearedJets.hh:42
double JET_BTAG_PERFECT(const Jet &j)
Return 1 if the given Jet contains a b, otherwise 0.
Definition: JetSmearingFunctions.hh:53
Particle representation, either from a HepMC::GenEvent or reconstructed.
Definition: Particle.hh:18
SmearedJets(const JetAlg &ja, const JetEffFn &bTagEffFn=JET_BTAG_PERFECT, const JetEffFn &cTagEffFn=JET_CTAG_PERFECT, const initializer_list< JetEffSmearFn > &effSmearFns={})
Constructor with tagging efficiencies, plus an ordered init-list of efficiency and smearing functions...
Definition: SmearedJets.hh:53
DEFAULT_RIVET_PROJ_CLONE(SmearedJets)
Clone on the heap.
size_t size() const
Count the jets.
Definition: JetFinder.hh:160
Representation of a HepMC event, and enabler of Projection caching.
Definition: Event.hh:22
Jets jetsByPt(const Cut &c=Cuts::open()) const
Definition: JetFinder.hh:125
SmearedJets(const JetAlg &ja, const initializer_list< JetEffSmearFn > &effSmearFns, const JetEffFn &bTagEffFn=JET_BTAG_PERFECT, const JetEffFn &cTagEffFn=JET_CTAG_PERFECT)
Constructor with an ordered init-list of efficiency and smearing functions, plus optional tagging eff...
Definition: SmearedJets.hh:74
Cmp< Projection > mkPCmp(const Projection &otherparent, const std::string &pname) const
void project(const Event &e)
Perform the jet finding & smearing calculation.
Definition: SmearedJets.hh:140
Abstract base class for projections which can return a set of Jets.
Definition: JetFinder.hh:15
SmearedJets(const JetAlg &ja, const JetSmearFn &smearFn, const JetEffFn &bTagEffFn, const JetEffFn &cTagEffFn, const JetEffFn &jetEffFn)
Constructor with trailing efficiency arg.
Definition: SmearedJets.hh:99
double JET_CTAG_PERFECT(const Jet &j)
Return 1 if the given Jet contains a c, otherwise 0.
Definition: JetSmearingFunctions.hh:57
double pT() const
Get the directly (alias).
Definition: ParticleBase.hh:63
SmearedJets(const JetAlg &ja, const vector< JetEffSmearFn > &effSmearFns, const JetEffFn &bTagEffFn=JET_BTAG_PERFECT, const JetEffFn &cTagEffFn=JET_CTAG_PERFECT)
Constructor with an ordered vector of efficiency and smearing functions, plus optional tagging effici...
Definition: SmearedJets.hh:84
function< Jet(const Jet &)> JetSmearFn
Typedef for Jet smearing functions/functors.
Definition: JetSmearingFunctions.hh:20
const PROJ & declare(const PROJ &proj, const std::string &name)
Register a contained projection (user-facing version)
Definition: ProjectionApplier.hh:160
Particles & tags()
Particles which have been tag-matched to this jet.
Definition: Jet.hh:89
double eta() const
Get the directly (alias).
Definition: ParticleBase.hh:87
Representation of a clustered jet of particles.
Definition: Jet.hh:18
const Jets truthJets() const
Get the truth jets (sorted by pT)
Definition: SmearedJets.hh:188
Base class for all Rivet projections.
Definition: Projection.hh:29
SmearedJets(const JetAlg &ja, const JetEffFn &bTagEffFn=JET_BTAG_PERFECT, const JetEffFn &cTagEffFn=JET_CTAG_PERFECT, const vector< JetEffSmearFn > &effSmearFns={})
Constructor with tagging efficiencies, plus an ordered vector of efficiency and smearing functions...
Definition: SmearedJets.hh:63
Wrapper projection for smearing Jets with detector resolutions and efficiencies.
Definition: SmearedJets.hh:33
double rand01()
Return a uniformly sampled random number between 0 and 1.
Cmp< T > cmp(const T &t1, const T &t2)
Global helper function for easy creation of Cmp objects.
Definition: Cmp.hh:255