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
 

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_
 
std::array< std::unique_ptr< CSCLUTReader >, CSCConstants::NUM_CLCT_PATTERNS_RUN3lutpatconv_
 
std::array< std::unique_ptr< CSCLUTReader >, CSCConstants::NUM_CLCT_PATTERNS_RUN3lutpos_
 
std::array< std::unique_ptr< CSCLUTReader >, CSCConstants::NUM_CLCT_PATTERNS_RUN3lutslope_
 
std::vector< std::string > patternConversionLUTFiles_
 
std::vector< std::string > positionLUTFiles_
 
std::vector< std::string > slopeLUTFiles_
 

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.

4  {
5  positionLUTFiles_ = conf.getParameter<std::vector<std::string>>("positionLUTFiles");
6  slopeLUTFiles_ = conf.getParameter<std::vector<std::string>>("slopeLUTFiles");
7  patternConversionLUTFiles_ = conf.getParameter<std::vector<std::string>>("patternConversionLUTFiles");
8 
9  for (int i = 0; i < 5; ++i) {
10  lutpos_[i] = std::make_unique<CSCLUTReader>(positionLUTFiles_[i]);
11  lutslope_[i] = std::make_unique<CSCLUTReader>(slopeLUTFiles_[i]);
12  lutpatconv_[i] = std::make_unique<CSCLUTReader>(patternConversionLUTFiles_[i]);
13  }
14 
16 }

References clct_pattern_, CSCPatternBank::clct_pattern_run3_, edm::ParameterSet::getParameter(), mps_fire::i, lutpatconv_, lutpos_, lutslope_, patternConversionLUTFiles_, positionLUTFiles_, and slopeLUTFiles_.

Member Function Documentation

◆ assignPositionCC()

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

Definition at line 154 of file ComparatorCodeLUT.cc.

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

References hltrates_dqm_sourceclient-live_cfg::offset.

Referenced by run().

◆ calculateComparatorCode()

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

Definition at line 113 of file ComparatorCodeLUT.cc.

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

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

Referenced by run().

◆ convertSlopeToRun2Pattern()

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

Definition at line 148 of file ComparatorCodeLUT.cc.

148  {
149  const unsigned slopeList[32] = {10, 10, 10, 8, 8, 8, 6, 6, 6, 4, 4, 4, 2, 2, 2, 2,
150  10, 10, 10, 9, 9, 9, 7, 7, 7, 5, 5, 5, 3, 3, 3, 3};
151  return slopeList[slope];
152 }

References slope.

Referenced by run().

◆ run()

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

Definition at line 18 of file ComparatorCodeLUT.cc.

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

References assignPositionCC(), calculateComparatorCode(), 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, lutpos_, lutslope_, 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.

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 57 of file ComparatorCodeLUT.h.

Referenced by run().

◆ lutpatconv_

std::array<std::unique_ptr<CSCLUTReader>, CSCConstants::NUM_CLCT_PATTERNS_RUN3> ComparatorCodeLUT::lutpatconv_
private

Definition at line 54 of file ComparatorCodeLUT.h.

Referenced by ComparatorCodeLUT().

◆ lutpos_

std::array<std::unique_ptr<CSCLUTReader>, CSCConstants::NUM_CLCT_PATTERNS_RUN3> ComparatorCodeLUT::lutpos_
private

Definition at line 52 of file ComparatorCodeLUT.h.

Referenced by ComparatorCodeLUT(), and run().

◆ lutslope_

std::array<std::unique_ptr<CSCLUTReader>, CSCConstants::NUM_CLCT_PATTERNS_RUN3> ComparatorCodeLUT::lutslope_
private

Definition at line 53 of file ComparatorCodeLUT.h.

Referenced by ComparatorCodeLUT(), and run().

◆ patternConversionLUTFiles_

std::vector<std::string> ComparatorCodeLUT::patternConversionLUTFiles_
private

Definition at line 49 of file ComparatorCodeLUT.h.

Referenced by ComparatorCodeLUT().

◆ positionLUTFiles_

std::vector<std::string> ComparatorCodeLUT::positionLUTFiles_
private

Definition at line 47 of file ComparatorCodeLUT.h.

Referenced by ComparatorCodeLUT().

◆ slopeLUTFiles_

std::vector<std::string> ComparatorCodeLUT::slopeLUTFiles_
private

Definition at line 48 of file ComparatorCodeLUT.h.

Referenced by ComparatorCodeLUT().

CSCConstants::INVALID_HALF_STRIP
Definition: CSCConstants.h:99
mps_fire.i
i
Definition: mps_fire.py:428
CSCConstants::NUM_HALF_STRIPS_PER_CFEB
Definition: CSCConstants.h:62
ComparatorCodeLUT::calculateComparatorCode
int calculateComparatorCode(const pattern &halfStripPattern) const
Definition: ComparatorCodeLUT.cc:113
CSCCLCTDigi::getQuartStripBit
bool getQuartStripBit() const
get single quart strip bit
Definition: CSCCLCTDigi.h:108
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
ComparatorCodeLUT::lutpatconv_
std::array< std::unique_ptr< CSCLUTReader >, CSCConstants::NUM_CLCT_PATTERNS_RUN3 > lutpatconv_
Definition: ComparatorCodeLUT.h:54
ComparatorCodeLUT::lutslope_
std::array< std::unique_ptr< CSCLUTReader >, CSCConstants::NUM_CLCT_PATTERNS_RUN3 > lutslope_
Definition: ComparatorCodeLUT.h:53
CSCConstants::NUM_LAYERS
Definition: CSCConstants.h:103
ComparatorCodeLUT::positionLUTFiles_
std::vector< std::string > positionLUTFiles_
Definition: ComparatorCodeLUT.h:47
ComparatorCodeLUT::lutpos_
std::array< std::unique_ptr< CSCLUTReader >, CSCConstants::NUM_CLCT_PATTERNS_RUN3 > lutpos_
Definition: ComparatorCodeLUT.h:52
ComparatorCodeLUT::slopeLUTFiles_
std::vector< std::string > slopeLUTFiles_
Definition: ComparatorCodeLUT.h:48
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
ComparatorCodeLUT::clct_pattern_
CSCPatternBank::LCTPatterns clct_pattern_
Definition: ComparatorCodeLUT.h:45
ComparatorCodeLUT::infoV_
unsigned infoV_
Definition: ComparatorCodeLUT.h:57
ComparatorCodeLUT::assignPositionCC
void assignPositionCC(const unsigned offset, std::tuple< int16_t, bool, bool > &returnValue) const
Definition: ComparatorCodeLUT.cc:154
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
CSCPatternBank::clct_pattern_run3_
static const LCTPatterns clct_pattern_run3_
Definition: CSCPatternBank.h:54
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
ComparatorCodeLUT::convertSlopeToRun2Pattern
unsigned convertSlopeToRun2Pattern(const unsigned slope) const
Definition: ComparatorCodeLUT.cc:148
ComparatorCodeLUT::patternConversionLUTFiles_
std::vector< std::string > patternConversionLUTFiles_
Definition: ComparatorCodeLUT.h:49
ComparatorCodeLUT::pattern
std::array< std::array< int, 3 >, CSCConstants::NUM_LAYERS > pattern
Definition: ComparatorCodeLUT.h:27
CSCConstants::CLCT_PATTERN_WIDTH
Definition: CSCConstants.h:116
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
slope
static const double slope[3]
Definition: CastorTimeSlew.cc:6
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82