Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-02-13 02:58:34

0001 #ifndef Validation_HLTrigger_HLTGenValObject_h
0002 #define Validation_HLTrigger_HLTGenValObject_h
0003 
0004 //********************************************************************************
0005 //
0006 // Description:
0007 //   This class is an object wrapper for the Generator level validation code.
0008 //   It handles the different type of objects the code needs to run on: GenParticles, GenJets and event-level energy sums
0009 //
0010 // Author : Finn Labe, UHH, Nov. 2021
0011 //
0012 //********************************************************************************
0013 
0014 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
0015 #include "DataFormats/JetReco/interface/GenJet.h"
0016 #include "DataFormats/HLTReco/interface/TriggerObject.h"
0017 
0018 #include "DataFormats/Math/interface/LorentzVector.h"
0019 #include <vector>
0020 
0021 class HLTGenValObject {
0022 public:
0023   // empty constructor
0024   HLTGenValObject() : trigObject_(0, 0., 0., 0., 0.) {}
0025 
0026   // constructor from GenParticle
0027   HLTGenValObject(const reco::GenParticle &p)
0028       : p4Polar_(p.p4()), p4Cartesian_(p.p4()), trigObject_(0, 0., 0., 0., 0.) {}
0029 
0030   // constructor from GenJet
0031   HLTGenValObject(const reco::GenJet &p) : p4Polar_(p.p4()), p4Cartesian_(p.p4()), trigObject_(0, 0., 0., 0., 0.) {}
0032 
0033   // constructor from LorentzVector (for energy sums)
0034   HLTGenValObject(const reco::Candidate::PolarLorentzVector &p)
0035       : p4Polar_(p), p4Cartesian_(p), trigObject_(0, 0., 0., 0., 0.) {}
0036 
0037   // object functions, for usage of HLTGenValObjects by other modules
0038   double pt() const { return p4Polar_.pt(); }
0039   double eta() const { return p4Polar_.eta(); }
0040   double phi() const { return p4Polar_.phi(); }
0041   double et() const { return (pt() <= 0) ? 0 : p4Cartesian_.Et(); }
0042   double mass() const { return p4Cartesian_.mass(); }
0043 
0044   double hasTrigObject() const { return trigObject_.pt() > 0; }
0045   const trigger::TriggerObject &trigObject() const { return trigObject_; }
0046   void setTrigObject(const trigger::TriggerObject &trigObject) { trigObject_ = trigObject; }
0047   double ptRes() const { return pt() > 0 ? trigObject_.pt() / pt() : 0.; }
0048   double etaRes() const { return eta() > 0 ? trigObject_.eta() / eta() : 0.; }
0049   double phiRes() const { return phi() > 0 ? trigObject_.phi() / phi() : 0.; }
0050   double massRes() const { return mass() > 0 ? trigObject_.mass() / mass() : 0.; }
0051 
0052 private:
0053   // containing information in two "shapes"
0054   math::PtEtaPhiMLorentzVector p4Polar_;
0055   math::XYZTLorentzVector p4Cartesian_;
0056   trigger::TriggerObject trigObject_;
0057 };
0058 
0059 #endif