Skip to content

Commit

Permalink
Merge pull request #46875 from fwyzard/constrain_TriggerObject_templa…
Browse files Browse the repository at this point in the history
…te_ctors

Constrain the TriggerObject template constructors
  • Loading branch information
cmsbuild authored Dec 5, 2024
2 parents 640040c + 9c90b8b commit c5dc5f7
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions DataFormats/HLTReco/interface/TriggerObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@

namespace trigger {

namespace impl {

template <typename T>
concept FourMomentum = requires(T o) {
o.pt();
o.eta();
o.phi();
o.mass();
};

template <typename T>
concept FourMomentumWithPdgId = FourMomentum<T> and requires(T o) { o.pdgId(); };

} // namespace impl

/// Single trigger physics object (e.g., an isolated muon)
class TriggerObject {
/// data members - similar to DataFormats/Candidate/interface/Particle.h
Expand All @@ -34,10 +49,10 @@ namespace trigger {
: id_(id), pt_(pt), eta_(eta), phi_(phi), mass_(mass) {}

/// any type T object implementing the methods pt(), eta(), phi(), mass()
template <typename T>
template <impl::FourMomentum T>
TriggerObject(int id, const T& o) : id_(id), pt_(o.pt()), eta_(o.eta()), phi_(o.phi()), mass_(o.mass()) {}
/// ... and pdgId()
template <typename T>
template <impl::FourMomentumWithPdgId T>
TriggerObject(const T& o) : id_(o.pdgId()), pt_(o.pt()), eta_(o.eta()), phi_(o.phi()), mass_(o.mass()) {}

/// setters
Expand Down

0 comments on commit c5dc5f7

Please sign in to comment.