File indexing completed on 2024-04-06 12:04:25
0001
0002
0003 #include "DataFormats/L1CaloTrigger/interface/L1CaloRegion.h"
0004
0005 using std::dec;
0006 using std::endl;
0007 using std::hex;
0008 using std::ostream;
0009
0010
0011 L1CaloRegion::L1CaloRegion() : m_id(), m_data(0), m_bx(0) {}
0012
0013
0014 L1CaloRegion::L1CaloRegion(
0015 unsigned et, bool overFlow, bool tauVeto, bool mip, bool quiet, unsigned crate, unsigned card, unsigned rgn)
0016 : m_id(crate, card, rgn),
0017 m_data(0),
0018 m_bx(0) {
0019 pack(et, overFlow, tauVeto, mip, quiet);
0020 }
0021
0022
0023 L1CaloRegion::L1CaloRegion(unsigned et, bool fineGrain, unsigned crate, unsigned rgn)
0024 : m_id(crate, 999, rgn),
0025 m_data(0),
0026 m_bx(0) {
0027 pack((et & 0xff), (et >= 0xff), fineGrain, false, false);
0028 }
0029
0030
0031 L1CaloRegion::L1CaloRegion(
0032 unsigned et, bool overFlow, bool fineGrain, bool mip, bool quiet, unsigned ieta, unsigned iphi)
0033 : m_id(ieta, iphi),
0034 m_data(0),
0035 m_bx(0) {
0036 pack(et, overFlow, fineGrain, mip, quiet);
0037 }
0038
0039
0040 L1CaloRegion::L1CaloRegion(uint16_t data, unsigned ieta, unsigned iphi, int16_t bx)
0041 : m_id(ieta, iphi), m_data(data), m_bx(bx) {}
0042
0043
0044 L1CaloRegion::~L1CaloRegion() {}
0045
0046
0047
0048
0049 L1CaloRegion L1CaloRegion::makeHBHERegion(
0050 unsigned et, bool overFlow, bool tauVeto, bool mip, bool quiet, unsigned crate, unsigned card, unsigned rgn) {
0051 L1CaloRegion r;
0052 r.setRegionId(L1CaloRegionDetId(crate, card, rgn));
0053 r.setBx(0);
0054 r.pack(et, overFlow, tauVeto, mip, quiet);
0055 return r;
0056 }
0057
0058
0059 L1CaloRegion L1CaloRegion::makeHFRegion(unsigned et, bool fineGrain, unsigned crate, unsigned rgn) {
0060 L1CaloRegion r;
0061 r.setRegionId(L1CaloRegionDetId(crate, 999, rgn));
0062 r.setBx(0);
0063 r.pack((et & 0xff), (et >= 0xff), fineGrain, false, false);
0064 return r;
0065 }
0066
0067
0068 L1CaloRegion L1CaloRegion::makeRegionFromGctIndices(
0069 unsigned et, bool overFlow, bool fineGrain, bool mip, bool quiet, unsigned ieta, unsigned iphi) {
0070 L1CaloRegion r;
0071 r.setRegionId(L1CaloRegionDetId(ieta, iphi));
0072 r.setBx(0);
0073 r.pack(et, overFlow, fineGrain, mip, quiet);
0074 return r;
0075 }
0076
0077
0078 L1CaloRegion L1CaloRegion::makeRegionFromUnpacker(
0079 uint16_t data, unsigned ieta, unsigned iphi, uint16_t block, uint16_t index, int16_t bx) {
0080 L1CaloRegion r;
0081 r.setRegionId(L1CaloRegionDetId(ieta, iphi));
0082 r.setRawData(data);
0083 r.setCaptureBlock(block);
0084 r.setCaptureIndex(index);
0085 r.setBx(bx);
0086 return r;
0087 }
0088
0089 L1CaloRegion L1CaloRegion::makeGctJetRegion(const unsigned et,
0090 const bool overFlow,
0091 const bool fineGrain,
0092 const unsigned ieta,
0093 const unsigned iphi,
0094 const int16_t bx) {
0095 L1CaloRegion r;
0096 r.setRegionId(L1CaloRegionDetId(ieta, iphi));
0097 r.setBx(bx);
0098 r.pack12BitsEt(et, overFlow, fineGrain, false, false);
0099 return r;
0100 }
0101
0102
0103 void L1CaloRegion::setBx(int16_t bx) { m_bx = bx; }
0104
0105
0106 void L1CaloRegion::setMip(bool mip) {
0107 if (mip) {
0108 m_data |= 0x1000;
0109 } else {
0110 m_data &= 0xefff;
0111 }
0112 }
0113
0114
0115 void L1CaloRegion::setQuiet(bool quiet) {
0116 if (quiet) {
0117 m_data |= 0x2000;
0118 } else {
0119 m_data &= 0xdfff;
0120 }
0121 }
0122
0123 void L1CaloRegion::pack(unsigned et, bool overFlow, bool fineGrain, bool mip, bool quiet) {
0124 bool checkOvF = overFlow || (et >= 0x400);
0125 m_data = (et & 0x3ff) | ((checkOvF) ? 0x400 : 0x0) | ((fineGrain) ? 0x800 : 0x0) | ((mip) ? 0x1000 : 0x0) |
0126 ((quiet) ? 0x2000 : 0x0);
0127 }
0128
0129 void L1CaloRegion::pack12BitsEt(unsigned et, bool overFlow, bool fineGrain, bool mip, bool quiet) {
0130 bool checkOvF = overFlow || (et >= 0x400);
0131 m_data = (et & 0xfff) | ((checkOvF) ? 0x400 : 0x0) | ((fineGrain) ? 0x800 : 0x0) | ((mip) ? 0x1000 : 0x0) |
0132 ((quiet) ? 0x2000 : 0x0);
0133 }
0134
0135
0136 ostream& operator<<(ostream& os, const L1CaloRegion& reg) {
0137 os << "L1CaloRegion:";
0138 os << " Et=" << reg.et();
0139 os << " o/f=" << reg.overFlow();
0140 os << " f/g=" << reg.fineGrain();
0141 os << " tau=" << reg.tauVeto() << endl;
0142 os << " RCT crate=" << reg.rctCrate();
0143 os << " RCT card=" << reg.rctCard();
0144 os << " RCT rgn=" << reg.rctRegionIndex();
0145 os << " RCT eta=" << reg.rctEta();
0146 os << " RCT phi=" << reg.rctPhi() << endl;
0147 os << " GCT eta=" << reg.gctEta();
0148 os << " GCT phi=" << reg.gctPhi() << endl;
0149 os << hex << " cap block=" << reg.capBlock() << dec << ", index=" << reg.capIndex() << ", BX=" << reg.bx();
0150 return os;
0151 }