CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/DataFormats/L1GlobalCaloTrigger/src/L1GctJetCand.cc

Go to the documentation of this file.
00001 
00002 
00003 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctJetCand.h"
00004 
00005 
00006 using std::ostream;
00007 using std::string;
00008 using std::hex;
00009 using std::dec;
00010 
00011 L1GctJetCand::L1GctJetCand() :
00012   m_data(0),
00013   m_isTau(false),
00014   m_isFor(false),
00015   m_captureBlock(0),
00016   m_captureIndex(0),
00017   m_bx(0)
00018 {
00019 
00020 }
00021 
00022 //constructor for GT
00023 L1GctJetCand::L1GctJetCand(uint16_t rawData, bool isTau, bool isFor) :
00024   m_data(rawData & 0x7fff), // 0x7fff is to mask off bit 15, which is not data that needs to be stored
00025   m_isTau(isTau),
00026   m_isFor(isFor),
00027   m_captureBlock(0),
00028   m_captureIndex(0),
00029   m_bx(0)
00030 {
00031 }
00032 
00033 //constructor for GCT unpacker
00034 L1GctJetCand::L1GctJetCand(uint16_t rawData, bool isTau, bool isFor, 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_isTau(isTau),
00037   m_isFor(isFor),
00038   m_captureBlock(block&0xfff),
00039   m_captureIndex(index&0xff),
00040   m_bx(bx)
00041 {
00042 }
00043 
00044 // constructor for use in emulator
00045 // eta = -6 to -0, +0 to +6. Sign is bit 3, 1 means -ve Z, 0 means +ve Z
00046 L1GctJetCand::L1GctJetCand(unsigned rank, unsigned phi, unsigned eta, bool isTau, bool isFor) : 
00047   m_data(0), // overridden below
00048   m_isTau(isTau),
00049   m_isFor(isFor),
00050   m_captureBlock(0),
00051   m_captureIndex(0),
00052   m_bx(0)
00053 { 
00054   m_data = (rank & 0x3f) + ((eta & 0xf)<<6) + ((phi & 0x1f)<<10); 
00055 }
00056 
00057 // constructor for use in emulator
00058 // eta = -6 to -0, +0 to +6. Sign is bit 3, 1 means -ve Z, 0 means +ve Z
00059 L1GctJetCand::L1GctJetCand(unsigned rank, unsigned phi, unsigned eta, bool isTau, bool isFor, uint16_t block, uint16_t index, int16_t bx) : 
00060   m_data(0), // overridden below
00061   m_isTau(isTau),
00062   m_isFor(isFor),
00063   m_captureBlock(block&0xfff),
00064   m_captureIndex(index&0xff),
00065   m_bx(bx)
00066 { 
00067   m_data = (rank & 0x3f) + ((eta & 0xf)<<6) + ((phi & 0x1f)<<10); 
00068 }
00069 
00070 L1GctJetCand::~L1GctJetCand() { } 
00071 
00072 // return name
00073 string L1GctJetCand::name() const { 
00074   if (m_isTau) { return "tau jet"; }
00075   else if (m_isFor) { return "forward jet"; }
00076   else { return "central jet"; }
00077 }
00078 
00079 
00080 // pretty print
00081 ostream& operator<<(ostream& s, const L1GctJetCand& cand) {
00082   if (cand.empty()) {
00083     s << "L1GctJetCand empty jet";
00084   } else {
00085     s << "L1GctJetCand : ";
00086     s << "rank=" << cand.rank();
00087     s << ", etaSign=" << cand.etaSign() << ", eta=" << (cand.etaIndex()&0x7) << ", phi=" << cand.phiIndex();
00088     s << " type=";
00089     if (cand.isTau()) { s << "tau"; }
00090     else if (cand.isForward()) { s << "forward"; }
00091     else { s << "central"; }
00092   }
00093   s << hex << " cap block=" << cand.capBlock() << dec << ", index=" << cand.capIndex() << ", BX=" << cand.bx();
00094   return s;
00095 }
00096 
00097 L1CaloRegionDetId L1GctJetCand::regionId() const {
00098 
00099   // get global eta
00100   unsigned eta;
00101   if ( !isForward() ) {
00102     eta = ( etaSign()==1 ? 10-(etaIndex()&0x7)  : (etaIndex()&0x7)+11 );
00103   }
00104   else {
00105     eta = ( etaSign()==1 ? 3-(etaIndex()&0x7) : (etaIndex()&0x7)+18 );
00106   }
00107 
00108   return L1CaloRegionDetId(eta, phiIndex());
00109 
00110 }
00111 
00112