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