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, bool overFlow, bool fineGrain, bool mip, bool quiet, unsigned ieta, unsigned iphi) :
00034 m_id(ieta, iphi),
00035 m_data(0),
00036 m_bx(0)
00037 {
00038 pack(et, overFlow, fineGrain, mip, quiet);
00039 }
00040
00041
00042 L1CaloRegion::L1CaloRegion(uint16_t data, unsigned ieta, unsigned iphi, int16_t bx) :
00043 m_id(ieta, iphi),
00044 m_data(data),
00045 m_bx(bx)
00046 {
00047
00048 }
00049
00050
00051 L1CaloRegion::~L1CaloRegion() { }
00052
00053
00054 void L1CaloRegion::setBx(int16_t bx) {
00055 m_bx = bx;
00056 }
00057
00058
00059 void L1CaloRegion::setMip(bool mip) {
00060 if (mip) { m_data |= 0x1000; }
00061 else { m_data &= 0xefff; }
00062 }
00063
00064
00065 void L1CaloRegion::setQuiet(bool quiet) {
00066 if (quiet) { m_data |= 0x2000; }
00067 else { m_data &= 0xdfff; }
00068 }
00069
00070 void L1CaloRegion::pack(unsigned et, bool overFlow, bool fineGrain, bool mip, bool quiet) {
00071 bool checkOvF = overFlow || (et>=0x400);
00072 m_data =
00073 (et & 0x3ff) |
00074 ((checkOvF) ? 0x400 : 0x0) |
00075 ((fineGrain) ? 0x800 : 0x0) |
00076 ((mip) ? 0x1000 : 0x0) |
00077 ((quiet) ? 0x2000 : 0x0);
00078 }
00079
00080
00081 ostream& operator << (ostream& os, const L1CaloRegion& reg) {
00082 os << "L1CaloRegion:" << hex;
00083 os << " Et=" << reg.et();
00084 os << " o/f=" << reg.overFlow();
00085 os << " f/g=" << reg.fineGrain();
00086 os << " tau=" << reg.tauVeto();
00087 os << " mip=" << reg.mip();
00088 os << " qt=" << reg.quiet();
00089 os << endl;
00090 os << " ";
00091 os << " RCT crate=" << reg.rctCrate();
00092 os << " RCT crad=" << reg.rctCard();
00093 os << " RCT rgn=" << reg.rctRegionIndex();
00094 os << " RCT eta=" << reg.rctEta();
00095 os << " RCT phi=" << reg.rctPhi();
00096 os << endl;
00097 os << " ";
00098 os << " GCT eta=" << reg.gctEta();
00099 os << " GCT phi=" << reg.gctPhi();
00100 os << endl;
00101 os << " BX=" << reg.m_bx << endl;
00102 os << dec;
00103 return os;
00104 }
00105