CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch2/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 
00090 
00091 // return region object
00092 L1CaloRegionDetId L1GctEmCand::regionId() const {
00093   // get global eta
00094   unsigned eta = ( etaSign()==1 ? 10-(etaIndex()&0x7) : 11+(etaIndex()&0x7) );
00095   return L1CaloRegionDetId(eta, phiIndex());
00096 }
00097 
00098 // construct from rank, eta, phi
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     // Default values for zero rank electrons,
00104     // different in hardware for positive and negative eta
00105     if ((eta & 0x8)==0) { m_data = 0x7000; } else { m_data = 0x7400; }
00106   }
00107 }
00108 
00109 // pretty print
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