CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DataFormats/L1GlobalCaloTrigger/src/L1GctInternEmCand.cc

Go to the documentation of this file.
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 // default constructor
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 // construct from raw data (for use in unpacking)
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 // construct from eta/phi etc
00035 L1GctInternEmCand::L1GctInternEmCand(unsigned rank, unsigned eta, unsigned etaSgn, unsigned phi, bool iso, unsigned block, unsigned index, int16_t bx) :
00036   m_data(0), // Over-ridden in construct()
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 // destructor
00046 L1GctInternEmCand::~L1GctInternEmCand() { } 
00047 
00048 // name of candidate type
00049 string L1GctInternEmCand::name() const {
00050   return (isolated() ? "iso EM" : "non iso EM" ); 
00051 }
00052 
00053 // was a candidate found
00054 bool L1GctInternEmCand::empty() const { 
00055   return (rank() == 0); 
00056 }
00057 
00058 // pretty print
00059 ostream& operator<<(ostream& s, const L1GctInternEmCand& cand) {
00060   s << "L1GctInternEmCand : ";
00061   s << "rank=" << cand.rank();
00062   s << ", etaSign=" << cand.etaSign() << ", eta=" << (cand.etaIndex()&0xf) << ", phi=" << cand.phiIndex();
00063   s << ", iso=" << cand.isolated();
00064   s << " cap block=" << hex << cand.capBlock();
00065   s << ", index=" << dec << cand.capIndex() << ", BX=" << cand.bx();
00066   return s;
00067 }
00068 
00069 // return region object
00070 L1CaloRegionDetId L1GctInternEmCand::regionId() const {
00071   // get global eta
00072   unsigned eta = ( etaSign()==1 ? 10-(etaIndex()&0xf) : 11+(etaIndex()&0xf) );
00073   return L1CaloRegionDetId(eta, phiIndex());
00074 }
00075 
00076 // construct from rank, eta, phi
00077 void L1GctInternEmCand::construct(unsigned rank, unsigned eta, unsigned etaSgn, unsigned phi) {
00078   m_data = (rank & 0x3f) + ((eta & 0xf)<<6) + ((etaSgn & 0x1)<<10) + ((phi & 0x1f)<<11);
00079 }