CMS 3D CMS Logo

PulseArray.cc
Go to the documentation of this file.
2 
4 
5 void PulseArray::initialize(unsigned numberOfChannels) {
6  numberOfChannels_ = numberOfChannels;
7  data_.clear();
9  for (unsigned layer = 0; layer < CSCConstants::NUM_LAYERS; layer++) {
10  data_[layer].resize(numberOfChannels);
11  }
12 }
13 
15  // set all elements in the 2D vector to 0
16  for (auto& p : data_) {
17  for (auto& q : p) {
18  q = 0;
19  }
20  }
21 }
22 
23 unsigned& PulseArray::operator()(const unsigned layer, const unsigned channel) { return data_[layer][channel]; }
24 
25 unsigned PulseArray::bitsInPulse() const { return 8 * sizeof(data_[0][0]); }
26 
27 void PulseArray::extend(const unsigned layer, const unsigned channel, const unsigned bx, const unsigned hit_persist) {
28  for (unsigned int ibx = bx; ibx < bx + hit_persist; ++ibx) {
29  data_[layer][channel] = data_[layer][channel] | (1 << ibx);
30  }
31 }
32 
33 bool PulseArray::oneShotAtBX(const unsigned layer, const unsigned channel, const unsigned bx) const {
34  return (data_[layer][channel] >> bx) & 1;
35 }
36 
37 bool PulseArray::isOneShotHighAtBX(const unsigned layer, const unsigned channel, const unsigned bx) const {
38  return oneShotAtBX(layer, channel, bx) == 1;
39 }
40 
41 unsigned PulseArray::numberOfLayersAtBX(const unsigned bx) const {
42  unsigned layers_hit = 0;
43  for (unsigned layer = 0; layer < CSCConstants::NUM_LAYERS; layer++) {
44  for (unsigned channel = 0; channel < numberOfChannels_; channel++) {
45  if (isOneShotHighAtBX(layer, channel, bx)) {
46  layers_hit++;
47  break;
48  }
49  }
50  }
51  return layers_hit;
52 }
void clear()
Definition: PulseArray.cc:14
bool isOneShotHighAtBX(const unsigned layer, const unsigned channel, const unsigned bx) const
Definition: PulseArray.cc:37
unsigned & operator()(const unsigned layer, const unsigned channel)
Definition: PulseArray.cc:23
constexpr std::array< uint8_t, layerIndexSize< TrackerTraits > > layer
std::vector< std::vector< unsigned > > data_
Definition: PulseArray.h:41
bool oneShotAtBX(const unsigned layer, const unsigned channel, const unsigned bx) const
Definition: PulseArray.cc:33
unsigned numberOfLayersAtBX(const unsigned bx) const
Definition: PulseArray.cc:41
void initialize(unsigned numberOfChannels)
Definition: PulseArray.cc:5
unsigned bitsInPulse() const
Definition: PulseArray.cc:25
void extend(const unsigned layer, const unsigned channel, const unsigned bx, const unsigned hit_persist)
Definition: PulseArray.cc:27
unsigned numberOfChannels_
Definition: PulseArray.h:42