CMS 3D CMS Logo

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