CMS 3D CMS Logo

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