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
0011 L1GctEmCand::L1GctEmCand() : m_data(0), m_iso(false), m_captureBlock(0), m_captureIndex(0), m_bx(0) {}
0012
0013
0014 L1GctEmCand::L1GctEmCand(uint16_t rawData, bool iso)
0015 : m_data(rawData & 0x7fff),
0016 m_iso(iso),
0017 m_captureBlock(0),
0018 m_captureIndex(0),
0019 m_bx(0) {}
0020
0021
0022 L1GctEmCand::L1GctEmCand(uint16_t rawData, bool iso, uint16_t block, uint16_t index, int16_t bx)
0023 : m_data(rawData & 0x7fff),
0024 m_iso(iso),
0025 m_captureBlock(block & 0xfff),
0026 m_captureIndex(index & 0xff),
0027 m_bx(bx) {}
0028
0029
0030
0031 L1GctEmCand::L1GctEmCand(unsigned rank, unsigned phi, unsigned eta, bool iso)
0032 : m_data(0),
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
0043
0044 L1GctEmCand::L1GctEmCand(unsigned rank, unsigned phi, unsigned eta, bool iso, uint16_t block, uint16_t index, int16_t bx)
0045 : m_data(0),
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
0054 L1GctEmCand::L1GctEmCand(L1CaloEmCand& c)
0055 : m_data(0),
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
0065 L1GctEmCand::~L1GctEmCand() {}
0066
0067
0068 string L1GctEmCand::name() const { return (isolated() ? "iso EM" : "non iso EM"); }
0069
0070
0071 L1CaloRegionDetId L1GctEmCand::regionId() const {
0072
0073 unsigned eta = (etaSign() == 1 ? 10 - (etaIndex() & 0x7) : 11 + (etaIndex() & 0x7));
0074 return L1CaloRegionDetId(eta, phiIndex());
0075 }
0076
0077
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
0083
0084 if ((eta & 0x8) == 0) {
0085 m_data = 0x7000;
0086 } else {
0087 m_data = 0x7400;
0088 }
0089 }
0090 }
0091
0092
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 }