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>
8 
10 public:
11  typedef std::vector<SiStripDigi>::const_iterator SiStripDigiIter;
12  typedef std::pair<SiStripDigiIter, SiStripDigiIter> SiStripDigiRange;
13 
14  static const uint16_t stripIndexMask = 0x7FFF; // The first strip index is in the low 15 bits of firstStrip_
15  static const uint16_t mergedValueMask = 0x8000; // The merged state is given by the high bit of firstStrip_
16 
22 
23  explicit SiStripCluster(const SiStripDigiRange& range);
24 
25  template <typename Iter>
26  SiStripCluster(const uint16_t& firstStrip, Iter begin, Iter end) : amplitudes_(begin, end), firstStrip_(firstStrip) {}
27 
28  template <typename Iter>
29  SiStripCluster(const uint16_t& firstStrip, Iter begin, Iter end, bool merged)
30  : amplitudes_(begin, end), firstStrip_(firstStrip) {
31  if (merged)
32  firstStrip_ |= mergedValueMask; // if this is a candidate merged cluster
33  }
34 
38  uint16_t firstStrip() const { return firstStrip_ & stripIndexMask; }
39 
51  const std::vector<uint8_t>& amplitudes() const { return amplitudes_; }
52 
56  float barycenter() const;
57 
61  int charge() const { return std::accumulate(amplitudes().begin(), amplitudes().end(), int(0)); }
62 
66  bool isMerged() const { return (firstStrip_ & mergedValueMask) != 0; }
67  void setMerged(bool mergedState) { mergedState ? firstStrip_ |= mergedValueMask : firstStrip_ &= stripIndexMask; }
68 
69  float getSplitClusterError() const { return error_x; }
70  void setSplitClusterError(float errx) { error_x = errx; }
71 
72 private:
73  std::vector<uint8_t> amplitudes_;
74 
75  uint16_t firstStrip_ = 0;
76 
77  // ggiurgiu@fnal.gov, 01/05/12
78  // Add cluster errors to be used by rechits from split clusters.
79  // A rechit from a split cluster has larger errors than rechits from normal clusters.
80  // However, when presented with a cluster, the CPE does not know if the cluster comes
81  // from a splitting procedure or not. That's why we have to instruct the CPE to use
82  // appropriate errors for split clusters.
83  // To avoid increase of data size on disk,these new data members are set as transient in:
84  // DataFormats/SiStripCluster/src/classes_def.xml
85  float error_x = -99999.9;
86 
87  // ggiurgiu@fnal.gov, 01/05/12
88  // Initialize the split cluster errors to un-physical values.
89  // The CPE will check these errors and if they are not un-physical,
90  // it will recognize the clusters as split and assign these (increased)
91  // errors to the corresponding rechit.
92 };
93 
94 // Comparison operators
95 inline bool operator<(const SiStripCluster& one, const SiStripCluster& other) {
96  return one.firstStrip() < other.firstStrip();
97 }
98 
99 inline bool operator<(const SiStripCluster& cluster, const uint16_t& firstStrip) {
100  return cluster.firstStrip() < firstStrip;
101 }
102 
103 inline bool operator<(const uint16_t& firstStrip, const SiStripCluster& cluster) {
104  return firstStrip < cluster.firstStrip();
105 }
106 #endif // DATAFORMATS_SISTRIPCLUSTER_H
int charge() const
bool isMerged() const
std::pair< SiStripDigiIter, SiStripDigiIter > SiStripDigiRange
bool operator<(const SiStripCluster &one, const SiStripCluster &other)
void setMerged(bool mergedState)
uint16_t firstStrip() const
float getSplitClusterError() const
SiStripCluster(const uint16_t &firstStrip, Iter begin, Iter end)
SiStripCluster(const uint16_t &firstStrip, Iter begin, Iter end, bool merged)
float barycenter() const
static const uint16_t mergedValueMask
#define end
Definition: vmac.h:39
std::vector< SiStripDigi >::const_iterator SiStripDigiIter
void setSplitClusterError(float errx)
#define begin
Definition: vmac.h:32
std::vector< uint8_t > amplitudes_
uint16_t firstStrip_
static const uint16_t stripIndexMask
const std::vector< uint8_t > & amplitudes() const