CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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.2 2013/02/28 00:34:26 wmtan Exp $
13  *
14  */
18 
19 namespace helper {
20  template<typename C1>
24  handle_(handle) { }
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 { return getRef(idx); }
31  private:
33  };
34 
35  template<typename T>
36  struct MasterCollection<edm::View<T> > {
39  handle_(handle) {
40  if(handle_->size() != 0)
41  ref_ = edm::RefToBaseProd<T>(handle_->refAt(0));
42  }
43  size_t size() const {
44  if (ref_.isNull()) return 0;
45  return ref_->size();
46  }
47  size_t index(size_t i) const {
48  return handle_->refAt(i).key();
49  }
50  const edm::RefToBaseProd<T> & get() const { return ref_; }
51  ref_type getRef(size_t idx) const { return ref_type(get(), idx); }
52  template<typename R>
53  R getConcreteRef(size_t idx) const { return getRef(idx).template castTo<R>(); }
54  private:
57  };
58 
59 }
60 
61 #endif
62 
int i
Definition: DBlmapReader.cc:9
ref_type getRef(size_t idx) const
MasterCollection(const edm::Handle< edm::View< T > > &handle)
R getConcreteRef(size_t idx) const
size_t index(size_t i) const
tuple handle
Definition: patZpeak.py:22
MasterCollection(const edm::Handle< C1 > &handle)
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...