File indexing completed on 2024-12-06 02:45:15
0001 #ifndef HLTReco_TriggerObject_h
0002 #define HLTReco_TriggerObject_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include "DataFormats/Candidate/interface/Particle.h"
0015 #include <cmath>
0016 #include <vector>
0017
0018 namespace trigger {
0019
0020 namespace impl {
0021
0022 template <typename T>
0023 concept FourMomentum = requires(T o) {
0024 o.pt();
0025 o.eta();
0026 o.phi();
0027 o.mass();
0028 };
0029
0030 template <typename T>
0031 concept FourMomentumWithPdgId = FourMomentum<T> and requires(T o) { o.pdgId(); };
0032
0033 }
0034
0035
0036 class TriggerObject {
0037
0038 private:
0039
0040 int id_;
0041
0042 float pt_, eta_, phi_, mass_;
0043
0044
0045 public:
0046
0047 TriggerObject() : id_(), pt_(), eta_(), phi_(), mass_() {}
0048 TriggerObject(int id, float pt, float eta, float phi, float mass)
0049 : id_(id), pt_(pt), eta_(eta), phi_(phi), mass_(mass) {}
0050
0051
0052 template <impl::FourMomentum T>
0053 TriggerObject(int id, const T& o) : id_(id), pt_(o.pt()), eta_(o.eta()), phi_(o.phi()), mass_(o.mass()) {}
0054
0055 template <impl::FourMomentumWithPdgId T>
0056 TriggerObject(const T& o) : id_(o.pdgId()), pt_(o.pt()), eta_(o.eta()), phi_(o.phi()), mass_(o.mass()) {}
0057
0058
0059 void setId(int id) { id_ = id; }
0060 void setPt(float pt) { pt_ = pt; }
0061 void setEta(float eta) { eta_ = eta; }
0062 void setPhi(float phi) { phi_ = phi; }
0063 void setMass(float mass) { mass_ = mass; }
0064
0065
0066 int id() const { return id_; }
0067 float pt() const { return pt_; }
0068 float eta() const { return eta_; }
0069 float phi() const { return phi_; }
0070 float mass() const { return mass_; }
0071
0072 float px() const { return pt_ * std::cos(phi_); }
0073 float py() const { return pt_ * std::sin(phi_); }
0074 float pz() const { return pt_ * std::sinh(eta_); }
0075 float p() const { return pt_ * std::cosh(eta_); }
0076 float energy() const { return std::sqrt(std::pow(mass_, 2) + std::pow(p(), 2)); }
0077
0078 float et() const { return std::sqrt(std::pow(mass_ / std::cosh(eta_), 2) + std::pow(pt_, 2)); }
0079
0080 reco::Particle particle(reco::Particle::Charge q = 0,
0081 const reco::Particle::Point& vertex = reco::Particle::Point(0, 0, 0),
0082 int status = 0,
0083 bool integerCharge = true) const {
0084 return reco::Particle(
0085 q, reco::Particle::LorentzVector(px(), py(), pz(), energy()), vertex, id(), status, integerCharge);
0086 }
0087 };
0088
0089
0090 typedef std::vector<TriggerObject> TriggerObjectCollection;
0091
0092 }
0093
0094 #endif