CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SiPixelClusterShapeCache.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 #ifndef DataFormats_SiPixelCluster_SiPixelClusterShapeData_h
3 #define DataFormats_SiPixelCluster_SiPixelClusterShapeData_h
4 
10 
11 #include <utility>
12 #include <vector>
13 #include <algorithm>
14 #include <cassert>
15 #include <memory>
16 
17 class PixelGeomDetUnit;
18 
20 public:
21  typedef std::vector<std::pair<int, int> >::const_iterator const_iterator;
22  typedef std::pair<const_iterator, const_iterator> Range;
25  : begin_(begin),
26  end_(end),
27  isStraight_(isStraight),
28  isComplete_(isComplete),
29  hasBigPixelsOnlyInside_(hasBigPixelsOnlyInside) {}
31 
32  Range size() const { return std::make_pair(begin_, end_); }
33 
34  bool isStraight() const { return isStraight_; }
35  bool isComplete() const { return isComplete_; }
37 
38 private:
41 };
42 
44 public:
46 
47  struct Field {
49 
50  Field(unsigned off, unsigned siz, bool s, bool c, bool h)
51  : offset(off), size(siz), straight(s), complete(c), has(h), filled(true) {}
52  unsigned offset : 24; // room for 2^24/9 = ~1.8e6 clusters, should be enough
53  unsigned size : 4; // max 9 elements / cluster (2^4-1=15)
54  unsigned straight : 1;
55  unsigned complete : 1;
56  unsigned has : 1;
57  unsigned filled : 1;
58  };
59 
62  explicit SiPixelClusterShapeCache(const edm::ProductID& id) : productId_(id) {}
64 
65  void resize(size_t size) {
66  data_.resize(size);
67  sizeData_.reserve(size);
68  }
69 
71  data_.swap(other.data_);
72  sizeData_.swap(other.sizeData_);
74  }
75 
76 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
77  void shrink_to_fit() {
78  data_.shrink_to_fit();
79  sizeData_.shrink_to_fit();
80  }
81 
82  template <typename T>
83  void insert(const ClusterRef& cluster, const T& data) {
84  static_assert(T::ArrayType::capacity() <= 15, "T::ArrayType::capacity() more than 15, bit field too narrow");
85  checkRef(cluster);
86 
87  data_[cluster.index()] =
88  Field(sizeData_.size(), data.size.size(), data.isStraight, data.isComplete, data.hasBigPixelsOnlyInside);
89  std::copy(data.size.begin(), data.size.end(), std::back_inserter(sizeData_));
90  }
91 
92  bool isFilled(const ClusterRef& cluster) const {
93  checkRef(cluster);
94  return data_[cluster.index()].filled;
95  }
96 
97  SiPixelClusterShapeData get(const ClusterRef& cluster, const PixelGeomDetUnit* pixDet) const {
98  checkRef(cluster);
99  Field f = data_[cluster.index()];
100  assert(f.filled);
101 
102  auto beg = sizeData_.begin() + f.offset;
103  auto end = beg + f.size;
104 
105  return SiPixelClusterShapeData(beg, end, f.straight, f.complete, f.has);
106  }
107 #endif
108 
109 private:
110  void checkRef(const ClusterRef& cluster) const;
111 
112  std::vector<Field> data_;
113  std::vector<std::pair<int, int> > sizeData_;
115 };
116 
117 #endif
bool isFilled(const ClusterRef &cluster) const
void insert(const ClusterRef &cluster, const T &data)
std::vector< std::pair< int, int > > sizeData_
const edm::EventSetup & c
void checkRef(const ClusterRef &cluster) const
Field(unsigned off, unsigned siz, bool s, bool c, bool h)
uint16_t *__restrict__ id
key_type index() const
Definition: Ref.h:253
assert(be >=bs)
SiPixelClusterShapeCache(const edm::HandleBase &handle)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
tuple handle
Definition: patZpeak.py:25
std::pair< const_iterator, const_iterator > Range
std::vector< std::pair< int, int > >::const_iterator const_iterator
Pixel cluster – collection of neighboring pixels above threshold.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
string end
Definition: dataset.py:937
SiPixelClusterShapeData(const_iterator begin, const_iterator end, bool isStraight, bool isComplete, bool hasBigPixelsOnlyInside)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
long double T
void swap(SiPixelClusterShapeCache &other)
edm::Ref< edmNew::DetSetVector< SiPixelCluster >, SiPixelCluster > ClusterRef
tuple size
Write out results.
SiPixelClusterShapeCache(const edm::ProductID &id)