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
00091
00092 L1CaloRegionDetId L1GctEmCand::regionId() const {
00093
00094 unsigned eta = ( etaSign()==1 ? 10-(etaIndex()&0x7) : 11+(etaIndex()&0x7) );
00095 return L1CaloRegionDetId(eta, phiIndex());
00096 }
00097
00098
00099 void L1GctEmCand::construct(unsigned rank, unsigned eta, unsigned phi) {
00100 if (rank>0) {
00101 m_data = (rank & 0x3f) + ((eta & 0xf)<<6) + ((phi & 0x1f)<<10);
00102 } else {
00103
00104
00105 if ((eta & 0x8)==0) { m_data = 0x7000; } else { m_data = 0x7400; }
00106 }
00107 }
00108
00109
00110 ostream& operator<<(ostream& s, const L1GctEmCand& cand) {
00111 s << "L1GctEmCand : ";
00112 s << "rank=" << cand.rank();
00113 s << ", etaSign=" << cand.etaSign() << ", eta=" << (cand.etaIndex()&0x7) << ", phi=" << cand.phiIndex();
00114 s << ", iso=" << cand.isolated();
00115 s << hex << " cap block=" << cand.capBlock() << dec << ", index=" << cand.capIndex() << ", BX=" << cand.bx();
00116 return s;
00117 }
00118
00119