CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
ComparatorCodeLUT Class Reference

#include <ComparatorCodeLUT.h>

Public Types

typedef std::array< std::array< int, 3 >, CSCConstants::NUM_LAYERSpattern
 

Public Member Functions

 ComparatorCodeLUT (const edm::ParameterSet &conf)
 
void run (CSCCLCTDigi &digi, unsigned numCFEBs, const CSCL1TPLookupTableCCLUT *lookupTableCCLUT) const
 

Private Member Functions

void assignPositionCC (const unsigned offset, std::tuple< int16_t, bool, bool > &returnValue) const
 
int calculateComparatorCode (const pattern &halfStripPattern) const
 
unsigned convertSlopeToRun2Pattern (const unsigned slope) const
 

Private Attributes

CSCPatternBank::LCTPatterns clct_pattern_ = {}
 
unsigned infoV_
 

Detailed Description

Helper class to calculate for the comparator code algorithm for Phase-2.

Author
Sven Dildick (Rice University)

Definition at line 25 of file ComparatorCodeLUT.h.

Member Typedef Documentation

◆ pattern

typedef std::array<std::array<int, 3>, CSCConstants::NUM_LAYERS> ComparatorCodeLUT::pattern

Definition at line 27 of file ComparatorCodeLUT.h.

Constructor & Destructor Documentation

◆ ComparatorCodeLUT()

ComparatorCodeLUT::ComparatorCodeLUT ( const edm::ParameterSet conf)

Definition at line 4 of file ComparatorCodeLUT.cc.

References clct_pattern_, and CSCPatternBank::clct_pattern_run3_.

4  {
6 }
CSCPatternBank::LCTPatterns clct_pattern_
static const LCTPatterns clct_pattern_run3_

Member Function Documentation

◆ assignPositionCC()

void ComparatorCodeLUT::assignPositionCC ( const unsigned  offset,
std::tuple< int16_t, bool, bool > &  returnValue 
) const
private

Definition at line 146 of file ComparatorCodeLUT.cc.

References hltrates_dqm_sourceclient-live_cfg::offset.

Referenced by run().

146  {
147  /*
148  | Value | Half-Strip Offset | Delta Half-Strip | Quarter-Strip Bit | Eighth-Strip Bit |
149  |-------|--------------------|-------------------|--------------------|------------------|
150  | 0 | -7/4 | -2 | 0 | 1 |
151  | 1 | -3/2 | -2 | 1 | 0 |
152  | 2 | -5/4 | -2 | 1 | 1 |
153  | 3 | -1 | -1 | 0 | 0 |
154  | 4 | -3/4 | -1 | 0 | 1 |
155  | 5 | -1/2 | -1 | 1 | 0 |
156  | 6 | -1/4 | -1 | 1 | 1 |
157  | 7 | 0 | 0 | 0 | 0 |
158  | 8 | 1/4 | 0 | 0 | 1 |
159  | 9 | 1/2 | 0 | 1 | 0 |
160  | 10 | 3/4 | 0 | 1 | 1 |
161  | 11 | 1 | 1 | 0 | 0 |
162  | 12 | 5/4 | 1 | 0 | 1 |
163  | 13 | 3/2 | 1 | 1 | 0 |
164  | 14 | 7/4 | 1 | 1 | 1 |
165  | 15 | 2 | 2 | 0 | 0 |
166  */
167  std::vector<std::tuple<int16_t, bool, bool>> my_tuple = {
168  {-2, false, true},
169  {-2, true, false},
170  {-2, true, true},
171  {-1, false, false},
172  {-1, false, true},
173  {-1, true, false},
174  {-1, true, true},
175  {0, false, false},
176  {0, false, true},
177  {0, true, false},
178  {0, true, true},
179  {1, false, false},
180  {1, false, true},
181  {1, true, false},
182  {1, true, true},
183  {2, false, false},
184  };
185  returnValue = my_tuple[offset];
186 }

◆ calculateComparatorCode()

int ComparatorCodeLUT::calculateComparatorCode ( const pattern halfStripPattern) const
private

Definition at line 105 of file ComparatorCodeLUT.cc.

References l1ctLayer2EG_cff::id, and CSCConstants::NUM_LAYERS.

Referenced by run().

