Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:47

0001 
0002 
0003 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctJetCand.h"
0004 
0005 using std::dec;
0006 using std::hex;
0007 using std::ostream;
0008 using std::string;
0009 
0010 L1GctJetCand::L1GctJetCand()
0011     : m_data(0), m_isTau(false), m_isFor(false), m_captureBlock(0), m_captureIndex(0), m_bx(0) {}
0012 
0013 //constructor for GT
0014 L1GctJetCand::L1GctJetCand(uint16_t rawData, bool isTau, bool isFor)
0015     : m_data(rawData & 0x7fff),  // 0x7fff is to mask off bit 15, which is not data that needs to be stored
0016       m_isTau(isTau),
0017       m_isFor(isFor),
0018       m_captureBlock(0),
0019       m_captureIndex(0),
0020       m_bx(0) {}
0021 
0022 //constructor for GCT unpacker
0023 L1GctJetCand::L1GctJetCand(uint16_t rawData, bool isTau, bool isFor, uint16_t block, uint16_t index, int16_t bx)
0024     : m_data(rawData & 0x7fff),  // 0x7fff is to mask off bit 15, which is not data that needs to be stored
0025       m_isTau(isTau),
0026       m_isFor(isFor),
0027       m_captureBlock(block & 0xfff),
0028       m_captureIndex(index & 0xff),
0029       m_bx(bx) {}
0030 
0031 // constructor for use in emulator
0032 // eta = -6 to -0, +0 to +6. Sign is bit 3, 1 means -ve Z, 0 means +ve Z
0033 L1GctJetCand::L1GctJetCand(unsigned rank, unsigned phi, unsigned eta, bool isTau, bool isFor)
0034     : m_data(0),  // overridden below
0035       m_isTau(isTau),
0036       m_isFor(isFor),
0037       m_captureBlock(0),
0038       m_captureIndex(0),
0039       m_bx(0) {
0040   m_data = (rank & 0x3f) + ((eta & 0xf) << 6) + ((phi & 0x1f) << 10);
0041 }
0042 
0043 // constructor for use in emulator
0044 // eta = -6 to -0, +0 to +6. Sign is bit 3, 1 means -ve Z, 0 means +ve Z
0045 L1GctJetCand::L1GctJetCand(
0046     unsigned rank, unsigned phi, unsigned eta, bool isTau, bool isFor, uint16_t block, uint16_t index, int16_t bx)
0047     : m_data(0),  // overridden below
0048       m_isTau(isTau),
0049       m_isFor(isFor),
0050       m_captureBlock(block & 0xfff),
0051       m_captureIndex(index & 0xff),
0052       m_bx(bx) {
0053   m_data = (rank & 0x3f) + ((eta & 0xf) << 6) + ((phi & 0x1f) << 10);
0054 }
0055 
0056 L1GctJetCand::~L1GctJetCand() {}
0057 
0058 // return name
0059 string L1GctJetCand::name() const {
0060   if (m_isTau) {
0061     return "tau jet";
0062   } else if (m_isFor) {
0063     return "forward jet";
0064   } else {
0065     return "central jet";
0066   }
0067 }
0068 
0069 // pretty print
0070 ostream& operator<<(ostream& s, const L1GctJetCand& cand) {
0071   if (cand.empty()) {
0072     s << "L1GctJetCand empty jet";
0073   } else {
0074     s << "L1GctJetCand : ";
0075     s << "rank=" << cand.rank();
0076     s << ", etaSign=" << cand.etaSign() << ", eta=" << (cand.etaIndex() & 0x7) << ", phi=" << cand.phiIndex();
0077     s << " type=";
0078     if (cand.isTau()) {
0079       s << "tau";
0080     } else if (cand.isForward()) {
0081       s << "forward";
0082     } else {
0083       s << "central";
0084     }
0085   }
0086   s << hex << " cap block=" << cand.capBlock() << dec << ", index=" << cand.capIndex() << ", BX=" << cand.bx();
0087   return s;
0088 }
0089 
0090 L1CaloRegionDetId L1GctJetCand::regionId() const {
0091   // get global eta
0092   unsigned eta;
0093   if (!isForward()) {
0094     eta = (etaSign() == 1 ? 10 - (etaIndex() & 0x7) : (etaIndex() & 0x7) + 11);
0095   } else {
0096     eta = (etaSign() == 1 ? 3 - (etaIndex() & 0x7) : (etaIndex() & 0x7) + 18);
0097   }
0098 
0099   return L1CaloRegionDetId(eta, phiIndex());
0100 }