CMS 3D CMS Logo

CSCCLCTDigi.cc
Go to the documentation of this file.
1 
11 #include <iomanip>
12 #include <iostream>
13 
15 
18  const uint16_t quality,
19  const uint16_t pattern,
20  const uint16_t striptype,
21  const uint16_t bend,
22  const uint16_t strip,
23  const uint16_t cfeb,
24  const uint16_t bx,
25  const uint16_t trknmb,
26  const uint16_t fullbx,
27  const int16_t compCode,
28  const Version version)
29  : valid_(valid),
30  quality_(quality),
31  pattern_(pattern),
32  striptype_(striptype),
33  bend_(bend),
34  strip_(strip),
35  cfeb_(cfeb),
36  bx_(bx),
37  trknmb_(trknmb),
38  fullbx_(fullbx),
39  compCode_(compCode),
40  version_(version) {
41  hits_.resize(NUM_LAYERS);
42  for (auto& p : hits_) {
43  p.resize(CLCT_PATTERN_WIDTH);
44  }
45 }
46 
49  : valid_(0),
50  quality_(0),
51  pattern_(0),
52  striptype_(0),
53  bend_(0),
54  strip_(0),
55  cfeb_(0),
56  bx_(0),
57  trknmb_(0),
58  fullbx_(0),
59  compCode_(-1),
60  version_(Version::Legacy) {
61  hits_.resize(NUM_LAYERS);
62  for (auto& p : hits_) {
63  p.resize(CLCT_PATTERN_WIDTH);
64  }
65 }
66 
69  valid_ = 0;
70  quality_ = 0;
71  pattern_ = 0;
72  striptype_ = 0;
73  bend_ = 0;
74  strip_ = 0;
75  cfeb_ = 0;
76  bx_ = 0;
77  trknmb_ = 0;
78  fullbx_ = 0;
79  compCode_ = -1;
80  hits_.clear();
81  hits_.resize(NUM_LAYERS);
82  for (auto& p : hits_) {
83  p.resize(CLCT_PATTERN_WIDTH);
84  }
85  setSlope(0);
86 }
87 
89 
90 void CSCCLCTDigi::setPattern(const uint16_t pattern) {
92 }
93 
94 uint16_t CSCCLCTDigi::getRun3Pattern() const {
95  if (!isRun3())
96  return 0;
98 }
99 
100 void CSCCLCTDigi::setRun3Pattern(const uint16_t pattern) {
101  if (!isRun3())
102  return;
104 }
105 
106 uint16_t CSCCLCTDigi::getSlope() const {
107  if (!isRun3())
108  return 0;
110 }
111 
112 void CSCCLCTDigi::setSlope(const uint16_t slope) {
113  if (!isRun3())
114  return;
116 }
117 
118 // slope in number of half-strips/layer
120  if (isRun3()) {
121  // 4-bit slope
122  float slope[17] = {
123  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};
124  return (2 * getBend() - 1) * slope[getSlope()];
125  } else {
126  int slope[11] = {0, 0, -8, 8, -6, 6, -4, 4, -2, 2, 0};
127  return float(slope[getPattern()] / 5.);
128  }
129 }
130 
131 uint16_t CSCCLCTDigi::getKeyStrip(const uint16_t n) const {
132  // 10-bit case for strip data word
133  if (compCode_ != -1 and n == 8) {
134  return getKeyStrip(4) * 2 + getEighthStrip();
135  }
136  // 9-bit case for strip data word
137  else if (compCode_ != -1 and n == 4) {
138  return getKeyStrip(2) * 2 + getQuartStrip();
139  }
140  // 8-bit case for strip data word (all other cases)
141  else {
142  return cfeb_ * 32 + getStrip();
143  }
144 }
145 
147 float CSCCLCTDigi::getFractionalStrip(const uint16_t n) const {
148  if (compCode_ != -1 and n == 8) {
149  return 0.125f * (getKeyStrip(n) + 0.5);
150  } else if (compCode_ != -1 and n == 4) {
151  return 0.25f * (getKeyStrip(n) + 0.5);
152  } else {
153  return 0.5f * (getKeyStrip(n) + 0.5);
154  }
155 }
156 
158 
160  if (!isRun3())
161  return false;
163 }
164 
166  if (!isRun3())
167  return false;
169 }
170 
171 void CSCCLCTDigi::setQuartStrip(const bool quartStrip) {
172  if (!isRun3())
173  return;
175 }
176 
177 void CSCCLCTDigi::setEighthStrip(const bool eighthStrip) {
178  if (!isRun3())
179  return;
181 }
182 
184 
185 bool CSCCLCTDigi::operator>(const CSCCLCTDigi& rhs) const {
186  // Several versions of CLCT sorting criteria were used before 2008.
187  // They are available in CMSSW versions prior to 3_1_0; here we only keep
188  // the latest one, used in TMB-07 firmware (w/o distrips).
189  bool returnValue = false;
190 
191  uint16_t quality1 = getQuality();
192  uint16_t quality2 = rhs.getQuality();
193 
194  // Run-3 case
195  if (version_ == Version::Run3) {
196  // Better-quality CLCTs are preferred.
197  // If two qualities are equal, smaller bending is preferred;
198  // left- and right-bend patterns are considered to be of
199  // the same quality. This corresponds to "pattern" being smaller!!!
200  // If both qualities and pattern id's are the same, lower keystrip
201  // is preferred.
202  if ((quality1 > quality2) || (quality1 == quality2 && getPattern() < rhs.getPattern()) ||
203  (quality1 == quality2 && getPattern() == rhs.getPattern() && getKeyStrip() < rhs.getKeyStrip())) {
204  returnValue = true;
205  }
206  }
207  // Legacy case:
208  else {
209  // The bend-direction bit pid[0] is ignored (left and right bends have
210  // equal quality).
211  uint16_t pattern1 = getPattern() & 14;
212  uint16_t pattern2 = rhs.getPattern() & 14;
213 
214  // Better-quality CLCTs are preferred.
215  // If two qualities are equal, larger pattern id (i.e., straighter pattern)
216  // is preferred; left- and right-bend patterns are considered to be of
217  // the same quality.
218  // If both qualities and pattern id's are the same, lower keystrip
219  // is preferred.
220  if ((quality1 > quality2) || (quality1 == quality2 && pattern1 > pattern2) ||
221  (quality1 == quality2 && pattern1 == pattern2 && getKeyStrip() < rhs.getKeyStrip())) {
222  returnValue = true;
223  }
224  }
225  return returnValue;
226 }
227 
228 bool CSCCLCTDigi::operator==(const CSCCLCTDigi& rhs) const {
229  // Exact equality.
230  bool returnValue = false;
231  if (isValid() == rhs.isValid() && getQuality() == rhs.getQuality() && getPattern() == rhs.getPattern() &&
232  getKeyStrip() == rhs.getKeyStrip() && getStripType() == rhs.getStripType() && getBend() == rhs.getBend() &&
233  getBX() == rhs.getBX() && getCompCode() == rhs.getCompCode()) {
234  returnValue = true;
235  }
236  return returnValue;
237 }
238 
239 bool CSCCLCTDigi::operator!=(const CSCCLCTDigi& rhs) const {
240  // True if == is false.
241  bool returnValue = true;
242  if ((*this) == rhs)
243  returnValue = false;
244  return returnValue;
245 }
246 
248 void CSCCLCTDigi::print() const {
249  if (isValid()) {
250  char stripType = (getStripType() == 0) ? 'D' : 'H';
251  char bend = (getBend() == 0) ? 'L' : 'R';
252 
253  edm::LogVerbatim("CSCDigi") << " CSC CLCT #" << std::setw(1) << getTrknmb() << ": Valid = " << std::setw(1)
254  << isValid() << " Key Strip = " << std::setw(3) << getKeyStrip()
255  << " Strip = " << std::setw(2) << getStrip() << " Quality = " << std::setw(1)
256  << getQuality() << " Pattern = " << std::setw(1) << getPattern()
257  << " Bend = " << std::setw(1) << bend << " Strip type = " << std::setw(1) << stripType
258  << " CFEB ID = " << std::setw(1) << getCFEB() << " BX = " << std::setw(1) << getBX()
259  << " Full BX= " << std::setw(1) << getFullBX() << " Comp Code= " << std::setw(1)
260  << getCompCode();
261  } else {
262  edm::LogVerbatim("CSCDigi") << "Not a valid Cathode LCT.";
263  }
264 }
265 
266 void CSCCLCTDigi::setDataWord(const uint16_t newWord, uint16_t& word, const unsigned shift, const unsigned mask) {
267  // clear the old value
268  word &= ~(mask << shift);
269 
270  // set the new value
271  word |= newWord << shift;
272 }
273 
274 uint16_t CSCCLCTDigi::getDataWord(const uint16_t word, const unsigned shift, const unsigned mask) const {
275  return (word >> shift) & mask;
276 }
277 
278 std::ostream& operator<<(std::ostream& o, const CSCCLCTDigi& digi) {
279  return o << "CSC CLCT #" << digi.getTrknmb() << ": Valid = " << digi.isValid() << " Quality = " << digi.getQuality()
280  << " Pattern = " << digi.getPattern() << " StripType = " << digi.getStripType()
281  << " Bend = " << digi.getBend() << " Strip = " << digi.getStrip() << " KeyStrip = " << digi.getKeyStrip()
282  << " CFEB = " << digi.getCFEB() << " BX = " << digi.getBX() << " Comp Code " << digi.getCompCode();
283 }
CSCCLCTDigi::striptype_
uint16_t striptype_
Definition: CSCCLCTDigi.h:208
CSCCLCTDigi::strip_
uint16_t strip_
Definition: CSCCLCTDigi.h:216
MessageLogger.h
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
Pattern_Info
Pattern_Info
Definition: CSCALCTDigi.cc:14
CSCCLCTDigi::getTrknmb
uint16_t getTrknmb() const
return track number (1,2)
Definition: CSCCLCTDigi.h:132
CSCCLCTDigi::operator!=
bool operator!=(const CSCCLCTDigi &) const
True if the preceding one is false.
Definition: CSCCLCTDigi.cc:239
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
CSCCLCTDigi::kRun3PatternMask
Definition: CSCCLCTDigi.h:24
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
CSCCLCTDigi::getCompCode
int16_t getCompCode() const
Definition: CSCCLCTDigi.h:171
CSCCLCTDigi::kLegacyPatternShift
Definition: CSCCLCTDigi.h:25
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
CSCCLCTDigi::kHalfStripShift
Definition: CSCCLCTDigi.h:22
CSCCLCTDigi::valid_
uint16_t valid_
Definition: CSCCLCTDigi.h:203
CSCCLCTDigi::setPattern
void setPattern(const uint16_t pattern)
set pattern
Definition: CSCCLCTDigi.cc:90
CSCCLCTDigi::getDataWord
uint16_t getDataWord(const uint16_t word, const unsigned shift, const unsigned mask) const
Definition: CSCCLCTDigi.cc:274
CSCCLCTDigi::setEighthStrip
void setEighthStrip(const bool eighthStrip)
set single eighth strip bit
Definition: CSCCLCTDigi.cc:177
CSCCLCTDigi::getKeyStrip
uint16_t getKeyStrip(const uint16_t n=2) const
Definition: CSCCLCTDigi.cc:131
CSCCLCTDigi::setQuartStrip
void setQuartStrip(const bool quartStrip)
set single quart strip bit
Definition: CSCCLCTDigi.cc:171
CSCCLCTDigi::getEighthStrip
bool getEighthStrip() const
get single eighth strip bit
Definition: CSCCLCTDigi.cc:165
CSCCLCTDigi
Definition: CSCCLCTDigi.h:17
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:42
CLCT_PATTERN_WIDTH
Definition: CSCCLCTDigi.cc:14
CSCCLCTDigi::pattern_
uint16_t pattern_
Definition: CSCCLCTDigi.h:207
quality
const uint32_t *__restrict__ Quality * quality
Definition: CAHitNtupletGeneratorKernelsImpl.h:109
sistrip::valid_
static const uint16_t valid_
Definition: Constants.h:17
word
uint64_t word
Definition: CTPPSTotemDataFormatter.cc:29
CSCCLCTDigi::hits_
ComparatorContainer hits_
Definition: CSCCLCTDigi.h:227
CSCCLCTDigi::kLegacyPatternMask
Definition: CSCCLCTDigi.h:24
CSCCLCTDigi::getQuality
uint16_t getQuality() const
return quality of a pattern (number of layers hit!)
Definition: CSCCLCTDigi.h:56
CSCCLCTDigi::getBend
uint16_t getBend() const
Definition: CSCCLCTDigi.h:93
CSCCLCTDigi::isRun3
bool isRun3() const
Distinguish Run-1/2 from Run-3.
Definition: CSCCLCTDigi.h:195
CSCCLCTDigi::bend_
uint16_t bend_
Definition: CSCCLCTDigi.h:211
CSCCLCTDigi::getFractionalStrip
float getFractionalStrip(const uint16_t n=2) const
return the fractional strip (middle of the strip)
Definition: CSCCLCTDigi.cc:147
CSCCLCTDigi::fullbx_
uint16_t fullbx_
Definition: CSCCLCTDigi.h:221
CSCCLCTDigi::setRun3
void setRun3(bool isRun3)
Definition: CSCCLCTDigi.cc:183
CSCCLCTDigi::getFullBX
uint16_t getFullBX() const
return 12-bit full BX.
Definition: CSCCLCTDigi.h:165
CSCCLCTDigi::operator>
bool operator>(const CSCCLCTDigi &) const
Definition: CSCCLCTDigi.cc:185
CSCCLCTDigi::bx_
uint16_t bx_
Definition: CSCCLCTDigi.h:219
CSCCLCTDigi::CSCCLCTDigi
CSCCLCTDigi()
default
Definition: CSCCLCTDigi.cc:48
CSCCLCTDigi::getStrip
uint16_t getStrip() const
return halfstrip that goes from 0 to 31 in a (D)CFEB
Definition: CSCCLCTDigi.cc:157
CSCCLCTDigi::kRun3SlopeShift
Definition: CSCCLCTDigi.h:25
CSCCLCTDigi::setRun3Pattern
void setRun3Pattern(const uint16_t pattern)
set pattern
Definition: CSCCLCTDigi.cc:100
CSCCLCTDigi::kEighthStripMask
Definition: CSCCLCTDigi.h:21
CSCCLCTDigi::kRun3PatternShift
Definition: CSCCLCTDigi.h:25
CSCCLCTDigi::cfeb_
uint16_t cfeb_
Definition: CSCCLCTDigi.h:218
CSCCLCTDigi::Version::Run3
CSCCLCTDigi::getStripType
uint16_t getStripType() const
return striptype
Definition: CSCCLCTDigi.h:85
CSCCLCTDigi::getQuartStrip
bool getQuartStrip() const
get single quart strip bit
Definition: CSCCLCTDigi.cc:159
CSCCLCTDigi::setDataWord
void setDataWord(const uint16_t newWord, uint16_t &word, const unsigned shift, const unsigned mask)
Definition: CSCCLCTDigi.cc:266
CSCCLCTDigi::isValid
bool isValid() const
check CLCT validity (1 - valid CLCT)
Definition: CSCCLCTDigi.h:50
topSingleLeptonDQM_PU_cfi.pattern
pattern
Definition: topSingleLeptonDQM_PU_cfi.py:39
CSCCLCTDigi::setSlope
void setSlope(const uint16_t slope)
set the slope
Definition: CSCCLCTDigi.cc:112
CSCCLCTDigi::getSlope
uint16_t getSlope() const
return the slope
Definition: CSCCLCTDigi.cc:106
CSCCLCTDigi::kRun3SlopeMask
Definition: CSCCLCTDigi.h:24
CSCCLCTDigi::getBX
uint16_t getBX() const
return BX
Definition: CSCCLCTDigi.h:123
CSCCLCTDigi::compCode_
int16_t compCode_
Definition: CSCCLCTDigi.h:225
edm::shift
static unsigned const int shift
Definition: LuminosityBlockID.cc:7
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
trklet::bend
double bend(double r, double rinv, double stripPitch)
Definition: Util.h:166
CSCCLCTDigi::clear
void clear()
clear this CLCT
Definition: CSCCLCTDigi.cc:68
CSCCLCTDigi::kQuartStripShift
Definition: CSCCLCTDigi.h:22
CSCCLCTDigi.h
NUM_LAYERS
Definition: CSCCLCTDigi.cc:14
CSCCLCTDigi::quality_
uint16_t quality_
Definition: CSCCLCTDigi.h:204
CSCCLCTDigi::getFractionalSlope
float getFractionalSlope() const
Definition: CSCCLCTDigi.cc:119
CSCCLCTDigi::Version::Legacy
CSCCLCTDigi::getCFEB
uint16_t getCFEB() const
return Key CFEB ID
Definition: CSCCLCTDigi.h:117
CSCCLCTDigi::kQuartStripMask
Definition: CSCCLCTDigi.h:21
CSCCLCTDigi::trknmb_
uint16_t trknmb_
Definition: CSCCLCTDigi.h:220
CSCCLCTDigi::print
void print() const
Print content of digi.
Definition: CSCCLCTDigi.cc:248
CSCCLCTDigi::operator==
bool operator==(const CSCCLCTDigi &) const
True if the two LCTs have exactly the same members (except the number).
Definition: CSCCLCTDigi.cc:228
RunInfoPI::valid
Definition: RunInfoPayloadInspectoHelper.h:16
CSCCLCTDigi::getPattern
uint16_t getPattern() const
return pattern
Definition: CSCCLCTDigi.cc:88
slope
static const double slope[3]
Definition: CastorTimeSlew.cc:6
CSCCLCTDigi::version_
Version version_
Definition: CSCCLCTDigi.h:229
CSCCLCTDigi::kHalfStripMask
Definition: CSCCLCTDigi.h:21
Version
Definition: InitMessage.h:39
BeamSplash_cfg.version
version
Definition: BeamSplash_cfg.py:45
operator<<
std::ostream & operator<<(std::ostream &o, const CSCCLCTDigi &digi)
Definition: CSCCLCTDigi.cc:278
CSCCLCTDigi::kEighthStripShift
Definition: CSCCLCTDigi.h:22
CSCCLCTDigi::getRun3Pattern
uint16_t getRun3Pattern() const
return pattern
Definition: CSCCLCTDigi.cc:94