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 
85  bool filter() const;
86 
87  bool isFromApprox() const;
88 
92  bool isMerged() const { return (firstStrip_ & mergedValueMask) != 0; }
93  void setMerged(bool mergedState) { mergedState ? firstStrip_ |= mergedValueMask : firstStrip_ &= stripIndexMask; }
94 
95  float getSplitClusterError() const { return error_x; }
96  void setSplitClusterError(float errx) { error_x = errx; }
97 
98 private:
99  std::vector<uint8_t> amplitudes_;
100 
101  uint16_t firstStrip_ = 0;
102 
103  //these are used if amplitude information is not available (using approximate cluster constructor)
104  float barycenter_ = 0;
105  int charge_ = 0;
106  bool filter_ = false;
107 
108  // ggiurgiu@fnal.gov, 01/05/12
109  // Add cluster errors to be used by rechits from split clusters.
110  // A rechit from a split cluster has larger errors than rechits from normal clusters.
111  // However, when presented with a cluster, the CPE does not know if the cluster comes
112  // from a splitting procedure or not. That's why we have to instruct the CPE to use
113  // appropriate errors for split clusters.
114  // To avoid increase of data size on disk,these new data members are set as transient in:
115  // DataFormats/SiStripCluster/src/classes_def.xml
116  float error_x = -99999.9;
117 
118  // ggiurgiu@fnal.gov, 01/05/12
119  // Initialize the split cluster errors to un-physical values.
120  // The CPE will check these errors and if they are not un-physical,
121  // it will recognize the clusters as split and assign these (increased)
122  // errors to the corresponding rechit.
123 };
124 
125 // Comparison operators
126 inline bool operator<(const SiStripCluster& one, const SiStripCluster& other) {
127  return one.firstStrip() < other.firstStrip();
128 }
129 
130 inline bool operator<(const SiStripCluster& cluster, const uint16_t& firstStrip) {
131  return cluster.firstStrip() < firstStrip;
132 }
133 
134 inline bool operator<(const uint16_t& firstStrip, const SiStripCluster& cluster) {
135  return firstStrip < cluster.firstStrip();
136 }
137 #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 isFromApprox() 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
bool filter() const
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:80
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