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