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