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
119 float CSCCLCTDigi::getFractionalSlope(const uint16_t nBits) const {
120  if (isRun3()) {
121  const float minSlope = 0;
122  const float maxSlope = 2.5;
123  const int range = pow(2, nBits);
124  const float deltaSlope = (maxSlope - minSlope) / range;
125  const float slopeValue = minSlope + deltaSlope * getSlope();
126  return (2 * getBend() - 1) * slopeValue;
127  } else {
128  int slope[11] = {0, 0, -8, 8, -6, 6, -4, 4, -2, 2, 0};
129  return float(slope[getPattern()] / 5.);
130  }
131 }
132 
133 uint16_t CSCCLCTDigi::getKeyStrip(const uint16_t n) const {
134  // 10-bit case for strip data word
135  if (compCode_ != -1 and n == 8) {
136  return getKeyStrip(4) * 2 + getEightStrip();
137  }
138  // 9-bit case for strip data word
139  else if (compCode_ != -1 and n == 4) {
140  return getKeyStrip(2) * 2 + getQuartStrip();
141  }
142  // 8-bit case for strip data word (all other cases)
143  else {
144  return cfeb_ * 32 + getStrip();
145  }
146 }
147 
149 float CSCCLCTDigi::getFractionalStrip(const uint16_t n) const {
150  if (compCode_ != -1 and n == 8) {
151  return 0.125f * (getKeyStrip(n) + 0.5);
152  } else if (compCode_ != -1 and n == 4) {
153  return 0.25f * (getKeyStrip(n) + 0.5);
154  } else {
155  return 0.5f * (getKeyStrip(n) + 0.5);
156  }
157 }
158 
160 
162  if (!isRun3())
163  return false;
165 }
166 
168  if (!isRun3())
169  return false;
171 }
172 
173 void CSCCLCTDigi::setQuartStrip(const bool quartStrip) {
174  if (!isRun3())
175  return;
177 }
178 
179 void CSCCLCTDigi::setEightStrip(const bool eightStrip) {
180  if (!isRun3())
181  return;
183 }
184 
186 
187 bool CSCCLCTDigi::operator>(const CSCCLCTDigi& rhs) const {
188  // Several versions of CLCT sorting criteria were used before 2008.
189  // They are available in CMSSW versions prior to 3_1_0; here we only keep
190  // the latest one, used in TMB-07 firmware (w/o distrips).
191  bool returnValue = false;
192 
193  uint16_t quality1 = getQuality();
194  uint16_t quality2 = rhs.getQuality();
195 
196  // Run-3 case
197  if (version_ == Version::Run3) {
198  // Better-quality CLCTs are preferred.
199  // If two qualities are equal, smaller bending is preferred;
200  // left- and right-bend patterns are considered to be of
201  // the same quality. This corresponds to "pattern" being smaller!!!
202  // If both qualities and pattern id's are the same, lower keystrip
203  // is preferred.
204  if ((quality1 > quality2) || (quality1 == quality2 && getPattern() < rhs.getPattern()) ||
205  (quality1 == quality2 && getPattern() == rhs.getPattern() && getKeyStrip() < rhs.getKeyStrip())) {
206  returnValue = true;
207  }
208  }
209  // Legacy case:
210  else {
211  // The bend-direction bit pid[0] is ignored (left and right bends have
212  // equal quality).
213  uint16_t pattern1 = getPattern() & 14;
214  uint16_t pattern2 = rhs.getPattern() & 14;
215 
216  // Better-quality CLCTs are preferred.
217  // If two qualities are equal, larger pattern id (i.e., straighter pattern)
218  // is preferred; left- and right-bend patterns are considered to be of
219  // the same quality.
220  // If both qualities and pattern id's are the same, lower keystrip
221  // is preferred.
222  if ((quality1 > quality2) || (quality1 == quality2 && pattern1 > pattern2) ||
223  (quality1 == quality2 && pattern1 == pattern2 && getKeyStrip() < rhs.getKeyStrip())) {
224  returnValue = true;
225  }
226  }
227  return returnValue;
228 }
229 
230 bool CSCCLCTDigi::operator==(const CSCCLCTDigi& rhs) const {
231  // Exact equality.
232  bool returnValue = false;
233  if (isValid() == rhs.isValid() && getQuality() == rhs.getQuality() && getPattern() == rhs.getPattern() &&
234  getKeyStrip() == rhs.getKeyStrip() && getStripType() == rhs.getStripType() && getBend() == rhs.getBend() &&
235  getBX() == rhs.getBX() && getCompCode() == rhs.getCompCode()) {
236  returnValue = true;
237  }
238  return returnValue;
239 }
240 
241 bool CSCCLCTDigi::operator!=(const CSCCLCTDigi& rhs) const {
242  // True if == is false.
243  bool returnValue = true;
244  if ((*this) == rhs)
245  returnValue = false;
246  return returnValue;
247 }
248 
250 void CSCCLCTDigi::print() const {
251  if (isValid()) {
252  char stripType = (getStripType() == 0) ? 'D' : 'H';
253  char bend = (getBend() == 0) ? 'L' : 'R';
254 
255  edm::LogVerbatim("CSCDigi") << " CSC CLCT #" << std::setw(1) << getTrknmb() << ": Valid = " << std::setw(1)
256  << isValid() << " Key Strip = " << std::setw(3) << getKeyStrip()
257  << " Strip = " << std::setw(2) << getStrip() << " Quality = " << std::setw(1)
258  << getQuality() << " Pattern = " << std::setw(1) << getPattern()
259  << " Bend = " << std::setw(1) << bend << " Strip type = " << std::setw(1) << stripType
260  << " CFEB ID = " << std::setw(1) << getCFEB() << " BX = " << std::setw(1) << getBX()
261  << " Full BX= " << std::setw(1) << getFullBX() << " Comp Code= " << std::setw(1)
262  << getCompCode();
263  } else {
264  edm::LogVerbatim("CSCDigi") << "Not a valid Cathode LCT.";
265  }
266 }
267 
268 void CSCCLCTDigi::setDataWord(const uint16_t newWord, uint16_t& word, const unsigned shift, const unsigned mask) {
269  // clear the old value
270  word &= ~(mask << shift);
271 
272  // set the new value
273  word |= newWord << shift;
274 }
275 
276 uint16_t CSCCLCTDigi::getDataWord(const uint16_t word, const unsigned shift, const unsigned mask) const {
277  return (word >> shift) & mask;
278 }
279 
280 std::ostream& operator<<(std::ostream& o, const CSCCLCTDigi& digi) {
281  return o << "CSC CLCT #" << digi.getTrknmb() << ": Valid = " << digi.isValid() << " Quality = " << digi.getQuality()
282  << " Pattern = " << digi.getPattern() << " StripType = " << digi.getStripType()
283  << " Bend = " << digi.getBend() << " Strip = " << digi.getStrip() << " KeyStrip = " << digi.getKeyStrip()
284  << " CFEB = " << digi.getCFEB() << " BX = " << digi.getBX() << " Comp Code " << digi.getCompCode();
285 }
CSCCLCTDigi::striptype_
uint16_t striptype_
Definition: CSCCLCTDigi.h:201
CSCCLCTDigi::strip_
uint16_t strip_
Definition: CSCCLCTDigi.h:209
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
CSCCLCTDigi::getFractionalSlope
float getFractionalSlope(const uint16_t slope=4) const
slope in number of half-strips/layer
Definition: CSCCLCTDigi.cc:119
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:125
CSCCLCTDigi::operator!=
bool operator!=(const CSCCLCTDigi &) const
True if the preceding one is false.
Definition: CSCCLCTDigi.cc:241
CSCCLCTDigi::kEightStripMask
Definition: CSCCLCTDigi.h:21
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:164
CSCCLCTDigi::kLegacyPatternShift
Definition: CSCCLCTDigi.h:25
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
CSCCLCTDigi::kHalfStripShift
Definition: CSCCLCTDigi.h:22
CSCCLCTDigi::setEightStrip
void setEightStrip(const bool eightStrip)
set single eight strip bit
Definition: CSCCLCTDigi.cc:179
CSCCLCTDigi::valid_
uint16_t valid_
Definition: CSCCLCTDigi.h:196
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:276
CSCCLCTDigi::getKeyStrip
uint16_t getKeyStrip(const uint16_t n=2) const
Definition: CSCCLCTDigi.cc:133
CSCCLCTDigi::setQuartStrip
void setQuartStrip(const bool quartStrip)
set single quart strip bit
Definition: CSCCLCTDigi.cc:173
CSCCLCTDigi
Definition: CSCCLCTDigi.h:17
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:36
CLCT_PATTERN_WIDTH
Definition: CSCCLCTDigi.cc:14
CSCCLCTDigi::pattern_
uint16_t pattern_
Definition: CSCCLCTDigi.h:200
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:220
CSCCLCTDigi::kLegacyPatternMask
Definition: CSCCLCTDigi.h:24
CSCCLCTDigi::getQuality
uint16_t getQuality() const
return quality of a pattern (number of layers hit!)
Definition: CSCCLCTDigi.h:54
CSCCLCTDigi::getBend
uint16_t getBend() const
Definition: CSCCLCTDigi.h:89
CSCCLCTDigi::isRun3
bool isRun3() const
Distinguish Run-1/2 from Run-3.
Definition: CSCCLCTDigi.h:188
CSCCLCTDigi::bend_
uint16_t bend_
Definition: CSCCLCTDigi.h:204
CSCCLCTDigi::getFractionalStrip
float getFractionalStrip(const uint16_t n=2) const
return the fractional strip (middle of the strip)
Definition: CSCCLCTDigi.cc:149
CSCCLCTDigi::fullbx_
uint16_t fullbx_
Definition: CSCCLCTDigi.h:214
CSCCLCTDigi::setRun3
void setRun3(bool isRun3)
Definition: CSCCLCTDigi.cc:185
CSCCLCTDigi::getFullBX
uint16_t getFullBX() const
return 12-bit full BX.
Definition: CSCCLCTDigi.h:158
CSCCLCTDigi::operator>
bool operator>(const CSCCLCTDigi &) const
Definition: CSCCLCTDigi.cc:187
CSCCLCTDigi::bx_
uint16_t bx_
Definition: CSCCLCTDigi.h:212
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:159
CSCCLCTDigi::kRun3SlopeShift
Definition: CSCCLCTDigi.h:25
CSCCLCTDigi::setRun3Pattern
void setRun3Pattern(const uint16_t pattern)
set pattern
Definition: CSCCLCTDigi.cc:100
CSCCLCTDigi::kRun3PatternShift
Definition: CSCCLCTDigi.h:25
CSCCLCTDigi::cfeb_
uint16_t cfeb_
Definition: CSCCLCTDigi.h:211
CSCCLCTDigi::Version::Run3
CSCCLCTDigi::getEightStrip
bool getEightStrip() const
get single eight strip bit
Definition: CSCCLCTDigi.cc:167
CSCCLCTDigi::getStripType
uint16_t getStripType() const
return striptype
Definition: CSCCLCTDigi.h:81
CSCCLCTDigi::getQuartStrip
bool getQuartStrip() const
get single quart strip bit
Definition: CSCCLCTDigi.cc:161
CSCCLCTDigi::setDataWord
void setDataWord(const uint16_t newWord, uint16_t &word, const unsigned shift, const unsigned mask)
Definition: CSCCLCTDigi.cc:268
CSCCLCTDigi::isValid
bool isValid() const
check CLCT validity (1 - valid CLCT)
Definition: CSCCLCTDigi.h:48
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:119
CSCCLCTDigi::kEightStripShift
Definition: CSCCLCTDigi.h:22
CSCCLCTDigi::compCode_
int16_t compCode_
Definition: CSCCLCTDigi.h:218
qcdUeDQM_cfi.quality
quality
Definition: qcdUeDQM_cfi.py:31
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:160
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:197
CSCCLCTDigi::Version::Legacy
CSCCLCTDigi::getCFEB
uint16_t getCFEB() const
return Key CFEB ID
Definition: CSCCLCTDigi.h:113
CSCCLCTDigi::kQuartStripMask
Definition: CSCCLCTDigi.h:21
CSCCLCTDigi::trknmb_
uint16_t trknmb_
Definition: CSCCLCTDigi.h:213
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
CSCCLCTDigi::print
void print() const
Print content of digi.
Definition: CSCCLCTDigi.cc:250
CSCCLCTDigi::operator==
bool operator==(const CSCCLCTDigi &) const
True if the two LCTs have exactly the same members (except the number).
Definition: CSCCLCTDigi.cc:230
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:222
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:280
CSCCLCTDigi::getRun3Pattern
uint16_t getRun3Pattern() const
return pattern
Definition: CSCCLCTDigi.cc:94