Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:31

0001 #ifndef DataFormatsL1TCorrelator_TkEm_h
0002 #define DataFormatsL1TCorrelator_TkEm_h
0003 
0004 // -*- C++ -*-
0005 //
0006 // Package:     L1Trigger
0007 // Class  :     TkEm
0008 //
0009 
0010 #include "DataFormats/L1Trigger/interface/L1Candidate.h"
0011 #include "DataFormats/Common/interface/Ptr.h"
0012 
0013 #include "DataFormats/L1Trigger/interface/EGamma.h"
0014 
0015 #include "DataFormats/L1TrackTrigger/interface/TTTypes.h"
0016 #include "DataFormats/L1TParticleFlow/interface/gt_datatypes.h"
0017 #include "FWCore/Utilities/interface/Exception.h"
0018 
0019 #include <ap_int.h>
0020 
0021 namespace l1t {
0022 
0023   class TkEm : public L1Candidate {
0024   public:
0025     TkEm();
0026 
0027     TkEm(const LorentzVector& p4, float tkisol = -999., float tkisolPV = -999);
0028 
0029     TkEm(const LorentzVector& p4, const edm::Ptr<L1Candidate>& egCaloPtr, float tkisol = -999., float tkisolPV = -999);
0030 
0031     enum class HWEncoding { None, CT, GT };
0032 
0033     // ---------- const member functions ---------------------
0034 
0035     const edm::Ptr<L1Candidate>& egCaloPtr() const { return egCaloPtr_; }
0036 
0037     float trkIsol() const { return trkIsol_; }          // not constrained to the PV, just track ptSum
0038     float trkIsolPV() const { return trkIsolPV_; }      // constrained to the PV by DZ
0039     float pfIsol() const { return pfIsol_; }            // not constrained to the PV, just track ptSum
0040     float pfIsolPV() const { return pfIsolPV_; }        // constrained to the PV by DZ
0041     float puppiIsol() const { return puppiIsol_; }      // not constrained to the PV, just track ptSum
0042     float puppiIsolPV() const { return puppiIsolPV_; }  // constrained to the PV by DZ
0043 
0044     // ---------- member functions ---------------------------
0045 
0046     void setTrkIsol(float TrkIsol) { trkIsol_ = TrkIsol; }
0047     void setTrkIsolPV(float TrkIsolPV) { trkIsolPV_ = TrkIsolPV; }
0048     void setPFIsol(float pfIsol) { pfIsol_ = pfIsol; }
0049     void setPFIsolPV(float pfIsolPV) { pfIsolPV_ = pfIsolPV; }
0050     void setPuppiIsol(float puppiIsol) { puppiIsol_ = puppiIsol; }
0051     void setPuppiIsolPV(float puppiIsolPV) { puppiIsolPV_ = puppiIsolPV; }
0052     void setEgCaloPtr(const edm::Ptr<L1Candidate>& egPtr) { egCaloPtr_ = egPtr; }
0053 
0054     template <int N>
0055     void setEgBinaryWord(ap_uint<N> word, HWEncoding encoding) {
0056       egBinaryWord0_ = word;
0057       egBinaryWord1_ = (word >> 32);
0058       egBinaryWord2_ = (word >> 64);
0059       encoding_ = encoding;
0060     }
0061 
0062     l1gt::Photon hwObj() const {
0063       if (encoding() != HWEncoding::GT) {
0064         throw cms::Exception("RuntimeError") << "TkEm::hwObj : encoding is not in GT format!" << std::endl;
0065       }
0066       return l1gt::Photon::unpack_ap(egBinaryWord<l1gt::Photon::BITWIDTH>());
0067     }
0068 
0069     template <int N>
0070     ap_uint<N> egBinaryWord() const {
0071       return ap_uint<N>(egBinaryWord0_) | (ap_uint<N>(egBinaryWord1_) << 32) | (ap_uint<N>(egBinaryWord2_) << 64);
0072     }
0073 
0074     HWEncoding encoding() const { return encoding_; }
0075 
0076   private:
0077     edm::Ptr<L1Candidate> egCaloPtr_;
0078     float trkIsol_;
0079     float trkIsolPV_;
0080     float pfIsol_;
0081     float pfIsolPV_;
0082     float puppiIsol_;
0083     float puppiIsolPV_;
0084     uint32_t egBinaryWord0_;
0085     uint32_t egBinaryWord1_;
0086     uint32_t egBinaryWord2_;
0087     HWEncoding encoding_;
0088   };
0089 }  // namespace l1t
0090 
0091 #endif