Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctEmCand.h"
0002 
0003 #include <iostream>
0004 
0005 using std::dec;
0006 using std::hex;
0007 using std::ostream;
0008 using std::string;
0009 
0010 // default constructor
0011 L1GctEmCand::L1GctEmCand() : m_data(0), m_iso(false), m_captureBlock(0), m_captureIndex(0), m_bx(0) {}
0012 
0013 // construct from raw data, no source (i.e. no capBlock/capIndex); used in GT
0014 L1GctEmCand::L1GctEmCand(uint16_t rawData, bool iso)
0015     : m_data(rawData & 0x7fff),  // 0x7fff is to mask off bit 15, which is not data that needs to be stored
0016       m_iso(iso),
0017       m_captureBlock(0),
0018       m_captureIndex(0),
0019       m_bx(0) {}
0020 
0021 // construct from raw data with source - used in GCT unpacker
0022 L1GctEmCand::L1GctEmCand(uint16_t rawData, bool iso, uint16_t block, uint16_t index, int16_t bx)
0023     : m_data(rawData & 0x7fff),  // 0x7fff is to mask off bit 15, which is not data that needs to be stored
0024       m_iso(iso),
0025       m_captureBlock(block & 0xfff),
0026       m_captureIndex(index & 0xff),
0027       m_bx(bx) {}
0028 
0029 // construct from content - used in GCT emulator
0030 // eta = -6 to -0, +0 to +6. Sign is bit 3, 1 means -ve Z, 0 means +ve Z
0031 L1GctEmCand::L1GctEmCand(unsigned rank, unsigned phi, unsigned eta, bool iso)
0032     : m_data(0),  // override below
0033       m_iso(iso),
0034       m_captureBlock(0),
0035       m_captureIndex(0),
0036       m_bx(0)
0037 
0038 {
0039   construct(rank, eta, phi);
0040 }
0041 
0042 // construct from content, with source (i.e. capBlock/capIndex); will be used in GCT emulator one day?
0043 // eta = -6 to -0, +0 to +6. Sign is bit 3, 1 means -ve Z, 0 means +ve Z
0044 L1GctEmCand::L1GctEmCand(unsigned rank, unsigned phi, unsigned eta, bool iso, uint16_t block, uint16_t index, int16_t bx)
0045     : m_data(0),  // override below
0046       m_iso(iso),
0047       m_captureBlock(block & 0xfff),
0048       m_captureIndex(index & 0xff),
0049       m_bx(bx) {
0050   construct(rank, eta, phi);
0051 }
0052 
0053 // construct from RCT output candidate
0054 L1GctEmCand::L1GctEmCand(L1CaloEmCand& c)
0055     : m_data(0),  // override below
0056       m_iso(c.isolated()),
0057       m_captureBlock(0),
0058       m_captureIndex(0),
0059       m_bx(c.bx()) {
0060   unsigned eta = ((c.regionId().rctEta() & 0x7) | (c.regionId().ieta() < 11 ? 0x8 : 0x0));
0061   construct(c.rank(), eta, c.regionId().iphi());
0062 }
0063 
0064 // destructor
0065 L1GctEmCand::~L1GctEmCand() {}
0066 
0067 // name of candidate type
0068 string L1GctEmCand::name() const { return (isolated() ? "iso EM" : "non iso EM"); }
0069 
0070 // return region object
0071 L1CaloRegionDetId L1GctEmCand::regionId() const {
0072   // get global eta
0073   unsigned eta = (etaSign() == 1 ? 10 - (etaIndex() & 0x7) : 11 + (etaIndex() & 0x7));
0074   return L1CaloRegionDetId(eta, phiIndex());
0075 }
0076 
0077 // construct from rank, eta, phi
0078 void L1GctEmCand::construct(unsigned rank, unsigned eta, unsigned phi) {
0079   if (rank > 0) {
0080     m_data = (rank & 0x3f) + ((eta & 0xf) << 6) + ((phi & 0x1f) << 10);
0081   } else {
0082     // Default values for zero rank electrons,
0083     // different in hardware for positive and negative eta
0084     if ((eta & 0x8) == 0) {
0085       m_data = 0x7000;
0086     } else {
0087       m_data = 0x7400;
0088     }
0089   }
0090 }
0091 
0092 // pretty print
0093 ostream& operator<<(ostream& s, const L1GctEmCand& cand) {
0094   s << "L1GctEmCand : ";
0095   s << "rank=" << cand.rank();
0096   s << ", etaSign=" << cand.etaSign() << ", eta=" << (cand.etaIndex() & 0x7) << ", phi=" << cand.phiIndex();
0097   s << ", iso=" << cand.isolated();
0098   s << hex << " cap block=" << cand.capBlock() << dec << ", index=" << cand.capIndex() << ", BX=" << cand.bx();
0099   return s;
0100 }