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 inline void idiscardIfAny(PBCONTAINER1& tofilter,
const PBCONTAINER2& tocompare,
482 typename std::function<
bool(
const typename PBCONTAINER1::value_type&,
483 const typename PBCONTAINER2::value_type&)> fn) {
484 for (
const auto& pbcmp : tocompare) {
485 ifilter_discard(tofilter, [&](
const typename PBCONTAINER1::value_type& pbfilt){
return fn(pbfilt, pbcmp); });
489 template<
typename PBCONTAINER1,
typename PBCONTAINER2>
490 inline PBCONTAINER1 discardIfAny(
const PBCONTAINER1& tofilter,
const PBCONTAINER2& tocompare,
491 typename std::function<
bool(
const typename PBCONTAINER1::value_type&,
492 const typename PBCONTAINER2::value_type&)> fn) {
493 PBCONTAINER1 tmp{tofilter};
494 idiscardIfAny(tmp, tocompare, fn);
499 template<
typename PBCONTAINER1,
typename PBCONTAINER2>
500 inline PBCONTAINER1 selectIfAny(
const PBCONTAINER1& tofilter,
const PBCONTAINER2& tocompare,
501 typename std::function<
bool(
const typename PBCONTAINER1::value_type&,
502 const typename PBCONTAINER2::value_type&)> fn) {
503 PBCONTAINER1 selected;
504 for (
const auto& pbfilt : tofilter) {
505 if (
any(tocompare, [&](
const typename PBCONTAINER2::value_type& pbcmp){
return fn(pbfilt, pbcmp); })) {
512 template<
typename PBCONTAINER1,
typename PBCONTAINER2>
513 inline void iselectIfAny(PBCONTAINER1& tofilter,
const PBCONTAINER2& tocompare,
514 typename std::function<
bool(
const typename PBCONTAINER1::value_type&,
515 const typename PBCONTAINER2::value_type&)> fn) {
516 tofilter = selectIfAny(tofilter, tocompare, fn);
521 template<
typename PBCONTAINER1,
typename PBCONTAINER2>
522 inline PBCONTAINER1 discardIfAll(
const PBCONTAINER1& tofilter,
const PBCONTAINER2& tocompare,
523 typename std::function<
bool(
const typename PBCONTAINER1::value_type&,
524 const typename PBCONTAINER2::value_type&)> fn) {
525 PBCONTAINER1 selected;
526 for (
const auto& pbfilt : tofilter) {
527 if (!
all(tocompare, [&](
const typename PBCONTAINER2::value_type& pbcmp){
return fn(pbfilt, pbcmp); })) {
534 template<
typename PBCONTAINER1,
typename PBCONTAINER2>
535 inline void idiscardIfAll(PBCONTAINER1& tofilter,
const PBCONTAINER2& tocompare,
536 typename std::function<
bool(
const typename PBCONTAINER1::value_type&,
537 const typename PBCONTAINER2::value_type&)> fn) {
538 tofilter = discardIfAll(tofilter, tocompare, fn);
542 template<
typename PBCONTAINER1,
typename PBCONTAINER2>
543 inline PBCONTAINER1 selectIfAll(
const PBCONTAINER1& tofilter,
const PBCONTAINER2& tocompare,
544 typename std::function<
bool(
const typename PBCONTAINER1::value_type&,
545 const typename PBCONTAINER2::value_type&)> fn) {
546 PBCONTAINER1 selected;
547 for (
const auto& pbfilt : tofilter) {
548 if (
all(tocompare, [&](
const typename PBCONTAINER2::value_type& pbcmp){
return fn(pbfilt, pbcmp); })) {
555 template<
typename PBCONTAINER1,
typename PBCONTAINER2>
556 inline void iselectIfAll(PBCONTAINER1& tofilter,
const PBCONTAINER2& tocompare,
557 typename std::function<
bool(
const typename PBCONTAINER1::value_type&,
558 const typename PBCONTAINER2::value_type&)> fn) {
559 tofilter = selectIfAll(tofilter, tocompare, fn);
568 template<
typename PBCONTAINER1,
typename PBCONTAINER2>
569 inline void idiscardIfAnyDeltaRLess(PBCONTAINER1& tofilter,
const PBCONTAINER2& tocompare,
double dR) {
570 for (
const typename PBCONTAINER2::value_type& pb : tocompare) {
575 template<
typename PBCONTAINER1,
typename PBCONTAINER2>
576 inline PBCONTAINER1 discardIfAnyDeltaRLess(
const PBCONTAINER1& tofilter,
const PBCONTAINER2& tocompare,
double dR) {
577 PBCONTAINER1 tmp{tofilter};
578 idiscardIfAnyDeltaRLess(tmp, tocompare, dR);
582 template<
typename PBCONTAINER1,
typename PBCONTAINER2>
583 inline void idiscardIfAnyDeltaPhiLess(PBCONTAINER1& tofilter,
const PBCONTAINER2& tocompare,
double dphi) {
584 for (
const typename PBCONTAINER2::value_type& pb : tocompare) {
589 template<
typename PBCONTAINER1,
typename PBCONTAINER2>
590 inline PBCONTAINER1 discardIfAnyDeltaPhiLess(
const PBCONTAINER1& tofilter,
const PBCONTAINER2& tocompare,
double dphi) {
591 PBCONTAINER1 tmp{tofilter};
592 idiscardIfAnyDeltaPhiLess(tmp, tocompare, dphi);
598 template<
typename PBCONTAINER1,
typename PBCONTAINER2>
599 inline PBCONTAINER1 selectIfAnyDeltaRLess(
const PBCONTAINER1& tofilter,
const PBCONTAINER2& tocompare,
double dR) {
600 PBCONTAINER1 selected;
601 for (
const typename PBCONTAINER1::value_type& f : tofilter) {
602 if (
any(tocompare,
deltaRLess(f, dR))) selected.push_back(f);
607 template<
typename PBCONTAINER1,
typename PBCONTAINER2>
608 inline void iselectIfAnyDeltaRLess(PBCONTAINER1& tofilter,
const PBCONTAINER2& tocompare,
double dR) {
609 tofilter = selectIfAnyDeltaRLess(tofilter, tocompare, dR);
613 template<
typename PBCONTAINER1,
typename PBCONTAINER2>
614 inline PBCONTAINER1 selectIfAnyDeltaPhiLess(
const PBCONTAINER1& tofilter,
const PBCONTAINER2& tocompare,
double dphi) {
615 PBCONTAINER1 selected;
616 for (
const typename PBCONTAINER1::value_type& f : tofilter) {
622 template<
typename PBCONTAINER1,
typename PBCONTAINER2>
623 inline void iselectIfAnyDeltaPhiLess(PBCONTAINER1& tofilter,
const PBCONTAINER2& tocompare,
double dphi) {
624 tofilter = selectIfAnyDeltaPhiLess(tofilter, 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
bool any(const CONTAINER &c)
Return true if x is true for any x in container c, otherwise false.
Definition: Utils.hh:323
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:637
(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:629
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:645
(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:659
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
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
bool all(const CONTAINER &c)
Return true if x is true for all x in container c, otherwise false.
Definition: Utils.hh:345
(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