Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:48

0001 //-------------------------------------------------
0002 //
0003 /** \class L1MuRegionalCand
0004  *  A regional muon trigger candidate as received by the GMT
0005 */
0006 //
0007 //
0008 //   Author :
0009 //   H. Sakulin                    HEPHY Vienna
0010 //
0011 //   Migrated to CMSSW:
0012 //   I. Mikulec
0013 //
0014 //--------------------------------------------------
0015 //---------------
0016 // C++ Headers --
0017 //---------------
0018 
0019 #include <iostream>
0020 #include <iomanip>
0021 
0022 //----------------------
0023 // Base Class Headers --
0024 //----------------------
0025 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuRegionalCand.h"
0026 
0027 //------------------------------------
0028 // Collaborating Class Declarations --
0029 //------------------------------------
0030 
0031 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0032 
0033 using namespace std;
0034 
0035 //              ---------------------
0036 //              -- Class Interface --
0037 //              ---------------------
0038 
0039 const float L1MuRegionalCand::m_invalidValue = -10.;
0040 
0041 /// constructor from data word
0042 L1MuRegionalCand::L1MuRegionalCand(unsigned dataword, int bx) : m_bx(bx), m_dataWord(dataword) {
0043   m_phiValue = m_invalidValue;
0044   m_etaValue = m_invalidValue;
0045   m_ptValue = m_invalidValue;
0046 }
0047 
0048 /// constructor from packed members
0049 L1MuRegionalCand::L1MuRegionalCand(unsigned type_idx,
0050                                    unsigned phi,
0051                                    unsigned eta,
0052                                    unsigned pt,
0053                                    unsigned charge,
0054                                    unsigned ch_valid,
0055                                    unsigned finehalo,
0056                                    unsigned quality,
0057                                    int bx)
0058     : m_bx(bx), m_dataWord(0) {
0059   setType(type_idx);
0060   setPhiPacked(phi);
0061   setEtaPacked(eta);
0062   setPtPacked(pt);
0063   setChargePacked(charge);
0064   setChargeValidPacked(ch_valid);
0065   setFineHaloPacked(finehalo);
0066   setQualityPacked(quality);
0067   m_phiValue = m_invalidValue;
0068   m_etaValue = m_invalidValue;
0069   m_ptValue = m_invalidValue;
0070 }
0071 
0072 void L1MuRegionalCand::reset() {
0073   m_bx = 0;
0074   m_dataWord = 0;
0075   m_phiValue = m_invalidValue;
0076   m_etaValue = m_invalidValue;
0077   m_ptValue = m_invalidValue;
0078 }
0079 
0080 float L1MuRegionalCand::phiValue() const {
0081   if (m_phiValue == m_invalidValue) {
0082     edm::LogWarning("ValueInvalid") << "L1MuRegionalCand::phiValue requested physical value is invalid";
0083   }
0084   return m_phiValue;
0085 }
0086 
0087 float L1MuRegionalCand::etaValue() const {
0088   if (m_etaValue == m_invalidValue) {
0089     edm::LogWarning("ValueInvalid") << "L1MuRegionalCand::etaValue requested physical value is invalid";
0090   }
0091   return m_etaValue;
0092 }
0093 
0094 float L1MuRegionalCand::ptValue() const {
0095   if (m_ptValue == m_invalidValue) {
0096     edm::LogWarning("ValueInvalid") << "L1MuRegionalCand::ptValue requested physical value is invalid";
0097   }
0098   return m_ptValue;
0099 }
0100 
0101 void L1MuRegionalCand::print() const {
0102   if (!empty()) {
0103     if (m_phiValue == m_invalidValue || m_etaValue == m_invalidValue || m_ptValue == m_invalidValue) {
0104       edm::LogVerbatim("GMT_Input_info") << setiosflags(ios::showpoint | ios::fixed | ios::right | ios::adjustfield)
0105                                          << "pt(index) = " << setw(2) << setprecision(1) << pt_packed() << "  "
0106                                          << "charge = " << setw(2) << chargeValue() << "  "
0107                                          << "eta(index) = " << setw(2) << eta_packed() << "  "
0108                                          << "phi(index) = " << setw(3) << phi_packed() << "  "
0109                                          << "quality = " << setw(1) << quality() << "  "
0110                                          << "charge_valid = " << setw(1) << chargeValid() << "  "
0111                                          << "fine_halo = " << setw(1) << isFineHalo() << "  "
0112                                          << "bx = " << setw(3) << bx() << "  "
0113                                          << "type_idx = " << setw(1) << type_idx();
0114     } else {
0115       edm::LogVerbatim("GMT_Input_info") << setiosflags(ios::showpoint | ios::fixed | ios::right | ios::adjustfield)
0116                                          << "pt = " << setw(5) << setprecision(1) << ptValue() << " GeV  "
0117                                          << "charge = " << setw(2) << chargeValue() << " "
0118                                          << "eta = " << setw(6) << setprecision(3) << etaValue() << "  "
0119                                          << "phi = " << setw(5) << setprecision(3) << phiValue() << " rad  "
0120                                          << "quality = " << setw(1) << quality() << "  "
0121                                          << "charge_valid = " << setw(1) << chargeValid() << "  "
0122                                          << "fine_halo = " << setw(1) << isFineHalo() << "  "
0123                                          << "bx = " << setw(3) << bx() << "  "
0124                                          << "type_idx = " << setw(1) << type_idx();
0125     }
0126   }
0127 }
0128 
0129 unsigned L1MuRegionalCand::readDataField(unsigned start, unsigned count) const {
0130   unsigned mask = ((1 << count) - 1) << start;
0131   return (m_dataWord & mask) >> start;
0132 }
0133 
0134 void L1MuRegionalCand::writeDataField(unsigned start, unsigned count, unsigned value) {
0135   if (value >= (1U << count))
0136     edm::LogWarning("ValueOutOfRange")  // value >= 0, since value is unsigned
0137         << "L1MuRegionalCand::writeDataField(): value " << value << " out of range for data field with bit width "
0138         << count;
0139 
0140   unsigned mask = ((1 << count) - 1) << start;
0141   m_dataWord &= ~mask;  // clear
0142   m_dataWord |= (value << start) & mask;
0143 }