CMS 3D CMS Logo

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