CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/DataFormats/L1GlobalMuonTrigger/src/L1MuRegionalCand.cc

Go to the documentation of this file.
00001 //-------------------------------------------------
00002 //
00006 //
00007 //   $Date: 2010/12/06 20:04:17 $
00008 //   $Revision: 1.7 $
00009 //
00010 //   Author :
00011 //   H. Sakulin                    HEPHY Vienna
00012 //
00013 //   Migrated to CMSSW:
00014 //   I. Mikulec
00015 //
00016 //--------------------------------------------------
00017 //---------------
00018 // C++ Headers --
00019 //---------------
00020 
00021 #include <iostream>
00022 #include <iomanip>
00023 
00024 //----------------------
00025 // Base Class Headers --
00026 //----------------------
00027 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuRegionalCand.h"
00028 
00029 //------------------------------------
00030 // Collaborating Class Declarations --
00031 //------------------------------------
00032 
00033 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00034 
00035 using namespace std;
00036 
00037 //              ---------------------
00038 //              -- Class Interface --
00039 //              ---------------------
00040 
00041 const float L1MuRegionalCand::m_invalidValue = -10.;
00042 
00044 L1MuRegionalCand::L1MuRegionalCand(unsigned dataword, int bx) : m_bx(bx), m_dataWord(dataword) {
00045   m_phiValue = m_invalidValue; 
00046   m_etaValue = m_invalidValue;
00047   m_ptValue = m_invalidValue;
00048 }
00049 
00051 L1MuRegionalCand::L1MuRegionalCand(unsigned type_idx, 
00052                      unsigned phi, unsigned eta, unsigned pt, unsigned charge,
00053                      unsigned ch_valid, unsigned finehalo, unsigned quality, int bx) : 
00054                      m_bx(bx), m_dataWord(0) {
00055   setType(type_idx);
00056   setPhiPacked(phi);
00057   setEtaPacked(eta);
00058   setPtPacked(pt);
00059   setChargePacked(charge);
00060   setChargeValidPacked(ch_valid);
00061   setFineHaloPacked(finehalo);
00062   setQualityPacked(quality);     
00063   m_phiValue = m_invalidValue; 
00064   m_etaValue = m_invalidValue;
00065   m_ptValue = m_invalidValue;
00066 }
00067 
00068 void L1MuRegionalCand::reset() {
00069 
00070   m_bx       = 0;
00071   m_dataWord = 0;
00072   m_phiValue = m_invalidValue; 
00073   m_etaValue = m_invalidValue;
00074   m_ptValue = m_invalidValue;
00075 
00076 }
00077 
00078 float L1MuRegionalCand::phiValue() const {
00079   if(m_phiValue == m_invalidValue) {
00080     edm::LogWarning("ValueInvalid") << 
00081      "L1MuRegionalCand::phiValue requested physical value is invalid";
00082   }
00083   return m_phiValue;
00084 }
00085 
00086 float L1MuRegionalCand::etaValue() const {
00087   if(m_etaValue == m_invalidValue) {
00088     edm::LogWarning("ValueInvalid") << 
00089      "L1MuRegionalCand::etaValue requested physical value is invalid";
00090   }
00091   return m_etaValue;
00092 }
00093 
00094 float L1MuRegionalCand::ptValue() const {
00095   if(m_ptValue == m_invalidValue) {
00096     edm::LogWarning("ValueInvalid") << 
00097      "L1MuRegionalCand::ptValue requested physical value is invalid";
00098   }
00099   return m_ptValue;
00100 }
00101 
00102 void L1MuRegionalCand::print() const {
00103   if ( !empty() ) {
00104     if(m_phiValue == m_invalidValue ||
00105        m_etaValue == m_invalidValue ||
00106        m_ptValue == m_invalidValue) {
00107       edm::LogVerbatim("GMT_Input_info")
00108            << setiosflags(ios::showpoint | ios::fixed | ios::right | ios::adjustfield)
00109        << "pt(index) = " << setw(2) << setprecision(1) << pt_packed() << "  "
00110        << "charge = " << setw(2) << chargeValue() << "  "
00111        << "eta(index) = " << setw(2) << eta_packed() << "  "
00112        << "phi(index) = " << setw(3) << phi_packed() << "  "
00113        << "quality = " << setw(1) << quality() << "  "
00114        << "charge_valid = " << setw(1) << chargeValid() << "  "
00115        << "fine_halo = " << setw(1) << isFineHalo() << "  "
00116        << "bx = " << setw(3) << bx() << "  " 
00117        << "type_idx = " << setw(1) << type_idx();
00118     } else {
00119       edm::LogVerbatim("GMT_Input_info")
00120            << setiosflags(ios::showpoint | ios::fixed | ios::right | ios::adjustfield)
00121            << "pt = " << setw(5) << setprecision(1) << ptValue() << " GeV  "
00122            << "charge = " << setw(2) << chargeValue() << " "
00123            << "eta = " << setw(6) << setprecision(3) << etaValue() << "  "
00124            << "phi = " << setw(5) << setprecision(3) << phiValue() << " rad  "
00125            << "quality = " << setw(1) << quality() << "  "
00126            << "charge_valid = " << setw(1) << chargeValid() << "  "
00127            << "fine_halo = " << setw(1) << isFineHalo() << "  "
00128            << "bx = " << setw(3) << bx() << "  " 
00129            << "type_idx = " << setw(1) << type_idx();
00130     }
00131   }
00132 }
00133 
00134 
00135 unsigned L1MuRegionalCand::readDataField(unsigned start, unsigned count) const {
00136   unsigned mask = ( (1 << count) - 1 ) << start;
00137   return (m_dataWord & mask) >> start;
00138 }
00139 
00140 void L1MuRegionalCand::writeDataField(unsigned start, unsigned count, unsigned value) {
00141   if ( value >= ( 1U << count ) ) edm::LogWarning("ValueOutOfRange") // value >= 0, since value is unsigned
00142          << "L1MuRegionalCand::writeDataField(): value " << value  
00143          << " out of range for data field with bit width "  << count;
00144 
00145   unsigned mask = ( (1 << count) - 1 ) << start;
00146   m_dataWord &= ~mask; // clear
00147   m_dataWord |= (value << start) & mask ;
00148 }
00149