test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCAnodeData2007.cc
Go to the documentation of this file.
4 #include <string.h> // for bzero
5 #include<iostream>
6 
8  : nAFEBs_(header.nLCTChipRead()), nTimeBins_(header.NTBins())
9 {
10  init(header);
11  bzero(theDataFrames, sizeInWords()*2);
13  alctBX_= header.BXNCount();
14 }
15 
16 
18  const unsigned short *buf)
19  : nAFEBs_(header.nLCTChipRead()), nTimeBins_(header.NTBins())
20 {
21  init(header);
22  memcpy(theDataFrames, buf, sizeInWords()*2);
23  alctBX_= header.BXNCount();
25 }
26 
27 
28 void CSCAnodeData2007::init(const CSCALCTHeader & header) {
32  static unsigned short int layerParts[7] = { 3, 3, 4, 6, 6, 8,10};
33  static unsigned short int wireGroups[7] = {32,32,48,64,64,96,112};
34  //header.ALCTDigis();
36  header.alctHeader2007().rawBins*layerParts[header.alctHeader2007().boardType];
37  layerParts_ = layerParts[header.alctHeader2007().boardType];
38  maxWireGroups_ = wireGroups[header.alctHeader2007().boardType];
39 }
40 
41 
42 std::vector<CSCWireDigi> CSCAnodeData2007::wireDigis(int layer) const {
43  std::vector<CSCWireDigi> digis;
44  uint32_t tbinbits=0;
45  uint32_t wireGroup=0;
47  for(int layerPart = 0; layerPart <layerParts_; ++layerPart) {
49  for (int j=0; (j<12)&&((layerPart*12+j)<maxWireGroups_) ;++j) {
52  for(int tbin = 0; tbin < nTimeBins_; ++tbin) {
53  CSCAnodeDataFrame2007 frame = findFrame(tbin, layer, layerPart);
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 = (layerPart*12+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  return digis;
74 }
75 
76 
77 CSCAnodeDataFrame2007 CSCAnodeData2007::findFrame(int tbin, int layer, int layerPart) const {
78  return CSCAnodeDataFrame2007(theDataFrames[index(tbin, layer, layerPart)]);
79 }
80 
81 
82 int CSCAnodeData2007::index(int tbin, int layer, int layerPart) const
83 {
84  assert(tbin<nTimeBins_);
85  assert(layer<=6);
86  assert(layerPart<layerParts_);
87  int result = tbin*6*layerParts_+(layer-1)*layerParts_+layerPart;
88  assert(result < MAXFRAMES);
89  return result;
90 }
91 
92 
93 void CSCAnodeData2007::add(const CSCWireDigi & digi, int layer)
94 {
95  int wireGroup = digi.getWireGroup();
96  // wireGroup = (layerPart*12+j)+1;
97  unsigned layerPart = (wireGroup-1) / 12;
98  unsigned wireInPart = (wireGroup-1) % 12;
99 
100  std::vector<int> timeBinsOn = digi.getTimeBinsOn();
101  for(std::vector<int>::const_iterator timeBinOn = timeBinsOn.begin();
102  timeBinOn != timeBinsOn.end(); ++timeBinOn)
103  {
104  // crash if there's a bad wire number, but don't freak out
105  // if a time bin is out of range
106  // assert(alctBoard < nAFEBs_);
107  if(layerPart >= layerParts_)
108  {
109  edm::LogError("CSCAnodeData|CSCRawToDigi") << "Bad Wire Number for this digi.";
110  return;
111  }
112 
113  if((*timeBinOn) >= 0 && (*timeBinOn) < nTimeBins_)
114  {
115  CSCAnodeDataFrame2007 frame = findFrame(*timeBinOn, layer, layerPart);
116  frame.addHit(wireInPart);
117  // FIXME doesn't carry over the (currently 0) leading bits
118  theDataFrames[index(*timeBinOn, layer, layerPart)] = frame.data();
119  }
120  else
121  {
122  LogTrace("CSCAnodeData|CSCRawToDigi")<< "warning: not saving anode data in bx " << *timeBinOn
123  << ": out of range ";
124  }
125  }
126 }
127 
129 {
130  int wireGroup = 12;
131  int timeBin = 6;
132  CSCWireDigi wireDigi(wireGroup, (1 << timeBin));
133  CSCALCTHeader header(1);
134  CSCAnodeData2007 anodeData(header);
135  anodeData.add(wireDigi, 1);
136  anodeData.add(wireDigi, 6);
137 
138  std::vector<CSCWireDigi> wires1 = anodeData.wireDigis(1);
139  std::vector<CSCWireDigi> wires6 = anodeData.wireDigis(6);
140 
141  assert(wires1.size() == 1);
142  assert(wires6.size() == 1);
143  assert(wires1[0].getWireGroup() == wireGroup);
144  assert(wires6[0].getWireGroup() == wireGroup);
145  assert(wires1[0].getTimeBin() == timeBin);
146  assert(wires6[0].getTimeBin() == timeBin);
147 
148 }
149 
assert(m_qm.get())
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
tuple result
Definition: mps_fire.py:84
std::vector< int > getTimeBinsOn() const
return vector of time bins ON
Definition: CSCWireDigi.cc:48
static void selfTest()
int j
Definition: DBlmapReader.cc:9
int index(int tbin, int layer, int layerPart) const
#define LogTrace(id)
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:24
unsigned short theDataFrames[MAXFRAMES]
virtual unsigned short int sizeInWords() const
the amount of the input binary buffer read, in 16-bit words
unsigned short int sizeInWords2007_
virtual void add(const CSCWireDigi &, int layer)
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
unsigned short int nTimeBins_
unsigned short int layerParts_
virtual std::vector< CSCWireDigi > wireDigis(int layer) const
input layer is from 1 to 6