1#ifndef PROJECTIONS_LHCBCOMMON_HH
2#define PROJECTIONS_LHCBCOMMON_HH
4#include "Rivet/Projections/FinalState.hh"
5#include "Rivet/Projections/PrimaryParticles.hh"
6#include "Rivet/Projections/UnstableParticles.hh"
23 HVRecoFinalState(
const Cut& c = Cuts::abseta > 2.0 && Cuts::abseta < 5.0,
24 const vector<PdgId>& Hadrons = {},
25 const Cut& hadcut = Cuts::OPEN)
26 :
FinalState(c), _theHFHadrons(), _hfcuts(hadcut) {
27 setName(
"LHCb::HVRecoFinalState");
29 Cut cpid = Cuts::OPEN;
30 for (
const PdgId&
id : Hadrons) {
34 if (cpid == Cuts::OPEN)
35 cpid = (Cuts::pid == id);
37 cpid = cpid || (Cuts::pid == id);
39 if ((hadcut == Cuts::OPEN) && (c != Cuts::OPEN)) _hfcuts = c;
40 if (cpid != Cuts::OPEN) _hfcuts = cpid && _hfcuts;
42 this->
declare(hvhad,
"HVHadrons");
45 virtual ~HVRecoFinalState() { }
48 _theHFHadrons.clear();
50 if (_theHFHadrons.empty()) {
51 _theParticles.clear();
54 MSG_DEBUG(
"Found " << _theHFHadrons.size() <<
" heavy-flavour hadrons in event");
56 if (_theParticles.empty()) {
57 MSG_DEBUG(
"No particles in final state.");
60 MSG_DEBUG(
"Final state contains " << _theParticles.size()
61 <<
" particles before adding heavy-flavour hadrons");
63 _theParticles = _theParticles + _theHFHadrons;
64 MSG_DEBUG(
"Added heavy-flavour hadrons to final state, now " << _theParticles.size()
65 <<
" particles in final state");
68 to_remove = to_remove +
p.stableDescendants();
71 <<
" stable descendants of heavy-flavour hadrons for removal from final state");
76 if (
p.genParticle() == r.genParticle()) {
82 MSG_DEBUG(
"Removed stable descendants of heavy-flavour hadrons from final state, now "
83 << _theParticles.size() <<
" particles in final state. Project done!");
98 virtual std::unique_ptr<Rivet::Projection>
clone()
const {
99 return std::unique_ptr<Projection>(
new HVRecoFinalState(*
this));
103 using Projection::operator=;
110 const HVRecoFinalState& other =
dynamic_cast<const HVRecoFinalState&
>(
p);
113 const PCmp prevcmp =
mkPCmp(other,
"HVHadrons");
114 if (prevcmp != CmpState::EQ)
return CmpState::NEQ;
116 const bool hfcutcmp = _hfcuts == other._hfcuts;
117 MSG_TRACE(_hfcuts <<
" VS " << other._hfcuts <<
" -> EQ == " << std::boolalpha << hfcutcmp);
118 if (!hfcutcmp)
return CmpState::NEQ;
virtual void project(const Event &e)
Apply the projection to the event.
FinalState(const Cut &c=Cuts::OPEN)
Construction using Cuts object.
virtual CmpState compare(const Projection &p) const
Compare projections.
virtual CmpState compare(const Projection &p) const
Definition LHCbCommon.hh:108
virtual std::unique_ptr< Rivet::Projection > clone() const
Definition LHCbCommon.hh:98
Particles hfHadrons() const
Definition LHCbCommon.hh:91
virtual void project(const Event &e)
Apply the projection to the event.
Definition LHCbCommon.hh:47
Particle representation, either from a HepMC::GenEvent or reconstructed.
Definition Particle.hh:50
Specialised vector of Particle objects.
Definition Particle.hh:21
std::enable_if_t< std::is_base_of< Projection, PROJ >::value, const PROJ & > apply(const Event &evt, const Projection &proj) const
Apply the supplied projection on event evt.
Definition ProjectionApplier.hh:124
const PROJ & declare(const PROJ &proj, const std::string &name) const
Register a contained projection (user-facing version).
Definition ProjectionApplier.hh:205
bool hasProjection(const std::string &name) const
Does this applier have a projection registered under the name name?
Definition ProjectionApplier.hh:55
Projection()
The default constructor.
friend class Event
Event is a friend.
Definition Projection.hh:33
Cmp< Projection > mkPCmp(const Projection &otherparent, const std::string &pname) const
void setName(const std::string &name)
Used by derived classes to set their name.
Definition Projection.hh:146
Project out all physical-but-decayed particles in an event.
Definition UnstableParticles.hh:26
Jets & idiscard(Jets &jets, const Cut &c)
Filter a jet collection in-place to the subset that fails the supplied Cut.
#define MSG_TRACE(x)
Lowest-level, most verbose messaging, using MSG_LVL.
Definition Logging.hh:193
#define MSG_DEBUG(x)
Debug messaging, not enabled by default, using MSG_LVL.
Definition Logging.hh:195
int threeCharge(int pid)
Definition ParticleIdUtils.hh:1020
bool isHeavyFlavour(int pid)
British-spelling alias for isHeavyFlavor.
Definition ParticleIdUtils.hh:709
bool isHadron(int pid)
Definition ParticleIdUtils.hh:415
double p(const ParticleBase &p)
Unbound function access to p.
Definition ParticleBaseUtils.hh:819
Common projections for LHCb specific conditions.
Definition LHCbCommon.hh:12
Definition LHCbCommon.hh:9
Cmp< Projection > PCmp
Typedef for Cmp<Projection>.
Definition Cmp.hh:259