CMS 3D CMS Logo

CSCAnodeData2006.cc
Go to the documentation of this file.
4 #include <cstring> // for bzero
5 #include <iostream>
6 
7 CSCAnodeDataFrame2006::CSCAnodeDataFrame2006(unsigned chip, unsigned tbin, unsigned data) : theFrame(0) {
8  // lowest bit, plus the OR of the next two.
9  unsigned packedChip = ((chip & 1) + 2 * (chip > 1));
10  theFrame = data + ((tbin & 0x1F) << 8) + (packedChip << 13);
11 }
12 
14  : nAFEBs_(header.nLCTChipRead()), nTimeBins_(header.NTBins()) {
15  LogTrace("CSCAnodeData|CSCRawToDigi") << "Making Anode data " << sizeInWords() << " AFEB " << nAFEBs_ << " TBINS "
16  << nTimeBins_;
17  bzero(theDataFrames, sizeInWords() * 2);
18  for (int afeb = 0; afeb < nAFEBs_; ++afeb) {
19  for (int tbin = 0; tbin < nTimeBins_; ++tbin) {
20  for (int layer = 1; layer <= 6; ++layer) {
21  for (int halfLayer = 0; halfLayer < 2; ++halfLayer) {
22  theDataFrames[index(afeb, tbin, layer) + halfLayer] = CSCAnodeDataFrame2006(afeb, tbin, 0).frame();
23  }
24  }
25  }
26  }
28  alctBX_ = header.BXNCount();
29 }
30 
31 // initialize
33  : nAFEBs_(header.nLCTChipRead()), nTimeBins_(header.NTBins()) {
37  LogTrace("CSCAnodeData|CSCRawToDigi") << "nAFEBs = " << nAFEBs_ << " nTimeBins = " << nTimeBins_
38  << " nFrames = " << sizeInWords();
39  LogTrace("CSCAnodeData|CSCRawToDigi") << header << " HEADER CHECK " << header.check();
40 
41  memcpy(theDataFrames, buf, sizeInWords() * 2);
42 }
43 
44 std::vector<CSCWireDigi> CSCAnodeData2006::wireDigis(int layer) const {
45  std::vector<CSCWireDigi> digis;
46  uint32_t tbinbits = 0;
47  uint16_t wireGroup = 0;
48  for (int afeb = 0; afeb < nAFEBs_; ++afeb) {
49  for (int halfLayer = 0; halfLayer < 2; ++halfLayer) {
50  for (int j = 0; j < 8; ++j) {
51  for (int tbin = 0; tbin < nTimeBins_; ++tbin) {
52  CSCAnodeDataFrame2006 frame(rawHit(afeb, tbin, layer, halfLayer));
53  // see if there's anything in 1st 8 bits. Usually zero
54  if (frame.data() != 0) {
55  if (frame.isHit(j)) {
56  tbinbits = tbinbits + (1 << tbin);
57  }
58  }
59  } //end of tbin loop
60  if (tbinbits != 0) {
61  wireGroup = (afeb * 16 + halfLayer * 8 + j) + 1;
62  uint32_t wireGroupBX = alctBX_;
63  wireGroup = wireGroup | (wireGroupBX << 16);
64  CSCWireDigi digi(wireGroup, tbinbits);
65  LogTrace("CSCAnodeData|CSCRawToDigi") << "Layer " << layer << " " << digi;
66  digis.push_back(digi);
67  tbinbits = 0;
68  }
69  }
70  }
71  }
72 
73  return digis;
74 }
75 
76 void CSCAnodeData2006::add(const CSCWireDigi &digi, int layer) {
77  int wireGroup = digi.getWireGroup();
78  int bxn = digi.getBeamCrossingTag();
79  int alctBoard = (wireGroup - 1) / 16;
80  int localGroup = (wireGroup - 1) % 16;
81 
82  // crash if there's a bad wire number, but don't freak out
83  // if a time bin is out of range
84  // assert(alctBoard < nAFEBs_);
85  if (alctBoard > nAFEBs_) {
86  edm::LogError("CSCAnodeData|CSCRawToDigi") << "Bad Wire Number for this digi.";
87  return;
88  }
89  if (bxn >= 0 && bxn < nTimeBins_) {
90  // 12 16-bit words per time bin, two per layer
91  // wiregroups 0-7 go on the first line, 8-15 go on the 2nd.
92  unsigned halfLayer = (localGroup > 7);
93  unsigned bitNumber = localGroup % 8;
94  // and pack it in the 8 bits allocated
95  addHit(alctBoard, bxn, layer, halfLayer, bitNumber);
96  } else {
97  LogTrace("CSCAnodeData|CSCRawToDigi") << "warning: not saving anode data in bx " << bxn << ": out of range ";
98  }
99 }
100 
101 void CSCAnodeData2006::addHit(int afeb, int tbin, int layer, int halfLayer, unsigned wireBit) {
102  int i = index(afeb, tbin, layer) + halfLayer;
104  frame.addHit(wireBit);
105  theDataFrames[i] = frame.frame();
106 }
107 
108 CSCAnodeDataFrame2006 CSCAnodeData2006::rawHit(int afeb, int tbin, int layer, int halfLayer) const {
109  return CSCAnodeDataFrame2006(theDataFrames[index(afeb, tbin, layer) + halfLayer]);
110 }
111 
112 int CSCAnodeData2006::index(int afeb, int tbin, int layer) const {
113  int result = (layer - 1) * 2 + 12 * tbin + afeb * 12 * nTimeBins_;
115  return result;
116 }
117 
118 #include <iostream>
120  CSCAnodeDataFrame2006 frame(2, 15, 32);
121  assert(frame.chip() == 2);
122  assert(frame.tbin() == 15);
123  assert(frame.data() == 32);
124  assert(frame.isHit(5));
125  assert(!frame.isHit(7));
126  frame.addHit(7);
127  assert(frame.isHit(7));
128 
129  CSCWireDigi wireDigi(10, (1 << 4));
131  CSCAnodeData2006 anodeData(header);
132  anodeData.add(wireDigi, 1);
133  anodeData.add(wireDigi, 6);
134 
135  std::vector<CSCWireDigi> wires1 = anodeData.wireDigis(1);
136  std::vector<CSCWireDigi> wires6 = anodeData.wireDigis(6);
137 
138  assert(wires1.size() == 1);
139  assert(wires6.size() == 1);
140  assert(wires1[0].getWireGroup() == 10);
141  assert(wires6[0].getWireGroup() == 10);
142 }
CSCAnodeData2006::add
void add(const CSCWireDigi &, int layer) override
Definition: CSCAnodeData2006.cc:76
mps_fire.i
i
Definition: mps_fire.py:428
CSCALCTHeader.h
CSCAnodeData2006::CSCAnodeData2006
CSCAnodeData2006(const CSCALCTHeader &)
a blank one, for Monte Carlo
Definition: CSCAnodeData2006.cc:13
MessageLogger.h
CSCAnodeData2006.h
CSCWireDigi::getWireGroup
int getWireGroup() const
default
Definition: CSCWireDigi.h:22
CSCAnodeData2006::selfTest
static void selfTest()
Definition: CSCAnodeData2006.cc:119
cms::cuda::assert
assert(be >=bs)
CSCAnodeData2006::addHit
void addHit(int afeb, int tbin, int layer, int halfLayer, unsigned wireBit)
Definition: CSCAnodeData2006.cc:101
CSCAnodeDataFrame2006::data
unsigned short data() const
Definition: CSCAnodeData2006.h:28
CSCAnodeDataFrame2006::CSCAnodeDataFrame2006
CSCAnodeDataFrame2006()
Definition: CSCAnodeData2006.h:10
CSCALCTHeader
Definition: CSCALCTHeader.h:21
CSCAnodeData2006::nAFEBs_
int nAFEBs_
in 2007 format the max number of frames is 1860
Definition: CSCAnodeData2006.h:70
CSCAnodeDataFrame2006
Definition: CSCAnodeData2006.h:8
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
CSCAnodeData2006::wireDigis
std::vector< CSCWireDigi > wireDigis(int layer) const override
input layer is from 1 to 6
Definition: CSCAnodeData2006.cc:44
CSCAnodeData2006::theDataFrames
unsigned short theDataFrames[2700]
we don't know the size at first. Max should be 7 boards * 32 bins * 6 layers * 2
Definition: CSCAnodeData2006.h:68
CSCAnodeData2006::sizeInWords
unsigned short int sizeInWords() const override
the amount of the input binary buffer read, in 16-bit words
Definition: CSCAnodeData2006.h:48
CSCAnodeData2006::index
int index(int afeb, int tbin, int layer) const
the index into theDataFrames
Definition: CSCAnodeData2006.cc:112
CSCWireDigi
Definition: CSCWireDigi.h:14
CSCAnodeDataFrame2006::chip
unsigned chip() const
Definition: CSCAnodeData2006.h:27
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
CSCAnodeData2006::alctBX_
unsigned int alctBX_
Definition: CSCAnodeData2006.h:72
CSCAnodeData2006::nTimeBins_
int nTimeBins_
Definition: CSCAnodeData2006.h:71
CSCAnodeData2006
Definition: CSCAnodeData2006.h:39
CSCAnodeData2006::rawHit
CSCAnodeDataFrame2006 rawHit(int afeb, int tbin, int layer, int halfLayer) const
Definition: CSCAnodeData2006.cc:108
CSCAnodeDataFrame2006::tbin
unsigned tbin() const
time bin
Definition: CSCAnodeData2006.h:24
amptDefault_cfi.frame
frame
Definition: amptDefault_cfi.py:12
CSCAnodeDataFrame2006::frame
unsigned short frame() const
Definition: CSCAnodeData2006.h:29
CSCWireDigi::getBeamCrossingTag
int getBeamCrossingTag() const
return tbin number, (obsolete, use getTimeBin() instead)
Definition: CSCWireDigi.cc:33
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
RecoTauValidation_cfi.header
header
Definition: RecoTauValidation_cfi.py:292
L1TBPTX_cfi.bitNumber
bitNumber
Definition: L1TBPTX_cfi.py:26
mps_fire.result
result
Definition: mps_fire.py:311
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
CSCAnodeDataFrame2006::theFrame
unsigned short theFrame
Definition: CSCAnodeData2006.h:32
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66