CMS 3D CMS Logo

SiStripCluster.h
Go to the documentation of this file.
1 #ifndef DATAFORMATS_SISTRIPCLUSTER_H
2 #define DATAFORMATS_SISTRIPCLUSTER_H
3 
5 #include <vector>
6 #include <numeric>
7 
9 public:
10  typedef std::vector<SiStripDigi>::const_iterator SiStripDigiIter;
11  typedef std::pair<SiStripDigiIter, SiStripDigiIter> SiStripDigiRange;
12 
13  static const uint16_t stripIndexMask = 0x7FFF; // The first strip index is in the low 15 bits of firstStrip_
14  static const uint16_t mergedValueMask = 0x8000; // The merged state is given by the high bit of firstStrip_
15 
21 
22  explicit SiStripCluster(const SiStripDigiRange& range);
23 
24  SiStripCluster(uint16_t firstStrip, std::vector<uint8_t>&& data)
26 
27  template <typename Iter>
29 
30  template <typename Iter>
31  SiStripCluster(const uint16_t& firstStrip, Iter begin, Iter end, bool merged)
33  if (merged)
34  firstStrip_ |= mergedValueMask; // if this is a candidate merged cluster
35  }
36 
37  // extend the cluster
38  template <typename Iter>
39  void extend(Iter begin, Iter end) {
40  amplitudes_.insert(amplitudes_.end(), begin, end);
41  }
42 
54  auto size() const { return amplitudes_.size(); }
55  auto const* begin() const { return amplitudes_.data(); }
56  auto const* end() const { return begin() + size(); }
57  auto operator[](int i) const { return *(begin() + i); }
58  bool empty() const { return amplitudes_.empty(); }
59  bool full() const { return false; }
60 
61  SiStripCluster const& amplitudes() const { return *this; }
62 
66  uint16_t firstStrip() const { return firstStrip_ & stripIndexMask; }
67  uint16_t endStrip() const { return firstStrip() + size(); }
68 
72  float barycenter() const;
73 
77  int charge() const { return std::accumulate(begin(), end(), int(0)); }
78 
82  bool isMerged() const { return (firstStrip_ & mergedValueMask) != 0; }
83  void setMerged(bool mergedState) { mergedState ? firstStrip_ |= mergedValueMask : firstStrip_ &= stripIndexMask; }
84 
85  float getSplitClusterError() const { return error_x; }
86  void setSplitClusterError(float errx) { error_x = errx; }
87 
88 private:
89  std::vector<uint8_t> amplitudes_;
90 
91  uint16_t firstStrip_ = 0;
92 
93  // ggiurgiu@fnal.gov, 01/05/12
94  // Add cluster errors to be used by rechits from split clusters.
95  // A rechit from a split cluster has larger errors than rechits from normal clusters.
96  // However, when presented with a cluster, the CPE does not know if the cluster comes
97  // from a splitting procedure or not. That's why we have to instruct the CPE to use
98  // appropriate errors for split clusters.
99  // To avoid increase of data size on disk,these new data members are set as transient in:
100  // DataFormats/SiStripCluster/src/classes_def.xml
101  float error_x = -99999.9;
102 
103  // ggiurgiu@fnal.gov, 01/05/12
104  // Initialize the split cluster errors to un-physical values.
105  // The CPE will check these errors and if they are not un-physical,
106  // it will recognize the clusters as split and assign these (increased)
107  // errors to the corresponding rechit.
108 };
109 
110 // Comparison operators
111 inline bool operator<(const SiStripCluster& one, const SiStripCluster& other) {
112  return one.firstStrip() < other.firstStrip();
113 }
114 
115 inline bool operator<(const SiStripCluster& cluster, const uint16_t& firstStrip) {
116  return cluster.firstStrip() < firstStrip;
117 }
118 
119 inline bool operator<(const uint16_t& firstStrip, const SiStripCluster& cluster) {
120  return firstStrip < cluster.firstStrip();
121 }
122 #endif // DATAFORMATS_SISTRIPCLUSTER_H
int charge() const
uint16_t firstStrip() const
std::pair< SiStripDigiIter, SiStripDigiIter > SiStripDigiRange
bool operator<(const SiStripCluster &one, const SiStripCluster &other)
void setMerged(bool mergedState)
auto const * begin() const
auto const * end() const
bool empty() const
SiStripCluster(const uint16_t &firstStrip, Iter begin, Iter end)
SiStripCluster(uint16_t firstStrip, std::vector< uint8_t > &&data)
bool full() const
SiStripCluster(const uint16_t &firstStrip, Iter begin, Iter end, bool merged)
SiStripCluster const & amplitudes() const
auto size() const
auto operator[](int i) const
bool isMerged() const
static const uint16_t mergedValueMask
void extend(Iter begin, Iter end)
std::vector< SiStripDigi >::const_iterator SiStripDigiIter
float getSplitClusterError() const
void setSplitClusterError(float errx)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
float barycenter() const
std::vector< uint8_t > amplitudes_
uint16_t firstStrip_
static const uint16_t stripIndexMask
def move(src, dest)
Definition: eostools.py:511
uint16_t endStrip() const