CMS 3D CMS Logo

DetSet.h
Go to the documentation of this file.
1 #ifndef DataFormats_Common_DetSet_h
2 #define DataFormats_Common_DetSet_h
3 
4 /*----------------------------------------------------------------------
5 
6 DetSet: A struct which combines a collection of homogeneous objects
7 associated with a common DetId with a DetId instance, holding the
8 common DetId value. The collected objects may or may not contain their
9 own copy of the common DetId.
10 
11 
12 ----------------------------------------------------------------------*/
13 
14 #include <vector>
15 #include <cstdint>
16 #include <cstddef>
18 
19 namespace edm {
20  typedef uint32_t det_id_type;
21 
22  template <class T>
23  struct DetSet {
24  typedef std::vector<T> collection_type;
25  // We don't just use T as value-type, in case we switch to a
26  // fancier underlying container.
29  typedef typename collection_type::const_reference const_reference;
30  typedef typename collection_type::iterator iterator;
31  typedef typename collection_type::const_iterator const_iterator;
33 
35  DetSet() : id(0), data() {}
37  explicit DetSet(det_id_type i) : id(i), data() {}
38 
39 #if defined(__GXX_EXPERIMENTAL_CXX0X__)
40  DetSet(DetSet<T> const& rh) : id(rh.id), data(rh.data) {}
41 
42  DetSet<T>& operator=(DetSet<T> const& rh) {
43  id = rh.id;
44  data = rh.data;
45  return *this;
46  }
47 
48  DetSet(DetSet<T>&& rh) noexcept : id(rh.id), data(std::move(rh.data)) {}
49 
50  DetSet<T>& operator=(DetSet<T>&& rh) noexcept {
51  id = rh.id;
52  data = std::move(rh.data);
53  return *this;
54  }
55 #endif
56 
57  iterator begin() { return data.begin(); }
58  iterator end() { return data.end(); }
59  const_iterator begin() const { return data.begin(); }
60  const_iterator end() const { return data.end(); }
61  size_type size() const { return data.size(); }
62  bool empty() const { return data.empty(); }
65  void reserve(size_t s) { data.reserve(s); }
66  void push_back(const T& t) { data.push_back(t); }
67  template <class... Args>
68  decltype(auto) emplace_back(Args&&... args) {
69  return data.emplace_back(std::forward<Args>(args)...);
70  }
71  void clear() { data.clear(); }
72  void swap(DetSet<T>& other) noexcept;
73 
74  det_id_type detId() const { return id; }
75 
76  //Used by ROOT storage
78 
81  }; // template struct DetSet
82 
83  // TODO: If it turns out that it is confusing to have operator<
84  // defined for DetSet, because this op< ignores the data member
85  // 'data', we could instead specialize the std::less class template
86  // directly.
87 
88  template <class T>
89  inline bool operator<(DetSet<T> const& x, DetSet<T> const& y) {
90  return x.detId() < y.detId();
91  }
92 
93  template <class T>
94  inline bool operator<(DetSet<T> const& x, det_id_type y) {
95  return x.detId() < y;
96  }
97 
98  template <class T>
99  inline bool operator<(det_id_type x, DetSet<T> const& y) {
100  return x < y.detId();
101  }
102 
103  template <class T>
104  inline void DetSet<T>::swap(DetSet<T>& other) noexcept {
105  data.swap(other.data);
106  std::swap(id, other.id);
107  }
108 
109  template <class T>
110  inline void swap(DetSet<T>& a, DetSet<T>& b) {
111  a.swap(b);
112  }
113 
114 } // namespace edm
115 
116 #endif
edm::DetSet::push_back
void push_back(const T &t)
Definition: DetSet.h:66
writedatasetfile.args
args
Definition: writedatasetfile.py:18
edm::DetSet::begin
const_iterator begin() const
Definition: DetSet.h:59
mps_fire.i
i
Definition: mps_fire.py:428
edm::DetSet::size
size_type size() const
Definition: DetSet.h:61
edm::DetSet::value_type
collection_type::value_type value_type
Definition: DetSet.h:27
edm::DetSet
Definition: DetSet.h:23
edm::DetSet::clear
void clear()
Definition: DetSet.h:71
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::DetSet::id
det_id_type id
Definition: DetSet.h:79
edm::DetSet::begin
iterator begin()
Definition: DetSet.h:57
watchdog.const
const
Definition: watchdog.py:83
Utilities.operator
operator
Definition: Utilities.py:24
edm::DetSet::empty
bool empty() const
Definition: DetSet.h:62
edm::DetSet::end
const_iterator end() const
Definition: DetSet.h:60
edm::DetSet::collection_type
std::vector< T > collection_type
Definition: DetSet.h:24
edm::DetSet::operator[]
reference operator[](size_type i)
Definition: DetSet.h:63
alignCSCRings.s
s
Definition: alignCSCRings.py:92
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
edm::DetSet::const_reference
collection_type::const_reference const_reference
Definition: DetSet.h:29
edm::operator<
bool operator<(DetSet< T > const &x, DetSet< T > const &y)
Definition: DetSet.h:89
edm::DetSet::operator[]
const_reference operator[](size_type i) const
Definition: DetSet.h:64
trackingPlots.other
other
Definition: trackingPlots.py:1464
CMS_CLASS_VERSION
#define CMS_CLASS_VERSION(_version_)
Definition: CMS_CLASS_VERSION.h:30
b
double b
Definition: hdecay.h:118
edm::DetSet::size_type
collection_type::size_type size_type
Definition: DetSet.h:32
edm::DetSet::iterator
collection_type::iterator iterator
Definition: DetSet.h:30
a
double a
Definition: hdecay.h:119
edm::DetSet::emplace_back
decltype(auto) emplace_back(Args &&... args)
Definition: DetSet.h:68
edm::DetSet::reference
collection_type::reference reference
Definition: DetSet.h:28
RecoTauValidation_cfi.reference
reference
Definition: RecoTauValidation_cfi.py:233
edm::DetSet::detId
det_id_type detId() const
Definition: DetSet.h:74
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition: JetExtendedAssociation.h:30
svgfig.template
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
edm::DetSet::DetSet
DetSet(det_id_type i)
constructor by detector identifier
Definition: DetSet.h:37
edm::DetSet::reserve
void reserve(size_t s)
Definition: DetSet.h:65
eostools.move
def move(src, dest)
Definition: eostools.py:511
CMS_CLASS_VERSION.h
edm::DetSet::swap
void swap(DetSet< T > &other) noexcept
Definition: DetSet.h:104
edm::DetSet::DetSet
DetSet()
default constructor
Definition: DetSet.h:35
T
long double T
Definition: Basic3DVectorLD.h:48
edm::DetSet::data
collection_type data
Definition: DetSet.h:80
edm::det_id_type
uint32_t det_id_type
Definition: DetSet.h:20
edm::DetSet::end
iterator end()
Definition: DetSet.h:58
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
edm::DetSet::const_iterator
collection_type::const_iterator const_iterator
Definition: DetSet.h:31