CMS 3D CMS Logo

EcalCondTowerObjectContainer.h
Go to the documentation of this file.
1 #ifndef ECAL_CONDTOWER_OBJECT_CONTAINER_HH
2 #define ECAL_CONDTOWER_OBJECT_CONTAINER_HH
3 
5 
9 
10 
11 // #include <cstdio>
12 
13 template < typename T >
15  public:
16  typedef T Item;
17  typedef Item value_type;
19  typedef typename std::vector<Item> Items;
20  typedef typename std::vector<Item>::const_iterator const_iterator;
21  typedef typename std::vector<Item>::iterator iterator;
22 
24  size_t ebsize=(size_t)EcalTrigTowerDetId::kEBTowersPerSM*18*2;
25  eb_.checkAndResize(ebsize);
26  size_t eesize=(size_t)632;
27  ee_.checkAndResize(eesize);
28  };
30 
31  inline
32  const Items & barrelItems() const { return eb_.items(); };
33 
34  inline
35  const Items & endcapItems() const { return ee_.items(); };
36 
37  inline
38  const Item & barrel( size_t hashedIndex ) const {
39  return eb_.item(hashedIndex);
40  }
41 
42  inline
43  const Item & endcap( size_t hashedIndex ) const {
44  return ee_.item(hashedIndex);
45  }
46 
47  inline void insert( std::pair<uint32_t, Item> const &a ) {
48  DetId id(a.first);
49  if( id.subdetId() == EcalBarrel || id.subdetId() == EcalTriggerTower ) {
50  eb_.insert(a);
51  } else if( id.subdetId() == EcalEndcap ) {
52  ee_.insert(a);
53  } else {
54 // std::cout <<"*** ERROR it is not barrel nor endcap tower"<< std::endl;
55  }
56  }
57 
58  inline
59  const_iterator find( uint32_t rawId ) const {
60  DetId id(rawId);
61  if( id.subdetId() == EcalBarrel || id.subdetId() == EcalTriggerTower ) {
62  const_iterator it = eb_.find(rawId);
63  if ( it != eb_.end() ) {
64  return it;
65  } else {
66  return ee_.end();
67  }
68  } else if( id.subdetId() == EcalEndcap ) {
69  return ee_.find(rawId);
70  } else {
71  return ee_.end();
72  }
73  }
74 
75  inline
76  const_iterator begin() const {
77  return eb_.begin();
78  }
79 
80  inline
81  const_iterator end() const {
82  return ee_.end();
83  }
84 
85  inline
86  void setValue(const uint32_t id, const Item &item) {
87  (*this)[id] = item;
88  }
89 
90  inline
91  const self & getMap() const {
92  return *this;
93  }
94 
95  inline
96  size_t size() const {
97  return eb_.size() + ee_.size();
98  }
99  // add coherent operator++, not needed now -- FIXME
100 
101  inline
102  Item & operator[]( uint32_t rawId )
103  {
104  DetId id(rawId);
105  return ( (id.subdetId() == EcalBarrel) | (id.subdetId() == EcalTriggerTower) ) ?
106  eb_[rawId] :
107  ee_[rawId];
108  }
109 
110  inline
111  Item operator[]( uint32_t rawId ) const {
112  DetId id(rawId);
113 
114  if( id.subdetId() == EcalBarrel || id.subdetId() == EcalTriggerTower ) {
115  return eb_[rawId];
116  } else if( id.subdetId() == EcalEndcap ) {
117  return ee_[rawId];
118  } else {
119  return Item();
120  }
121  }
122 
123  private:
126 
128 };
129 
131 #endif
const_iterator begin() const
Definition: EcalContainer.h:85
void insert(std::pair< uint32_t, Item > const &a)
const Item & endcap(size_t hashedIndex) const
const Item & item(size_t hashid) const
Definition: EcalContainer.h:36
const Items & items() const
Definition: EcalContainer.h:40
const_iterator end() const
Definition: EcalContainer.h:89
Item operator[](uint32_t rawId) const
EcalContainer< EcalTrigTowerDetId, Item > eb_
void setValue(const uint32_t id, const Item &item)
const_iterator find(uint32_t rawId) const
EcalCondTowerObjectContainer< float > EcalTowerFloatCondObjectContainer
int hashedIndex(int ieta, int iphi)
Definition: EcalPyUtils.cc:42
const_iterator find(uint32_t rawId) const
Definition: EcalContainer.h:79
EcalContainer< EcalScDetId, Item > ee_
Definition: DetId.h:18
void checkAndResize()
Definition: EcalContainer.h:53
#define COND_SERIALIZABLE
Definition: Serializable.h:38
const Item & barrel(size_t hashedIndex) const
void insert(std::pair< uint32_t, Item > const &a)
Definition: EcalContainer.h:32
double a
Definition: hdecay.h:121
std::vector< Item >::iterator iterator
std::vector< Item >::const_iterator const_iterator
size_t size() const
Definition: EcalContainer.h:93
static const int kEBTowersPerSM
long double T