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  void clear() {
24  eb_.clear();
25  ee_.clear();
26  }
27 
28  inline const Items & barrelItems() const { return eb_.items(); };
29 
30  inline const Items & endcapItems() const { return ee_.items(); };
31 
32  inline const Item & barrel( size_t hashedIndex ) const {
33  return eb_.item(hashedIndex);
34  }
35 
36  inline const Item & endcap( size_t hashedIndex ) const {
37  return ee_.item(hashedIndex);
38  }
39 
40  inline 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 const_iterator find( uint32_t rawId ) const {
60  DetId id(rawId);
61  switch (id.subdetId()) {
62  case EcalBarrel :
63  {
64  const_iterator it = eb_.find(rawId);
65  if ( it != eb_.end() ) {
66  return it;
67  } else {
68  return ee_.end();
69  }
70  }
71  break;
72  case EcalEndcap :
73  {
74  return ee_.find(rawId);
75  }
76  break;
77  default:
78  // FIXME (add throw)
79  return ee_.end();
80  }
81  return ee_.end();
82  }
83 
84  inline const_iterator begin() const {
85  return eb_.begin();
86  }
87 
88  inline const_iterator end() const {
89  return ee_.end();
90  }
91 
92  inline void setValue(const uint32_t id, const Item &item) {
93  (*this)[id] = item;
94  }
95 
96  inline const self & getMap() const {
97  return *this;
98  }
99 
100  inline size_t size() const {
101  return eb_.size() + ee_.size();
102  }
103  // add coherent operator++, not needed now -- FIXME
104 
105  inline Item & operator[]( uint32_t rawId )
106  {
107  DetId id(rawId);
108  return (id.subdetId()==EcalBarrel) ? eb_[rawId] : ee_[rawId];
109 
110  }
111 
112  inline Item operator[]( uint32_t rawId ) const {
113  DetId id(rawId);
114  switch (id.subdetId()) {
115  case EcalBarrel :
116  {
117  return eb_[rawId];
118  }
119  break;
120  case EcalEndcap :
121  {
122  return ee_[rawId];
123  }
124  break;
125  default:
126  // FIXME (add throw)
127  // sizeof(Item) <= sizeof(int64_t) for all Items.
128  return Item();
129  }
130  }
131 
132  void summary(float & arg_mean_x_EB,float & arg_rms_EB,int & arg_num_x_EB,
133  float & arg_mean_x_EE,float & arg_rms_EE,int & arg_num_x_EE) const {
134 
135  //std::stringstream ss;
136 
137  const int kSides = 2;
138  const int kBarlRings = EBDetId::MAX_IETA;
139  const int kBarlWedges = EBDetId::MAX_IPHI;
140  const int kEndcWedgesX = EEDetId::IX_MAX;
141  const int kEndcWedgesY = EEDetId::IY_MAX;
142 
144 
145  float mean_x_EB=0;
146  float mean_xx_EB=0;
147  int num_x_EB=0;
148 
149  float mean_x_EE=0;
150  float mean_xx_EE=0;
151  int num_x_EE=0;
152 
153 
154  for (int sign=0; sign<kSides; sign++) {
155 
156  int thesign = sign==1 ? 1:-1;
157 
158  for (int ieta=0; ieta<kBarlRings; ieta++) {
159  for (int iphi=0; iphi<kBarlWedges; iphi++) {
160  EBDetId id((ieta+1)*thesign, iphi+1);
161 
162  //float x= object()[id.rawId()];
163  float x= eb_[id.rawId()];
164  num_x_EB++;
165  mean_x_EB=mean_x_EB+x;
166  mean_xx_EB=mean_xx_EB+x*x;
167  }
168  }
169 
170  for (int ix=0; ix<kEndcWedgesX; ix++) {
171  for (int iy=0; iy<kEndcWedgesY; iy++) {
172  if (! EEDetId::validDetId(ix+1,iy+1,thesign))
173  continue;
174 
175  EEDetId id(ix+1,iy+1,thesign);
176  //float x=object()[id.rawId()];
177  float x=ee_[id.rawId()];
178  num_x_EE++;
179  mean_x_EE=mean_x_EE+x;
180  mean_xx_EE=mean_xx_EE+x*x;
181 
182  }//iy
183  }//ix
184 
185 
186  }
187 
188  mean_x_EB=mean_x_EB/num_x_EB;
189  mean_x_EE=mean_x_EE/num_x_EE;
190  mean_xx_EB=mean_xx_EB/num_x_EB;
191  mean_xx_EE=mean_xx_EE/num_x_EE;
192  float rms_EB=(mean_xx_EB-mean_x_EB*mean_x_EB);
193  float rms_EE=(mean_xx_EE-mean_x_EE*mean_x_EE);
194 
195 
196  arg_mean_x_EB = mean_x_EB;
197  arg_rms_EB = rms_EB;
198  arg_num_x_EB = num_x_EB;
199 
200 
201  arg_mean_x_EE = mean_x_EE;
202  arg_rms_EE = rms_EE;
203  arg_num_x_EE = num_x_EE;
204 
205  //ss << "ECAL BARREL Mean: "<< mean_x_EB <<" RMS: "<< rms_EB << " Nchan: "<< num_x_EB<< std::endl
206  // << "ECAL Endcap Mean: "<< mean_x_EE <<" RMS: "<< rms_EE << " Nchan: "<< num_x_EE<< std::endl ;
207 
208 
209  //return ss.str();
210  }
211 
212  private:
213 
216 
218 };
219 
221 #endif
const_iterator begin() const
Definition: EcalContainer.h:80
std::vector< Item >::iterator iterator
const Item & item(size_t hashid) const
Definition: EcalContainer.h:34
const self & getMap() const
const Items & items() const
Definition: EcalContainer.h:36
const_iterator end() const
Definition: EcalContainer.h:82
static const int kBarlRings
const Items & barrelItems() const
Item & operator[](uint32_t rawId)
Item operator[](uint32_t rawId) const
static const int kSides
static const int kBarlWedges
void setValue(const uint32_t id, const Item &item)
int hashedIndex(int ieta, int iphi)
Definition: EcalPyUtils.cc:42
static const int kEndcWedgesX
EcalContainer< EBDetId, Item > eb_
const_iterator find(uint32_t rawId) const
Definition: EcalContainer.h:73
const_iterator begin() const
void summary(float &arg_mean_x_EB, float &arg_rms_EB, int &arg_num_x_EB, float &arg_mean_x_EE, float &arg_rms_EE, int &arg_num_x_EE) const
void insert(std::pair< uint32_t, Item > const &a)
static const int IX_MAX
Definition: EEDetId.h:298
Definition: DetId.h:18
static const int MAX_IPHI
Definition: EBDetId.h:137
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
std::vector< Item >::const_iterator const_iterator
static const int MAX_IETA
Definition: EBDetId.h:136
#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_
static const int IY_MAX
Definition: EEDetId.h:302
const_iterator end() const
const Item & barrel(size_t hashedIndex) const
const Items & endcapItems() const
size_t size() const
Definition: EcalContainer.h:84
const Item & endcap(size_t hashedIndex) const
long double T
EcalCondObjectContainer< float > EcalFloatCondObjectContainer
static const int kEndcWedgesY