CMS 3D CMS Logo

FWItemRandomAccessor.h
Go to the documentation of this file.
1 #ifndef Fireworks_Core_FWItemRandomAccessor_h
2 #define Fireworks_Core_FWItemRandomAccessor_h
3 // -*- C++ -*-
4 //
5 // Package: Core
6 // Class : FWItemRandomAccessor
7 //
8 // Original Author: Giulio Eulisse
9 // Created: Thu Feb 18 15:19:44 EDT 2008
10 //
11 
12 // system include files
14 
15 // user include files
18 
19 // forward declarations
20 
29 public:
30  ~FWItemRandomAccessorBase() override;
31 
32  const void *data() const override;
33  const TClass *type() const override;
34  const TClass *modelType() const override;
35 
36  bool isCollection() const override;
37 
38  void setData(const edm::ObjectWithDict &) override;
39  void reset() override;
40 
41 protected:
42  void *getDataPtr() const;
43  FWItemRandomAccessorBase(const TClass *type, const std::type_info &modelTypeName);
44  const TClass *m_type;
45  const TClass *m_modelType;
46  mutable void *m_data;
47 
48 private:
49  FWItemRandomAccessorBase(const FWItemRandomAccessorBase &) = delete; // stop default
50 
51  const FWItemRandomAccessorBase &operator=(const FWItemRandomAccessorBase &) = delete; // stop default
52 };
53 
71 template <class C, class V = typename C::value_type>
73  typedef C container_type;
75 
76 public:
77  FWItemRandomAccessor(const TClass *iClass) : FWItemRandomAccessorBase(iClass, typeid(container_value_type)) {}
78 
80 
81  // ---------- const member functions ---------------------
82  const void *modelData(int iIndex) const override {
83  if (!getDataPtr())
84  return nullptr;
85  return &(reinterpret_cast<container_type *>(getDataPtr())->operator[](iIndex));
86  }
87 
88  unsigned int size() const override {
89  if (!getDataPtr())
90  return 0;
91  return reinterpret_cast<const container_type *>(getDataPtr())->size();
92  }
93 };
94 
102 template <class C, class COLL = typename C::value_type, class V = typename COLL::value_type>
104 public:
105  typedef C container_type;
106  typedef COLL collection_type;
108 
109  FWItemDetSetAccessor(const TClass *iClass) : FWItemRandomAccessorBase(iClass, typeid(collection_value_type)) {}
110 
112 
113  const void *modelData(int iIndex) const override {
114  if (!getDataPtr())
115  return nullptr;
116  const container_type *c = reinterpret_cast<const container_type *>(getDataPtr());
117  size_t collectionOffset = 0;
118  for (typename container_type::const_iterator ci = c->begin(), ce = c->end(); ci != ce; ++ci) {
119  size_t i = iIndex - collectionOffset;
120  if (i < ci->size())
121  return &(ci->operator[](i));
122  collectionOffset += ci->size();
123  }
124 
125  return nullptr;
126  }
127 
128  unsigned int size() const override {
129  if (!getDataPtr())
130  return 0;
131  const container_type *c = reinterpret_cast<const container_type *>(getDataPtr());
132  size_t finalSize = 0;
133 
134  for (typename container_type::const_iterator i = c->begin(), e = c->end(); i != e; ++i)
135  finalSize += i->size();
136 
137  return finalSize;
138  }
139 };
140 
143 template <class C, class COLL = typename C::value_type, class V = typename COLL::value_type>
145 public:
146  typedef C container_type;
147  typedef COLL collection_type;
149 
150  FWItemNewDetSetAccessor(const TClass *iClass) : FWItemRandomAccessorBase(iClass, typeid(collection_value_type)) {}
151 
153 
154  const void *modelData(int iIndex) const override {
155  if (!getDataPtr())
156  return nullptr;
157  const container_type *c = reinterpret_cast<const container_type *>(getDataPtr());
158  if (iIndex < 0)
159  return nullptr;
160 
161  return &(c->data().operator[](iIndex));
162  }
163 
164  unsigned int size() const override {
165  if (!getDataPtr())
166  return 0;
167  const container_type *c = reinterpret_cast<const container_type *>(getDataPtr());
168  return c->dataSize();
169  }
170 };
171 
172 template <class C, class R = typename C::Range, class V = typename R::value_type>
174 public:
175  typedef C container_type;
176  typedef R range_type;
177  typedef V value_type;
178 
179  FWItemRangeAccessor(const TClass *iClass) : FWItemRandomAccessorBase(iClass, typeid(value_type)) {}
180 
182 
183  const void *modelData(int iIndex) const override {
184  if (!getDataPtr())
185  return nullptr;
186  const container_type *c = reinterpret_cast<const container_type *>(getDataPtr());
187  size_t collectionOffset = 0;
188  for (typename container_type::const_iterator ci = c->begin(), ce = c->end(); ci != ce; ++ci) {
189  size_t i = iIndex - collectionOffset;
190  if (i < std::distance(ci->first, ci->second))
191  return &(*(ci + i));
192  collectionOffset += ci->size();
193  }
194 
195  return nullptr;
196  }
197 
198  unsigned int size() const override {
199  if (!getDataPtr())
200  return 0;
201  const container_type *c = reinterpret_cast<const container_type *>(getDataPtr());
202  size_t finalSize = 0;
203 
204  for (typename range_type::const_iterator ci = c->begin(), ce = c->end(); ci != ce; ++ci)
205  finalSize += std::distance(ci->first, ci->second);
206 
207  return finalSize;
208  }
209 };
210 
211 template <class C, class V>
213 public:
214  typedef C container_type;
215  typedef V value_type;
216 
217  FWItemMuonDigiAccessor(const TClass *iClass) : FWItemRandomAccessorBase(iClass, typeid(value_type)) {}
218 
220 
221  const void *modelData(int iIndex) const override {
222  if (!getDataPtr())
223  return nullptr;
224  const container_type *c = reinterpret_cast<const container_type *>(getDataPtr());
225  size_t collectionOffset = 0;
226 
227  for (typename container_type::DigiRangeIterator ci = c->begin(), ce = c->end(); ci != ce; ++ci) {
228  int i = iIndex - collectionOffset;
229 
231 
232  if (i < std::distance(vt.second.first, vt.second.second))
233  return &(*(vt.second.first + i));
234  collectionOffset += std::distance(vt.second.first, vt.second.second);
235  }
236 
237  return nullptr;
238  }
239 
240  unsigned int size() const override {
241  if (!getDataPtr())
242  return 0;
243  const container_type *c = reinterpret_cast<const container_type *>(getDataPtr());
244  size_t finalSize = 0;
245 
246  for (typename container_type::DigiRangeIterator ci = c->begin(), ce = c->end(); ci != ce; ++ci) {
248  finalSize += std::distance(vt.second.first, vt.second.second);
249  }
250 
251  return finalSize;
252  }
253 };
254 
255 template <class C>
257 public:
258  typedef C container_type;
259 
260  BXVectorAccessor(const TClass *iClass) : FWItemRandomAccessorBase(iClass, typeid(typename C::value_type)) {}
261 
263 
264  const void *modelData(int iIndex) const override {
265  if (!getDataPtr())
266  return nullptr;
267 
268  const container_type *c = reinterpret_cast<const container_type *>(getDataPtr());
269 
270  return &(c->at(0, iIndex));
271  }
272 
273  unsigned int size() const override {
274  if (!getDataPtr())
275  return 0;
276 
277  const container_type *c = reinterpret_cast<const container_type *>(getDataPtr());
278 
279  return c->size(0);
280  }
281 };
282 
283 #endif
FWItemRandomAccessorBase::~FWItemRandomAccessorBase
~FWItemRandomAccessorBase() override
Definition: FWItemRandomAccessor.cc:32
cms::cuda::V
cudaStream_t T uint32_t const T *__restrict__ const uint32_t *__restrict__ uint32_t int cudaStream_t V
Definition: HistoContainer.h:99
FWItemRandomAccessorBase::m_data
void * m_data
Definition: FWItemRandomAccessor.h:46
mps_fire.i
i
Definition: mps_fire.py:355
FWItemRangeAccessor::range_type
R range_type
Definition: FWItemRandomAccessor.h:176
BXVectorAccessor
Definition: FWItemRandomAccessor.h:256
FWItemDetSetAccessor
Definition: FWItemRandomAccessor.h:103
FWItemRandomAccessorBase::operator=
const FWItemRandomAccessorBase & operator=(const FWItemRandomAccessorBase &)=delete
FWItemDetSetAccessor::size
unsigned int size() const override
Definition: FWItemRandomAccessor.h:128
edm::ObjectWithDict
Definition: ObjectWithDict.h:17
FWItemRandomAccessor::container_value_type
V container_value_type
Definition: FWItemRandomAccessor.h:74
FWItemRandomAccessorBase::isCollection
bool isCollection() const override
Definition: FWItemRandomAccessor.cc:75
HLT_2018_cff.distance
distance
Definition: HLT_2018_cff.py:6417
FWItemRangeAccessor::size
unsigned int size() const override
Definition: FWItemRandomAccessor.h:198
FWItemRangeAccessor::container_type
C container_type
Definition: FWItemRandomAccessor.h:175
FWItemDetSetAccessor::modelData
const void * modelData(int iIndex) const override
Definition: FWItemRandomAccessor.h:113
FWItemMuonDigiAccessor::value_type
V value_type
Definition: FWItemRandomAccessor.h:215
ObjectWithDict.h
BXVectorAccessor::modelData
const void * modelData(int iIndex) const override
Definition: FWItemRandomAccessor.h:264
FWItemRandomAccessorBase
Definition: FWItemRandomAccessor.h:28
FWItemMuonDigiAccessor
Definition: FWItemRandomAccessor.h:212
FWItemRandomAccessorBase::data
const void * data() const override
Definition: FWItemRandomAccessor.cc:64
FWItemDetSetAccessor::collection_value_type
V collection_value_type
Definition: FWItemRandomAccessor.h:107
FWItemMuonDigiAccessor::container_type
C container_type
Definition: FWItemRandomAccessor.h:214
REGISTER_FWITEMACCESSOR_METHODS
#define REGISTER_FWITEMACCESSOR_METHODS()
Definition: register_itemaccessorbase_macro.h:27
BXVectorAccessor::size
unsigned int size() const override
Definition: FWItemRandomAccessor.h:273
FWItemRandomAccessorBase::getDataPtr
void * getDataPtr() const
Definition: FWItemRandomAccessor.cc:66
FWItemRandomAccessorBase::modelType
const TClass * modelType() const override
Definition: FWItemRandomAccessor.cc:70
FWItemDetSetAccessor::collection_type
COLL collection_type
Definition: FWItemRandomAccessor.h:106
FWItemRandomAccessor::size
unsigned int size() const override
Definition: FWItemRandomAccessor.h:88
FWItemAccessorBase.h
FWItemRandomAccessorBase::type
const TClass * type() const override
Definition: FWItemRandomAccessor.cc:68
FWItemRandomAccessor
Definition: FWItemRandomAccessor.h:72
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition: JetExtendedAssociation.h:30
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
FWItemRangeAccessor
Definition: FWItemRandomAccessor.h:173
FWItemNewDetSetAccessor::collection_value_type
V collection_value_type
Definition: FWItemRandomAccessor.h:148
FWItemMuonDigiAccessor::modelData
const void * modelData(int iIndex) const override
Definition: FWItemRandomAccessor.h:221
FWItemRandomAccessorBase::reset
void reset() override
Definition: FWItemRandomAccessor.cc:59
FWItemRandomAccessorBase::FWItemRandomAccessorBase
FWItemRandomAccessorBase(const TClass *type, const std::type_info &modelTypeName)
Definition: FWItemRandomAccessor.cc:24
FWItemRandomAccessor::container_type
C container_type
Definition: FWItemRandomAccessor.h:73
FWItemNewDetSetAccessor::collection_type
COLL collection_type
Definition: FWItemRandomAccessor.h:147
FWItemRandomAccessorBase::m_type
const TClass * m_type
Definition: FWItemRandomAccessor.h:44
FWItemMuonDigiAccessor::size
unsigned int size() const override
Definition: FWItemRandomAccessor.h:240
type
type
Definition: HCALResponse.h:21
FWItemDetSetAccessor::FWItemDetSetAccessor
FWItemDetSetAccessor(const TClass *iClass)
Definition: FWItemRandomAccessor.h:109
FWItemNewDetSetAccessor::FWItemNewDetSetAccessor
FWItemNewDetSetAccessor(const TClass *iClass)
Definition: FWItemRandomAccessor.h:150
gen::C
C
Definition: PomwigHadronizer.cc:76
FWItemRandomAccessorBase::setData
void setData(const edm::ObjectWithDict &) override
override if id of an object should be different than the index
Definition: FWItemRandomAccessor.cc:49
BXVectorAccessor::BXVectorAccessor
BXVectorAccessor(const TClass *iClass)
Definition: FWItemRandomAccessor.h:260
FWItemRangeAccessor::value_type
V value_type
Definition: FWItemRandomAccessor.h:177
FWItemRandomAccessor::FWItemRandomAccessor
FWItemRandomAccessor(const TClass *iClass)
Definition: FWItemRandomAccessor.h:77
FWItemAccessorBase
Definition: FWItemAccessorBase.h:33
FWItemRandomAccessor::modelData
const void * modelData(int iIndex) const override
Definition: FWItemRandomAccessor.h:82
FWItemNewDetSetAccessor
Definition: FWItemRandomAccessor.h:144
FWItemNewDetSetAccessor::size
unsigned int size() const override
Definition: FWItemRandomAccessor.h:164
FWItemDetSetAccessor::container_type
C container_type
Definition: FWItemRandomAccessor.h:105
FWItemAccessorRegistry.h
FWItemRangeAccessor::FWItemRangeAccessor
FWItemRangeAccessor(const TClass *iClass)
Definition: FWItemRandomAccessor.h:179
FWItemRangeAccessor::modelData
const void * modelData(int iIndex) const override
Definition: FWItemRandomAccessor.h:183
FWItemNewDetSetAccessor::container_type
C container_type
Definition: FWItemRandomAccessor.h:146
FWItemNewDetSetAccessor::modelData
const void * modelData(int iIndex) const override
Definition: FWItemRandomAccessor.h:154
dttmaxenums::R
Definition: DTTMax.h:29
FWItemRandomAccessorBase::m_modelType
const TClass * m_modelType
Definition: FWItemRandomAccessor.h:45
BXVectorAccessor::container_type
C container_type
Definition: FWItemRandomAccessor.h:258
FWItemMuonDigiAccessor::FWItemMuonDigiAccessor
FWItemMuonDigiAccessor(const TClass *iClass)
Definition: FWItemRandomAccessor.h:217
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37