CMS 3D CMS Logo

EcalCondObjectContainer.h
Go to the documentation of this file.
1 #ifndef ECAL_COND_OBJECT_CONTAINER_HH
2 #define ECAL_COND_OBJECT_CONTAINER_HH
3 
5 
9 
10 template < typename T >
12  public:
13  typedef T Item;
14  typedef Item value_type;
16  typedef typename std::vector<Item> Items;
17  typedef typename std::vector<Item>::const_iterator const_iterator;
18  typedef typename std::vector<Item>::iterator iterator;
19 
22 
23  inline
24  const Items & barrelItems() const { return eb_.items(); };
25 
26  inline
27  const Items & endcapItems() const { return ee_.items(); };
28 
29  inline
30  const Item & barrel( size_t hashedIndex ) const {
31  return eb_.item(hashedIndex);
32  }
33 
34  inline
35  const Item & endcap( size_t hashedIndex ) const {
36  return ee_.item(hashedIndex);
37  }
38 
39  inline
40  void insert( std::pair<uint32_t, Item> const &a ) {
41  DetId id(a.first);
42  switch (id.subdetId()) {
43  case EcalBarrel :
44  {
45  eb_.insert(a);
46  }
47  break;
48  case EcalEndcap :
49  {
50  ee_.insert(a);
51  }
52  break;
53  default:
54  // FIXME (add throw)
55  return;
56  }
57  }
58 
59  inline
60  const_iterator find( uint32_t rawId ) const {
61  DetId id(rawId);
62  switch (id.subdetId()) {
63  case EcalBarrel :
64  {
65  const_iterator it = eb_.find(rawId);
66  if ( it != eb_.end() ) {
67  return it;
68  } else {
69  return ee_.end();
70  }
71  }
72  break;
73  case EcalEndcap :
74  {
75  return ee_.find(rawId);
76  }
77  break;
78  default:
79  // FIXME (add throw)
80  return ee_.end();
81  }
82  return ee_.end();
83  }
84 
85  inline
86  const_iterator begin() const {
87  return eb_.begin();
88  }
89 
90  inline
91  const_iterator end() const {
92  return ee_.end();
93  }
94 
95  inline
96  void setValue(const uint32_t id, const Item &item) {
97  (*this)[id] = item;
98  }
99 
100  inline
101  const self & getMap() const {
102  return *this;
103  }
104 
105  inline
106  size_t size() const {
107  return eb_.size() + ee_.size();
108  }
109  // add coherent operator++, not needed now -- FIXME
110 
111  inline
112  Item & operator[]( uint32_t rawId )
113  {
114  DetId id(rawId);
115  return (id.subdetId()==EcalBarrel) ? eb_[rawId] : ee_[rawId];
116 
117  }
118 
119  inline
120  Item operator[]( uint32_t rawId ) const {
121  DetId id(rawId);
122  switch (id.subdetId()) {
123  case EcalBarrel :
124  {
125  return eb_[rawId];
126  }
127  break;
128  case EcalEndcap :
129  {
130  return ee_[rawId];
131  }
132  break;
133  default:
134  // FIXME (add throw)
135  // sizeof(Item) <= sizeof(int64_t) for all Items.
136  return Item();
137  }
138  }
139 
140  private:
141 
144 
146 };
147 
149 #endif
const_iterator begin() const
Definition: EcalContainer.h:85
std::vector< Item >::iterator iterator
const Item & item(size_t hashid) const
Definition: EcalContainer.h:36
const self & getMap() const
const Items & items() const
Definition: EcalContainer.h:40
const_iterator end() const
Definition: EcalContainer.h:89
const Items & barrelItems() const
Item & operator[](uint32_t rawId)
Item operator[](uint32_t rawId) const
void setValue(const uint32_t id, const Item &item)
int hashedIndex(int ieta, int iphi)
Definition: EcalPyUtils.cc:42
EcalContainer< EBDetId, Item > eb_
const_iterator find(uint32_t rawId) const
Definition: EcalContainer.h:79
const_iterator begin() const
void insert(std::pair< uint32_t, Item > const &a)
Definition: DetId.h:18
std::vector< Item >::const_iterator const_iterator
#define COND_SERIALIZABLE
Definition: Serializable.h:38
void insert(std::pair< uint32_t, Item > const &a)
Definition: EcalContainer.h:32
double a
Definition: hdecay.h:121
const_iterator find(uint32_t rawId) const
EcalContainer< EEDetId, Item > ee_
const_iterator end() const
const Item & barrel(size_t hashedIndex) const
const Items & endcapItems() const
size_t size() const
Definition: EcalContainer.h:93
const Item & endcap(size_t hashedIndex) const
long double T
EcalCondObjectContainer< float > EcalFloatCondObjectContainer