Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:41

0001 #ifndef HLTReco_TriggerObject_h
0002 #define HLTReco_TriggerObject_h
0003 
0004 /** \class trigger::TriggerObject
0005  *
0006  *  A single trigger object (e.g., an isolated muon, or MET)
0007  *  - described by its 4-momentum and physics type
0008  *
0009  *
0010  *  \author Martin Grunewald
0011  *
0012  */
0013 
0014 #include "DataFormats/Candidate/interface/Particle.h"
0015 #include <cmath>
0016 #include <vector>
0017 
0018 namespace trigger {
0019 
0020   /// Single trigger physics object (e.g., an isolated muon)
0021   class TriggerObject {
0022     /// data members - similar to DataFormats/Candidate/interface/Particle.h
0023   private:
0024     /// id or physics type (including electric charge) - similar to pdgId
0025     int id_;
0026     /// 4-momentum of physics object
0027     float pt_, eta_, phi_, mass_;
0028 
0029     /// methods
0030   public:
0031     /// constructors
0032     TriggerObject() : id_(), pt_(), eta_(), phi_(), mass_() {}
0033     TriggerObject(int id, float pt, float eta, float phi, float mass)
0034         : id_(id), pt_(pt), eta_(eta), phi_(phi), mass_(mass) {}
0035 
0036     /// any type T object implementing the methods pt(), eta(), phi(), mass()
0037     template <typename T>
0038     TriggerObject(int id, const T& o) : id_(id), pt_(o.pt()), eta_(o.eta()), phi_(o.phi()), mass_(o.mass()) {}
0039     /// ... and pdgId()
0040     template <typename T>
0041     TriggerObject(const T& o) : id_(o.pdgId()), pt_(o.pt()), eta_(o.eta()), phi_(o.phi()), mass_(o.mass()) {}
0042 
0043     /// setters
0044     void setId(int id) { id_ = id; }
0045     void setPt(float pt) { pt_ = pt; }
0046     void setEta(float eta) { eta_ = eta; }
0047     void setPhi(float phi) { phi_ = phi; }
0048     void setMass(float mass) { mass_ = mass; }
0049 
0050     /// getters
0051     int id() const { return id_; }
0052     float pt() const { return pt_; }
0053     float eta() const { return eta_; }
0054     float phi() const { return phi_; }
0055     float mass() const { return mass_; }
0056 
0057     float px() const { return pt_ * std::cos(phi_); }
0058     float py() const { return pt_ * std::sin(phi_); }
0059     float pz() const { return pt_ * std::sinh(eta_); }
0060     float p() const { return pt_ * std::cosh(eta_); }
0061     float energy() const { return std::sqrt(std::pow(mass_, 2) + std::pow(p(), 2)); }
0062     // et = energy/cosh(eta)
0063     float et() const { return std::sqrt(std::pow(mass_ / std::cosh(eta_), 2) + std::pow(pt_, 2)); }
0064 
0065     reco::Particle particle(reco::Particle::Charge q = 0,
0066                             const reco::Particle::Point& vertex = reco::Particle::Point(0, 0, 0),
0067                             int status = 0,
0068                             bool integerCharge = true) const {
0069       return reco::Particle(
0070           q, reco::Particle::LorentzVector(px(), py(), pz(), energy()), vertex, id(), status, integerCharge);
0071     }
0072   };
0073 
0074   /// collection of trigger physics objects (e.g., all isolated muons)
0075   typedef std::vector<TriggerObject> TriggerObjectCollection;
0076 
0077 }  // namespace trigger
0078 
0079 #endif