105  {
106  int id = 0;
107 
108  for (unsigned int column = 0; column < CSCConstants::NUM_LAYERS; column++) {
109  int rowPat = 0; //physical arrangement of the three bits
110  int rowCode = 0; //code used to identify the arrangement
111 
112  //use Firmware definition for comparator code definition
113  for (int row = 2; row >= 0; row--) {
114  rowPat = rowPat << 1; //bitshift the last number to the left
115  rowPat += halfStripPattern[column][row];
116  }
117  switch (rowPat) {
118  case 0: //000
119  rowCode = 0;
120  break;
121  case 1: //00X
122  rowCode = 1;
123  break;
124  case 2: //0X0
125  rowCode = 2;
126  break;
127  case 4: //00X
128  rowCode = 3;
129  break;
130  default:
131  // default return value is -1
132  return -1;
133  }
134  //each column has two bits of information, largest layer is most significant bit
135  id += (rowCode << 2 * column);
136  }
137  return id;
138 }

◆ convertSlopeToRun2Pattern()

unsigned ComparatorCodeLUT::convertSlopeToRun2Pattern ( const unsigned  slope) const
private

Definition at line 140 of file ComparatorCodeLUT.cc.

References slope.

Referenced by run().

140  {
141  const unsigned slopeList[32] = {10, 10, 10, 8, 8, 8, 6, 6, 6, 4, 4, 4, 2, 2, 2, 2,
142  10, 10, 10, 9, 9, 9, 7, 7, 7, 5, 5, 5, 3, 3, 3, 3};
143  return slopeList[slope];
144 }
static const double slope[3]

◆ run()

void ComparatorCodeLUT::run ( CSCCLCTDigi digi,
unsigned  numCFEBs,
const CSCL1TPLookupTableCCLUT lookupTableCCLUT 
) const

Definition at line 8 of file ComparatorCodeLUT.cc.

References assignPositionCC(), calculateComparatorCode(), CSCL1TPLookupTableCCLUT::cclutPosition(), CSCL1TPLookupTableCCLUT::cclutSlope(), clct_pattern_, CSCConstants::CLCT_PATTERN_WIDTH, convertSlopeToRun2Pattern(), CSCCLCTDigi::getHits(), CSCCLCTDigi::getKeyStrip(), CSCCLCTDigi::getPattern(), CSCCLCTDigi::getQuartStripBit(), mps_fire::i, infoV_, CSCConstants::INVALID_HALF_STRIP, dqmiolumiharvest::j, LogDebug, CSCConstants::NUM_HALF_STRIPS_PER_CFEB, CSCConstants::NUM_LAYERS, CSCCLCTDigi::setBend(), CSCCLCTDigi::setCFEB(), CSCCLCTDigi::setCompCode(), CSCCLCTDigi::setEighthStripBit(), CSCCLCTDigi::setPattern(), CSCCLCTDigi::setQuartStripBit(), CSCCLCTDigi::setRun3(), CSCCLCTDigi::setRun3Pattern(), CSCCLCTDigi::setSlope(), CSCCLCTDigi::setStrip(), and testProducerWithPsetDescEmpty_cfi::x1.

