CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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)
25  : amplitudes_(std::move(data)), firstStrip_(firstStrip) {}
26 
27  template <typename Iter>
28  SiStripCluster(const uint16_t& firstStrip, Iter begin, Iter end) : amplitudes_(begin, end), firstStrip_(firstStrip) {}
29 
30  template <typename Iter>
31  SiStripCluster(const uint16_t& firstStrip, Iter begin, Iter end, bool merged)
32  : amplitudes_(begin, end), firstStrip_(firstStrip) {
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 
46  uint16_t firstStrip() const { return firstStrip_ & stripIndexMask; }
47 
48  uint16_t endStrip() const { return firstStrip() + size(); }
49 
61  uint8_t const* begin() const { return amplitudes_.data(); }
62  uint8_t const* end() const { return begin() + size(); }
63  uint8_t size() const { return amplitudes_.size(); }
64  uint8_t operator[](int i) const { return *(begin() + i); }
65  bool empty() const { return 0 == size(); }
66  bool full() const { return false; }
67 
68  SiStripCluster const& amplitudes() const { return *this; }
69 
73  float barycenter() const;
74 
78  int charge() const { return std::accumulate(begin(), end(), int(0)); }
79 
83  bool isMerged() const { return (firstStrip_ & mergedValueMask) != 0; }
84  void setMerged(bool mergedState) { mergedState ? firstStrip_ |= mergedValueMask : firstStrip_ &= stripIndexMask; }
85 
86  float getSplitClusterError() const { return error_x; }
87  void setSplitClusterError(float errx) { error_x = errx; }
88 
89 private:
90  std::vector<uint8_t> amplitudes_;
91 
92  uint16_t firstStrip_ = 0;
93 
94  // ggiurgiu@fnal.gov, 01/05/12
95  // Add cluster errors to be used by rechits from split clusters.
96  // A rechit from a split cluster has larger errors than rechits from normal clusters.
97  // However, when presented with a cluster, the CPE does not know if the cluster comes
98  // from a splitting procedure or not. That's why we have to instruct the CPE to use
99  // appropriate errors for split clusters.
100  // To avoid increase of data size on disk,these new data members are set as transient in:
101  // DataFormats/SiStripCluster/src/classes_def.xml
102  float error_x = -99999.9;
103 
104  // ggiurgiu@fnal.gov, 01/05/12
105  // Initialize the split cluster errors to un-physical values.
106  // The CPE will check these errors and if they are not un-physical,
107  // it will recognize the clusters as split and assign these (increased)
108  // errors to the corresponding rechit.
109 };
110 
111 // Comparison operators
112 inline bool operator<(const SiStripCluster& one, const SiStripCluster& other) {
113  return one.firstStrip() < other.firstStrip();
114 }
115 
116 inline bool operator<(const SiStripCluster& cluster, const uint16_t& firstStrip) {
117  return cluster.firstStrip() < firstStrip;
118 }
119 
120 inline bool operator<(const uint16_t& firstStrip, const SiStripCluster& cluster) {
121  return firstStrip < cluster.firstStrip();
122 }
123 #endif // DATAFORMATS_SISTRIPCLUSTER_H
bool full() const
int charge() const
bool isMerged() const
std::pair< SiStripDigiIter, SiStripDigiIter > SiStripDigiRange
SiStripCluster const & amplitudes() const
void setMerged(bool mergedState)
uint16_t firstStrip() const
uint8_t operator[](int i) const
bool empty() const
const uint16_t range(const Frame &aFrame)
float getSplitClusterError() const
SiStripCluster(const uint16_t &firstStrip, Iter begin, Iter end)
SiStripCluster(uint16_t firstStrip, std::vector< uint8_t > &&data)
SiStripCluster(const uint16_t &firstStrip, Iter begin, Iter end, bool merged)
def move
Definition: eostools.py:511
uint8_t const * begin() const
float barycenter() const
static const uint16_t mergedValueMask
void extend(Iter begin, Iter end)
std::vector< SiStripDigi >::const_iterator SiStripDigiIter
void setSplitClusterError(float errx)
bool operator<(DTCELinkId const &lhs, DTCELinkId const &rhs)
Definition: DTCELinkId.h:70
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
std::vector< uint8_t > amplitudes_
uint16_t firstStrip_
static const uint16_t stripIndexMask
uint16_t endStrip() const
uint8_t size() const
uint8_t const * end() const