CMS 3D CMS Logo

SiStripCluster.h
Go to the documentation of this file.
1 #ifndef DATAFORMATS_SISTRIPCLUSTER_H
2 #define DATAFORMATS_SISTRIPCLUSTER_H
3 
6 #include <vector>
7 #include <numeric>
8 #include <iostream>
9 
11 
13 public:
14  typedef std::vector<SiStripDigi>::const_iterator SiStripDigiIter;
15  typedef std::pair<SiStripDigiIter, SiStripDigiIter> SiStripDigiRange;
16 
17  static const uint16_t stripIndexMask = 0x7FFF; // The first strip index is in the low 15 bits of firstStrip_
18  static const uint16_t mergedValueMask = 0x8000; // The merged state is given by the high bit of firstStrip_
19 
25 
26  explicit SiStripCluster(const SiStripDigiRange& range);
27 
28  SiStripCluster(uint16_t firstStrip, std::vector<uint8_t>&& data)
30 
31  template <typename Iter>
33 
34  template <typename Iter>
35  SiStripCluster(const uint16_t& firstStrip, Iter begin, Iter end, bool merged)
37  if (merged)
38  firstStrip_ |= mergedValueMask; // if this is a candidate merged cluster
39  }
40 
41  SiStripCluster(const SiStripApproximateCluster cluster, const uint16_t maxStrips);
42 
43  // extend the cluster
44  template <typename Iter>
45  void extend(Iter begin, Iter end) {
46  amplitudes_.insert(amplitudes_.end(), begin, end);
47  }
48 
60  auto size() const { return amplitudes_.size(); }
61  auto const* begin() const { return amplitudes_.data(); }
62  auto const* end() const { return begin() + size(); }
63  auto operator[](int i) const { return *(begin() + i); }
64  bool empty() const { return amplitudes_.empty(); }
65  bool full() const { return false; }
66 
67  SiStripCluster const& amplitudes() const { return *this; }
68 
72  uint16_t firstStrip() const { return firstStrip_ & stripIndexMask; }
73  uint16_t endStrip() const { return firstStrip() + size(); }
74 
78  float barycenter() const;
79 
83  int charge() const;
84 
88  bool isMerged() const { return (firstStrip_ & mergedValueMask) != 0; }
89  void setMerged(bool mergedState) { mergedState ? firstStrip_ |= mergedValueMask : firstStrip_ &= stripIndexMask; }
90 
91  float getSplitClusterError() const { return error_x; }
92  void setSplitClusterError(float errx) { error_x = errx; }
93 
94 private:
95  std::vector<uint8_t> amplitudes_;
96 
97  uint16_t firstStrip_ = 0;
98 
99  //these are used if amplitude information is not available (using approximate cluster constructor)
100  float barycenter_ = 0;
101  int charge_ = 0;
102 
103  // ggiurgiu@fnal.gov, 01/05/12
104  // Add cluster errors to be used by rechits from split clusters.
105  // A rechit from a split cluster has larger errors than rechits from normal clusters.
106  // However, when presented with a cluster, the CPE does not know if the cluster comes
107  // from a splitting procedure or not. That's why we have to instruct the CPE to use
108  // appropriate errors for split clusters.
109  // To avoid increase of data size on disk,these new data members are set as transient in:
110  // DataFormats/SiStripCluster/src/classes_def.xml
111  float error_x = -99999.9;
112 
113  // ggiurgiu@fnal.gov, 01/05/12
114  // Initialize the split cluster errors to un-physical values.
115  // The CPE will check these errors and if they are not un-physical,
116  // it will recognize the clusters as split and assign these (increased)
117  // errors to the corresponding rechit.
118 };
119 
120 // Comparison operators
121 inline bool operator<(const SiStripCluster& one, const SiStripCluster& other) {
122  return one.firstStrip() < other.firstStrip();
123 }
124 
125 inline bool operator<(const SiStripCluster& cluster, const uint16_t& firstStrip) {
126  return cluster.firstStrip() < firstStrip;
127 }
128 
129 inline bool operator<(const uint16_t& firstStrip, const SiStripCluster& cluster) {
130  return firstStrip < cluster.firstStrip();
131 }
132 #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