1 #ifndef RIVET_PARTICLEBASEUTILS_HH 2 #define RIVET_PARTICLEBASEUTILS_HH 4 #include "Rivet/ParticleBase.hh" 26 virtual bool operator()(
const ParticleBase& p)
const = 0;
33 PtGtr(
double pt) : ptcut(pt) { }
35 bool operator()(
const ParticleBase& p)
const {
return p.
pT() > ptcut; }
44 PtLess(
double pt) : ptcut(pt) { }
45 bool operator()(
const ParticleBase& p)
const {
return p.
pT() < ptcut; }
53 PtInRange(pair<double, double> ptcuts) : ptcut(ptcuts) { }
56 bool operator()(
const ParticleBase& p)
const {
return p.
pT() >= ptcut.first && p.
pT() < ptcut.second; }
57 pair<double,double> ptcut;
65 EtaGtr(
double eta) : etacut(eta) { }
67 bool operator()(
const ParticleBase& p)
const {
return p.
eta() > etacut; }
74 EtaLess(
double eta) : etacut(eta) { }
76 bool operator()(
const ParticleBase& p)
const {
return p.
eta() < etacut; }
83 EtaInRange(pair<double, double> etacuts) : etacut(etacuts) { }
86 bool operator()(
const ParticleBase& p)
const {
return p.
eta() >= etacut.first && p.
eta() < etacut.second; }
87 pair<double,double> etacut;
94 AbsEtaGtr(
double abseta) : absetacut(abseta) { }
104 AbsEtaLess(
double abseta) : absetacut(abseta) { }
114 AbsEtaInRange(
const pair<double, double>& absetacuts) : absetacut(absetacuts) { }
117 bool operator()(
const ParticleBase& p)
const {
return p.
abseta() >= absetacut.first && p.
abseta() < absetacut.second; }
118 pair<double,double> absetacut;
126 RapGtr(
double rap) : rapcut(rap) { }
128 bool operator()(
const ParticleBase& p)
const {
return p.
rap() > rapcut; }
135 RapLess(
double rap) : rapcut(rap) { }
137 bool operator()(
const ParticleBase& p)
const {
return p.
rap() < rapcut; }
144 RapInRange(
const pair<double, double>& rapcuts) : rapcut(rapcuts) { }
147 bool operator()(
const ParticleBase& p)
const {
return p.
rap() >= rapcut.first && p.
rap() < rapcut.second; }
148 pair<double,double> rapcut;
155 AbsRapGtr(
double absrap) : absrapcut(absrap) { }
165 AbsRapLess(
double absrap) : absrapcut(absrap) { }
175 AbsRapInRange(
const pair<double, double>& absrapcuts) : absrapcut(absrapcuts) { }
178 bool operator()(
const ParticleBase& p)
const {
return p.
absrap() >= absrapcut.first && p.
absrap() < absrapcut.second; }
179 pair<double,double> absrapcut;
191 : refvec(vec.
mom()), drcut(dr), rapscheme(scheme) { }
193 : refvec(vec), drcut(dr), rapscheme(scheme) { }
195 : drcut(dr), rapscheme(PSEUDORAPIDITY) { refvec.setPx(vec.x()); refvec.setPy(vec.y()); refvec.setPz(vec.z()); }
196 bool operator()(
const ParticleBase& p)
const {
return deltaR(p, refvec, rapscheme) > drcut; }
206 : refvec(vec.
mom()), drcut(dr), rapscheme(scheme) { }
208 : refvec(vec), drcut(dr), rapscheme(scheme) { }
210 : drcut(dr), rapscheme(PSEUDORAPIDITY) { refvec.setPx(vec.x()); refvec.setPy(vec.y()); refvec.setPz(vec.z()); }
211 bool operator()(
const ParticleBase& p)
const {
return deltaR(p, refvec, rapscheme) < drcut; }
221 : refvec(vec.
mom()), drcut(dr), rapscheme(scheme) { }
225 : refvec(vec), drcut(dr), rapscheme(scheme) { }
229 : drcut(dr), rapscheme(PSEUDORAPIDITY) { refvec.setPx(vec.x()); refvec.setPy(vec.y()); refvec.setPz(vec.z()); }
233 const double dR =
deltaR(p, refvec, rapscheme);
234 return dR >= drcut.first && dR < drcut.second;
237 pair<double,double> drcut;
246 : refvec(vec.
p3()), dphicut(dphi) { }
248 : refvec(vec.
p3()), dphicut(dphi) { }
250 : refvec(vec), dphicut(dphi) { }
260 : refvec(vec.
p3()), dphicut(dphi) { }
262 : refvec(vec.
p3()), dphicut(dphi) { }
264 : refvec(vec), dphicut(dphi) { }
274 : refvec(vec.
mom()), dphicut(dphi) { }
278 : refvec(vec), dphicut(dphi) { }
282 : refvec(vec), dphicut(dphi) { }
286 const double dphi =
deltaPhi(p, refvec);
287 return dphi >= dphicut.first && dphi < dphicut.second;
290 pair<double,double> dphicut;
298 : refvec(vec.
p3()), detacut(deta) { }
300 : refvec(vec.
p3()), detacut(deta) { }
302 : refvec(vec), detacut(deta) { }
303 bool operator()(
const ParticleBase& p)
const {
return std::abs(
deltaEta(p, refvec)) > detacut; }
312 : refvec(vec.
p3()), detacut(deta) { }
314 : refvec(vec.
p3()), detacut(deta) { }
316 : refvec(vec), detacut(deta) { }
317 bool operator()(
const ParticleBase& p)
const {
return std::abs(
deltaEta(p, refvec)) < detacut; }
326 : refvec(vec.
mom()), detacut(deta) { }
330 : refvec(vec), detacut(deta) { }
334 : refvec(vec), detacut(deta) { }
338 const double deta =
deltaEta(p, refvec);
339 return deta >= detacut.first && deta < detacut.second;
342 pair<double,double> detacut;
350 : refvec(vec.
mom()), drapcut(drap) { }
352 : refvec(vec), drapcut(drap) { }
353 bool operator()(
const ParticleBase& p)
const {
return std::abs(
deltaRap(p, refvec)) > drapcut; }
362 : refvec(vec.
mom()), drapcut(drap) { }
364 : refvec(vec), drapcut(drap) { }
365 bool operator()(
const ParticleBase& p)
const {
return std::abs(
deltaRap(p, refvec)) < drapcut; }
374 : refvec(vec.
mom()), drapcut(drap) { }
378 : refvec(vec), drapcut(drap) { }
382 const double drap =
deltaRap(p, refvec);
383 return drap >= drapcut.first && drap < drapcut.second;
386 pair<double,double> drapcut;
401 virtual double operator()(
const ParticleBase& p)
const = 0;
409 DeltaRWRT(
const Vector3& p3) : p(p3.
mod(), p3.x(), p3.y(), p3.z()), rapscheme(PSEUDORAPIDITY) {}
412 double operator()(
const Vector3& p3)
const {
return deltaR(p, p3); }
449 double operator()(
const Vector3& p3)
const {
return fabs(
deltaEta(p, p3)); }
480 template<
typename PBCONTAINER1,
typename PBCONTAINER2>
481 void idiscardIfAny(PBCONTAINER1& tofilter,
const PBCONTAINER2& tocompare,
482 typename std::function<
bool(
const typename PBCONTAINER1::value_type&,
const typename PBCONTAINER2::value_type&)> fn) {
483 for (
const auto& pbcmp : tocompare)
484 ifilter_discard(tofilter, [&](
const typename PBCONTAINER1::value_type& pbfilt){
return fn(pbfilt, pbcmp); });
487 template<
typename PBCONTAINER1,
typename PBCONTAINER2>
488 PBCONTAINER1 discardIfAny(
const PBCONTAINER1& tofilter,
const PBCONTAINER2& tocompare,
489 typename std::function<
bool(
const typename PBCONTAINER1::value_type&,
const typename PBCONTAINER2::value_type&)> fn) {
490 PBCONTAINER1 tmp{tofilter};
491 idiscardIfAny(tmp, tocompare, fn);
495 template<
typename PBCONTAINER1,
typename PBCONTAINER2>
496 void iselectIfAny(PBCONTAINER1& tofilter,
const PBCONTAINER2& tocompare,
497 typename std::function<
bool(
const typename PBCONTAINER1::value_type&,
const typename PBCONTAINER2::value_type&)> fn) {
498 for (
const auto& pbcmp : tocompare)
499 ifilter_select(tofilter, [&](
const typename PBCONTAINER1::value_type& pbfilt){
return fn(pbfilt, pbcmp); });
502 template<
typename PBCONTAINER1,
typename PBCONTAINER2>
503 PBCONTAINER1 selectIfAny(
const PBCONTAINER1& tofilter,
const PBCONTAINER2& tocompare,
504 typename std::function<
bool(
const typename PBCONTAINER1::value_type&,
const typename PBCONTAINER2::value_type&)> fn) {
505 PBCONTAINER1 tmp{tofilter};
506 iselectIfAny(tmp, tocompare, fn);
516 template<
typename PBCONTAINER1,
typename PBCONTAINER2>
517 void idiscardIfAnyDeltaRLess(PBCONTAINER1& tofilter,
const PBCONTAINER2& tocompare,
double dR) {
522 template<
typename PBCONTAINER1,
typename PBCONTAINER2>
523 PBCONTAINER1 discardIfAnyDeltaRLess(
const PBCONTAINER1& tofilter,
const PBCONTAINER2& tocompare,
double dR) {
524 PBCONTAINER1 tmp{tofilter};
525 idiscardIfAnyDeltaRLess(tmp, tocompare, dR);
529 template<
typename PBCONTAINER1,
typename PBCONTAINER2>
530 void idiscardIfAnyDeltaPhiLess(PBCONTAINER1& tofilter,
const PBCONTAINER2& tocompare,
double dphi) {
535 template<
typename PBCONTAINER1,
typename PBCONTAINER2>
536 PBCONTAINER1 discardIfAnyDeltaPhiLess(
const PBCONTAINER1& tofilter,
const PBCONTAINER2& tocompare,
double dphi) {
537 PBCONTAINER1 tmp{tofilter};
538 idiscardIfAnyDeltaPhiLess(tmp, tocompare, dphi);
542 template<
typename PBCONTAINER1,
typename PBCONTAINER2>
543 void iselectIfAnyDeltaRLess(PBCONTAINER1& tofilter,
const PBCONTAINER2& tocompare,
double dR) {
548 template<
typename PBCONTAINER1,
typename PBCONTAINER2>
549 PBCONTAINER1 selectIfAnyDeltaRLess(
const PBCONTAINER1& tofilter,
const PBCONTAINER2& tocompare,
double dR) {
550 PBCONTAINER1 tmp{tofilter};
551 iselectIfAnyDeltaRLess(tmp, tocompare, dR);
555 template<
typename PBCONTAINER1,
typename PBCONTAINER2>
556 void iselectIfAnyDeltaPhiLess(PBCONTAINER1& tofilter,
const PBCONTAINER2& tocompare,
double dphi) {
561 template<
typename PBCONTAINER1,
typename PBCONTAINER2>
562 PBCONTAINER1 selectIfAnyDeltaPhiLess(
const PBCONTAINER1& tofilter,
const PBCONTAINER2& tocompare,
double dphi) {
563 PBCONTAINER1 tmp{tofilter};
564 iselectIfAnyDeltaPhiLess(tmp, tocompare, dphi);
Definition: MC_Cent_pPb.hh:10
double abseta() const
Get the directly (alias).
Definition: Vector4.hh:159
double pT() const
Calculate the transverse momentum .
Definition: Vector4.hh:628
Abs pseudorapidity greater-than functor.
Definition: ParticleBaseUtils.hh:93
double eta() const
Synonym for pseudorapidity.
Definition: Vector4.hh:152
Pseudorapidity less-than functor.
Definition: ParticleBaseUtils.hh:73
Base type for Particle -> double functors.
Definition: ParticleBaseUtils.hh:400
double absrap() const
Absolute rapidity.
Definition: Vector4.hh:605
(with respect to another momentum, vec) greater-than functor
Definition: ParticleBaseUtils.hh:348
(with respect to another momentum, vec) greater-than functor
Definition: ParticleBaseUtils.hh:296
function< bool(const ParticleBase &, const ParticleBase &)> ParticleBaseSorter
std::function instantiation for functors taking two ParticleBase and returning a bool ...
Definition: ParticleBaseUtils.hh:21
Abs pseudorapidity momentum less-than functor.
Definition: ParticleBaseUtils.hh:103
const FourMomentum & mom() const
Get equivalent single momentum four-vector (const) (alias).
Definition: ParticleBase.hh:39
double abseta() const
Get the directly (alias).
Definition: ParticleBase.hh:91
Vector3 p3() const
Get 3-momentum part, .
Definition: Vector4.hh:578
Pseudorapidity in-range functor.
Definition: ParticleBaseUtils.hh:82
Abs rapidity in-range functor.
Definition: ParticleBaseUtils.hh:174
function< bool(const ParticleBase &)> ParticleBaseSelector
std::function instantiation for functors taking a ParticleBase and returning a bool ...
Definition: ParticleBaseUtils.hh:19
Base type for Particle -> bool functors.
Definition: ParticleBaseUtils.hh:25
double mass() const
Get the mass directly.
Definition: ParticleBase.hh:80
(with respect to another 4-momentum, vec) greater-than functor
Definition: ParticleBaseUtils.hh:189
double deltaEta(double eta1, double eta2, bool sign=false)
Definition: MathUtils.hh:586
(with respect to another 4-momentum, vec) in-range functor
Definition: ParticleBaseUtils.hh:272
Calculator of with respect to a given momentum.
Definition: ParticleBaseUtils.hh:419
Transverse momentum in-range functor.
Definition: ParticleBaseUtils.hh:52
double Et() const
Get the directly.
Definition: ParticleBase.hh:75
(with respect to another momentum, vec) less-than functor
Definition: ParticleBaseUtils.hh:360
double deltaPhi(double phi1, double phi2, bool sign=false)
Calculate the difference between two angles in radians.
Definition: MathUtils.hh:578
double rap() const
Get the directly (alias).
Definition: ParticleBase.hh:96
Transverse momentum greater-than functor.
Definition: ParticleBaseUtils.hh:32
Calculator of with respect to a given momentum.
Definition: ParticleBaseUtils.hh:431
Rapidity in-range functor.
Definition: ParticleBaseUtils.hh:143
Vector3 pTvec() const
Get the transverse 3-momentum directly.
Definition: ParticleBase.hh:117
Pseudorapidity greater-than functor.
Definition: ParticleBaseUtils.hh:64
Abs rapidity greater-than functor.
Definition: ParticleBaseUtils.hh:154
Vector3 p3() const
Get the 3-momentum directly.
Definition: ParticleBase.hh:108
double pT() const
Get the directly (alias).
Definition: ParticleBase.hh:63
Calculator of with respect to a given momentum.
Definition: ParticleBaseUtils.hh:465
Calculator of with respect to a given momentum.
Definition: ParticleBaseUtils.hh:406
(with respect to another 4-momentum, vec) less-than functor
Definition: ParticleBaseUtils.hh:204
Base class for particle-like things like Particle and Jet.
Definition: ParticleBase.hh:13
double deltaRap(double y1, double y2, bool sign=false)
Definition: MathUtils.hh:594
(with respect to another momentum, vec) less-than functor
Definition: ParticleBaseUtils.hh:310
double deltaR(double rap1, double phi1, double rap2, double phi2)
Definition: MathUtils.hh:608
Abs rapidity momentum less-than functor.
Definition: ParticleBaseUtils.hh:164
double absrap() const
Get the directly (alias).
Definition: ParticleBase.hh:100
RapScheme
Enum for rapidity variable to be used in calculating , applying rapidity cuts, etc.
Definition: MathConstants.hh:46
Vector3 vector3() const
Get the spatial part of the 4-vector as a 3-vector.
Definition: Vector4.hh:162
Abs pseudorapidity in-range functor.
Definition: ParticleBaseUtils.hh:113
Calculator of with respect to a given momentum.
Definition: ParticleBaseUtils.hh:455
Transverse momentum less-than functor.
Definition: ParticleBaseUtils.hh:42
Jets & ifilter_select(Jets &jets, const Cut &c)
Filter a jet collection in-place to the subset that passes the supplied Cut.
double eta() const
Get the directly (alias).
Definition: ParticleBase.hh:87
Rapidity greater-than functor.
Definition: ParticleBaseUtils.hh:125
(with respect to another 4-momentum, vec) in-range functor
Definition: ParticleBaseUtils.hh:219
Three-dimensional specialisation of Vector.
Definition: Vector3.hh:26
(with respect to another momentum, vec) less-than functor
Definition: ParticleBaseUtils.hh:258
(with respect to another momentum, vec) greater-than functor
Definition: ParticleBaseUtils.hh:244
Calculator of with respect to a given momentum.
Definition: ParticleBaseUtils.hh:443
Specialized version of the FourVector with momentum/energy functionality.
Definition: Vector4.hh:301
Jets & ifilter_discard(Jets &jets, const Cut &c)
Filter a jet collection in-place to the subset that fails the supplied Cut.
double p() const
Get the 3-momentum magnitude directly.
Definition: ParticleBase.hh:110
double rap() const
Alias for rapidity.
Definition: Vector4.hh:596
double mod() const
Calculate the modulus of a vector. .
Definition: VectorN.hh:95
(with respect to another 4-momentum, vec) in-range functor
Definition: ParticleBaseUtils.hh:324
(with respect to another 4-momentum, vec) in-range functor
Definition: ParticleBaseUtils.hh:372
Rapidity momentum less-than functor.
Definition: ParticleBaseUtils.hh:134