CMS 3D CMS Logo

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