CMS 3D CMS Logo

CSCAnodeData2007.cc
Go to the documentation of this file.
5 #include <cstring> // for bzero
6 #include <iostream>
7 
9  : nAFEBs_(header.nLCTChipRead()), nTimeBins_(header.NTBins()) {
10  init(header);
11  bzero(theDataFrames, sizeInWords() * 2);
13  alctBX_ = header.BXNCount();
14 }
15 
17  : nAFEBs_(header.nLCTChipRead()), nTimeBins_(header.NTBins()) {
18  init(header);
19  memcpy(theDataFrames, buf, sizeInWords() * 2);
20  alctBX_ = header.BXNCount();
22 }
23 
28  static const unsigned short int layerParts[7] = {3, 3, 4, 6, 6, 8, 10};
29  static const unsigned short int wireGroups[7] = {32, 32, 48, 64, 64, 96, 112};
30  //header.ALCTDigis();
31  sizeInWords2007_ = (1 - header.alctHeader2007().rawOverflow) * 6 * header.alctHeader2007().rawBins *
32  layerParts[header.alctHeader2007().boardType];
33  layerParts_ = layerParts[header.alctHeader2007().boardType];
34  maxWireGroups_ = wireGroups[header.alctHeader2007().boardType];
35 }
36 
37 std::vector<CSCWireDigi> CSCAnodeData2007::wireDigis(int layer) const {
38  std::vector<CSCWireDigi> digis;
39  uint32_t tbinbits = 0;
40  uint32_t wireGroup = 0;
42  for (int layerPart = 0; layerPart < layerParts_; ++layerPart) {
44  for (int j = 0; (j < 12) && ((layerPart * 12 + j) < maxWireGroups_); ++j) {
47  for (int tbin = 0; tbin < nTimeBins_; ++tbin) {
48  CSCAnodeDataFrame2007 frame = findFrame(tbin, layer, layerPart);
49  if (frame.data() != 0) {
50  if (frame.isHit(j)) {
51  tbinbits = tbinbits + (1 << tbin);
52  }
53  }
54  } //end of tbin loop
55  if (tbinbits != 0) {
56  wireGroup = (layerPart * 12 + j) + 1;
58  uint32_t wireGroupBX = alctBX_;
59  wireGroup = wireGroup | (wireGroupBX << 16);
60  CSCWireDigi digi(wireGroup, tbinbits);
61  LogTrace("CSCAnodeData|CSCRawToDigi") << "Layer " << layer << " " << digi;
62  digis.push_back(digi);
63  tbinbits = 0;
64  }
65  }
66  }
67 
68  return digis;
69 }
70 
71 CSCAnodeDataFrame2007 CSCAnodeData2007::findFrame(int tbin, int layer, int layerPart) const {
72  return CSCAnodeDataFrame2007(theDataFrames[index(tbin, layer, layerPart)]);
73 }
74 
75 int CSCAnodeData2007::index(int tbin, int layer, int layerPart) const {
76  assert(tbin < nTimeBins_);
78  assert(layerPart < layerParts_);
79  int result = tbin * 6 * layerParts_ + (layer - 1) * layerParts_ + layerPart;
81  return result;
82 }
83 
84 void CSCAnodeData2007::add(const CSCWireDigi &digi, int layer) {
85  int wireGroup = digi.getWireGroup();
86  // wireGroup = (layerPart*12+j)+1;
87  unsigned layerPart = (wireGroup - 1) / 12;
88  unsigned wireInPart = (wireGroup - 1) % 12;
89 
90  std::vector<int> timeBinsOn = digi.getTimeBinsOn();
91  for (std::vector<int>::const_iterator timeBinOn = timeBinsOn.begin(); timeBinOn != timeBinsOn.end(); ++timeBinOn) {
92  // crash if there's a bad wire number, but don't freak out
93  // if a time bin is out of range
94  // assert(alctBoard < nAFEBs_);
95  if (layerPart >= layerParts_) {
96  edm::LogError("CSCAnodeData|CSCRawToDigi") << "Bad Wire Number for this digi.";
97  return;
98  }
99 
100  if ((*timeBinOn) >= 0 && (*timeBinOn) < nTimeBins_) {
101  CSCAnodeDataFrame2007 frame = findFrame(*timeBinOn, layer, layerPart);
102  frame.addHit(wireInPart);
103  // FIXME doesn't carry over the (currently 0) leading bits
104  theDataFrames[index(*timeBinOn, layer, layerPart)] = frame.data();
105  } else {
106  LogTrace("CSCAnodeData|CSCRawToDigi")
107  << "warning: not saving anode data in bx " << *timeBinOn << ": out of range ";
108  }
109  }
110 }
111 
113  int wireGroup = 12;
114  int timeBin = 6;
115  CSCWireDigi wireDigi(wireGroup, (1 << timeBin));
117  CSCAnodeData2007 anodeData(header);
118  anodeData.add(wireDigi, 1);
119  anodeData.add(wireDigi, 6);
120 
121  std::vector<CSCWireDigi> wires1 = anodeData.wireDigis(1);
122  std::vector<CSCWireDigi> wires6 = anodeData.wireDigis(6);
123 
124  assert(wires1.size() == 1);
125  assert(wires6.size() == 1);
126  assert(wires1[0].getWireGroup() == wireGroup);
127  assert(wires6[0].getWireGroup() == wireGroup);
128  assert(wires1[0].getTimeBin() == timeBin);
129  assert(wires6[0].getTimeBin() == timeBin);
130 }
CSCALCTHeader.h
MessageLogger.h
CSCAnodeData2007::MAXFRAMES
Definition: CSCAnodeData2007.h:54
CSCAnodeData2007::theDataFrames
unsigned short theDataFrames[MAXFRAMES]
Definition: CSCAnodeData2007.h:55
CSCAnodeData2007.h
CSCWireDigi::getWireGroup
int getWireGroup() const
default
Definition: CSCWireDigi.h:22
cms::cuda::assert
assert(be >=bs)
CSCAnodeData2007::findFrame
CSCAnodeDataFrame2007 findFrame(int tbin, int layer, int layerPart) const
Definition: CSCAnodeData2007.cc:71
CSCAnodeData2007::add
void add(const CSCWireDigi &, int layer) override
Definition: CSCAnodeData2007.cc:84
CSCDetId.h
CSCAnodeData2007::nTimeBins_
unsigned short int nTimeBins_
Definition: CSCAnodeData2007.h:58
CSCALCTHeader
Definition: CSCALCTHeader.h:21
CSCAnodeData2007::maxWireGroups_
unsigned short int maxWireGroups_
number of layer parts in the ALCT
Definition: CSCAnodeData2007.h:61
CSCAnodeData2007::alctBX_
unsigned int alctBX_
number of wiregroups in the ALCT
Definition: CSCAnodeData2007.h:62
CSCAnodeData2007::init
void init(const CSCALCTHeader &)
Definition: CSCAnodeData2007.cc:24
CSCAnodeData2007::index
int index(int tbin, int layer, int layerPart) const
Definition: CSCAnodeData2007.cc:75
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
CSCWireDigi::getTimeBinsOn
std::vector< int > getTimeBinsOn() const
return vector of time bins ON
Definition: CSCWireDigi.cc:48
CSCAnodeData2007
Definition: CSCAnodeData2007.h:30
CSCWireDigi
Definition: CSCWireDigi.h:14
CSCAnodeData2007::wireDigis
std::vector< CSCWireDigi > wireDigis(int layer) const override
input layer is from 1 to 6
Definition: CSCAnodeData2007.cc:37
CSCAnodeData2007::CSCAnodeData2007
CSCAnodeData2007(const CSCALCTHeader &)
a blank one, for Monte Carlo
Definition: CSCAnodeData2007.cc:8
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
visDQMUpload.buf
buf
Definition: visDQMUpload.py:160
CSCAnodeData2007::sizeInWords
unsigned short int sizeInWords() const override
the amount of the input binary buffer read, in 16-bit words
Definition: CSCAnodeData2007.h:39
amptDefault_cfi.frame
frame
Definition: amptDefault_cfi.py:12
CSCAnodeData2007::layerParts_
unsigned short int layerParts_
Definition: CSCAnodeData2007.h:60
CSCDetId::maxLayerId
static int maxLayerId()
Definition: CSCDetId.h:243
RecoTauValidation_cfi.header
header
Definition: RecoTauValidation_cfi.py:291
mps_fire.result
result
Definition: mps_fire.py:311
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
CSCAnodeDataFrame2007
Definition: CSCAnodeData2007.h:9
CSCAnodeData2007::sizeInWords2007_
unsigned short int sizeInWords2007_
Definition: CSCAnodeData2007.h:56
CSCAnodeData2007::selfTest
static void selfTest()
Definition: CSCAnodeData2007.cc:112