CMS 3D CMS Logo

CSCCFEBTimeSlice.cc
Go to the documentation of this file.
2 #include <cassert>
3 #include <iomanip>
4 #include <cstdint>
5 
6 // a Gray code is An ordering of 2n binary numbers such that
7 // only one bit changes from one entry to the next
8 // const unsigned layerGrayCode[] = {3,1,5,6,4,2};
9 const unsigned layerInverseGrayCode[] = {1, 5, 0, 4, 2, 3};
10 // const unsigned channelGrayCode[] = {0,1,3,2, 6,7,5,4, 12,13,15,14, 10,11,9,8};
11 const unsigned channelInverseGrayCode[] = {0, 1, 3, 2, 7, 6, 4, 5, 15, 14, 12, 13, 8, 9, 11, 10};
12 
14  bzero(this, 99 * 2);
15  dummy = 0x7FFF;
16  blank_space_1 = 0x7;
17  blank_space_3 = 0x7;
18 }
19 
21 // trig_time( frame & 0xFF ),
22 // sca_blk( (frame>>8) & 0xF ),
23 // l1a_phase((frame>>12( & 0x1),
24 // lct_phase((frame>>13( & 0x1),
25 // sca_full((frame>>14) & 0x1),
26 // ts_flag(((frame>>15) & 0x1)
27 {
28  memcpy(this, &frame, 2);
29 }
30 
31 CSCCFEBDataWord *CSCCFEBTimeSlice::timeSample(int layer, int channel, bool isDCFEB) const {
32  assert(layer >= 1 && layer <= 6);
33  assert(channel >= 1 && channel <= 16);
34  int layerIndex = layerInverseGrayCode[layer - 1];
35 
36  unsigned channelIndex = channelInverseGrayCode[channel - 1];
37  if (isDCFEB)
38  channelIndex = channel - 1;
39  unsigned scaBin = channelIndex * 6 + layerIndex;
40  assert(scaBin < 96U); // scaBin >= 0, since scaBin is unsigned
41  return timeSample(scaBin);
42 }
43 
45  unsigned int result = 0;
46  for (unsigned i = 0; i < 16; ++i) {
47  result |= timeSample(i * 6 + layer - 1)->controllerData << i;
48  }
50 }
51 
53  for (int layer = 1; layer <= 6; ++layer) {
54  for (int channel = 1; channel <= 16; ++channel) {
55  const unsigned short *shortWord = reinterpret_cast<const unsigned short *>(&controllerWord);
56  timeSample(layer, channel)->controllerData = (*shortWord >> (channel - 1)) & 1;
57  }
58  }
59 }
60 
61 unsigned CSCCFEBTimeSlice::calcCRC() const {
62  unsigned CRC = 0;
63  for (uint16_t pos = 0; pos < 96; ++pos)
64  CRC = (theSamples[pos] & 0x1fff) ^ ((theSamples[pos] & 0x1fff) << 1) ^
65  (((CRC & 0x7ffc) >> 2) | ((0x0003 & CRC) << 13)) ^ ((CRC & 0x7ffc) >> 1);
66  return CRC;
67 }
68 
69 std::ostream &operator<<(std::ostream &os, const CSCCFEBTimeSlice &slice) {
70  for (int ichannel = 1; ichannel <= 16; ++ichannel) {
71  for (int ilayer = 1; ilayer <= 6; ++ilayer) {
72  //unsigned index = (ilayer-1) + (ichannel-1)*6;
73  //int value = (slice.timeSample(index))->adcCounts - 560;
74  int value = (slice.timeSample(ilayer, ichannel))->adcCounts - 560;
75  os << " " << std::setw(5) << std::dec << value;
76  }
77  os << std::endl;
78  }
79  return os;
80 }
mps_fire.i
i
Definition: mps_fire.py:428
pos
Definition: PixelAliasList.h:18
CSCCFEBTimeSlice
Definition: CSCCFEBTimeSlice.h:52
cms::cuda::assert
assert(be >=bs)
CSCCFEBTimeSlice::theSamples
unsigned short theSamples[96]
Definition: CSCCFEBTimeSlice.h:108
operator<<
std::ostream & operator<<(std::ostream &os, const CSCCFEBTimeSlice &slice)
Definition: CSCCFEBTimeSlice.cc:69
CSCCFEBTimeSlice::blank_space_3
unsigned blank_space_3
Definition: CSCCFEBTimeSlice.h:126
CSCCFEBTimeSlice.h
CSCCFEBTimeSlice::CSCCFEBTimeSlice
CSCCFEBTimeSlice()
Definition: CSCCFEBTimeSlice.cc:13
CSCCFEBDataWord::controllerData
unsigned short controllerData
combined from all 16 strips to make a word
Definition: CSCCFEBTimeSlice.h:24
CSCCFEBDataWord
Definition: CSCCFEBTimeSlice.h:20
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
CSCCFEBTimeSlice::blank_space_1
unsigned blank_space_1
Definition: CSCCFEBTimeSlice.h:120
channelInverseGrayCode
const unsigned channelInverseGrayCode[]
Definition: CSCCFEBTimeSlice.cc:11
CSCCFEBTimeSlice::setControllerWord
void setControllerWord(const CSCCFEBSCAControllerWord &controllerWord)
Definition: CSCCFEBTimeSlice.cc:52
CSCCFEBTimeSlice::timeSample
CSCCFEBDataWord * timeSample(int index) const
input from 0 to 95
Definition: CSCCFEBTimeSlice.h:57
value
Definition: value.py:1
RawDataTask_cfi.CRC
CRC
Definition: RawDataTask_cfi.py:59
CSCCFEBTimeSlice::calcCRC
unsigned calcCRC() const
Definition: CSCCFEBTimeSlice.cc:61
relativeConstraints.value
value
Definition: relativeConstraints.py:53
amptDefault_cfi.frame
frame
Definition: amptDefault_cfi.py:12
mps_fire.result
result
Definition: mps_fire.py:311
dummy
Definition: DummySelector.h:38
CSCCFEBSCAControllerWord
Definition: CSCCFEBTimeSlice.h:36
layerInverseGrayCode
const unsigned layerInverseGrayCode[]
Definition: CSCCFEBTimeSlice.cc:9
CSCCFEBTimeSlice::scaControllerWord
CSCCFEBSCAControllerWord scaControllerWord(int layer) const
unpacked from the controller words for each channel in the layer
Definition: CSCCFEBTimeSlice.cc:44
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
CSCCFEBSCAControllerWord::CSCCFEBSCAControllerWord
CSCCFEBSCAControllerWord()
Definition: CSCCFEBTimeSlice.h:42
mergeAndRegister.slice
slice
Definition: mergeAndRegister.py:121