Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 //-------------------------------------------------
0002 //
0003 //   Class: L1MuGMTCand
0004 //
0005 //   Description: L1 Global Muon Trigger Candidate
0006 //
0007 //
0008 //
0009 //   Author :
0010 //   N. Neumeister            CERN EP
0011 //
0012 //   Migrated to CMSSW:
0013 //   I. Mikulec
0014 //
0015 //--------------------------------------------------
0016 
0017 //-----------------------
0018 // This Class's Header --
0019 //-----------------------
0020 
0021 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTCand.h"
0022 
0023 //---------------
0024 // C++ Headers --
0025 //---------------
0026 
0027 #include <iostream>
0028 #include <iomanip>
0029 #include <cmath>
0030 
0031 //-------------------------------
0032 // Collaborating Class Headers --
0033 //-------------------------------
0034 
0035 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0036 
0037 //---------------------------------
0038 //       class L1MuGMTCand
0039 //---------------------------------
0040 
0041 using namespace std;
0042 
0043 const float L1MuGMTCand::m_invalidValue = -10.;
0044 
0045 //----------------
0046 // Constructors --
0047 //----------------
0048 
0049 L1MuGMTCand::L1MuGMTCand() : m_name("L1MuGMTCand"), m_bx(0), m_dataWord(0) {
0050   m_phiValue = m_invalidValue;
0051   m_etaValue = m_invalidValue;
0052   m_ptValue = m_invalidValue;
0053 }
0054 
0055 L1MuGMTCand::L1MuGMTCand(const L1MuGMTCand& mu)
0056     : m_name(mu.m_name),
0057       m_bx(mu.m_bx),
0058       m_dataWord(mu.m_dataWord),
0059       m_phiValue(mu.m_phiValue),
0060       m_etaValue(mu.m_etaValue),
0061       m_ptValue(mu.m_ptValue) {}
0062 
0063 L1MuGMTCand::L1MuGMTCand(unsigned data, int bx) : m_name("L1MuGMTCand"), m_bx(bx), m_dataWord(data) {
0064   m_phiValue = m_invalidValue;
0065   m_etaValue = m_invalidValue;
0066   m_ptValue = m_invalidValue;
0067 }
0068 
0069 //--------------
0070 // Destructor --
0071 //--------------
0072 L1MuGMTCand::~L1MuGMTCand() { reset(); }
0073 
0074 //--------------
0075 // Operations --
0076 //--------------
0077 
0078 //
0079 // reset Muon Track Candidate
0080 //
0081 void L1MuGMTCand::reset() {
0082   m_bx = 0;
0083   m_dataWord = 0;
0084   m_phiValue = m_invalidValue;
0085   m_etaValue = m_invalidValue;
0086   m_ptValue = m_invalidValue;
0087 }
0088 
0089 //
0090 // return phi of track candidate in radians
0091 //
0092 float L1MuGMTCand::phiValue() const {
0093   if (m_phiValue == m_invalidValue) {
0094     edm::LogWarning("ValueInvalid") << "L1MuGMTCand::phiValue requested physical value is invalid";
0095   }
0096   return m_phiValue;
0097 }
0098 
0099 //
0100 // return eta of track candidate
0101 //
0102 float L1MuGMTCand::etaValue() const {
0103   if (m_etaValue == m_invalidValue) {
0104     edm::LogWarning("ValueInvalid") << "L1MuGMTCand::etaValue requested physical value is invalid";
0105   }
0106   return m_etaValue;
0107 }
0108 
0109 //
0110 // return pt-value of track candidate in GeV
0111 //
0112 float L1MuGMTCand::ptValue() const {
0113   if (m_ptValue == m_invalidValue) {
0114     edm::LogWarning("ValueInvalid") << "L1MuRegionalCand::ptValue requested physical value is invalid";
0115   }
0116   return m_ptValue;
0117 }
0118 
0119 //
0120 // Equal operator
0121 //
0122 bool L1MuGMTCand::operator==(const L1MuGMTCand& cand) const {
0123   if (m_bx != cand.m_bx)
0124     return false;
0125   if (m_dataWord != cand.m_dataWord)
0126     return false;
0127   return true;
0128 }
0129 
0130 //
0131 // Unequal operator
0132 //
0133 bool L1MuGMTCand::operator!=(const L1MuGMTCand& cand) const {
0134   if (m_bx != cand.m_bx)
0135     return true;
0136   if (m_dataWord != cand.m_dataWord)
0137     return true;
0138   return false;
0139 }
0140 
0141 //
0142 // print parameters of track candidate
0143 //
0144 void L1MuGMTCand::print() const {
0145   if (!empty()) {
0146     if (m_phiValue == m_invalidValue || m_etaValue == m_invalidValue || m_ptValue == m_invalidValue) {
0147       edm::LogVerbatim("GMT_Candidate_info") << setiosflags(ios::right | ios::adjustfield | ios::showpoint | ios::fixed)
0148                                              << "bx = " << setw(2) << bx() << " " << endl
0149                                              << "pt(index) = " << setw(2) << ptIndex() << "  "
0150                                              << "charge = " << setw(2) << charge() << "  "
0151                                              << "eta(index) = " << setw(2) << etaIndex() << "  "
0152                                              << "phi(index) = " << setw(3) << phiIndex() << "  "
0153                                              << "quality = " << setw(1) << quality() << "  "
0154                                              << "isolated = " << setw(1) << isol() << "  "
0155                                              << "mip = " << setw(1) << mip() << endl;
0156     } else {
0157       edm::LogVerbatim("GMT_Candidate_info") << setiosflags(ios::right | ios::adjustfield | ios::showpoint | ios::fixed)
0158                                              << "bx = " << setw(2) << bx() << " " << endl
0159                                              << "pt = " << setw(5) << setprecision(1) << ptValue() << " GeV  "
0160                                              << "charge = " << setw(2) << charge() << "  "
0161                                              << "eta = " << setw(5) << setprecision(2) << etaValue() << "  "
0162                                              << "phi = " << setw(5) << setprecision(3) << phiValue() << " rad  "
0163                                              << "quality = " << setw(1) << quality() << "  "
0164                                              << "isolated = " << setw(1) << isol() << "  "
0165                                              << "mip = " << setw(1) << mip() << endl;
0166     }
0167   }
0168 }
0169 
0170 //
0171 // output stream operator for track candidate
0172 //
0173 ostream& operator<<(ostream& s, const L1MuGMTCand& id) {
0174   if (!id.empty()) {
0175     s << setiosflags(ios::showpoint | ios::fixed) << "bx = " << setw(2) << id.bx() << "  "
0176       << "pt = " << setw(5) << setprecision(1) << id.ptValue() << " GeV  "
0177       << "charge = " << setw(2) << id.charge() << "  "
0178       << "eta = " << setw(5) << setprecision(2) << id.etaValue() << "  "
0179       << "phi = " << setw(5) << setprecision(3) << id.phiValue() << " rad  "
0180       << "quality = " << setw(1) << id.quality() << "  "
0181       << "isolated = " << setw(1) << id.isol() << "  "
0182       << "mip = " << setw(1) << id.mip() << "  ";
0183   }
0184   return s;
0185 }