CMS 3D CMS Logo

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),
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 
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_);
73  std::swap(productId_, other.productId_);
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
SiPixelClusterShapeData::hasBigPixelsOnlyInside
bool hasBigPixelsOnlyInside() const
Definition: SiPixelClusterShapeCache.h:36
gpuVertexFinder::capacity
size d for d tracks hist hist capacity()
SiPixelClusterShapeData::isStraight
bool isStraight() const
Definition: SiPixelClusterShapeCache.h:34
funct::false
false
Definition: Factorize.h:29
SiPixelClusterShapeCache
Definition: SiPixelClusterShapeCache.h:43
SiPixelClusterShapeCache::get
SiPixelClusterShapeData get(const ClusterRef &cluster, const PixelGeomDetUnit *pixDet) const
Definition: SiPixelClusterShapeCache.h:97
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
patZpeak.handle
handle
Definition: patZpeak.py:23
SiPixelClusterShapeCache::SiPixelClusterShapeCache
SiPixelClusterShapeCache(const edm::ProductID &id)
Definition: SiPixelClusterShapeCache.h:62
SiPixelClusterShapeCache::Field::offset
unsigned offset
Definition: SiPixelClusterShapeCache.h:52
SiPixelClusterShapeCache::ClusterRef
edm::Ref< edmNew::DetSetVector< SiPixelCluster >, SiPixelCluster > ClusterRef
Definition: SiPixelClusterShapeCache.h:45
SiPixelClusterShapeCache::Field
Definition: SiPixelClusterShapeCache.h:47
SiPixelCluster.h
edm::HandleBase
Definition: HandleBase.h:40
cms::cuda::assert
assert(be >=bs)
SiPixelClusterShapeData::~SiPixelClusterShapeData
~SiPixelClusterShapeData()
Definition: SiPixelClusterShapeCache.cc:4
SiPixelClusterShapeCache::Field::filled
unsigned filled
Definition: SiPixelClusterShapeCache.h:57
SiPixelCluster
Pixel cluster – collection of neighboring pixels above threshold.
Definition: SiPixelCluster.h:28
SiPixelClusterShapeCache::SiPixelClusterShapeCache
SiPixelClusterShapeCache(const edm::HandleBase &handle)
Definition: SiPixelClusterShapeCache.h:61
SiPixelClusterShapeData::size
Range size() const
Definition: SiPixelClusterShapeCache.h:32
SiPixelClusterShapeCache::sizeData_
std::vector< std::pair< int, int > > sizeData_
Definition: SiPixelClusterShapeCache.h:113
edm::Ref::index
key_type index() const
Definition: Ref.h:253
SiPixelClusterShapeData::isStraight_
const bool isStraight_
Definition: SiPixelClusterShapeCache.h:40
edm::Ref
Definition: AssociativeIterator.h:58
HandleBase.h
alignCSCRings.s
s
Definition: alignCSCRings.py:92
SiPixelClusterShapeCache::Field::Field
Field()
Definition: SiPixelClusterShapeCache.h:48
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
PixelGeomDetUnit
Definition: PixelGeomDetUnit.h:15
mps_fire.end
end
Definition: mps_fire.py:242
ProductID.h
trackingPlots.other
other
Definition: trackingPlots.py:1464
h
SiPixelClusterShapeData::Range
std::pair< const_iterator, const_iterator > Range
Definition: SiPixelClusterShapeCache.h:22
SiPixelClusterShapeData::begin_
const_iterator begin_
Definition: SiPixelClusterShapeCache.h:39
SiPixelClusterShapeData::isComplete
bool isComplete() const
Definition: SiPixelClusterShapeCache.h:35
funct::true
true
Definition: Factorize.h:173
SiPixelClusterShapeCache::Field::size
unsigned size
Definition: SiPixelClusterShapeCache.h:53
SiPixelClusterShapeCache::Field::has
unsigned has
Definition: SiPixelClusterShapeCache.h:56
SiPixelClusterShapeCache::~SiPixelClusterShapeCache
~SiPixelClusterShapeCache()
Definition: SiPixelClusterShapeCache.cc:6
SiPixelClusterShapeCache::productId_
edm::ProductID productId_
Definition: SiPixelClusterShapeCache.h:114
SiPixelClusterShapeData::const_iterator
std::vector< std::pair< int, int > >::const_iterator const_iterator
Definition: SiPixelClusterShapeCache.h:21
SiPixelClusterShapeData::isComplete_
const bool isComplete_
Definition: SiPixelClusterShapeCache.h:40
SiPixelClusterShapeCache::SiPixelClusterShapeCache
SiPixelClusterShapeCache()
Definition: SiPixelClusterShapeCache.h:60
SiPixelClusterShapeCache::shrink_to_fit
void shrink_to_fit()
Definition: SiPixelClusterShapeCache.h:77
SiPixelClusterShapeCache::checkRef
void checkRef(const ClusterRef &cluster) const
Definition: SiPixelClusterShapeCache.cc:8
Ref.h
SiPixelClusterShapeData::hasBigPixelsOnlyInside_
const bool hasBigPixelsOnlyInside_
Definition: SiPixelClusterShapeCache.h:40
SiPixelClusterShapeCache::swap
void swap(SiPixelClusterShapeCache &other)
Definition: SiPixelClusterShapeCache.h:70
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
T
long double T
Definition: Basic3DVectorLD.h:48
SiPixelClusterShapeCache::data_
std::vector< Field > data_
Definition: SiPixelClusterShapeCache.h:112
SiPixelClusterShapeCache::insert
void insert(const ClusterRef &cluster, const T &data)
Definition: SiPixelClusterShapeCache.h:83
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
SiPixelClusterShapeData::end_
const_iterator end_
Definition: SiPixelClusterShapeCache.h:39
SiPixelClusterShapeCache::isFilled
bool isFilled(const ClusterRef &cluster) const
Definition: SiPixelClusterShapeCache.h:92
SiPixelClusterShapeCache::Field::straight
unsigned straight
Definition: SiPixelClusterShapeCache.h:54
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
SiPixelClusterShapeCache::Field::Field
Field(unsigned off, unsigned siz, bool s, bool c, bool h)
Definition: SiPixelClusterShapeCache.h:50
SiPixelClusterShapeData
Definition: SiPixelClusterShapeCache.h:19
SiPixelClusterShapeData::SiPixelClusterShapeData
SiPixelClusterShapeData(const_iterator begin, const_iterator end, bool isStraight, bool isComplete, bool hasBigPixelsOnlyInside)
Definition: SiPixelClusterShapeCache.h:23
DetSetVectorNew.h
edm::ProductID
Definition: ProductID.h:27
SiPixelClusterShapeCache::Field::complete
unsigned complete
Definition: SiPixelClusterShapeCache.h:55
SiPixelClusterShapeCache::resize
void resize(size_t size)
Definition: SiPixelClusterShapeCache.h:65
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443