Rivet API documentation

Rivet 4.1.3
ParticleUtils.hh
1#ifndef RIVET_PARTICLEUTILS_HH
2#define RIVET_PARTICLEUTILS_HH
3
4#include "Rivet/Particle.hh"
5#include "Rivet/Tools/ParticleBaseUtils.hh"
6#include "Rivet/Tools/ParticleIdUtils.hh"
7
8// Macros to map Rivet::Particle functions to PID:: functions of the same name
9#define PARTICLE_TO_PID_BOOLFN(fname) inline bool fname (const Particle& p) { return PID:: fname (p.pid()); }
10#define PARTICLE_TO_PID_INTFN(fname) inline int fname (const Particle& p) { return PID:: fname (p.pid()); }
11#define PARTICLE_TO_PID_DBLFN(fname) inline double fname (const Particle& p) { return PID:: fname (p.pid()); }
12
13namespace Rivet {
14
15
18
21
23 inline int pid(const Particle& p) {
24 return p.pid();
25 }
26
28 inline int abspid(const Particle& p) {
29 return p.abspid();
30 }
31
32
34 PARTICLE_TO_PID_BOOLFN(isCharged)
35
36
37 PARTICLE_TO_PID_BOOLFN(isNeutral)
38
39
40
41 PARTICLE_TO_PID_BOOLFN(isNeutrino)
42
43
44 PARTICLE_TO_PID_BOOLFN(isChargedLepton)
45
46
47 PARTICLE_TO_PID_BOOLFN(isLepton)
48
49
50 PARTICLE_TO_PID_BOOLFN(isPhoton)
51
52
53 PARTICLE_TO_PID_BOOLFN(isElectron)
54
55
56 PARTICLE_TO_PID_BOOLFN(isMuon)
57
58
59 PARTICLE_TO_PID_BOOLFN(isTau)
60
61
62 PARTICLE_TO_PID_BOOLFN(isHadron)
63
64
65 PARTICLE_TO_PID_BOOLFN(isMeson)
66
67
68 PARTICLE_TO_PID_BOOLFN(isBaryon)
69
70
71 PARTICLE_TO_PID_BOOLFN(isQuark)
72
73
74 PARTICLE_TO_PID_BOOLFN(isParton)
75
76
77
78 PARTICLE_TO_PID_BOOLFN(isWplus)
79
80
81 PARTICLE_TO_PID_BOOLFN(isWminus)
82
83
84 PARTICLE_TO_PID_BOOLFN(isW)
85
86
87 PARTICLE_TO_PID_BOOLFN(isZ)
88
89
90 PARTICLE_TO_PID_BOOLFN(isHiggs)
91
92
93 PARTICLE_TO_PID_BOOLFN(isStrange)
94
95
96 PARTICLE_TO_PID_BOOLFN(isCharm)
97
98
99 PARTICLE_TO_PID_BOOLFN(isBottom)
100
101
102 PARTICLE_TO_PID_BOOLFN(isTop)
103
104
105
106 PARTICLE_TO_PID_BOOLFN(isHeavyFlavour)
107
108
109 PARTICLE_TO_PID_BOOLFN(isHeavyParton)
110
111
112 PARTICLE_TO_PID_BOOLFN(isLightParton)
113
114
115
116 PARTICLE_TO_PID_BOOLFN(isHeavyMeson)
117
118
119 PARTICLE_TO_PID_BOOLFN(isHeavyBaryon)
120
121
122 PARTICLE_TO_PID_BOOLFN(isHeavyHadron)
123
124
125
126 PARTICLE_TO_PID_BOOLFN(isLightMeson)
127
128
129 PARTICLE_TO_PID_BOOLFN(isLightBaryon)
130
131
132 PARTICLE_TO_PID_BOOLFN(isLightHadron)
133
134
135
136 PARTICLE_TO_PID_BOOLFN(isBottomMeson)
137
138
139 PARTICLE_TO_PID_BOOLFN(isBottomBaryon)
140
141
142 PARTICLE_TO_PID_BOOLFN(isBottomHadron)
143
144
145
149 PARTICLE_TO_PID_BOOLFN(isCharmMeson)
150
151
156 PARTICLE_TO_PID_BOOLFN(isCharmBaryon)
157
158
159 PARTICLE_TO_PID_BOOLFN(isCharmHadron)
160
161
162 // /// Determine if the PID is that of a strange meson
163 // PARTICLE_TO_PID_BOOLFN(isStrangeMeson)
164
165 // /// Determine if the PID is that of a strange baryon
166 // PARTICLE_TO_PID_BOOLFN(isStrangeBaryon)
167
168 // /// Determine if the PID is that of a strange hadron
169 // PARTICLE_TO_PID_BOOLFN(isStrangeHadron)
170
171
172
173 PARTICLE_TO_PID_BOOLFN(isReggeon)
174
175
176 PARTICLE_TO_PID_BOOLFN(isDiquark)
177
178
179 PARTICLE_TO_PID_BOOLFN(isPentaquark)
180
181
182 PARTICLE_TO_PID_BOOLFN(isSUSY)
183
184
185 PARTICLE_TO_PID_BOOLFN(isRhadron)
186
187
188 PARTICLE_TO_PID_BOOLFN(isTechnicolor)
189
190
191 PARTICLE_TO_PID_BOOLFN(isExcited)
192
193
194 PARTICLE_TO_PID_BOOLFN(isKK)
195
196
197 PARTICLE_TO_PID_BOOLFN(isGraviton)
198
199
200 PARTICLE_TO_PID_BOOLFN(isBSM)
201
202
203
204 PARTICLE_TO_PID_BOOLFN(isGenSpecific)
205
206
207 PARTICLE_TO_PID_BOOLFN(isResonance)
208
209
210 PARTICLE_TO_PID_BOOLFN(isTransportable)
211
212
213
214 PARTICLE_TO_PID_BOOLFN(hasUp)
215
216
217 PARTICLE_TO_PID_BOOLFN(hasDown)
218
219
220 PARTICLE_TO_PID_BOOLFN(hasStrange)
221
222
223 PARTICLE_TO_PID_BOOLFN(hasCharm)
224
225
226 PARTICLE_TO_PID_BOOLFN(hasBottom)
227
228
229 PARTICLE_TO_PID_BOOLFN(hasTop)
230
231
232
233 PARTICLE_TO_PID_INTFN(jSpin)
234
235
236 PARTICLE_TO_PID_INTFN(sSpin)
237
238
239 PARTICLE_TO_PID_INTFN(lSpin)
240
241
242
243 PARTICLE_TO_PID_DBLFN(charge)
244
245
246 PARTICLE_TO_PID_INTFN(charge3)
247
248
249 PARTICLE_TO_PID_DBLFN(abscharge)
250
251
252 PARTICLE_TO_PID_INTFN(abscharge3)
253
254
255 PARTICLE_TO_PID_INTFN(nuclZ)
256
257
258 PARTICLE_TO_PID_INTFN(nuclA)
259
260
261 PARTICLE_TO_PID_INTFN(nuclNlambda)
262
263
264
265
266
270
271 inline bool isSameSign(const Particle& a, const Particle& b) {
272 return PID::isSameSign(a.pid(), b.pid());
273 }
274 inline bool isOppSign(const Particle& a, const Particle& b) {
275 return PID::isOppSign(a.pid(), b.pid());
276 }
277 inline bool isSameFlav(const Particle& a, const Particle& b) {
278 return PID::isSameFlav(a.pid(), b.pid());
279 }
280 inline bool isOppFlav(const Particle& a, const Particle& b) {
281 return PID::isOppFlav(a.pid(), b.pid());
282 }
283
284 inline bool isOSSF(const Particle& a, const Particle& b) {
285 return PID::isOSSF(a.pid(), b.pid());
286 }
287 inline bool isSSSF(const Particle& a, const Particle& b) {
288 return PID::isSSSF(a.pid(), b.pid());
289 }
290 inline bool isOSOF(const Particle& a, const Particle& b) {
291 return PID::isOSOF(a.pid(), b.pid());
292 }
293 inline bool isSSOF(const Particle& a, const Particle& b) {
294 return PID::isSSOF(a.pid(), b.pid());
295 }
296
298
299
302
305 inline bool oppSign(const Particle& a, const Particle& b) {
306 return sign(a.charge3()) == -sign(b.charge3()) && sign(a.charge3()) != ZERO;
307 }
308
311 inline bool sameSign(const Particle& a, const Particle& b) {
312 return sign(a.charge3()) == sign(b.charge3());
313 }
314
317 inline bool oppCharge(const Particle& a, const Particle& b) {
318 return a.charge3() == -b.charge3() && a.charge3() != 0;
319 }
320
323 inline bool sameCharge(const Particle& a, const Particle& b) {
324 return a.charge3() == b.charge3();
325 }
326
328 inline bool diffCharge(const Particle& a, const Particle& b) {
329 return a.charge3() != b.charge3();
330 }
331
333
334
336
337
340
342 inline bool isFirstWith(const Particle& p, const ParticleSelector& f) {
343 return p.isFirstWith(f);
344 }
345
347 inline bool isFirstWithout(const Particle& p, const ParticleSelector& f) {
348 return p.isFirstWithout(f);
349 }
350
351
353 inline bool isLastWith(const Particle& p, const ParticleSelector& f) {
354 return p.isLastWith(f);
355 }
356
358 inline bool isLastWithout(const Particle& p, const ParticleSelector& f) {
359 return p.isLastWithout(f);
360 }
361
362
364 inline bool hasAncestorWith(const Particle& p, const ParticleSelector& f, bool only_physical = true) {
365 return p.hasAncestorWith(f, only_physical);
366 }
367
369 inline bool hasAncestorWithout(const Particle& p, const ParticleSelector& f, bool only_physical = true) {
370 return p.hasAncestorWithout(f, only_physical);
371 }
372
373
375 inline bool hasParentWith(const Particle& p, const ParticleSelector& f) {
376 return p.hasParentWith(f);
377 }
378
380 inline bool hasParentWithout(const Particle& p, const ParticleSelector& f) {
381 return p.hasParentWithout(f);
382 }
383
384
386 inline bool hasChildWith(const Particle& p, const ParticleSelector& f) {
387 return p.hasChildWith(f);
388 }
389
391 inline bool hasChildWithout(const Particle& p, const ParticleSelector& f) {
392 return p.hasChildWithout(f);
393 }
394
395
397 inline bool hasDescendantWith(const Particle& p, const ParticleSelector& f, bool remove_duplicates = true) {
398 return p.hasDescendantWith(f, remove_duplicates);
399 }
400
402 inline bool hasDescendantWithout(const Particle& p,
403 const ParticleSelector& f,
404 bool remove_duplicates = true) {
405 return p.hasDescendantWithout(f, remove_duplicates);
406 }
407
408
410 inline bool hasStableDescendantWith(const Particle& p, const ParticleSelector& f) {
411 return p.hasStableDescendantWith(f);
412 }
413
415 inline bool hasStableDescendantWithout(const Particle& p, const ParticleSelector& f) {
416 return p.hasStableDescendantWithout(f);
417 }
418
419
421 inline bool isVisible(const Particle& p) {
422 return p.isVisible();
423 }
424
433 inline bool isDirect(const Particle& p,
434 bool allow_from_direct_tau = false,
435 bool allow_from_direct_mu = false) {
436 return p.isDirect(allow_from_direct_tau, allow_from_direct_mu);
437 }
438
443 inline bool isPrompt(const Particle& p,
444 bool allow_from_prompt_tau = false,
445 bool allow_from_prompt_mu = false) {
446 return p.isPrompt(allow_from_prompt_tau, allow_from_prompt_mu);
447 }
448
449
451 inline bool isStable(const Particle& p) {
452 return p.isStable();
453 }
454
456 inline bool hasHadronicDecay(const Particle& p) {
457 if (p.isStable()) return false;
458 if (p.hasChildWith(isHadron)) return true;
459 return false;
460 }
461
463 inline bool hasLeptonicDecay(const Particle& p) {
464 if (p.isStable()) return false;
465 if (p.hasChildWith(isHadron)) return false;
466 return true;
467 }
468
469
471 inline bool fromBottom(const Particle& p) {
472 return p.fromBottom();
473 }
474
476 inline bool fromCharm(const Particle& p) {
477 return p.fromCharm();
478 }
479
481 inline bool fromHadron(const Particle& p) {
482 return p.fromHadron();
483 }
484
486 inline bool fromTau(const Particle& p, bool prompt_taus_only = false) {
487 return p.fromTau(prompt_taus_only);
488 }
489
491 inline bool fromPromptTau(const Particle& p) {
492 return p.fromPromptTau();
493 }
494
496
497
502
505 virtual bool operator()(const Particle& p) const = 0;
506 virtual ~BoolParticleFunctor() { }
507 };
508
510 struct BoolParticleAND : public BoolParticleFunctor {
511 BoolParticleAND(const std::vector<ParticleSelector>& sels)
512 : selectors(sels) { }
513 BoolParticleAND(const ParticleSelector& a, const ParticleSelector& b)
514 : selectors({a, b}) { }
515 BoolParticleAND(const ParticleSelector& a, const ParticleSelector& b, const ParticleSelector& c)
516 : selectors({a, b, c}) { }
517 bool operator()(const Particle& p) const {
518 for (const ParticleSelector& sel : selectors)
519 if (!sel(p)) return false;
520 return true;
521 }
522 std::vector<ParticleSelector> selectors;
523 };
524
525 inline BoolParticleAND operator&&(const ParticleSelector& a, const ParticleSelector& b) {
526 return BoolParticleAND(a, b);
527 }
528
529
531 struct BoolParticleOR : public BoolParticleFunctor {
532 BoolParticleOR(const std::vector<ParticleSelector>& sels)
533 : selectors(sels) { }
534 BoolParticleOR(const ParticleSelector& a, const ParticleSelector& b)
535 : selectors({a, b}) { }
536 BoolParticleOR(const ParticleSelector& a, const ParticleSelector& b, const ParticleSelector& c)
537 : selectors({a, b, c}) { }
538 bool operator()(const Particle& p) const {
539 for (const ParticleSelector& sel : selectors)
540 if (sel(p)) return true;
541 return false;
542 }
543 std::vector<ParticleSelector> selectors;
544 };
545
546 inline BoolParticleOR operator||(const ParticleSelector& a, const ParticleSelector& b) {
547 return BoolParticleOR(a, b);
548 }
549
551 struct BoolParticleNOT : public BoolParticleFunctor {
552 BoolParticleNOT(const ParticleSelector& sel)
553 : selector(sel) { }
554 bool operator()(const Particle& p) const {
555 return !selector(p);
556 }
557 ParticleSelector selector;
558 };
559
560 inline BoolParticleNOT operator!(const ParticleSelector& a) {
561 return BoolParticleNOT(a);
562 }
563
564
566 struct HasPID : public BoolParticleFunctor {
567 HasPID(PdgId pid)
568 : targetpids{pid} { }
569 HasPID(vector<PdgId> pids)
570 : targetpids{pids} { }
571 HasPID(initializer_list<PdgId> pids)
572 : targetpids{pids} { }
573 bool operator()(const Particle& p) const {
574 return contains(targetpids, p.pid());
575 }
576 vector<PdgId> targetpids;
577 };
578 using hasPID = HasPID;
579
581 struct HasAbsPID : public BoolParticleFunctor {
582 HasAbsPID(PdgId pid)
583 : targetapids{abs(pid)} { }
584 HasAbsPID(vector<PdgId> pids) {
585 for (PdgId pid : pids) targetapids.push_back(abs(pid));
586 }
587 HasAbsPID(initializer_list<PdgId> pids) {
588 for (PdgId pid : pids) targetapids.push_back(abs(pid));
589 }
590 bool operator()(const Particle& p) const {
591 return contains(targetapids, p.abspid());
592 }
593 vector<PdgId> targetapids;
594 };
595 using hasAbsPID = HasAbsPID;
596
597
599 struct FirstParticleWith : public BoolParticleFunctor {
600 FirstParticleWith(const ParticleSelector& f)
601 : fn(f) { }
602 FirstParticleWith(const Cut& c);
603 bool operator()(const Particle& p) const {
604 return isFirstWith(p, fn);
605 }
606 ParticleSelector fn;
607 };
608 using firstParticleWith = FirstParticleWith;
609
611 struct FirstParticleWithout : public BoolParticleFunctor {
612 FirstParticleWithout(const ParticleSelector& f)
613 : fn(f) { }
614 FirstParticleWithout(const Cut& c);
615 bool operator()(const Particle& p) const {
616 return isFirstWithout(p, fn);
617 }
618 ParticleSelector fn;
619 };
620 using firstParticleWithout = FirstParticleWithout;
621
622
624 struct LastParticleWith : public BoolParticleFunctor {
625 template <typename FN>
626 LastParticleWith(const FN& f)
627 : fn(f) { }
628 LastParticleWith(const Cut& c);
629 bool operator()(const Particle& p) const {
630 return isLastWith(p, fn);
631 }
632 std::function<bool(const Particle&)> fn;
633 };
634 using lastParticleWith = LastParticleWith;
635
637 struct LastParticleWithout : public BoolParticleFunctor {
638 LastParticleWithout(const ParticleSelector& f)
639 : fn(f) { }
640 LastParticleWithout(const Cut& c);
641 bool operator()(const Particle& p) const {
642 return isLastWithout(p, fn);
643 }
644 ParticleSelector fn;
645 };
646 using lastParticleWithout = LastParticleWithout;
647
648
650 struct HasParticleAncestorWith : public BoolParticleFunctor {
651 HasParticleAncestorWith(const ParticleSelector& f, bool only_physical = true)
652 : fn(f), onlyphysical(only_physical) { }
653 HasParticleAncestorWith(const Cut& c, bool only_physical = true);
654 bool operator()(const Particle& p) const {
655 return hasAncestorWith(p, fn, onlyphysical);
656 }
657 ParticleSelector fn;
658 bool onlyphysical;
659 };
660 using hasParticleAncestorWith = HasParticleAncestorWith;
661
663 struct HasParticleAncestorWithout : public BoolParticleFunctor {
664 HasParticleAncestorWithout(const ParticleSelector& f, bool only_physical = true)
665 : fn(f), onlyphysical(only_physical) { }
666 HasParticleAncestorWithout(const Cut& c, bool only_physical = true);
667 bool operator()(const Particle& p) const {
668 return hasAncestorWithout(p, fn, onlyphysical);
669 }
670 ParticleSelector fn;
671 bool onlyphysical;
672 };
673 using hasParticleAncestorWithout = HasParticleAncestorWithout;
674
675
677 struct HasParticleParentWith : public BoolParticleFunctor {
678 HasParticleParentWith(const ParticleSelector& f)
679 : fn(f) { }
680 HasParticleParentWith(const Cut& c);
681 bool operator()(const Particle& p) const {
682 return hasParentWith(p, fn);
683 }
684 ParticleSelector fn;
685 };
686 using hasParticleParentWith = HasParticleParentWith;
687
689 struct HasParticleParentWithout : public BoolParticleFunctor {
690 HasParticleParentWithout(const ParticleSelector& f)
691 : fn(f) { }
692 HasParticleParentWithout(const Cut& c);
693 bool operator()(const Particle& p) const {
694 return hasParentWithout(p, fn);
695 }
696 ParticleSelector fn;
697 };
698 using hasParticleParentWithout = HasParticleParentWithout;
699
700
702 struct HasParticleChildWith : public BoolParticleFunctor {
703 HasParticleChildWith(const ParticleSelector& f)
704 : fn(f) { }
705 HasParticleChildWith(const Cut& c);
706 bool operator()(const Particle& p) const {
707 return hasChildWith(p, fn);
708 }
709 ParticleSelector fn;
710 };
711 using hasParticleChildWith = HasParticleChildWith;
712
714 struct HasParticleChildWithout : public BoolParticleFunctor {
715 HasParticleChildWithout(const ParticleSelector& f)
716 : fn(f) { }
717 HasParticleChildWithout(const Cut& c);
718 bool operator()(const Particle& p) const {
719 return hasChildWithout(p, fn);
720 }
721 ParticleSelector fn;
722 };
723 using hasParticleChildWithout = HasParticleChildWithout;
724
725
727 struct HasParticleDescendantWith : public BoolParticleFunctor {
728 HasParticleDescendantWith(const ParticleSelector& f, bool remove_duplicates = true)
729 : fn(f), rmduplicates(remove_duplicates) { }
730 HasParticleDescendantWith(const Cut& c, bool remove_duplicates = true);
731 bool operator()(const Particle& p) const {
732 return hasDescendantWith(p, fn, rmduplicates);
733 }
734 ParticleSelector fn;
735 bool rmduplicates;
736 };
737 using hasParticleDescendantWith = HasParticleDescendantWith;
738
740 struct HasParticleDescendantWithout : public BoolParticleFunctor {
741 HasParticleDescendantWithout(const ParticleSelector& f, bool remove_duplicates = true)
742 : fn(f), rmduplicates(remove_duplicates) { }
743 HasParticleDescendantWithout(const Cut& c, bool remove_duplicates = true);
744 bool operator()(const Particle& p) const {
745 return hasDescendantWithout(p, fn, rmduplicates);
746 }
747 ParticleSelector fn;
748 bool rmduplicates;
749 };
750 using hasParticleDescendantWithout = HasParticleDescendantWithout;
751
753
754
757
759 Particles& iselect(Particles& particles, const Cut& c);
760
762 inline Particles select(const Particles& particles, const Cut& c) {
763 Particles rtn = particles;
764 return iselect(rtn, c);
765 }
766
768 inline Particles select(const Particles& particles, const Cut& c, Particles& out) {
769 out = select(particles, c);
770 return out;
771 }
772
774 Particles& idiscard(Particles& particles, const Cut& c);
775
777 inline Particles discard(const Particles& particles, const Cut& c) {
778 Particles rtn = particles;
779 return idiscard(rtn, c);
780 }
781
783 inline Particles discard(const Particles& particles, const Cut& c, Particles& out) {
784 out = discard(particles, c);
785 return out;
786 }
787
788
789 // inline void ifilterIsolateDeltaR(Particles& particles, const FourMomenta& vecs) {
790 // ifilter_discard(particles,
791 // }
792
793
794 // inline Particles filterIsolateDeltaR(const Particles& particles, const FourMomenta& vecs) {
795 // }
796
798
799
802
804 inline PdgIdPair pids(const ParticlePair& pp) {
805 return make_pair(pp.first.pid(), pp.second.pid());
806 }
807
808 namespace Kin {
809
811 inline pair<double, double> energies(const ParticlePair& pp) {
812 return make_pair(pp.first.E(), pp.second.E());
813 }
814
816 inline pair<FourMomentum, FourMomentum> moms(const ParticlePair& pp) {
817 return make_pair(pp.first.mom(), pp.second.mom());
818 }
819
821 inline double mass(const ParticlePair& pp) {
822 return mass(pp.first, pp.second);
823 }
824
826 inline double mass2(const ParticlePair& pp) {
827 return mass2(pp.first, pp.second);
828 }
829
831 inline double mT(const ParticlePair& pp) {
832 return mT(pp.first, pp.second);
833 }
834
836 inline double pT(const ParticlePair& pp) {
837 return pT(pp.first, pp.second);
838 }
839
840 }
841
843
844
850
851 namespace Kin {
852
854 inline double mass(const Particle& p, const FourMomentum& p4) {
855 return mass(p.mom(), p4);
856 }
857
859 inline double mass(const FourMomentum& p4, const Particle& p) {
860 return mass(p4, p.mom());
861 }
862
864 inline double mass(const Particle& p1, const Particle& p2) {
865 return mass(p1.mom(), p2.mom());
866 }
867
869 inline double mass2(const Particle& p, const P4& p4) {
870 return mass2(p.mom(), p4);
871 }
872
874 inline double mass2(const P4& p4, const Particle& p) {
875 return mass2(p4, p.mom());
876 }
877
879 inline double mass2(const Particle& p1, const Particle& p2) {
880 return mass2(p1.mom(), p2.mom());
881 }
882
884 inline double pT(const Particle& p, const P4& p4) {
885 return pT(p.mom(), p4);
886 }
887
889 inline double pT(const P4& p4, const Particle& p) {
890 return pT(p4, p.mom());
891 }
892
894 inline double pT(const Particle& p1, const Particle& p2) {
895 return pT(p1.mom(), p2.mom());
896 }
897
898 }
899
901
902
910 namespace Kin {
911
913 inline double pT(const Particle& p) {
914 return p.pT();
915 }
916
917 inline double sumPt(const Particles& ps) {
918 return sum(ps, Kin::pT, 0.0);
919 }
920
921 inline FourMomentum sumP4(const Particles& ps) {
922 return sum(ps, Kin::p4, FourMomentum());
923 }
924
925 inline Vector3 sumP3(const Particles& ps) {
926 return sum(ps, Kin::p3, Vector3());
927 }
928
930
932
933 }
934
935
936 // Import Kin namespace into Rivet
937 using namespace Kin;
938
939
941 inline bool isSame(const Particle& a, const Particle& b) {
942 return a.isSame(b);
943 }
944
946
947
950 inline bool containsPID(const Particles& parts, int id, bool abs = false) {
951 if (abs) return any(parts, HasAbsPID(id));
952 return any(parts, HasPID(id));
953 }
954
955
958 inline bool isRadiative(const Particle& part) {
959 const Particles& parents = part.parents();
960 if (parents.size() != 1) return false;
961
962 const Particle& mother = parents[0];
963 return (part.pid() != mother.pid()) && (containsPID(mother.children(), mother.pid()));
964 }
965
966
970 bool cascadeContains(const Particles& parts, const vector<int>& pids, bool absolute, bool ignorephoton);
971
973
974}
975
976#endif
Particle representation, either from a HepMC::GenEvent or reconstructed.
Definition Particle.hh:50
bool isSame(const Particle &other) const
Definition Particle.hh:789
PdgId pid() const
This Particle's PDG ID code.
Definition Particle.hh:221
Particles parents(const Cut &c=Cuts::OPEN) const
Particles children(const Cut &c=Cuts::OPEN) const
Get a list of the direct descendants from the current particle (with optional selection Cut).
int charge3() const
Three times the charge of this Particle (i.e. integer multiple of smallest quark charge).
Definition Particle.hh:246
Specialised vector of Particle objects.
Definition Particle.hh:21
STL class.
bool any(const CONTAINER &c)
Return true if x is true for any x in container c, otherwise false.
Definition Utils.hh:364
Jets & idiscard(Jets &jets, const Cut &c)
Filter a jet collection in-place to the subset that fails the supplied Cut.
Jets select(const Jets &jets, const Cut &c)
Filter a jet collection in-place to the subset that passes the supplied Cut.
Definition JetUtils.hh:183
Jets & iselect(Jets &jets, const Cut &c)
Filter a jet collection in-place to the subset that passes the supplied Cut.
Jets discard(const Jets &jets, const Cut &c)
Filter a jet collection in-place to the subset that fails the supplied Cut.
Definition JetUtils.hh:201
double pT(const ParticleBase &p)
Unbound function access to pT.
Definition ParticleBaseUtils.hh:824
FourMomentum p4(const ParticleBase &p)
Unbound function access to momentum.
Definition ParticleBaseUtils.hh:804
Vector3 p3(const ParticleBase &p)
Unbound function access to p3.
Definition ParticleBaseUtils.hh:809
double mass(const ParticleBase &p)
Unbound function access to mass.
Definition ParticleBaseUtils.hh:859
double mass2(const ParticleBase &p, const P4 &p4)
Get the mass^2 of a ParticleBase and a P4.
Definition ParticleBaseUtils.hh:887
double p(const ParticleBase &p)
Unbound function access to p.
Definition ParticleBaseUtils.hh:819
double mT(const ParticleBase &p, const P4 &p4)
Get the transverse mass of a ParticleBase and a P4.
Definition ParticleBaseUtils.hh:905
bool sameCharge(const Particle &a, const Particle &b)
Definition ParticleUtils.hh:323
bool oppCharge(const Particle &a, const Particle &b)
Definition ParticleUtils.hh:317
bool oppSign(const Particle &a, const Particle &b)
Return true if Particles a and b have the opposite charge sign.
Definition ParticleUtils.hh:305
bool sameSign(const Particle &a, const Particle &b)
Definition ParticleUtils.hh:311
bool diffCharge(const Particle &a, const Particle &b)
Return true if Particles a and b have a different (not necessarily opposite) charge.
Definition ParticleUtils.hh:328
int pid(const Particle &p)
Unbound function access to PID code.
Definition ParticleUtils.hh:23
int abspid(const Particle &p)
Unbound function access to abs PID code.
Definition ParticleUtils.hh:28
bool isSame(const Particle &a, const Particle &b)
Check Particle equivalence.
Definition ParticleUtils.hh:941
bool isVisible(const Particle &p)
Is this particle potentially visible in a detector?
Definition ParticleUtils.hh:421
bool hasParentWith(const Particle &p, const ParticleSelector &f)
Determine whether a particle has a parent which meets the function requirement.
Definition ParticleUtils.hh:375
bool fromHadron(const Particle &p)
Determine whether the particle is from a hadron decay.
Definition ParticleUtils.hh:481
bool hasStableDescendantWith(const Particle &p, const ParticleSelector &f)
Determine whether a particle has a stable descendant which meets the function requirement.
Definition ParticleUtils.hh:410
bool isFirstWithout(const Particle &p, const ParticleSelector &f)
Determine whether a particle is the first in a decay chain not to meet the function requirement.
Definition ParticleUtils.hh:347
bool isLastWithout(const Particle &p, const ParticleSelector &f)
Determine whether a particle is the last in a decay chain not to meet the function requirement.
Definition ParticleUtils.hh:358
bool isDirect(const Particle &p, bool allow_from_direct_tau=false, bool allow_from_direct_mu=false)
Decide if a given particle is direct, via Particle::isDirect().
Definition ParticleUtils.hh:433
bool isFirstWith(const Particle &p, const ParticleSelector &f)
Determine whether a particle is the first in a decay chain to meet the function requirement.
Definition ParticleUtils.hh:342
bool fromTau(const Particle &p, bool prompt_taus_only=false)
Determine whether the particle is from a tau decay.
Definition ParticleUtils.hh:486
bool hasParentWithout(const Particle &p, const ParticleSelector &f)
Determine whether a particle has a parent which doesn't meet the function requirement.
Definition ParticleUtils.hh:380
bool fromPromptTau(const Particle &p)
Determine whether the particle is from a prompt tau decay.
Definition ParticleUtils.hh:491
bool hasChildWithout(const Particle &p, const ParticleSelector &f)
Determine whether a particle has a child which doesn't meet the function requirement.
Definition ParticleUtils.hh:391
bool fromCharm(const Particle &p)
Determine whether the particle is from a c-hadron decay.
Definition ParticleUtils.hh:476
bool hasDescendantWith(const Particle &p, const ParticleSelector &f, bool remove_duplicates=true)
Determine whether a particle has a descendant which meets the function requirement.
Definition ParticleUtils.hh:397
bool hasAncestorWith(const Particle &p, const ParticleSelector &f, bool only_physical=true)
Determine whether a particle has an ancestor which meets the function requirement.
Definition ParticleUtils.hh:364
bool hasHadronicDecay(const Particle &p)
Decide if a given particle decays hadronically.
Definition ParticleUtils.hh:456
bool isStable(const Particle &p)
Decide if a given particle is stable, via Particle::isStable().
Definition ParticleUtils.hh:451
bool hasChildWith(const Particle &p, const ParticleSelector &f)
Determine whether a particle has a child which meets the function requirement.
Definition ParticleUtils.hh:386
bool isPrompt(const Particle &p, bool allow_from_prompt_tau=false, bool allow_from_prompt_mu=false)
Decide if a given particle is prompt, via Particle::isPrompt().
Definition ParticleUtils.hh:443
bool isLastWith(const Particle &p, const ParticleSelector &f)
Determine whether a particle is the last in a decay chain to meet the function requirement.
Definition ParticleUtils.hh:353
bool hasLeptonicDecay(const Particle &p)
Decide if a given particle decays leptonically (decays, and no hadrons).
Definition ParticleUtils.hh:463
bool hasStableDescendantWithout(const Particle &p, const ParticleSelector &f)
Determine whether a particle has a stable descendant which doesn't meet the function requirement.
Definition ParticleUtils.hh:415
bool hasAncestorWithout(const Particle &p, const ParticleSelector &f, bool only_physical=true)
Determine whether a particle has an ancestor which doesn't meet the function requirement.
Definition ParticleUtils.hh:369
bool fromBottom(const Particle &p)
Determine whether the particle is from a b-hadron decay.
Definition ParticleUtils.hh:471
bool hasDescendantWithout(const Particle &p, const ParticleSelector &f, bool remove_duplicates=true)
Determine whether a particle has a descendant which doesn't meet the function requirement.
Definition ParticleUtils.hh:402
PdgIdPair pids(const ParticlePair &pp)
Get the PDG ID codes of a ParticlePair.
Definition ParticleUtils.hh:804
bool isRadiative(const Particle &part)
Check whether a particle is radiative.
Definition ParticleUtils.hh:958
bool containsPID(const Particles &parts, int id, bool abs=false)
Check for pid membership in a list of particles.
Definition ParticleUtils.hh:950
bool cascadeContains(const Particles &parts, const vector< int > &pids, bool absolute, bool ignorephoton)
Check whether a set of particles' decay chains can contain the requested list of pids.
Definition LHCbCommon.hh:9
constexpr std::enable_if_t< std::is_arithmetic_v< NUM >, int > sign(NUM val)
Find the sign of a number.
Definition MathUtils.hh:295
Cut operator!(const Cut &cptr)
Logical NOT operation on a cut.
Cut operator&&(const Cut &aptr, const Cut &bptr)
std::pair< Particle, Particle > ParticlePair
Typedef for a pair of Particle objects.
Definition Particle.hh:43
T sum(const DressedLeptons &c, FN &&fn, const T &start=T())
Generic sum function, adding fn(x) for all x in container c, starting with start.
Definition DressedLepton.hh:66
bool contains(const std::string &s, const std::string &sub)
Does s contain sub as a substring?
Definition RivetSTL.hh:213
Cut operator||(const Cut &aptr, const Cut &bptr)
Functor for and-combination of selector logic.
Definition ParticleUtils.hh:510
Base type for Particle -> bool functors.
Definition ParticleUtils.hh:504
Functor for inverting selector logic.
Definition ParticleUtils.hh:551
Functor for or-combination of selector logic.
Definition ParticleUtils.hh:531
Determine whether a particle is the first in a decay chain to meet the cut/function.
Definition ParticleUtils.hh:599
Determine whether a particle is the first in a decay chain not to meet the cut/function.
Definition ParticleUtils.hh:611
|PID| matching functor
Definition ParticleUtils.hh:581
PID matching functor.
Definition ParticleUtils.hh:566
Determine whether a particle has an ancestor which meets the cut/function.
Definition ParticleUtils.hh:650
Determine whether a particle has an ancestor which doesn't meet the cut/function.
Definition ParticleUtils.hh:663
Determine whether a particle has a child which meets the cut/function.
Definition ParticleUtils.hh:702
Determine whether a particle has a child which doesn't meet the cut/function.
Definition ParticleUtils.hh:714
Determine whether a particle has a descendant which meets the cut/function.
Definition ParticleUtils.hh:727
Determine whether a particle has a descendant which doesn't meet the cut/function.
Definition ParticleUtils.hh:740
Determine whether a particle has an parent which meets the cut/function.
Definition ParticleUtils.hh:677
Determine whether a particle has an parent which doesn't meet the cut/function.
Definition ParticleUtils.hh:689
Determine whether a particle is the last in a decay chain to meet the cut/function.
Definition ParticleUtils.hh:624
Determine whether a particle is the last in a decay chain not to meet the cut/function.
Definition ParticleUtils.hh:637