CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/DataFormats/L1GlobalCaloTrigger/src/L1GctEmCand.cc

Go to the documentation of this file.
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 // default constructor
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 // construct from raw data, no source (i.e. no capBlock/capIndex); used in GT
00023 L1GctEmCand::L1GctEmCand(uint16_t rawData, bool iso) :
00024   m_data(rawData & 0x7fff), // 0x7fff is to mask off bit 15, which is not data that needs to be stored
00025   m_iso(iso),
00026   m_captureBlock(0),
00027   m_captureIndex(0),
00028   m_bx(0)
00029 {
00030 
00031 }
00032 
00033 // construct from raw data with source - used in GCT unpacker
00034  L1GctEmCand::L1GctEmCand(uint16_t rawData, bool iso, uint16_t block, uint16_t index, int16_t bx) :
00035    m_data(rawData & 0x7fff), // 0x7fff is to mask off bit 15, which is not data that needs to be stored
00036    m_iso(iso),
00037    m_captureBlock(block&0xfff),
00038    m_captureIndex(index&0xff),
00039    m_bx(bx)
00040 {
00041 
00042 }
00043 
00044 // construct from content - used in GCT emulator
00045 // eta = -6 to -0, +0 to +6. Sign is bit 3, 1 means -ve Z, 0 means +ve Z
00046 L1GctEmCand::L1GctEmCand(unsigned rank, unsigned phi, unsigned eta, bool iso) : 
00047   m_data(0), // override below
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 // construct from content, with source (i.e. capBlock/capIndex); will be used in GCT emulator one day?
00058 // eta = -6 to -0, +0 to +6. Sign is bit 3, 1 means -ve Z, 0 means +ve Z
00059 L1GctEmCand::L1GctEmCand(unsigned rank, unsigned phi, unsigned eta, bool iso, uint16_t block, uint16_t index, int16_t bx) : 
00060   m_data(0), // override below
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 // construct from RCT output candidate
00070 L1GctEmCand::L1GctEmCand(L1CaloEmCand& c) :
00071   m_data(0), // override below
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 // destructor
00082 L1GctEmCand::~L1GctEmCand() { } 
00083 
00084 // name of candidate type
00085 string L1GctEmCand::name() const {
00086   return (isolated() ? "iso EM" : "non iso EM" ); 
00087 }
00088 
00089 // was a candidate found
00090 bool L1GctEmCand::empty() const { 
00091   return (rank() == 0); 
00092 }
00093 
00094 // return region object
00095 L1CaloRegionDetId L1GctEmCand::regionId() const {
00096   // get global eta
00097   unsigned eta = ( etaSign()==1 ? 10-(etaIndex()&0x7) : 11+(etaIndex()&0x7) );
00098   return L1CaloRegionDetId(eta, phiIndex());
00099 }
00100 
00101 // construct from rank, eta, phi
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     // Default values for zero rank electrons,
00107     // different in hardware for positive and negative eta
00108     if ((eta & 0x8)==0) { m_data = 0x7000; } else { m_data = 0x7400; }
00109   }
00110 }
00111 
00112 // pretty print
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