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