10  {
11  // print out the old CLCT for debugging
12  if (infoV_ > 2) {
13  std::ostringstream strm;
14  strm << "\n";
15  strm << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
16  strm << "+ Before CCCLUT algorithm: +\n";
17  strm << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
18  strm << " Old CLCT digi " << digi << "\n";
19  strm << " 1/4 strip bit " << digi.getQuartStripBit() << " 1/8 strip bit " << digi.getEighthStripBit() << "\n";
20  strm << " 1/4 strip number " << digi.getKeyStrip(4) << " 1/8 strip number " << digi.getKeyStrip(8) << "\n";
21  strm << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
22  LogDebug("ComparatorCodeLUT") << strm.str();
23  }
24 
25  // set Run-3 flag
26  digi.setRun3(true);
27 
28  // Get the comparator hits
29  auto compHits = digi.getHits();
30 
31  // Wrap the comparator code in a format for calculation
32  pattern compHitsCC;
33 
34  for (int i = 0; i < CSCConstants::NUM_LAYERS; i++) {
35  int iCC = 0;
36  for (int j = 0; j < CSCConstants::CLCT_PATTERN_WIDTH; j++) {
37  // only fill when the pattern is active
38  if (clct_pattern_[digi.getPattern()][i][j]) {
39  if (compHits[i][j] != CSCConstants::INVALID_HALF_STRIP) {
40  compHitsCC[i][iCC] = 1;
41  } else {
42  compHitsCC[i][iCC] = 0;
43  }
44  iCC++;
45  }
46  }
47  }
48 
49  // calculate the comparator code
50  const int comparatorCode(calculateComparatorCode(compHitsCC));
51 
52  // store the comparator code
53  digi.setCompCode(comparatorCode);
54 
55  // calculate the slope and position offset
56  const int pattern(digi.getPattern());
57 
58  // set the Run-3 pattern
59  digi.setRun3Pattern(pattern);
60 
61  // look-up the unsigned values
62  const unsigned positionCC(lookupTableCCLUT->cclutPosition(pattern, comparatorCode));
63  const unsigned slopeCC(lookupTableCCLUT->cclutSlope(pattern, comparatorCode));
64  const unsigned run2PatternCC(convertSlopeToRun2Pattern(slopeCC));
65 
66  // if the slope is negative, set bending to 0
67  const bool slopeCCSign((slopeCC >> 4) & 0x1);
68  const unsigned slopeCCValue(slopeCC & 0xf);
69  digi.setBend(slopeCCSign);
70 
71  // calculate the new position
72  uint16_t halfstrip = digi.getKeyStrip();
73  std::tuple<int16_t, bool, bool> stripoffset;
74  assignPositionCC(positionCC, stripoffset);
75  const int halfstripoffset = std::get<0>(stripoffset);
76  halfstrip += halfstripoffset;
77 
78  // store the new CFEB, 1/2, 1/4 and 1/8 strip positions
79  digi.setCFEB(halfstrip / CSCConstants::NUM_HALF_STRIPS_PER_CFEB);
80  digi.setStrip(halfstrip % CSCConstants::NUM_HALF_STRIPS_PER_CFEB);
81  digi.setQuartStripBit(std::get<1>(stripoffset));
82  digi.setEighthStripBit(std::get<2>(stripoffset));
83 
84  // store the bending angle value in the pattern data member
85  digi.setSlope(slopeCCValue);
86 
87  // set the quasi Run-2 pattern - to accommodate integration with EMTF/OMTF
88  digi.setPattern(run2PatternCC);
89 
90  // now print out the new CLCT for debugging
91  if (infoV_ > 2) {
92  std::ostringstream strm;
93  strm << "\n";
94  strm << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
95  strm << "+ CCCLUT algorithm results: +\n";
96  strm << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
97  strm << " New CLCT digi " << digi << "\n";
98  strm << " 1/4 strip bit " << digi.getQuartStripBit() << " 1/8 strip bit " << digi.getEighthStripBit() << "\n";
99  strm << " 1/4 strip number " << digi.getKeyStrip(4) << " 1/8 strip number " << digi.getKeyStrip(8) << "\n";
100  strm << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
101  LogDebug("ComparatorCodeLUT") << strm.str();
102  }
103 }
unsigned convertSlopeToRun2Pattern(const unsigned slope) const
std::array< std::array< int, 3 >, CSCConstants::NUM_LAYERS > pattern
int calculateComparatorCode(const pattern &halfStripPattern) const
CSCPatternBank::LCTPatterns clct_pattern_
bool getQuartStripBit() const
get single quart strip bit
Definition: CSCCLCTDigi.h:108
void assignPositionCC(const unsigned offset, std::tuple< int16_t, bool, bool > &returnValue) const
unsigned cclutSlope(unsigned pattern, unsigned code) const
unsigned cclutPosition(unsigned pattern, unsigned code) const
#define LogDebug(id)

Member Data Documentation

◆ clct_pattern_

CSCPatternBank::LCTPatterns ComparatorCodeLUT::clct_pattern_ = {}
private

Definition at line 45 of file ComparatorCodeLUT.h.

Referenced by ComparatorCodeLUT(), and run().

◆ infoV_

unsigned ComparatorCodeLUT::infoV_
private

Definition at line 48 of file ComparatorCodeLUT.h.

Referenced by run().