Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-06-20 01:53:32

0001 #ifndef L1Trigger_Phase2L1ParticleFlow_newfirmware_gcteminput_ref_h
0002 #define L1Trigger_Phase2L1ParticleFlow_newfirmware_gcteminput_ref_h
0003 
0004 #include "DataFormats/L1TParticleFlow/interface/layer1_emulator.h"
0005 
0006 #include "L1Trigger/Phase2L1ParticleFlow/interface/corrector.h"
0007 #include "L1Trigger/Phase2L1ParticleFlow/interface/ParametricResolution.h"
0008 
0009 namespace edm {
0010   class ParameterSet;
0011   class ParameterSetDescription;
0012 }  // namespace edm
0013 
0014 namespace l1ct {
0015   class GctEmClusterDecoderEmulator {
0016   public:
0017     GctEmClusterDecoderEmulator() {};
0018 
0019     // only works in CMSSW
0020     GctEmClusterDecoderEmulator(const edm::ParameterSet &pset);
0021 
0022     GctEmClusterDecoderEmulator(const std::string &corrFile,
0023                                 l1tpf::ParametricResolution::Kind kind,
0024                                 std::vector<float> etas,
0025                                 std::vector<float> offsets,
0026                                 std::vector<float> scales,
0027                                 std::vector<float> ptMins,
0028                                 std::vector<float> ptMaxs)
0029         : corrector_(corrFile), resol_(kind, etas, offsets, scales, ptMins, ptMaxs) {}
0030 
0031     ~GctEmClusterDecoderEmulator() = default;
0032 
0033     static edm::ParameterSetDescription getParameterSetDescription();
0034 
0035     l1ct::EmCaloObjEmu decode(const l1ct::PFRegionEmu &sector, const ap_uint<64> &in) const;
0036 
0037   private:
0038     ap_uint<12> pt(const ap_uint<64> &in) const { return in.range(11, 0); }
0039 
0040     // crystal eta (unsigned 7 bits)
0041     ap_uint<7> eta(const ap_uint<64> &in) const { return (ap_uint<7>)in.range(18, 12); }
0042 
0043     // crystal phi (signed 7 bits)
0044     ap_int<7> phi(const ap_uint<64> &in) const { return (ap_int<7>)in.range(25, 19); }
0045 
0046     // iso flag: two bits, least significant bit is the standalone WP (true or false), second bit is the looseTk WP (true or false)
0047     // e.g. 0b01 : standalone iso flag passed, loose Tk iso flag did not pass
0048     ap_uint<2> isoFlags(const ap_uint<64> &in) const { return in.range(36, 35); }
0049     bool passes_iso(const ap_uint<64> &in) const { return (isoFlags(in) & 0x1); }         // standalone iso WP
0050     bool passes_looseTkiso(const ap_uint<64> &in) const { return (isoFlags(in) & 0x2); }  // loose Tk iso WP
0051 
0052     // shower shape shape flag: two bits, least significant bit is the standalone WP, second bit is the looseTk WP
0053     // e.g. 0b01 : standalone shower shape flag passed, loose Tk shower shape flag did not pass
0054     ap_uint<2> shapeFlags(const ap_uint<64> &in) const { return in.range(49, 48); }
0055 
0056     bool passes_ss(const ap_uint<64> &in) const { return (shapeFlags(in) & 0x1); }         // standalone shower shape WP
0057     bool passes_looseTkss(const ap_uint<64> &in) const { return (shapeFlags(in) & 0x2); }  // loose Tk shower shape WP
0058 
0059     // tools for GCT clusters
0060     l1tpf::corrector corrector_;
0061     l1tpf::ParametricResolution resol_;
0062   };
0063 
0064 }  // namespace l1ct
0065 
0066 #endif