CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CSCCLCTDigi.h
Go to the documentation of this file.
1 #ifndef DataFormats_CSCDigi_CSCCLCTDigi_h
2 #define DataFormats_CSCDigi_CSCCLCTDigi_h
3 
12 #include <cstdint>
13 #include <iosfwd>
14 #include <vector>
15 #include <limits>
16 
17 class CSCCLCTDigi {
18 public:
19  typedef std::vector<std::vector<uint16_t>> ComparatorContainer;
20 
21  enum class Version { Legacy = 0, Run3 };
22  // for data vs emulator studies
23  enum CLCTBXMask { kBXDataMask = 0x3 };
24 
26  CSCCLCTDigi(const uint16_t valid,
27  const uint16_t quality,
28  const uint16_t pattern,
29  const uint16_t striptype,
30  const uint16_t bend,
31  const uint16_t strip,
32  const uint16_t cfeb,
33  const uint16_t bx,
34  const uint16_t trknmb = 0,
35  const uint16_t fullbx = 0,
36  const int16_t compCode = -1,
38  const bool run3_quart_strip_bit = false,
39  const bool run3_eighth_strip_bit = false,
40  const uint16_t run3_pattern = 0,
41  const uint16_t run3_slope = 0);
42 
44  CSCCLCTDigi();
45 
47  void clear();
48 
50  bool isValid() const { return valid_; }
51 
53  void setValid(const uint16_t valid) { valid_ = valid; }
54 
56  uint16_t getQuality() const { return quality_; }
57 
59  void setQuality(const uint16_t quality) { quality_ = quality; }
60 
62  uint16_t getPattern() const { return pattern_; }
63 
65  void setPattern(const uint16_t pattern) { pattern_ = pattern; }
66 
68  uint16_t getRun3Pattern() const { return run3_pattern_; }
69 
71  void setRun3Pattern(const uint16_t pattern) { run3_pattern_ = pattern; }
72 
74  uint16_t getSlope() const { return run3_slope_; }
75 
77  void setSlope(const uint16_t slope) { run3_slope_ = slope; }
78 
82  float getFractionalSlope() const;
83 
85  uint16_t getStripType() const { return striptype_; }
86 
88  void setStripType(const uint16_t stripType) { striptype_ = stripType; }
89 
93  uint16_t getBend() const { return bend_; }
94 
96  void setBend(const uint16_t bend) { bend_ = bend; }
97 
99  uint16_t getStrip() const { return strip_; }
100 
102  void setStrip(const uint16_t strip) { strip_ = strip; }
103 
105  void setQuartStripBit(const bool quartStripBit) { run3_quart_strip_bit_ = quartStripBit; }
106 
108  bool getQuartStripBit() const { return run3_quart_strip_bit_; }
109 
111  void setEighthStripBit(const bool eighthStripBit) { run3_eighth_strip_bit_ = eighthStripBit; }
112 
114  bool getEighthStripBit() const { return run3_eighth_strip_bit_; }
115 
117  uint16_t getCFEB() const { return cfeb_; }
118 
120  void setCFEB(const uint16_t cfeb) { cfeb_ = cfeb; }
121 
123  uint16_t getBX() const { return bx_; }
124 
126  uint16_t getBXData() const { return bx_ & kBXDataMask; }
127 
129  void setBX(const uint16_t bx) { bx_ = bx; }
130 
132  uint16_t getTrknmb() const { return trknmb_; }
133 
140  uint16_t getKeyStrip(const uint16_t n = 2) const;
141 
142  /*
143  Strips are numbered starting from 1 in CMSSW
144  Half-strips, quarter-strips and eighth-strips are numbered starting from 0
145  The table below shows the correct numbering
146  ---------------------------------------------------------------------------------
147  strip | 1 | 2 |
148  ---------------------------------------------------------------------------------
149  1/2-strip | 0 | 1 | 2 | 3 |
150  ---------------------------------------------------------------------------------
151  1/4-strip | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
152  ---------------------------------------------------------------------------------
153  1/8-strip | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
154  ---------------------------------------------------------------------------------
155 
156  Note: the CSC geometry also has a strip offset of +/- 0.25 strips. When comparing the
157  CLCT/LCT position with the true muon position, take the offset into account!
158  */
159  float getFractionalStrip(const uint16_t n = 2) const;
160 
162  void setTrknmb(const uint16_t number) { trknmb_ = number; }
163 
165  uint16_t getFullBX() const { return fullbx_; }
166 
168  void setFullBX(const uint16_t fullbx) { fullbx_ = fullbx; }
169 
170  // 12-bit comparator code
171  int16_t getCompCode() const { return (isRun3() ? compCode_ : -1); }
172 
173  void setCompCode(const int16_t code) { compCode_ = code; }
174 
175  // comparator hits in this CLCT
176  const ComparatorContainer& getHits() const { return hits_.empty() ? emptyContainer() : hits_; }
177 
178  void setHits(const ComparatorContainer& hits) { hits_ = hits; }
179 
183  bool operator>(const CSCCLCTDigi&) const;
184 
186  bool operator==(const CSCCLCTDigi&) const;
187 
189  bool operator!=(const CSCCLCTDigi&) const;
190 
192  void print() const;
193 
195  bool isRun3() const { return version_ == Version::Run3; }
196 
197  void setRun3(bool isRun3);
198 
199 private:
200  static const ComparatorContainer& emptyContainer();
201  uint16_t valid_;
202  uint16_t quality_;
203  // Run-1/2 pattern number.
204  // For Run-3 CLCTs, please use run3_pattern_. For some backward
205  // compatibility the trigger emulator translates run3_pattern_
206  // approximately into pattern_ with a lookup table
207  uint16_t pattern_;
208  uint16_t striptype_; // not used since mid-2008
209  // Common definition for left/right bending in Run-1, Run-2 and Run-3.
210  // 0: right; 1: left
211  uint16_t bend_;
212  // actually the half-strip number
213  uint16_t strip_;
214  // There are up to 7 (D)CFEBs in a chamber
215  uint16_t cfeb_;
216  uint16_t bx_;
217  uint16_t trknmb_;
218  uint16_t fullbx_;
219 
220  // new members in Run-3:
221 
222  // 12-bit comparator code
223  // set by default to -1 for Run-1 and Run-2 CLCTs
224  int16_t compCode_;
225  // 1/4-strip bit set by CCLUT (see DN-19-059)
227  // 1/8-strip bit set by CCLUT
229  // In Run-3, the CLCT digi has 3-bit pattern ID, 0 through 4
230  uint16_t run3_pattern_;
231  // 4-bit bending value. There will be 16 bending values * 2 (left/right)
232  uint16_t run3_slope_;
233 
234  // which hits are in this CLCT?
237 };
238 
239 std::ostream& operator<<(std::ostream& o, const CSCCLCTDigi& digi);
240 
241 #endif
uint16_t trknmb_
Definition: CSCCLCTDigi.h:217
uint16_t getRun3Pattern() const
return pattern
Definition: CSCCLCTDigi.h:68
uint16_t run3_slope_
Definition: CSCCLCTDigi.h:232
uint16_t getFullBX() const
return 12-bit full BX.
Definition: CSCCLCTDigi.h:165
uint16_t strip_
Definition: CSCCLCTDigi.h:213
void setQuartStripBit(const bool quartStripBit)
set single quart strip bit
Definition: CSCCLCTDigi.h:105
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
uint16_t valid_
Definition: CSCCLCTDigi.h:201
void setBend(const uint16_t bend)
set bend
Definition: CSCCLCTDigi.h:96
static const double slope[3]
void setStrip(const uint16_t strip)
set strip
Definition: CSCCLCTDigi.h:102
void setStripType(const uint16_t stripType)
set stripType
Definition: CSCCLCTDigi.h:88
float getFractionalStrip(const uint16_t n=2) const
return the fractional strip (middle of the strip)
Definition: CSCCLCTDigi.cc:123
string quality
void setPattern(const uint16_t pattern)
set pattern
Definition: CSCCLCTDigi.h:65
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
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
void setCompCode(const int16_t code)
Definition: CSCCLCTDigi.h:173
uint16_t fullbx_
Definition: CSCCLCTDigi.h:218
void setRun3(bool isRun3)
Definition: CSCCLCTDigi.cc:133
ComparatorContainer hits_
Definition: CSCCLCTDigi.h:235
void setSlope(const uint16_t slope)
set the slope
Definition: CSCCLCTDigi.h:77
void setRun3Pattern(const uint16_t pattern)
set pattern
Definition: CSCCLCTDigi.h:71
void setValid(const uint16_t valid)
set valid
Definition: CSCCLCTDigi.h:53
void setHits(const ComparatorContainer &hits)
Definition: CSCCLCTDigi.h:178
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
uint16_t getStrip() const
return halfstrip that goes from 0 to 31 in a (D)CFEB
Definition: CSCCLCTDigi.h:99
void setQuality(const uint16_t quality)
set quality
Definition: CSCCLCTDigi.h:59
uint16_t cfeb_
Definition: CSCCLCTDigi.h:215
bool run3_quart_strip_bit_
Definition: CSCCLCTDigi.h:226
const ComparatorContainer & getHits() const
Definition: CSCCLCTDigi.h:176
void setFullBX(const uint16_t fullbx)
Set 12-bit full BX.
Definition: CSCCLCTDigi.h:168
uint16_t getSlope() const
return the slope
Definition: CSCCLCTDigi.h:74
uint16_t getPattern() const
return pattern
Definition: CSCCLCTDigi.h:62
void setBX(const uint16_t bx)
set bx
Definition: CSCCLCTDigi.h:129
void setCFEB(const uint16_t cfeb)
set Key CFEB ID
Definition: CSCCLCTDigi.h:120
void setEighthStripBit(const bool eighthStripBit)
set single eighth strip bit
Definition: CSCCLCTDigi.h:111
uint16_t getBXData() const
return 2-bit BX as in data
Definition: CSCCLCTDigi.h:126
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
void setTrknmb(const uint16_t number)
Set track number (1,2) after sorting CLCTs.
Definition: CSCCLCTDigi.h:162
bool getQuartStripBit() const
get single quart strip bit
Definition: CSCCLCTDigi.h:108