00001 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctInternEmCand.h"
00002
00003 #include <iostream>
00004
00005 #include "DataFormats/L1CaloTrigger/interface/L1CaloRegionDetId.h"
00006
00007 using std::ostream;
00008 using std::string;
00009 using std::hex;
00010 using std::dec;
00011
00012
00013 L1GctInternEmCand::L1GctInternEmCand() :
00014 m_data(0),
00015 m_captureBlock(0),
00016 m_captureIndex(0),
00017 m_iso(false),
00018 m_bx(0)
00019 {
00020
00021 }
00022
00023
00024 L1GctInternEmCand::L1GctInternEmCand(uint16_t data, bool iso, unsigned block, unsigned index, int16_t bx) :
00025 m_data(data),
00026 m_captureBlock(block&0xfff),
00027 m_captureIndex(index&0xff),
00028 m_iso(iso),
00029 m_bx(bx)
00030 {
00031
00032 }
00033
00034
00035 L1GctInternEmCand::L1GctInternEmCand(unsigned rank, unsigned eta, unsigned etaSgn, unsigned phi, bool iso, unsigned block, unsigned index, int16_t bx) :
00036 m_data(0),
00037 m_captureBlock(block&0xfff),
00038 m_captureIndex(index&0xff),
00039 m_iso(iso),
00040 m_bx(bx)
00041 {
00042 construct(rank, eta, etaSgn, phi);
00043 }
00044
00045
00046 L1GctInternEmCand::~L1GctInternEmCand() { }
00047
00048
00049 string L1GctInternEmCand::name() const {
00050 return (isolated() ? "iso EM" : "non iso EM" );
00051 }
00052
00053
00054 bool L1GctInternEmCand::empty() const {
00055 return (rank() == 0);
00056 }
00057
00058
00059 ostream& operator<<(ostream& s, const L1GctInternEmCand& cand) {
00060 s << "L1GctInternEmCand : ";
00061 s << "rank=" << hex << cand.rank();
00062 s << ", etaSign=" << cand.etaSign() << ", eta=" << (cand.etaIndex()&0xf) << ", phi=" << cand.phiIndex();
00063 s << ", iso=" << cand.isolated();
00064 s << " cap block=" << cand.capBlock() << ", index=" << cand.capIndex() << ", BX=" << cand.bx() << dec;
00065 return s;
00066 }
00067
00068
00069 L1CaloRegionDetId L1GctInternEmCand::regionId() const {
00070
00071 unsigned eta = ( etaSign()==1 ? 10-(etaIndex()&0xf) : 11+(etaIndex()&0xf) );
00072 return L1CaloRegionDetId(eta, phiIndex());
00073 }
00074
00075
00076 void L1GctInternEmCand::construct(unsigned rank, unsigned eta, unsigned etaSgn, unsigned phi) {
00077 m_data = (rank & 0x3f) + ((eta & 0xf)<<6) + ((etaSgn & 0x1)<<10) + ((phi & 0x1f)<<11);
00078 }