Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:51

0001 #ifndef L1GCTJET_H_
0002 #define L1GCTJET_H_
0003 
0004 #include <functional>
0005 #include <vector>
0006 #include <ostream>
0007 #include <memory>
0008 
0009 #include "DataFormats/L1CaloTrigger/interface/L1CaloRegionDetId.h"
0010 #include <cstdint>
0011 
0012 /*!
0013  * \author Jim Brooke & Robert Frazier
0014  * \date April 2006
0015  */
0016 
0017 /*! \class L1GctJet
0018  * \brief A Level-1 jet candidate, used within GCT emulation
0019  * 
0020  *  Move this to DataFormats/L1GlobalCaloTrigger if possible
0021  */
0022 
0023 class L1GctJetCand;
0024 class L1GctJetEtCalibrationLut;
0025 
0026 class L1GctJet {
0027 public:
0028   //Statics
0029   enum numberOfBits { kRawsumBitWidth = 10, kRawsumMaxValue = (1 << kRawsumBitWidth) - 1 };
0030 
0031   //Typedefs
0032   typedef std::shared_ptr<L1GctJetEtCalibrationLut> lutPtr;
0033 
0034   //Constructors/destructors
0035   L1GctJet(const uint16_t rawsum = 0,
0036            const unsigned eta = 0,
0037            const unsigned phi = 0,
0038            const bool overFlow = false,
0039            const bool forwardJet = true,
0040            const bool tauVeto = true,
0041            const int16_t bx = 0);
0042   ~L1GctJet();
0043 
0044   // set rawsum and position bits
0045   void setRawsum(const uint16_t rawsum) {
0046     m_rawsum = rawsum & kRawsumMaxValue;
0047     m_overFlow |= (rawsum > kRawsumMaxValue);
0048   }
0049   void setDetId(const L1CaloRegionDetId detId) { m_id = detId; }
0050   void setOverFlow(const bool overFlow) { m_overFlow = overFlow; }
0051   void setTauVeto(const bool tauVeto) { m_tauVeto = tauVeto; }
0052   void setForward(const bool forward) { m_forwardJet = forward; }
0053   void setBx(const int16_t bx) { m_bx = bx; }
0054 
0055   // get rawsum and position bits
0056   uint16_t rawsum() const { return m_rawsum; }
0057   L1CaloRegionDetId id() const { return m_id(); }
0058   bool tauVeto() const { return m_tauVeto; }
0059 
0060   /// get overflow
0061   bool overFlow() const { return m_overFlow; }
0062 
0063   /// test whether this jet candidate is a valid tau jet
0064   bool isTauJet() const { return (!m_forwardJet && !m_tauVeto); }
0065 
0066   /// test whether this jet candidate is a (non-tau) central jet
0067   bool isCentralJet() const { return (!m_forwardJet && m_tauVeto); }
0068 
0069   /// test whether this jet candidate is a forward jet
0070   bool isForwardJet() const { return m_forwardJet; }
0071 
0072   /// test whether this jet candidate has been filled
0073   bool isNullJet() const { return ((m_rawsum == 0) && (globalEta() == 0) && (globalPhi() == 0)); }
0074 
0075   friend std::ostream& operator<<(std::ostream& os, const L1GctJet& cand);
0076 
0077   /// test whether two jets are the same
0078   bool operator==(const L1GctJet& cand) const;
0079 
0080   /// test whether two jets are different
0081   bool operator!=(const L1GctJet& cand) const;
0082 
0083   ///Setup an existing jet all in one go
0084   void setupJet(const uint16_t rawsum,
0085                 const unsigned eta,
0086                 const unsigned phi,
0087                 const bool overFlow,
0088                 const bool forwardJet,
0089                 const bool tauVeto = true,
0090                 const int16_t bx = 0);
0091 
0092   /// eta value in global CMS coordinates
0093   unsigned globalEta() const { return m_id.ieta(); }
0094 
0095   /// phi value in global CMS coordinates
0096   unsigned globalPhi() const { return m_id.iphi(); }
0097 
0098   /// eta value in global CMS coordinates
0099   unsigned rctEta() const { return m_id.rctEta(); }
0100 
0101   /// phi value in global CMS coordinates
0102   unsigned rctPhi() const { return m_id.rctPhi(); }
0103 
0104   /// eta value as encoded in hardware at the GCT output
0105   unsigned hwEta() const;
0106 
0107   /// phi value as encoded in hardware at the GCT output
0108   unsigned hwPhi() const;
0109 
0110   /// the bunch crossing number
0111   int16_t bx() const { return m_bx; }
0112 
0113   /// Functions to convert from internal format to external jet candidates at the output of the jetFinder
0114   L1GctJetCand jetCand(const lutPtr lut) const;
0115   L1GctJetCand jetCand(const std::vector<lutPtr>& luts) const;
0116 
0117   /// The two separate Lut outputs
0118   uint16_t rank(const lutPtr lut) const;
0119   unsigned calibratedEt(const lutPtr lut) const;
0120 
0121 private:
0122   uint16_t m_rawsum;
0123   /// region id, encodes eta and phi
0124   L1CaloRegionDetId m_id;
0125   bool m_overFlow;
0126   bool m_forwardJet;
0127   bool m_tauVeto;
0128   int16_t m_bx;
0129 
0130   uint16_t lutValue(const lutPtr lut) const;
0131 };
0132 
0133 std::ostream& operator<<(std::ostream& os, const L1GctJet& cand);
0134 
0135 #endif /*L1GCTJET_H_*/