00001
00002
00003 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctJetCand.h"
00004
00005
00006 using std::ostream;
00007 using std::string;
00008 using std::hex;
00009 using std::dec;
00010
00011 L1GctJetCand::L1GctJetCand() :
00012 m_data(0),
00013 m_isTau(false),
00014 m_isFor(false),
00015 m_captureBlock(0),
00016 m_captureIndex(0),
00017 m_bx(0)
00018 {
00019
00020 }
00021
00022
00023 L1GctJetCand::L1GctJetCand(uint16_t rawData, bool isTau, bool isFor) :
00024 m_data(rawData & 0x7fff),
00025 m_isTau(isTau),
00026 m_isFor(isFor),
00027 m_captureBlock(0),
00028 m_captureIndex(0),
00029 m_bx(0)
00030 {
00031 }
00032
00033
00034 L1GctJetCand::L1GctJetCand(uint16_t rawData, bool isTau, bool isFor, uint16_t block, uint16_t index, int16_t bx) :
00035 m_data(rawData & 0x7fff),
00036 m_isTau(isTau),
00037 m_isFor(isFor),
00038 m_captureBlock(block&0xfff),
00039 m_captureIndex(index&0xff),
00040 m_bx(bx)
00041 {
00042 }
00043
00044
00045
00046 L1GctJetCand::L1GctJetCand(unsigned rank, unsigned phi, unsigned eta, bool isTau, bool isFor) :
00047 m_data(0),
00048 m_isTau(isTau),
00049 m_isFor(isFor),
00050 m_captureBlock(0),
00051 m_captureIndex(0),
00052 m_bx(0)
00053 {
00054 m_data = (rank & 0x3f) + ((eta & 0xf)<<6) + ((phi & 0x1f)<<10);
00055 }
00056
00057
00058
00059 L1GctJetCand::L1GctJetCand(unsigned rank, unsigned phi, unsigned eta, bool isTau, bool isFor, uint16_t block, uint16_t index, int16_t bx) :
00060 m_data(0),
00061 m_isTau(isTau),
00062 m_isFor(isFor),
00063 m_captureBlock(block&0xfff),
00064 m_captureIndex(index&0xff),
00065 m_bx(bx)
00066 {
00067 m_data = (rank & 0x3f) + ((eta & 0xf)<<6) + ((phi & 0x1f)<<10);
00068 }
00069
00070 L1GctJetCand::~L1GctJetCand() { }
00071
00072
00073 string L1GctJetCand::name() const {
00074 if (m_isTau) { return "tau jet"; }
00075 else if (m_isFor) { return "forward jet"; }
00076 else { return "central jet"; }
00077 }
00078
00079
00080 bool L1GctJetCand::empty() const {
00081 return (rank() == 0);
00082 }
00083
00084
00085 ostream& operator<<(ostream& s, const L1GctJetCand& cand) {
00086 if (cand.empty()) {
00087 s << "L1GctJetCand empty jet";
00088 } else {
00089 s << "L1GctJetCand : ";
00090 s << "rank=" << cand.rank();
00091 s << ", etaSign=" << cand.etaSign() << ", eta=" << (cand.etaIndex()&0x7) << ", phi=" << cand.phiIndex();
00092 s << " type=";
00093 if (cand.isTau()) { s << "tau"; }
00094 else if (cand.isForward()) { s << "forward"; }
00095 else { s << "central"; }
00096 }
00097 s << hex << " cap block=" << cand.capBlock() << dec << ", index=" << cand.capIndex() << ", BX=" << cand.bx();
00098 return s;
00099 }
00100
00101 L1CaloRegionDetId L1GctJetCand::regionId() const {
00102
00103
00104 unsigned eta;
00105 if ( !isForward() ) {
00106 eta = ( etaSign()==1 ? 10-(etaIndex()&0x7) : (etaIndex()&0x7)+11 );
00107 }
00108 else {
00109 eta = ( etaSign()==1 ? 3-(etaIndex()&0x7) : (etaIndex()&0x7)+18 );
00110 }
00111
00112 return L1CaloRegionDetId(eta, phiIndex());
00113
00114 }
00115
00117 unsigned L1GctJetCand::rank() const { return m_data & 0x3f; }
00118
00120 unsigned L1GctJetCand::etaIndex() const { return (m_data>>6) & 0xf; }
00121
00123 unsigned L1GctJetCand::phiIndex() const { return (m_data>>10) & 0x1f; }
00124