CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CSCCLCTDigi.cc
Go to the documentation of this file.
1 
11 #include <iomanip>
12 #include <iostream>
13 
15 
16 namespace {
17  CSCCLCTDigi::ComparatorContainer makeEmptyContainer() {
19  ret.resize(NUM_LAYERS);
20  for (auto& p : ret) {
21  p.resize(CLCT_PATTERN_WIDTH);
22  }
23  return ret;
24  }
25 } // namespace
26 
28  static ComparatorContainer const s_container = makeEmptyContainer();
29  return s_container;
30 }
31 
33 CSCCLCTDigi::CSCCLCTDigi(const uint16_t valid,
34  const uint16_t quality,
35  const uint16_t pattern,
36  const uint16_t striptype,
37  const uint16_t bend,
38  const uint16_t strip,
39  const uint16_t cfeb,
40  const uint16_t bx,
41  const uint16_t trknmb,
42  const uint16_t fullbx,
43  const int16_t compCode,
44  const Version version,
45  const bool run3_quart_strip_bit,
46  const bool run3_eighth_strip_bit,
47  const uint16_t run3_pattern,
48  const uint16_t run3_slope)
49  : valid_(valid),
50  quality_(quality),
51  pattern_(pattern),
52  striptype_(striptype),
53  bend_(bend),
54  strip_(strip),
55  cfeb_(cfeb),
56  bx_(bx),
57  trknmb_(trknmb),
58  fullbx_(fullbx),
59  compCode_(compCode),
60  run3_quart_strip_bit_(run3_quart_strip_bit),
61  run3_eighth_strip_bit_(run3_eighth_strip_bit),
62  run3_pattern_(run3_pattern),
63  run3_slope_(run3_slope),
64  hits_(),
65  version_(version) {}
66 
69  clear(); // set contents to zero
70 }
71 
74  valid_ = 0;
75  quality_ = 0;
76  pattern_ = 0;
77  striptype_ = 0;
78  bend_ = 0;
79  strip_ = 0;
80  cfeb_ = 0;
81  bx_ = 0;
82  trknmb_ = 0;
83  fullbx_ = 0;
84  // Run-3 variables
85  compCode_ = -1;
86  run3_quart_strip_bit_ = false;
87  run3_eighth_strip_bit_ = false;
88  run3_pattern_ = 0;
89  run3_slope_ = 0;
91  hits_.clear();
92 }
93 
94 // slope in number of half-strips/layer
96  if (isRun3()) {
97  // 4-bit slope
98  float slope[17] = {
99  0.0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1.0, 1.125, 1.25, 1.375, 1.5, 1.625, 1.75, 2.0, 2.5};
100  return (2 * getBend() - 1) * slope[getSlope()];
101  } else {
102  int slope[11] = {0, 0, -8, 8, -6, 6, -4, 4, -2, 2, 0};
103  return float(slope[getPattern()] / 5.);
104  }
105 }
106 
107 uint16_t CSCCLCTDigi::getKeyStrip(const uint16_t n) const {
108  // 10-bit case for strip data word
109  if (compCode_ != -1 and n == 8) {
110  return getKeyStrip(4) * 2 + getEighthStripBit();
111  }
112  // 9-bit case for strip data word
113  else if (compCode_ != -1 and n == 4) {
114  return getKeyStrip(2) * 2 + getQuartStripBit();
115  }
116  // 8-bit case for strip data word (all other cases)
117  else {
118  return cfeb_ * 32 + getStrip();
119  }
120 }
121 
123 float CSCCLCTDigi::getFractionalStrip(const uint16_t n) const {
124  if (compCode_ != -1 and n == 8) {
125  return 0.125f * (getKeyStrip(n) + 0.5);
126  } else if (compCode_ != -1 and n == 4) {
127  return 0.25f * (getKeyStrip(n) + 0.5);
128  } else {
129  return 0.5f * (getKeyStrip(n) + 0.5);
130  }
131 }
132 
134 
135 bool CSCCLCTDigi::operator>(const CSCCLCTDigi& rhs) const {
136  // Several versions of CLCT sorting criteria were used before 2008.
137  // They are available in CMSSW versions prior to 3_1_0; here we only keep
138  // the latest one, used in TMB-07 firmware (w/o distrips).
139  bool returnValue = false;
140 
141  uint16_t quality1 = getQuality();
142  uint16_t quality2 = rhs.getQuality();
143 
144  // Run-3 case
145  if (version_ == Version::Run3) {
146  // Better-quality CLCTs are preferred.
147  // If two qualities are equal, smaller bending is preferred;
148  // left- and right-bend patterns are considered to be of
149  // the same quality. This corresponds to "pattern" being smaller!!!
150  // If both qualities and pattern id's are the same, lower keystrip
151  // is preferred.
152  if ((quality1 > quality2) || (quality1 == quality2 && getPattern() < rhs.getPattern()) ||
153  (quality1 == quality2 && getPattern() == rhs.getPattern() && getKeyStrip() < rhs.getKeyStrip())) {
154  returnValue = true;
155  }
156  }
157  // Legacy case:
158  else {
159  // The bend-direction bit pid[0] is ignored (left and right bends have
160  // equal quality).
161  uint16_t pattern1 = getPattern() & 14;
162  uint16_t pattern2 = rhs.getPattern() & 14;
163 
164  // Better-quality CLCTs are preferred.
165  // If two qualities are equal, larger pattern id (i.e., straighter pattern)
166  // is preferred; left- and right-bend patterns are considered to be of
167  // the same quality.
168  // If both qualities and pattern id's are the same, lower keystrip
169  // is preferred.
170  if ((quality1 > quality2) || (quality1 == quality2 && pattern1 > pattern2) ||
171  (quality1 == quality2 && pattern1 == pattern2 && getKeyStrip() < rhs.getKeyStrip())) {
172  returnValue = true;
173  }
174  }
175  return returnValue;
176 }
177 
178 bool CSCCLCTDigi::operator==(const CSCCLCTDigi& rhs) const {
179  // Exact equality.
180  bool returnValue = false;
181  if (isValid() == rhs.isValid() && getQuality() == rhs.getQuality() && getPattern() == rhs.getPattern() &&
182  getKeyStrip() == rhs.getKeyStrip() && getStripType() == rhs.getStripType() && getBend() == rhs.getBend() &&
183  getBX() == rhs.getBX() && getCompCode() == rhs.getCompCode()) {
184  returnValue = true;
185  }
186  return returnValue;
187 }
188 
189 bool CSCCLCTDigi::operator!=(const CSCCLCTDigi& rhs) const {
190  // True if == is false.
191  bool returnValue = true;
192  if ((*this) == rhs)
193  returnValue = false;
194  return returnValue;
195 }
196 
198 void CSCCLCTDigi::print() const {
199  if (isValid()) {
200  char stripType = (getStripType() == 0) ? 'D' : 'H';
201  char bend = (getBend() == 0) ? 'L' : 'R';
202 
203  edm::LogVerbatim("CSCDigi") << " CSC CLCT #" << std::setw(1) << getTrknmb() << ": Valid = " << std::setw(1)
204  << isValid() << " Key Strip = " << std::setw(3) << getKeyStrip()
205  << " Strip = " << std::setw(2) << getStrip() << " Quality = " << std::setw(1)
206  << getQuality() << " Pattern = " << std::setw(1) << getPattern()
207  << " Bend = " << std::setw(1) << bend << " Strip type = " << std::setw(1) << stripType
208  << " CFEB ID = " << std::setw(1) << getCFEB() << " BX = " << std::setw(1) << getBX()
209  << " Full BX= " << std::setw(1) << getFullBX() << " Comp Code= " << std::setw(1)
210  << getCompCode();
211  } else {
212  edm::LogVerbatim("CSCDigi") << "Not a valid Cathode LCT.";
213  }
214 }
215 
216 std::ostream& operator<<(std::ostream& o, const CSCCLCTDigi& digi) {
217  if (digi.isRun3())
218  return o << "CSC CLCT #" << digi.getTrknmb() << ": Valid = " << digi.isValid() << " BX = " << digi.getBX()
219  << " Run-2 Pattern = " << digi.getPattern() << " Run-3 Pattern = " << digi.getRun3Pattern()
220  << " Quality = " << digi.getQuality() << " Comp Code " << digi.getCompCode()
221  << " Bend = " << digi.getBend() << "\n"
222  << " Slope = " << digi.getSlope() << " CFEB = " << digi.getCFEB() << " Strip = " << digi.getStrip()
223  << " KeyHalfStrip = " << digi.getKeyStrip() << " KeyQuartStrip = " << digi.getKeyStrip(4)
224  << " KeyEighthStrip = " << digi.getKeyStrip(8);
225  else
226  return o << "CSC CLCT #" << digi.getTrknmb() << ": Valid = " << digi.isValid() << " BX = " << digi.getBX()
227  << " Pattern = " << digi.getPattern() << " Quality = " << digi.getQuality() << " Bend = " << digi.getBend()
228  << " CFEB = " << digi.getCFEB() << " HalfStrip = " << digi.getStrip()
229  << " KeyHalfStrip = " << digi.getKeyStrip();
230 }
uint16_t trknmb_
Definition: CSCCLCTDigi.h:217
Log< level::Info, true > LogVerbatim
uint16_t getRun3Pattern() const
return pattern
Definition: CSCCLCTDigi.h:68
uint16_t run3_slope_
Definition: CSCCLCTDigi.h:232
tuple ret
prodAgent to be discontinued
uint16_t getFullBX() const
return 12-bit full BX.
Definition: CSCCLCTDigi.h:165
uint16_t strip_
Definition: CSCCLCTDigi.h:213
void print() const
Print content of digi.
Definition: CSCCLCTDigi.cc:198
uint16_t getBX() const
return BX
Definition: CSCCLCTDigi.h:123
uint16_t getBend() const
Definition: CSCCLCTDigi.h:93
uint16_t pattern_
Definition: CSCCLCTDigi.h:207
uint32_t const *__restrict__ Quality * quality
uint16_t valid_
Definition: CSCCLCTDigi.h:201
static const double slope[3]
float getFractionalStrip(const uint16_t n=2) const
return the fractional strip (middle of the strip)
Definition: CSCCLCTDigi.cc:123
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
static const uint16_t valid_
Definition: Constants.h:17
float getFractionalSlope() const
Definition: CSCCLCTDigi.cc:95
uint16_t getStripType() const
return striptype
Definition: CSCCLCTDigi.h:85
bool run3_eighth_strip_bit_
Definition: CSCCLCTDigi.h:228
uint16_t getKeyStrip(const uint16_t n=2) const
Definition: CSCCLCTDigi.cc:107
uint16_t bx_
Definition: CSCCLCTDigi.h:216
CSCCLCTDigi()
default (calls clear())
Definition: CSCCLCTDigi.cc:68
uint16_t run3_pattern_
Definition: CSCCLCTDigi.h:230
std::vector< std::vector< uint16_t > > ComparatorContainer
Definition: CSCCLCTDigi.h:19
static const ComparatorContainer & emptyContainer()
Definition: CSCCLCTDigi.cc:27
uint16_t bend_
Definition: CSCCLCTDigi.h:211
bool operator>(const CSCCLCTDigi &) const
Definition: CSCCLCTDigi.cc:135
uint16_t getCFEB() const
return Key CFEB ID
Definition: CSCCLCTDigi.h:117
uint16_t fullbx_
Definition: CSCCLCTDigi.h:218
void setRun3(bool isRun3)
Definition: CSCCLCTDigi.cc:133
ComparatorContainer hits_
Definition: CSCCLCTDigi.h:235
bool getEighthStripBit() const
get single eighth strip bit
Definition: CSCCLCTDigi.h:114
bool isValid() const
check CLCT validity (1 - valid CLCT)
Definition: CSCCLCTDigi.h:50
bool operator!=(const CSCCLCTDigi &) const
True if the preceding one is false.
Definition: CSCCLCTDigi.cc:189
Pattern_Info
Definition: CSCALCTDigi.cc:17
uint16_t getStrip() const
return halfstrip that goes from 0 to 31 in a (D)CFEB
Definition: CSCCLCTDigi.h:99
uint16_t cfeb_
Definition: CSCCLCTDigi.h:215
bool run3_quart_strip_bit_
Definition: CSCCLCTDigi.h:226
uint16_t getSlope() const
return the slope
Definition: CSCCLCTDigi.h:74
uint16_t getPattern() const
return pattern
Definition: CSCCLCTDigi.h:62
bool operator==(const CSCCLCTDigi &) const
True if the two LCTs have exactly the same members (except the number).
Definition: CSCCLCTDigi.cc:178
uint16_t getTrknmb() const
return track number (1,2)
Definition: CSCCLCTDigi.h:132
void clear()
clear this CLCT
Definition: CSCCLCTDigi.cc:73
uint16_t getQuality() const
return quality of a pattern (number of layers hit!)
Definition: CSCCLCTDigi.h:56
uint16_t striptype_
Definition: CSCCLCTDigi.h:208
uint16_t quality_
Definition: CSCCLCTDigi.h:202
bool isRun3() const
Distinguish Run-1/2 from Run-3.
Definition: CSCCLCTDigi.h:195
int16_t getCompCode() const
Definition: CSCCLCTDigi.h:171
int16_t compCode_
Definition: CSCCLCTDigi.h:224
Version version_
Definition: CSCCLCTDigi.h:236
bool getQuartStripBit() const
get single quart strip bit
Definition: CSCCLCTDigi.h:108