00001
00002
00003 #include "DataFormats/L1CaloTrigger/interface/L1CaloRegion.h"
00004
00005 using std::ostream;
00006 using std::endl;
00007 using std::hex;
00008 using std::dec;
00009
00010
00011 L1CaloRegion::L1CaloRegion() : m_id(), m_data(0), m_bx(0) { }
00012
00013
00014
00015 L1CaloRegion::L1CaloRegion(unsigned et, bool overFlow, bool tauVeto, bool mip, bool quiet, unsigned crate, unsigned card, unsigned rgn) :
00016 m_id(crate, card, rgn),
00017 m_data(0),
00018 m_bx(0)
00019 {
00020 pack(et, overFlow, tauVeto, mip, quiet);
00021 }
00022
00023
00024 L1CaloRegion::L1CaloRegion(unsigned et, bool fineGrain, unsigned crate, unsigned rgn) :
00025 m_id(crate, 999, rgn),
00026 m_data(0),
00027 m_bx(0)
00028 {
00029 pack((et & 0xff), (et >= 0xff), fineGrain, false, false);
00030 }
00031
00032
00033 L1CaloRegion::L1CaloRegion(unsigned et,
00034 bool overFlow,
00035 bool fineGrain,
00036 bool mip,
00037 bool quiet,
00038 unsigned ieta,
00039 unsigned iphi) :
00040 m_id(ieta, iphi),
00041 m_data(0),
00042 m_bx(0)
00043 {
00044 pack(et, overFlow, fineGrain, mip, quiet);
00045 }
00046
00047
00048 L1CaloRegion::L1CaloRegion(uint16_t data, unsigned ieta, unsigned iphi, int16_t bx) :
00049 m_id(ieta, iphi),
00050 m_data(data),
00051 m_bx(bx)
00052 {
00053
00054 }
00055
00056
00057 L1CaloRegion::~L1CaloRegion() { }
00058
00059
00060
00061
00062 L1CaloRegion L1CaloRegion::makeHBHERegion(unsigned et,
00063 bool overFlow,
00064 bool tauVeto,
00065 bool mip,
00066 bool quiet,
00067 unsigned crate,
00068 unsigned card,
00069 unsigned rgn) {
00070 L1CaloRegion r;
00071 r.setRegionId( L1CaloRegionDetId(crate, card, rgn) );
00072 r.setBx(0);
00073 r.pack(et, overFlow, tauVeto, mip, quiet);
00074 return r;
00075 }
00076
00077
00078 L1CaloRegion L1CaloRegion::makeHFRegion(unsigned et,
00079 bool fineGrain,
00080 unsigned crate,
00081 unsigned rgn) {
00082 L1CaloRegion r;
00083 r.setRegionId( L1CaloRegionDetId(crate, 999, rgn) );
00084 r.setBx(0);
00085 r.pack((et & 0xff), (et >= 0xff), fineGrain, false, false);
00086 return r;
00087 }
00088
00089
00090 L1CaloRegion L1CaloRegion::makeRegionFromGctIndices(unsigned et,
00091 bool overFlow,
00092 bool fineGrain,
00093 bool mip,
00094 bool quiet,
00095 unsigned ieta,
00096 unsigned iphi) {
00097 L1CaloRegion r;
00098 r.setRegionId( L1CaloRegionDetId(ieta, iphi) );
00099 r.setBx(0);
00100 r.pack(et, overFlow, fineGrain, mip, quiet);
00101 return r;
00102 }
00103
00104
00105 L1CaloRegion L1CaloRegion::makeRegionFromUnpacker(uint16_t data,
00106 unsigned ieta,
00107 unsigned iphi,
00108 uint16_t block,
00109 uint16_t index,
00110 int16_t bx)
00111 {
00112 L1CaloRegion r;
00113 r.setRegionId( L1CaloRegionDetId(ieta,iphi) );
00114 r.setRawData(data);
00115 r.setCaptureBlock(block);
00116 r.setCaptureIndex(index);
00117 r.setBx(bx);
00118 return r;
00119 }
00120
00121 L1CaloRegion L1CaloRegion::makeGctJetRegion(const unsigned et,
00122 const bool overFlow,
00123 const bool fineGrain,
00124 const unsigned ieta,
00125 const unsigned iphi,
00126 const int16_t bx) {
00127 L1CaloRegion r;
00128 r.setRegionId( L1CaloRegionDetId(ieta, iphi) );
00129 r.setBx(bx);
00130 r.pack12BitsEt(et, overFlow, fineGrain, false, false);
00131 return r;
00132
00133 }
00134
00135
00136 void L1CaloRegion::setBx(int16_t bx) {
00137 m_bx = bx;
00138 }
00139
00140
00141 void L1CaloRegion::setMip(bool mip) {
00142 if (mip) { m_data |= 0x1000; }
00143 else { m_data &= 0xefff; }
00144 }
00145
00146
00147 void L1CaloRegion::setQuiet(bool quiet) {
00148 if (quiet) { m_data |= 0x2000; }
00149 else { m_data &= 0xdfff; }
00150 }
00151
00152 void L1CaloRegion::pack(unsigned et, bool overFlow, bool fineGrain, bool mip, bool quiet) {
00153 bool checkOvF = overFlow || (et>=0x400);
00154 m_data =
00155 (et & 0x3ff) |
00156 ((checkOvF) ? 0x400 : 0x0) |
00157 ((fineGrain) ? 0x800 : 0x0) |
00158 ((mip) ? 0x1000 : 0x0) |
00159 ((quiet) ? 0x2000 : 0x0);
00160 }
00161
00162 void L1CaloRegion::pack12BitsEt(unsigned et, bool overFlow, bool fineGrain, bool mip, bool quiet) {
00163 bool checkOvF = overFlow || (et>=0x400);
00164 m_data =
00165 (et & 0xfff) |
00166 ((checkOvF) ? 0x400 : 0x0) |
00167 ((fineGrain) ? 0x800 : 0x0) |
00168 ((mip) ? 0x1000 : 0x0) |
00169 ((quiet) ? 0x2000 : 0x0);
00170 }
00171
00172
00173 ostream& operator << (ostream& os, const L1CaloRegion& reg) {
00174 os << "L1CaloRegion:";
00175 os << " Et=" << reg.et();
00176 os << " o/f=" << reg.overFlow();
00177 os << " f/g=" << reg.fineGrain();
00178 os << " tau=" << reg.tauVeto() << endl;
00179 os << " RCT crate=" << reg.rctCrate();
00180 os << " RCT card=" << reg.rctCard();
00181 os << " RCT rgn=" << reg.rctRegionIndex();
00182 os << " RCT eta=" << reg.rctEta();
00183 os << " RCT phi=" << reg.rctPhi() << endl;
00184 os << " GCT eta=" << reg.gctEta();
00185 os << " GCT phi=" << reg.gctPhi() << endl;
00186 os << hex << " cap block=" << reg.capBlock() << dec << ", index=" << reg.capIndex() << ", BX=" << reg.bx();
00187 return os;
00188 }
00189