Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:27

0001 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctInternEmCand.h"
0002 
0003 #include <iostream>
0004 
0005 #include "DataFormats/L1CaloTrigger/interface/L1CaloRegionDetId.h"
0006 
0007 using std::dec;
0008 using std::hex;
0009 using std::ostream;
0010 using std::string;
0011 
0012 // default constructor
0013 L1GctInternEmCand::L1GctInternEmCand() : m_data(0), m_captureBlock(0), m_captureIndex(0), m_iso(false), m_bx(0) {}
0014 
0015 // construct from raw data (for use in unpacking)
0016 L1GctInternEmCand::L1GctInternEmCand(uint16_t data, bool iso, unsigned block, unsigned index, int16_t bx)
0017     : m_data(data), m_captureBlock(block & 0xfff), m_captureIndex(index & 0xff), m_iso(iso), m_bx(bx) {}
0018 
0019 // construct from eta/phi etc
0020 L1GctInternEmCand::L1GctInternEmCand(
0021     unsigned rank, unsigned eta, unsigned etaSgn, unsigned phi, bool iso, unsigned block, unsigned index, int16_t bx)
0022     : m_data(0),  // Over-ridden in construct()
0023       m_captureBlock(block & 0xfff),
0024       m_captureIndex(index & 0xff),
0025       m_iso(iso),
0026       m_bx(bx) {
0027   construct(rank, eta, etaSgn, phi);
0028 }
0029 
0030 // destructor
0031 L1GctInternEmCand::~L1GctInternEmCand() {}
0032 
0033 // name of candidate type
0034 string L1GctInternEmCand::name() const { return (isolated() ? "iso EM" : "non iso EM"); }
0035 
0036 // was a candidate found
0037 bool L1GctInternEmCand::empty() const { return (rank() == 0); }
0038 
0039 // pretty print
0040 ostream& operator<<(ostream& s, const L1GctInternEmCand& cand) {
0041   s << "L1GctInternEmCand : ";
0042   s << "rank=" << cand.rank();
0043   s << ", etaSign=" << cand.etaSign() << ", eta=" << (cand.etaIndex() & 0xf) << ", phi=" << cand.phiIndex();
0044   s << ", iso=" << cand.isolated();
0045   s << " cap block=" << hex << cand.capBlock();
0046   s << ", index=" << dec << cand.capIndex() << ", BX=" << cand.bx();
0047   return s;
0048 }
0049 
0050 // return region object
0051 L1CaloRegionDetId L1GctInternEmCand::regionId() const {
0052   // get global eta
0053   unsigned eta = (etaSign() == 1 ? 10 - (etaIndex() & 0xf) : 11 + (etaIndex() & 0xf));
0054   return L1CaloRegionDetId(eta, phiIndex());
0055 }
0056 
0057 // construct from rank, eta, phi
0058 void L1GctInternEmCand::construct(unsigned rank, unsigned eta, unsigned etaSgn, unsigned phi) {
0059   m_data = (rank & 0x3f) + ((eta & 0xf) << 6) + ((etaSgn & 0x1) << 10) + ((phi & 0x1f) << 11);
0060 }