CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DetSetNew.h
Go to the documentation of this file.
1 #ifndef DataFormats_Common_DetSetNew_h
2 #define DataFormats_Common_DetSetNew_h
3 
5 #include <vector>
6 #include <cassert>
7 
8 namespace edmNew {
9  // FIXME move it elsewhere....
10  typedef unsigned int det_id_type;
11 
12  template<typename T> class DetSetVector;
13 
14  /* a proxy to a variable size array of T belonging to
15  * a "channel" identified by an 32bit id
16  *
17  * FIXME interface to be finalized once use-cases fully identified
18  *
19  */
20  template<typename T>
21  class DetSet {
22  public:
24  typedef unsigned int size_type; // for persistency
25  typedef unsigned int id_type;
26  typedef T data_type;
27 
28  typedef std::vector<data_type> DataContainer;
29  typedef data_type * iterator;
30  typedef data_type const * const_iterator;
31 
33  typedef id_type key_type;
34 
35 
36  inline
37  DetSet() : m_id(0), m_data(0), m_offset(-1), m_size(0){}
38  inline
39  DetSet(id_type i, DataContainer const & idata, size_type ioffset, size_type isize) :
40  m_id(i), m_data(&idata), m_offset(ioffset), m_size(isize) {}
41 
42  inline
43  DetSet(Container const & icont,
44  typename Container::Item const & item, bool update) :
45  m_id(0), m_data(0), m_offset(-1), m_size(0){
46  set(icont,item, update);
47  }
48 
49  //FIXME (it may confuse users as size_type is same type as id_type...)
50  inline
51  void set(Container const & icont,
52  typename Container::Item const & item, bool update=true);
53 
54  bool isValid() const { return m_offset>=0;}
55 
56  inline
58  return data()[i];
59  }
60 
61  inline
63  return data()[i];
64  }
65 
66  inline
67  iterator begin() { return data();}
68 
69  inline
70  iterator end() { return data()+m_size;}
71 
72  inline
73  const_iterator begin() const { return data();}
74 
75  inline
76  const_iterator end() const { return data()+m_size;}
77 
78  int offset() const {return m_offset;}
79 
80  inline
81  id_type id() const { return m_id;}
82 
83  inline
84  id_type detId() const { return m_id;}
85 
86  inline
87  size_type size() const { return m_size; }
88 
89  inline
90  bool empty() const { return m_size==0;}
91 
92 
93  template<typename HandleT>
95  makeRefTo(HandleT const & handle, const_iterator ci) const {
97  }
98 
99 
100  private:
101 
102  DataContainer const & container() const { return *m_data; }
103 
104  data_type const * data() const {
106  return m_data ? (&((*m_data)[m_offset])) : 0;
107  }
108 
110  assert(m_data);
111  return const_cast<data_type *>(&((*m_data)[m_offset]));
112  }
113 
116  int m_offset;
118  };
119 }
120 
121 #endif // DataFormats_Common_DetSet_h
const_iterator begin() const
Definition: DetSetNew.h:73
int i
Definition: DBlmapReader.cc:9
int offset() const
Definition: DetSetNew.h:78
const_iterator end() const
Definition: DetSetNew.h:76
unsigned int det_id_type
Definition: DetSetNew.h:10
data_type operator[](size_type i) const
Definition: DetSetNew.h:62
void set(Container const &icont, typename Container::Item const &item, bool update=true)
assert(m_qm.get())
unsigned int id_type
Definition: DetSetNew.h:25
data_type value_type
Definition: DetSetNew.h:32
data_type const * const_iterator
Definition: DetSetNew.h:30
data_type * iterator
Definition: DetSetNew.h:29
id_type key_type
Definition: DetSetNew.h:33
std::vector< data_type > DataContainer
Definition: DetSetNew.h:28
size_type m_size
Definition: DetSetNew.h:117
DetSet(Container const &icont, typename Container::Item const &item, bool update)
Definition: DetSetNew.h:43
bool isValid() const
Definition: DetSetNew.h:54
bool empty() const
Definition: DetSetNew.h:90
tuple handle
Definition: patZpeak.py:22
DetSet(id_type i, DataContainer const &idata, size_type ioffset, size_type isize)
Definition: DetSetNew.h:39
DataContainer const & container() const
Definition: DetSetNew.h:102
DataContainer const * m_data
Definition: DetSetNew.h:115
data_type & operator[](size_type i)
Definition: DetSetNew.h:57
data_type * data()
Definition: DetSetNew.h:109
id_type detId() const
Definition: DetSetNew.h:84
id_type m_id
Definition: DetSetNew.h:114
DetSetVector< T > Container
Definition: DetSetNew.h:23
iterator end()
Definition: DetSetNew.h:70
#define update(a, b)
id_type id() const
Definition: DetSetNew.h:81
edm::Ref< typename HandleT::element_type, typename HandleT::element_type::value_type::value_type > makeRefTo(HandleT const &handle, const_iterator ci) const
Definition: DetSetNew.h:95
size_type size() const
Definition: DetSetNew.h:87
long double T
data_type const * data() const
Definition: DetSetNew.h:104
unsigned int size_type
Definition: DetSetNew.h:24
iterator begin()
Definition: DetSetNew.h:67