Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef L1CALOREGION_H
0002 #define L1CALOREGION_H
0003 
0004 #include <ostream>
0005 
0006 #include "DataFormats/L1CaloTrigger/interface/L1CaloRegionDetId.h"
0007 
0008 /*!
0009  * \author Jim Brooke
0010  * \date May 2006
0011  */
0012 
0013 /*!
0014  * \class L1CaloRegion
0015  * \brief A calorimeter trigger region (sum of 4x4 trigger towers)
0016  *
0017  * 
0018  *
0019  */
0020 
0021 class L1CaloRegion {
0022 public:
0023   /// default constructor
0024   L1CaloRegion();
0025 
0026   /// constructor for RCT emulator (HB/HE regions) - to be removed!
0027   L1CaloRegion(
0028       unsigned et, bool overFlow, bool tauVeto, bool mip, bool quiet, unsigned crate, unsigned card, unsigned rgn);
0029 
0030   /// constructor for RCT emulator (HF regions) - to be removed!
0031   L1CaloRegion(unsigned et, bool fineGrain, unsigned crate, unsigned rgn);
0032 
0033   /// construct with GCT eta,phi indices, for testing GCT emulator - note argument ordering! - to be removed!
0034   L1CaloRegion(unsigned et, bool overFlow, bool fineGrain, bool mip, bool quiet, unsigned ieta, unsigned iphi);
0035 
0036   /// constructor from raw data and GCT indices for unpacking - to be removed!
0037   L1CaloRegion(uint16_t data, unsigned ieta, unsigned iphi, int16_t bx);
0038 
0039   /// destructor
0040   ~L1CaloRegion();
0041 
0042   // named ctors
0043 
0044   /// constructor HB/HE region from components
0045   static L1CaloRegion makeHBHERegion(const unsigned et,
0046                                      const bool overFlow,
0047                                      const bool tauVeto,
0048                                      const bool mip,
0049                                      const bool quiet,
0050                                      const unsigned crate,
0051                                      const unsigned card,
0052                                      const unsigned rgn);
0053 
0054   /// construct HF region from components
0055   static L1CaloRegion makeHFRegion(const unsigned et, const bool fineGrain, const unsigned crate, const unsigned rgn);
0056 
0057   /// construct region from GCT indices
0058   static L1CaloRegion makeRegionFromGctIndices(const unsigned et,
0059                                                const bool overFlow,
0060                                                const bool fineGrain,
0061                                                const bool mip,
0062                                                const bool quiet,
0063                                                const unsigned ieta,
0064                                                const unsigned iphi);
0065   /// constructor from raw data and GCT indices for unpacking
0066   static L1CaloRegion makeRegionFromUnpacker(const uint16_t data,
0067                                              const unsigned ieta,
0068                                              const unsigned iphi,
0069                                              const uint16_t block,
0070                                              const uint16_t index,
0071                                              const int16_t bx);
0072 
0073   /// construct region for use in GCT internal jet-finding
0074   static L1CaloRegion makeGctJetRegion(const unsigned et,
0075                                        const bool overFlow,
0076                                        const bool fineGrain,
0077                                        const unsigned ieta,
0078                                        const unsigned iphi,
0079                                        const int16_t bx);
0080 
0081   // get/set methods for the data
0082 
0083   /// reset the data content (not position id!)
0084   void reset() { m_data = 0; }
0085 
0086   /// get raw data
0087   uint16_t raw() const { return m_data; }
0088 
0089   /// get Et
0090   unsigned et() const { return (isHf() ? m_data & 0xff : m_data & 0x3ff); }
0091 
0092   /// get Et for internal GCT use
0093   unsigned etFullScale() const { return m_data & 0xfff; }
0094 
0095   /// get overflow
0096   bool overFlow() const { return ((m_data >> 10) & 0x1) != 0; }
0097 
0098   /// get tau veto bit
0099   bool tauVeto() const { return (isHf() ? false : fineGrain()); }
0100 
0101   /// get fine grain bit
0102   bool fineGrain() const { return ((m_data >> 11) & 0x1) != 0; }
0103 
0104   /// get MIP bit
0105   bool mip() const { return ((m_data >> 12) & 0x1) != 0; }
0106 
0107   /// get quiet bit
0108   bool quiet() const { return ((m_data >> 13) & 0x1) != 0; }
0109 
0110   /// set cap block
0111   void setCaptureBlock(uint16_t capBlock) { m_captureBlock = capBlock; }
0112 
0113   /// set cap index
0114   void setCaptureIndex(uint16_t capIndex) { m_captureIndex = capIndex; }
0115 
0116   /// set bx
0117   void setBx(int16_t bx);
0118 
0119   /// set data
0120   void setRawData(uint32_t data) { m_data = data; }
0121 
0122   /// set MIP bit (required for GCT emulator standalone operation)
0123   void setMip(bool mip);
0124 
0125   /// set quiet bit (required for GCT emulator standalone operation)
0126   void setQuiet(bool quiet);
0127 
0128   // get methods for the geographical information
0129 
0130   /// get global region ID
0131   L1CaloRegionDetId id() const { return m_id; }
0132 
0133   /// forward or central region
0134   bool isHf() const { return m_id.isHf(); }
0135   bool isHbHe() const { return !m_id.isHf(); }
0136 
0137   /// get RCT crate ID
0138   unsigned rctCrate() const { return m_id.rctCrate(); }
0139 
0140   /// get RCT reciever card ID (valid output for HB/HE)
0141   unsigned rctCard() const { return m_id.rctCard(); }
0142 
0143   /// get RCT region index
0144   unsigned rctRegionIndex() const { return m_id.rctRegion(); }
0145 
0146   /// get local eta index (within RCT crate)
0147   unsigned rctEta() const { return m_id.rctEta(); }
0148 
0149   /// get local phi index (within RCT crate)
0150   unsigned rctPhi() const { return m_id.rctPhi(); }
0151 
0152   /// get GCT eta index
0153   unsigned gctEta() const { return m_id.ieta(); }
0154 
0155   /// get GCT phi index
0156   unsigned gctPhi() const { return m_id.iphi(); }
0157 
0158   /// which capture block did this come from
0159   unsigned capBlock() const { return m_captureBlock; }
0160 
0161   /// what index within capture block
0162   unsigned capIndex() const { return m_captureIndex; }
0163 
0164   /// get bunch-crossing index
0165   int16_t bx() const { return m_bx; }
0166 
0167   /// equality operator, including rank, feature bits, and position
0168   int operator==(const L1CaloRegion& c) const {
0169     return ((m_data == c.raw() && m_id == c.id()) || (this->empty() && c.empty()));
0170   }
0171 
0172   /// inequality operator
0173   int operator!=(const L1CaloRegion& c) const { return !(*this == c); }
0174 
0175   /// is there any information in the candidate
0176   bool empty() const { return (m_data == 0); }
0177 
0178   /// print to stream
0179   friend std::ostream& operator<<(std::ostream& os, const L1CaloRegion& reg);
0180 
0181 private:
0182   /// set region ID
0183   void setRegionId(L1CaloRegionDetId id) { m_id = id; }
0184 
0185   /// pack the raw data from arguments (used in constructors)
0186   void pack(unsigned et, bool overFlow, bool fineGrain, bool mip, bool quiet);
0187 
0188   /// pack the raw data from arguments (used in constructors)
0189   void pack12BitsEt(unsigned et, bool overFlow, bool fineGrain, bool mip, bool quiet);
0190 
0191   /// region id
0192   L1CaloRegionDetId m_id;
0193 
0194   /// region data : et, overflow, fine grain/tau veto, mip and quiet bits
0195   uint16_t m_data;
0196   uint16_t m_captureBlock;
0197   uint8_t m_captureIndex;
0198   int16_t m_bx;
0199 };
0200 
0201 #endif /*L1CALOREGION_H*/