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 
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
SiStripCluster::begin
uint8_t const * begin() const
Definition: SiStripCluster.h:61
SiStripCluster::setMerged
void setMerged(bool mergedState)
Definition: SiStripCluster.h:84
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
mps_fire.i
i
Definition: mps_fire.py:428
SiPixelPI::one
Definition: SiPixelPayloadInspectorHelper.h:39
SiStripCluster::barycenter
float barycenter() const
Definition: SiStripCluster.cc:25
SiStripCluster::error_x
float error_x
Definition: SiStripCluster.h:102
SiStripCluster::SiStripCluster
SiStripCluster(uint16_t firstStrip, std::vector< uint8_t > &&data)
Definition: SiStripCluster.h:24
SiStripCluster::full
bool full() const
Definition: SiStripCluster.h:66
SiStripCluster::stripIndexMask
static const uint16_t stripIndexMask
Definition: SiStripCluster.h:13
SiStripCluster::SiStripCluster
SiStripCluster(const uint16_t &firstStrip, Iter begin, Iter end, bool merged)
Definition: SiStripCluster.h:31
SiStripCluster::firstStrip
uint16_t firstStrip() const
Definition: SiStripCluster.h:46
SiStripCluster::setSplitClusterError
void setSplitClusterError(float errx)
Definition: SiStripCluster.h:87
SiStripCluster::amplitudes_
std::vector< uint8_t > amplitudes_
Definition: SiStripCluster.h:90
SiStripCluster::getSplitClusterError
float getSplitClusterError() const
Definition: SiStripCluster.h:86
SiStripCluster::empty
bool empty() const
Definition: SiStripCluster.h:65
SiStripDigi.h
trackingPlots.other
other
Definition: trackingPlots.py:1460
SiStripCluster::SiStripDigiIter
std::vector< SiStripDigi >::const_iterator SiStripDigiIter
Definition: SiStripCluster.h:10
SiStripCluster::isMerged
bool isMerged() const
Definition: SiStripCluster.h:83
SiStripCluster::end
uint8_t const * end() const
Definition: SiStripCluster.h:62
SiStripCluster::size
uint8_t size() const
Definition: SiStripCluster.h:63
SiStripCluster::SiStripCluster
SiStripCluster()
Definition: SiStripCluster.h:20
operator<
bool operator<(const SiStripCluster &one, const SiStripCluster &other)
Definition: SiStripCluster.h:112
SiStripCluster::amplitudes
SiStripCluster const & amplitudes() const
Definition: SiStripCluster.h:68
SiStripCluster::charge
int charge() const
Definition: SiStripCluster.h:78
SiStripCluster::SiStripDigiRange
std::pair< SiStripDigiIter, SiStripDigiIter > SiStripDigiRange
Definition: SiStripCluster.h:11
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
SiStripCluster::endStrip
uint16_t endStrip() const
Definition: SiStripCluster.h:48
SiStripCluster::SiStripCluster
SiStripCluster(const uint16_t &firstStrip, Iter begin, Iter end)
Definition: SiStripCluster.h:28
SiStripCluster::operator[]
uint8_t operator[](int i) const
Definition: SiStripCluster.h:64
SiStripCluster::mergedValueMask
static const uint16_t mergedValueMask
Definition: SiStripCluster.h:14
SiStripCluster::extend
void extend(Iter begin, Iter end)
Definition: SiStripCluster.h:39
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
SiStripCluster
Definition: SiStripCluster.h:8
SiStripCluster::firstStrip_
uint16_t firstStrip_
Definition: SiStripCluster.h:92