Skip to content

Commit c5dc5f7

Browse files
authored
Merge pull request #46875 from fwyzard/constrain_TriggerObject_template_ctors
Constrain the TriggerObject template constructors
2 parents 640040c + 9c90b8b commit c5dc5f7

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

DataFormats/HLTReco/interface/TriggerObject.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,21 @@
1717

1818
namespace trigger {
1919

20+
namespace impl {
21+
22+
template <typename T>
23+
concept FourMomentum = requires(T o) {
24+
o.pt();
25+
o.eta();
26+
o.phi();
27+
o.mass();
28+
};
29+
30+
template <typename T>
31+
concept FourMomentumWithPdgId = FourMomentum<T> and requires(T o) { o.pdgId(); };
32+
33+
} // namespace impl
34+
2035
/// Single trigger physics object (e.g., an isolated muon)
2136
class TriggerObject {
2237
/// data members - similar to DataFormats/Candidate/interface/Particle.h
@@ -34,10 +49,10 @@ namespace trigger {
3449
: id_(id), pt_(pt), eta_(eta), phi_(phi), mass_(mass) {}
3550

3651
/// any type T object implementing the methods pt(), eta(), phi(), mass()
37-
template <typename T>
52+
template <impl::FourMomentum T>
3853
TriggerObject(int id, const T& o) : id_(id), pt_(o.pt()), eta_(o.eta()), phi_(o.phi()), mass_(o.mass()) {}
3954
/// ... and pdgId()
40-
template <typename T>
55+
template <impl::FourMomentumWithPdgId T>
4156
TriggerObject(const T& o) : id_(o.pdgId()), pt_(o.pt()), eta_(o.eta()), phi_(o.phi()), mass_(o.mass()) {}
4257

4358
/// setters

0 commit comments

Comments
 (0)