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 #include <vector>
11 
12 template <typename T>
14 public:
15  typedef T Item;
16  typedef Item value_type;
18  typedef typename std::vector<Item> Items;
19  typedef typename std::vector<Item>::const_iterator const_iterator;
20  typedef typename std::vector<Item>::iterator iterator;
21 
24 
25  void clear() {
26  eb_.clear();
27  ee_.clear();
28  }
29 
30  inline const Items &barrelItems() const { return eb_.items(); };
31 
32  inline const Items &endcapItems() const { return ee_.items(); };
33 
34  inline const Item &barrel(size_t hashedIndex) const { return eb_.item(hashedIndex); }
35 
36  inline const Item &endcap(size_t hashedIndex) const { return ee_.item(hashedIndex); }
37 
38  inline void insert(std::pair<uint32_t, Item> const &a) {
39  DetId id(a.first);
40  switch (id.subdetId()) {
41  case EcalBarrel: {
42  eb_.insert(a);
43  } break;
44  case EcalEndcap: {
45  ee_.insert(a);
46  } break;
47  default:
48  // FIXME (add throw)
49  return;
50  }
51  }
52 
53  inline const_iterator find(uint32_t rawId) const {
54  DetId id(rawId);
55  switch (id.subdetId()) {
56  case EcalBarrel: {
57  const_iterator it = eb_.find(rawId);
58  if (it != eb_.end()) {
59  return it;
60  } else {
61  return ee_.end();
62  }
63  } break;
64  case EcalEndcap: {
65  return ee_.find(rawId);
66  } break;
67  default:
68  // FIXME (add throw)
69  return ee_.end();
70  }
71  return ee_.end();
72  }
73 
74  inline const_iterator begin() const { return eb_.begin(); }
75 
76  inline const_iterator end() const { return ee_.end(); }
77 
78  inline void setValue(const uint32_t id, const Item &item) { (*this)[id] = item; }
79 
80  inline const self &getMap() const { return *this; }
81 
82  inline size_t size() const { return eb_.size() + ee_.size(); }
83  // add coherent operator++, not needed now -- FIXME
84 
85  inline Item &operator[](uint32_t rawId) {
86  DetId id(rawId);
87  return (id.subdetId() == EcalBarrel) ? eb_[rawId] : ee_[rawId];
88  }
89 
90  inline Item operator[](uint32_t rawId) const {
91  DetId id(rawId);
92  switch (id.subdetId()) {
93  case EcalBarrel: {
94  return eb_[rawId];
95  } break;
96  case EcalEndcap: {
97  return ee_[rawId];
98  } break;
99  default:
100  // FIXME (add throw)
101  // sizeof(Item) <= sizeof(int64_t) for all Items.
102  return Item();
103  }
104  }
105 
106  void summary(float &arg_mean_x_EB,
107  float &arg_rms_EB,
108  int &arg_num_x_EB,
109  float &arg_mean_x_EE,
110  float &arg_rms_EE,
111  int &arg_num_x_EE) const {
112  //std::stringstream ss;
113 
114  const int kSides = 2;
115  const int kBarlRings = EBDetId::MAX_IETA;
116  const int kBarlWedges = EBDetId::MAX_IPHI;
117  const int kEndcWedgesX = EEDetId::IX_MAX;
118  const int kEndcWedgesY = EEDetId::IY_MAX;
119 
121 
122  float mean_x_EB = 0;
123  float mean_xx_EB = 0;
124  int num_x_EB = 0;
125 
126  float mean_x_EE = 0;
127  float mean_xx_EE = 0;
128  int num_x_EE = 0;
129 
130  for (int sign = 0; sign < kSides; sign++) {
131  int thesign = sign == 1 ? 1 : -1;
132 
133  for (int ieta = 0; ieta < kBarlRings; ieta++) {
134  for (int iphi = 0; iphi < kBarlWedges; iphi++) {
135  EBDetId id((ieta + 1) * thesign, iphi + 1);
136 
137  //float x= object()[id.rawId()];
138  float x = eb_[id.rawId()];
139  num_x_EB++;
140  mean_x_EB = mean_x_EB + x;
141  mean_xx_EB = mean_xx_EB + x * x;
142  }
143  }
144 
145  for (int ix = 0; ix < kEndcWedgesX; ix++) {
146  for (int iy = 0; iy < kEndcWedgesY; iy++) {
147  if (!EEDetId::validDetId(ix + 1, iy + 1, thesign))
148  continue;
149 
150  EEDetId id(ix + 1, iy + 1, thesign);
151  //float x=object()[id.rawId()];
152  float x = ee_[id.rawId()];
153  num_x_EE++;
154  mean_x_EE = mean_x_EE + x;
155  mean_xx_EE = mean_xx_EE + x * x;
156 
157  } //iy
158  } //ix
159  }
160 
161  mean_x_EB = mean_x_EB / num_x_EB;
162  mean_x_EE = mean_x_EE / num_x_EE;
163  mean_xx_EB = mean_xx_EB / num_x_EB;
164  mean_xx_EE = mean_xx_EE / num_x_EE;
165  float rms_EB = (mean_xx_EB - mean_x_EB * mean_x_EB);
166  float rms_EE = (mean_xx_EE - mean_x_EE * mean_x_EE);
167 
168  arg_mean_x_EB = mean_x_EB;
169  arg_rms_EB = rms_EB;
170  arg_num_x_EB = num_x_EB;
171 
172  arg_mean_x_EE = mean_x_EE;
173  arg_rms_EE = rms_EE;
174  arg_num_x_EE = num_x_EE;
175 
176  //ss << "ECAL BARREL Mean: "<< mean_x_EB <<" RMS: "<< rms_EB << " Nchan: "<< num_x_EB<< std::endl
177  // << "ECAL Endcap Mean: "<< mean_x_EE <<" RMS: "<< rms_EE << " Nchan: "<< num_x_EE<< std::endl ;
178 
179  //return ss.str();
180  }
181 
182 private:
185 
187 };
188 
190 #endif
EcalCondObjectContainer::getMap
const self & getMap() const
Definition: EcalCondObjectContainer.h:80
EcalTimeDependentCorrections::Values
Definition: EcalTimeDependentCorrections.h:16
EcalCondObjectContainer::end
const_iterator end() const
Definition: EcalCondObjectContainer.h:76
kBarlRings
static const int kBarlRings
Definition: EcalGeomPhiSymHelper.h:7
EcalContainer::end
const_iterator end() const
Definition: EcalContainer.h:82
EcalContainer::items
const Items & items() const
Definition: EcalContainer.h:36
EcalContainer::item
const Item & item(size_t hashid) const
Definition: EcalContainer.h:34
EcalCondObjectContainer::endcapItems
const Items & endcapItems() const
Definition: EcalCondObjectContainer.h:32
EcalCondObjectContainer::operator[]
Item & operator[](uint32_t rawId)
Definition: EcalCondObjectContainer.h:85
EcalContainer< EBDetId, Item >
EcalCondObjectContainer::ee_
EcalContainer< EEDetId, Item > ee_
Definition: EcalCondObjectContainer.h:184
EcalCondObjectContainer::iterator
std::vector< Item >::iterator iterator
Definition: EcalCondObjectContainer.h:20
EBDetId
Definition: EBDetId.h:17
EcalCondObjectContainer::summary
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
Definition: EcalCondObjectContainer.h:106
EBDetId.h
EEDetId.h
COND_SERIALIZABLE
#define COND_SERIALIZABLE
Definition: Serializable.h:39
Validation_hcalonly_cfi.sign
sign
Definition: Validation_hcalonly_cfi.py:32
DDAxes::x
EcalCondObjectContainer::size
size_t size() const
Definition: EcalCondObjectContainer.h:82
EcalCondObjectContainer::barrel
const Item & barrel(size_t hashedIndex) const
Definition: EcalCondObjectContainer.h:34
EcalCondObjectContainer::endcap
const Item & endcap(size_t hashedIndex) const
Definition: EcalCondObjectContainer.h:36
EcalCondObjectContainer
Definition: EcalCondObjectContainer.h:13
kEndcWedgesY
static const int kEndcWedgesY
Definition: EcalGeomPhiSymHelper.h:12
EcalBarrel
Definition: EcalSubdetector.h:10
EcalContainer.h
EcalCondObjectContainer::~EcalCondObjectContainer
~EcalCondObjectContainer()
Definition: EcalCondObjectContainer.h:23
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
EcalCondObjectContainer::begin
const_iterator begin() const
Definition: EcalCondObjectContainer.h:74
DetId
Definition: DetId.h:17
EcalCondObjectContainer::eb_
EcalContainer< EBDetId, Item > eb_
Definition: EcalCondObjectContainer.h:183
EcalCondObjectContainer::find
const_iterator find(uint32_t rawId) const
Definition: EcalCondObjectContainer.h:53
EBDetId::MAX_IPHI
static const int MAX_IPHI
Definition: EBDetId.h:137
EEDetId::IY_MAX
static const int IY_MAX
Definition: EEDetId.h:302
EcalCondObjectContainer::barrelItems
const Items & barrelItems() const
Definition: EcalCondObjectContainer.h:30
EEDetId
Definition: EEDetId.h:14
EcalEndcap
Definition: EcalSubdetector.h:10
EcalCondObjectContainer::value_type
Item value_type
Definition: EcalCondObjectContainer.h:16
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
EcalCondObjectContainer::setValue
void setValue(const uint32_t id, const Item &item)
Definition: EcalCondObjectContainer.h:78
a
double a
Definition: hdecay.h:119
EcalCondObjectContainer::Item
T Item
Definition: EcalCondObjectContainer.h:15
EcalContainer::clear
void clear()
Definition: EcalContainer.h:27
EEDetId::IX_MAX
static const int IX_MAX
Definition: EEDetId.h:298
Serializable.h
EcalContainer::find
const_iterator find(uint32_t rawId) const
Definition: EcalContainer.h:73
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
kSides
static const int kSides
Definition: EcalGeomPhiSymHelper.h:9
kEndcWedgesX
static const int kEndcWedgesX
Definition: EcalGeomPhiSymHelper.h:11
EcalCondObjectContainer::insert
void insert(std::pair< uint32_t, Item > const &a)
Definition: EcalCondObjectContainer.h:38
EcalCondObjectContainer::operator[]
Item operator[](uint32_t rawId) const
Definition: EcalCondObjectContainer.h:90
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
T
long double T
Definition: Basic3DVectorLD.h:48
EcalCondObjectContainer::Items
std::vector< Item > Items
Definition: EcalCondObjectContainer.h:18
EEDetId::validDetId
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
EcalCondObjectContainer::const_iterator
std::vector< Item >::const_iterator const_iterator
Definition: EcalCondObjectContainer.h:19
kBarlWedges
static const int kBarlWedges
Definition: EcalGeomPhiSymHelper.h:8
EcalContainer::insert
void insert(std::pair< uint32_t, Item > const &a)
Definition: EcalContainer.h:32
EcalCondObjectContainer::EcalCondObjectContainer
EcalCondObjectContainer()
Definition: EcalCondObjectContainer.h:22
EcalFloatCondObjectContainer
EcalCondObjectContainer< float > EcalFloatCondObjectContainer
Definition: EcalCondObjectContainer.h:189
EcalContainer::begin
const_iterator begin() const
Definition: EcalContainer.h:80
ecalpyutils::hashedIndex
int hashedIndex(int ieta, int iphi)
Definition: EcalPyUtils.cc:38
EcalContainer::size
size_t size() const
Definition: EcalContainer.h:84
EBDetId::MAX_IETA
static const int MAX_IETA
Definition: EBDetId.h:136
EcalCondObjectContainer::clear
void clear()
Definition: EcalCondObjectContainer.h:25