CMS 3D CMS Logo

MasterCollectionHelper.h
Go to the documentation of this file.
1 #ifndef CommonTools_UtilAlgos_MasterCollectionHelper_h
2 #define CommonTools_UtilAlgos_MasterCollectionHelper_h
3 /* \class helper::MasterCollection<C>
4  *
5  * differentiate index addressing in case of edm::View
6  * since a View retrieving a collection of reference
7  * would have referece indices (key()) pointing to the master
8  * collection different from reference position into the view
9  *
10  * \author Luca Lista, INFN
11  *
12  * \version $Id: MasterCollectionHelper.h,v 1.1 2009/03/03 13:07:26 llista Exp $
13  *
14  */
19 
20 namespace helper {
21  template <typename C1>
25  size_t size() const { return handle_->size(); }
26  size_t index(size_t i) const { return i; }
27  const edm::Handle<C1>& get() const { return handle_; }
28  ref_type getRef(size_t idx) const { return ref_type(get(), idx); }
29  template <typename R>
30  R getConcreteRef(size_t idx) const {
31  return getRef(idx);
32  }
33 
34  private:
36  };
37 
38  template <typename T>
39  struct MasterCollection<edm::View<T> > {
42  if (!handle_->empty()) {
43  ref_ = edm::makeRefToBaseProdFrom(handle_->refAt(0), event);
44  }
45  }
46  size_t size() const {
47  if (ref_.isNull())
48  return 0;
49  return ref_->size();
50  }
51  size_t index(size_t i) const { return handle_->refAt(i).key(); }
52  const edm::RefToBaseProd<T>& get() const { return ref_; }
53  ref_type getRef(size_t idx) const { return ref_type(get(), idx); }
54  template <typename R>
55  R getConcreteRef(size_t idx) const {
56  return getRef(idx).template castTo<R>();
57  }
58 
59  private:
62  };
63 
64 } // namespace helper
65 
66 #endif
Handle.h
mps_fire.i
i
Definition: mps_fire.py:428
helper::MasterCollection::get
const edm::Handle< C1 > & get() const
Definition: MasterCollectionHelper.h:27
helper::MasterCollection
Definition: MasterCollectionHelper.h:22
helper::MasterCollection::getRef
ref_type getRef(size_t idx) const
Definition: MasterCollectionHelper.h:28
sistrip::View
View
Definition: ConstantsForView.h:26
patZpeak.handle
handle
Definition: patZpeak.py:23
edm
HLT enums.
Definition: AlignableModifier.h:19
helper::MasterCollection< edm::View< T > >::getConcreteRef
R getConcreteRef(size_t idx) const
Definition: MasterCollectionHelper.h:55
helper::MasterCollection::MasterCollection
MasterCollection(const edm::Handle< C1 > &handle, edm::Event const &event)
Definition: MasterCollectionHelper.h:24
helper::MasterCollection< edm::View< T > >::MasterCollection
MasterCollection(const edm::Handle< edm::View< T > > &handle, edm::Event const &event)
Definition: MasterCollectionHelper.h:41
helper::MasterCollection< edm::View< T > >::ref_type
edm::RefToBase< T > ref_type
Definition: MasterCollectionHelper.h:40
helper::MasterCollection< edm::View< T > >::ref_
edm::RefToBaseProd< T > ref_
Definition: MasterCollectionHelper.h:61
edm::Handle< C1 >
edm::Ref
Definition: AssociativeIterator.h:58
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
helper::MasterCollection< edm::View< T > >::getRef
ref_type getRef(size_t idx) const
Definition: MasterCollectionHelper.h:53
helper::MasterCollection::size
size_t size() const
Definition: MasterCollectionHelper.h:25
RefToBaseProd.h
edm::View
Definition: CaloClusterFwd.h:14
edm::makeRefToBaseProdFrom
RefToBaseProd< T > makeRefToBaseProdFrom(RefToBase< T > const &iRef, Event const &iEvent)
Definition: makeRefToBaseProdFrom.h:34
helper::MasterCollection::handle_
edm::Handle< C1 > handle_
Definition: MasterCollectionHelper.h:35
edmPickEvents.event
event
Definition: edmPickEvents.py:273
helper
Definition: helper.py:1
helper::MasterCollection< edm::View< T > >::handle_
edm::Handle< edm::View< T > > handle_
Definition: MasterCollectionHelper.h:60
makeRefToBaseProdFrom.h
helper::MasterCollection::index
size_t index(size_t i) const
Definition: MasterCollectionHelper.h:26
helper::MasterCollection::ref_type
edm::Ref< C1 > ref_type
Definition: MasterCollectionHelper.h:23
helper::MasterCollection< edm::View< T > >::size
size_t size() const
Definition: MasterCollectionHelper.h:46
edm::RefToBase
Definition: AssociativeIterator.h:54
View.h
event
Definition: event.py:1
helper::MasterCollection< edm::View< T > >::get
const edm::RefToBaseProd< T > & get() const
Definition: MasterCollectionHelper.h:52
edm::Event
Definition: Event.h:73
dttmaxenums::R
Definition: DTTMax.h:29
helper::MasterCollection::getConcreteRef
R getConcreteRef(size_t idx) const
Definition: MasterCollectionHelper.h:30
helper::MasterCollection< edm::View< T > >::index
size_t index(size_t i) const
Definition: MasterCollectionHelper.h:51
edm::RefToBaseProd
Definition: RefToBase.h:65