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 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
102  {
103  DetId id(rawId);
104 
105  if( id.subdetId() == EcalBarrel || id.subdetId() == EcalTriggerTower ) {
106  return eb_[rawId];
107  } else if( id.subdetId() == EcalEndcap ) {
108  return ee_[rawId];
109  } else {
110  thread_local static Item dummy;
111  return dummy;
112  }
113  }
114 #else
115  ;
116 #endif
117 
118  inline
119  Item operator[]( uint32_t rawId ) const {
120  DetId id(rawId);
121 
122  if( id.subdetId() == EcalBarrel || id.subdetId() == EcalTriggerTower ) {
123  return eb_[rawId];
124  } else if( id.subdetId() == EcalEndcap ) {
125  return ee_[rawId];
126  } else {
127  return Item();
128  }
129  }
130 
131  private:
134 };
135 
137 #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
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