test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1MuRegionalCand.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
6 //
7 //
8 // Author :
9 // H. Sakulin HEPHY Vienna
10 //
11 // Migrated to CMSSW:
12 // I. Mikulec
13 //
14 //--------------------------------------------------
15 //---------------
16 // C++ Headers --
17 //---------------
18 
19 #include <iostream>
20 #include <iomanip>
21 
22 //----------------------
23 // Base Class Headers --
24 //----------------------
26 
27 //------------------------------------
28 // Collaborating Class Declarations --
29 //------------------------------------
30 
32 
33 using namespace std;
34 
35 // ---------------------
36 // -- Class Interface --
37 // ---------------------
38 
39 const float L1MuRegionalCand::m_invalidValue = -10.;
40 
42 L1MuRegionalCand::L1MuRegionalCand(unsigned dataword, int bx) : m_bx(bx), m_dataWord(dataword) {
46 }
47 
50  unsigned phi, unsigned eta, unsigned pt, unsigned charge,
51  unsigned ch_valid, unsigned finehalo, unsigned quality, int bx) :
52  m_bx(bx), m_dataWord(0) {
53  setType(type_idx);
54  setPhiPacked(phi);
55  setEtaPacked(eta);
56  setPtPacked(pt);
57  setChargePacked(charge);
58  setChargeValidPacked(ch_valid);
59  setFineHaloPacked(finehalo);
60  setQualityPacked(quality);
64 }
65 
67 
68  m_bx = 0;
69  m_dataWord = 0;
73 
74 }
75 
77  if(m_phiValue == m_invalidValue) {
78  edm::LogWarning("ValueInvalid") <<
79  "L1MuRegionalCand::phiValue requested physical value is invalid";
80  }
81  return m_phiValue;
82 }
83 
85  if(m_etaValue == m_invalidValue) {
86  edm::LogWarning("ValueInvalid") <<
87  "L1MuRegionalCand::etaValue requested physical value is invalid";
88  }
89  return m_etaValue;
90 }
91 
93  if(m_ptValue == m_invalidValue) {
94  edm::LogWarning("ValueInvalid") <<
95  "L1MuRegionalCand::ptValue requested physical value is invalid";
96  }
97  return m_ptValue;
98 }
99 
101  if ( !empty() ) {
102  if(m_phiValue == m_invalidValue ||
105  edm::LogVerbatim("GMT_Input_info")
106  << setiosflags(ios::showpoint | ios::fixed | ios::right | ios::adjustfield)
107  << "pt(index) = " << setw(2) << setprecision(1) << pt_packed() << " "
108  << "charge = " << setw(2) << chargeValue() << " "
109  << "eta(index) = " << setw(2) << eta_packed() << " "
110  << "phi(index) = " << setw(3) << phi_packed() << " "
111  << "quality = " << setw(1) << quality() << " "
112  << "charge_valid = " << setw(1) << chargeValid() << " "
113  << "fine_halo = " << setw(1) << isFineHalo() << " "
114  << "bx = " << setw(3) << bx() << " "
115  << "type_idx = " << setw(1) << type_idx();
116  } else {
117  edm::LogVerbatim("GMT_Input_info")
118  << setiosflags(ios::showpoint | ios::fixed | ios::right | ios::adjustfield)
119  << "pt = " << setw(5) << setprecision(1) << ptValue() << " GeV "
120  << "charge = " << setw(2) << chargeValue() << " "
121  << "eta = " << setw(6) << setprecision(3) << etaValue() << " "
122  << "phi = " << setw(5) << setprecision(3) << phiValue() << " rad "
123  << "quality = " << setw(1) << quality() << " "
124  << "charge_valid = " << setw(1) << chargeValid() << " "
125  << "fine_halo = " << setw(1) << isFineHalo() << " "
126  << "bx = " << setw(3) << bx() << " "
127  << "type_idx = " << setw(1) << type_idx();
128  }
129  }
130 }
131 
132 
133 unsigned L1MuRegionalCand::readDataField(unsigned start, unsigned count) const {
134  unsigned mask = ( (1 << count) - 1 ) << start;
135  return (m_dataWord & mask) >> start;
136 }
137 
138 void L1MuRegionalCand::writeDataField(unsigned start, unsigned count, unsigned value) {
139  if ( value >= ( 1U << count ) ) edm::LogWarning("ValueOutOfRange") // value >= 0, since value is unsigned
140  << "L1MuRegionalCand::writeDataField(): value " << value
141  << " out of range for data field with bit width " << count;
142 
143  unsigned mask = ( (1 << count) - 1 ) << start;
144  m_dataWord &= ~mask; // clear
145  m_dataWord |= (value << start) & mask ;
146 }
147 
void writeDataField(unsigned start, unsigned count, unsigned value)
virtual void print() const
print candidate
float etaValue() const
get eta-value of muon candidate
virtual bool empty() const
return empty flag
L1MuRegionalCand(unsigned dataword=0, int bx=0)
constructor from data word
void setChargeValidPacked(unsigned valid)
Set Charge Valid.
bool isFineHalo() const
is it fine (DT) / halo (CSC) ?
float ptValue() const
get pt-value of muon candidate in GeV
unsigned readDataField(unsigned start, unsigned count) const
static const float m_invalidValue
unsigned eta_packed() const
return eta packed as in hardware
void setType(unsigned type)
Set Type: 0 DT, 1 bRPC, 2 CSC, 3 fRPC.
float phiValue() const
get phi-value of muon candidate in radians (low edge of bin)
void setChargePacked(unsigned ch)
Set Charge (0=pos, 1=neg)
void setPtPacked(unsigned pt)
Set Pt: 0..31.
bool chargeValid() const
is the charge valid ?
unsigned int quality() const
return quality
Geom::Phi< T > phi() const
void setPhiPacked(unsigned phi)
Set Phi: 0..143.
int bx() const
return bunch crossing identifier
void setQualityPacked(unsigned qual)
Set Quality: 0..7.
void setEtaPacked(unsigned eta)
Set Eta: 6-bit code.
virtual void reset()
reset
void setFineHaloPacked(unsigned fh)
Set Fine / Halo.
unsigned pt_packed() const
return pt packed as in hardware
unsigned type_idx() const
return type: 0 DT, 1 bRPC, 2 CSC, 3 fRPC
int chargeValue() const
get charge
unsigned phi_packed() const
return phi packed as in hardware