CMS 3D CMS Logo

HcalCondObjectContainer.h
Go to the documentation of this file.
1 #ifndef HcalCondObjectContainer_h
2 #define HcalCondObjectContainer_h
3 
6 
12 
13 #include <vector>
14 #include <string>
15 
16 class HcalTopology;
17 
18 //#define HCAL_COND_SUPPRESS_DEFAULT
19 
21 public:
22  const HcalTopology* topo() const { return topo_; }
24  void setTopo(const HcalTopology* topo);
25 
26 protected:
30  topo_ = o.topo();
31  packedIndexVersion_ = o.packedIndexVersion_;
32  return *this;
33  }
34 #ifndef __GCCXML__
37 #endif
38 
40  unsigned int indexFor(DetId) const;
41  unsigned int sizeFor(DetId) const;
43  inline HcalOtherSubdetector extractOther(const DetId& id) const {
44  return HcalOtherSubdetector((id.rawId() >> 20) & 0x1F);
45  }
46  std::string textForId(const DetId& id) const;
47 
48 private:
50 
52 };
53 
54 template <class Item>
56 public:
57  // default constructor
59 
60  // destructor:
61  virtual ~HcalCondObjectContainer();
62 
63  // get the object back
64  const Item* getValues(DetId fId, bool throwOnFail = true) const;
65 
66  // does the object exist ?
67  bool exists(DetId fId) const;
68 
69  // set the object/fill it in:
70  bool addValues(const Item& myItem);
71 
72  // list of available channels:
73  std::vector<DetId> getAllChannels() const;
74 
75  virtual std::string myname() const { return (std::string) "Hcal Undefined"; }
76 
77  // setting types for easier work for getAllContainers()
78  typedef std::pair<std::string, std::vector<Item> > tHcalCont;
79  typedef std::vector<tHcalCont> tAllContWithNames;
80 
82  tAllContWithNames allContainers;
83  allContainers.push_back(tHcalCont("HB", HBcontainer));
84  allContainers.push_back(tHcalCont("HE", HEcontainer));
85  allContainers.push_back(tHcalCont("HO", HOcontainer));
86  allContainers.push_back(tHcalCont("HF", HFcontainer));
87  allContainers.push_back(tHcalCont("HT", HTcontainer));
88  allContainers.push_back(tHcalCont("ZDC", ZDCcontainer));
89  allContainers.push_back(tHcalCont("CALIB", CALIBcontainer));
90  allContainers.push_back(tHcalCont("CASTOR", CASTORcontainer));
91  return allContainers;
92  }
93 
94 private:
95  void initContainer(DetId container);
96 
97  std::vector<Item> HBcontainer;
98  std::vector<Item> HEcontainer;
99  std::vector<Item> HOcontainer;
100  std::vector<Item> HFcontainer;
101  std::vector<Item> HTcontainer;
102  std::vector<Item> ZDCcontainer;
103  std::vector<Item> CALIBcontainer;
104  std::vector<Item> CASTORcontainer;
105 
107 };
108 
109 template <class Item>
111 
112 template <class Item>
114  Item emptyItem;
115 
116  if (fId.det() == DetId::Hcal) {
117  switch (HcalSubdetector(fId.subdetId())) {
118  case HcalBarrel:
119  for (unsigned int i = 0; i < sizeFor(fId); i++)
120  HBcontainer.push_back(emptyItem);
121  break;
122  case HcalEndcap:
123  for (unsigned int i = 0; i < sizeFor(fId); i++)
124  HEcontainer.push_back(emptyItem);
125  break;
126  case HcalOuter:
127  for (unsigned int i = 0; i < sizeFor(fId); i++)
128  HOcontainer.push_back(emptyItem);
129  break;
130  case HcalForward:
131  for (unsigned int i = 0; i < sizeFor(fId); i++)
132  HFcontainer.push_back(emptyItem);
133  break;
134  case HcalTriggerTower:
135  for (unsigned int i = 0; i < sizeFor(fId); i++)
136  HTcontainer.push_back(emptyItem);
137  break;
138  case HcalOther:
139  if (extractOther(fId) == HcalCalibration) {
140  for (unsigned int i = 0; i < sizeFor(fId); i++)
141  CALIBcontainer.push_back(emptyItem);
142  }
143  break;
144  default:
145  break;
146  }
147  } else if (fId.det() == DetId::Calo) {
149  for (unsigned int i = 0; i < sizeFor(fId); i++)
150  CASTORcontainer.push_back(emptyItem);
151  } else if (fId.subdetId() == HcalZDCDetId::SubdetectorId) {
152  for (unsigned int i = 0; i < sizeFor(fId); i++)
153  ZDCcontainer.push_back(emptyItem);
154  }
155  }
156 }
157 
158 template <class Item>
159 const Item* HcalCondObjectContainer<Item>::getValues(DetId fId, bool throwOnFail) const {
160  unsigned int index = indexFor(fId);
161 
162  const Item* cell = nullptr;
163 
164  if (index < 0xFFFFFFFu) {
165  if (fId.det() == DetId::Hcal) {
166  switch (HcalSubdetector(fId.subdetId())) {
167  case HcalBarrel:
168  if (index < HBcontainer.size())
169  cell = &(HBcontainer.at(index));
170  break;
171  case HcalEndcap:
172  if (index < HEcontainer.size())
173  cell = &(HEcontainer.at(index));
174  break;
175  case HcalForward:
176  if (index < HFcontainer.size())
177  cell = &(HFcontainer.at(index));
178  break;
179  case HcalOuter:
180  if (index < HOcontainer.size())
181  cell = &(HOcontainer.at(index));
182  break;
183  case HcalTriggerTower:
184  if (index < HTcontainer.size())
185  cell = &(HTcontainer.at(index));
186  break;
187  case HcalOther:
188  if (extractOther(fId) == HcalCalibration && index < CALIBcontainer.size())
189  cell = &(CALIBcontainer.at(index));
190  break;
191  default:
192  break;
193  }
194  } else if (fId.det() == DetId::Calo) {
196  if (index < CASTORcontainer.size())
197  cell = &(CASTORcontainer.at(index));
198  } else if (fId.subdetId() == HcalZDCDetId::SubdetectorId) {
199  if (index < ZDCcontainer.size())
200  cell = &(ZDCcontainer.at(index));
201  }
202  }
203  }
204 
205  if ((!cell)) {
206  if (throwOnFail) {
207  throw cms::Exception("Conditions not found")
208  << "Unavailable Conditions of type " << myname() << " for cell " << textForId(fId);
209  }
210  } else if (!hcalEqualDetId(cell, fId)) {
211  if (throwOnFail) {
212  throw cms::Exception("Conditions mismatch")
213  << "Requested conditions of type " << myname() << " for cell " << textForId(fId)
214  << " got conditions for cell " << textForId(DetId(cell->rawId()));
215  }
216  cell = nullptr;
217  }
218 
219  return cell;
220 }
221 
222 template <class Item>
224  const Item* cell = getValues(fId, false);
225 
226  if (cell) {
227  if (hcalEqualDetId(cell, fId))
228  return true;
229  }
230  return false;
231 }
232 
233 template <class Item>
235  bool success = false;
236  DetId fId(myItem.rawId());
237  unsigned int index = indexFor(fId);
238 
239  Item* cell = nullptr;
240 
241  if (index < 0xFFFFFFFu) {
242  if (fId.det() == DetId::Hcal) {
243  switch (HcalSubdetector(fId.subdetId())) {
244  case HcalBarrel:
245  if (HBcontainer.empty())
246  initContainer(fId);
247  if (index < HBcontainer.size())
248  cell = &(HBcontainer.at(index));
249  break;
250  case HcalEndcap:
251  if (HEcontainer.empty())
252  initContainer(fId);
253  if (index < HEcontainer.size())
254  cell = &(HEcontainer.at(index));
255  break;
256  case HcalForward:
257  if (HFcontainer.empty())
258  initContainer(fId);
259  if (index < HFcontainer.size())
260  cell = &(HFcontainer.at(index));
261  break;
262  case HcalOuter:
263  if (HOcontainer.empty())
264  initContainer(fId);
265  if (index < HOcontainer.size())
266  cell = &(HOcontainer.at(index));
267  break;
268  case HcalTriggerTower:
269  if (HTcontainer.empty())
270  initContainer(fId);
271  if (index < HTcontainer.size())
272  cell = &(HTcontainer.at(index));
273  break;
274  case HcalOther:
275  if (extractOther(fId) == HcalCalibration) {
276  if (CALIBcontainer.empty())
277  initContainer(fId);
278  if (index < CALIBcontainer.size())
279  cell = &(CALIBcontainer.at(index));
280  }
281  break;
282  default:
283  break;
284  }
285  } else if (fId.det() == DetId::Calo) {
286  if (fId.subdetId() == HcalCastorDetId::SubdetectorId) {
287  if (CASTORcontainer.empty())
288  initContainer(fId);
289  if (index < CASTORcontainer.size())
290  cell = &(CASTORcontainer.at(index));
291  } else if (fId.subdetId() == HcalZDCDetId::SubdetectorId) {
292  if (ZDCcontainer.empty())
293  initContainer(fId);
294  if (index < ZDCcontainer.size())
295  cell = &(ZDCcontainer.at(index));
296  }
297  }
298  }
299 
300  if (cell != nullptr) {
301  (*cell) = myItem;
302  success = true;
303  }
304 
305  if (!success)
306  throw cms::Exception("Filling of conditions failed")
307  << " no valid filling possible for Conditions of type " << myname() << " for DetId " << textForId(fId);
308  return success;
309 }
310 
311 template <class Item>
313  std::vector<DetId> channels;
314  Item emptyItem;
315  for (unsigned int i = 0; i < HBcontainer.size(); i++) {
316  if (emptyItem.rawId() != HBcontainer.at(i).rawId())
317  channels.push_back(DetId(HBcontainer.at(i).rawId()));
318  }
319  for (unsigned int i = 0; i < HEcontainer.size(); i++) {
320  if (emptyItem.rawId() != HEcontainer.at(i).rawId())
321  channels.push_back(DetId(HEcontainer.at(i).rawId()));
322  }
323  for (unsigned int i = 0; i < HOcontainer.size(); i++) {
324  if (emptyItem.rawId() != HOcontainer.at(i).rawId())
325  channels.push_back(DetId(HOcontainer.at(i).rawId()));
326  }
327  for (unsigned int i = 0; i < HFcontainer.size(); i++) {
328  if (emptyItem.rawId() != HFcontainer.at(i).rawId())
329  channels.push_back(DetId(HFcontainer.at(i).rawId()));
330  }
331  for (unsigned int i = 0; i < HTcontainer.size(); i++) {
332  if (emptyItem.rawId() != HTcontainer.at(i).rawId())
333  channels.push_back(DetId(HTcontainer.at(i).rawId()));
334  }
335  for (unsigned int i = 0; i < ZDCcontainer.size(); i++) {
336  if (emptyItem.rawId() != ZDCcontainer.at(i).rawId())
337  channels.push_back(DetId(ZDCcontainer.at(i).rawId()));
338  }
339  for (unsigned int i = 0; i < CALIBcontainer.size(); i++) {
340  if (emptyItem.rawId() != CALIBcontainer.at(i).rawId())
341  channels.push_back(DetId(CALIBcontainer.at(i).rawId()));
342  }
343  for (unsigned int i = 0; i < CASTORcontainer.size(); i++) {
344  if (emptyItem.rawId() != CASTORcontainer.at(i).rawId())
345  channels.push_back(DetId(CASTORcontainer.at(i).rawId()));
346  }
347 
348  return channels;
349 }
350 
351 #endif
HcalOther
Definition: HcalAssistant.h:38
HcalCondObjectContainerBase::HcalCondObjectContainerBase
HcalCondObjectContainerBase(HcalCondObjectContainerBase const &o)
Definition: HcalCondObjectContainer.h:27
HcalCondObjectContainer::CALIBcontainer
std::vector< Item > CALIBcontainer
Definition: HcalCondObjectContainer.h:103
mps_fire.i
i
Definition: mps_fire.py:428
HcalCondObjectContainer::tHcalCont
std::pair< std::string, std::vector< Item > > tHcalCont
Definition: HcalCondObjectContainer.h:78
HcalCondObjectContainerBase::setTopo
void setTopo(const HcalTopology *topo)
Definition: HcalCondObjectContainerBase.cc:17
HcalCondObjectContainer::~HcalCondObjectContainer
virtual ~HcalCondObjectContainer()
Definition: HcalCondObjectContainer.h:110
HcalCondObjectContainer::HEcontainer
std::vector< Item > HEcontainer
Definition: HcalCondObjectContainer.h:98
DetId::det
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
HcalCondObjectContainer::tAllContWithNames
std::vector< tHcalCont > tAllContWithNames
Definition: HcalCondObjectContainer.h:79
HcalTopology
Definition: HcalTopology.h:26
DetId::Hcal
Definition: DetId.h:28
COND_SERIALIZABLE
#define COND_SERIALIZABLE
Definition: Serializable.h:39
COND_TRANSIENT
#define COND_TRANSIENT
Definition: Serializable.h:63
HcalCastorDetId::SubdetectorId
static const int SubdetectorId
Definition: HcalCastorDetId.h:28
HcalCondObjectContainerBase::getCreatorPackedIndexVersion
int getCreatorPackedIndexVersion() const
Definition: HcalCondObjectContainer.h:23
HcalBarrel
Definition: HcalAssistant.h:33
HcalZDCDetId.h
HcalCondObjectContainerBase::packedIndexVersion_
int packedIndexVersion_
Definition: HcalCondObjectContainer.h:42
HcalCondObjectContainer::HBcontainer
std::vector< Item > HBcontainer
Definition: HcalCondObjectContainer.h:97
DetId::Calo
Definition: DetId.h:29
HcalCondObjectContainerBase::textForId
std::string textForId(const DetId &id) const
Definition: HcalCondObjectContainerBase.cc:123
HcalCondObjectContainer::getValues
const Item * getValues(DetId fId, bool throwOnFail=true) const
Definition: HcalCondObjectContainer.h:159
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:42
HcalCondObjectContainer::CASTORcontainer
std::vector< Item > CASTORcontainer
Definition: HcalCondObjectContainer.h:104
HcalCondObjectContainer
Definition: HcalCondObjectContainer.h:55
DetId
Definition: DetId.h:17
HcalCondObjectContainerBase::topo_
const HcalTopology * topo_
Definition: HcalCondObjectContainer.h:49
HcalCondObjectContainerBase::operator=
HcalCondObjectContainerBase & operator=(HcalCondObjectContainerBase const &o)
Definition: HcalCondObjectContainer.h:29
summarizeEdmComparisonLogfiles.success
success
Definition: summarizeEdmComparisonLogfiles.py:114
HcalOuter
Definition: HcalAssistant.h:35
HcalCalibration
Definition: HcalAssistant.h:40
HcalZDCDetId::SubdetectorId
static const int SubdetectorId
Definition: HcalZDCDetId.h:25
HcalCondObjectContainer::exists
bool exists(DetId fId) const
Definition: HcalCondObjectContainer.h:223
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
HcalCondObjectContainerBase
Definition: HcalCondObjectContainer.h:20
HcalCondObjectContainer::ZDCcontainer
std::vector< Item > ZDCcontainer
Definition: HcalCondObjectContainer.h:102
HcalCondObjectContainerBase::sizeFor
unsigned int sizeFor(DetId) const
Definition: HcalCondObjectContainerBase.cc:80
HcalOtherSubdetector
HcalOtherSubdetector
Definition: HcalAssistant.h:40
HcalDetId.h
HcalCondObjectContainer::getAllChannels
std::vector< DetId > getAllChannels() const
Definition: HcalCondObjectContainer.h:312
HcalCondObjectContainerBase::topo
const HcalTopology * topo() const
Definition: HcalCondObjectContainer.h:22
Serializable.h
HcalCondObjectContainerBase::indexFor
unsigned int indexFor(DetId) const
Definition: HcalCondObjectContainerBase.cc:24
HcalCondObjectContainer::HcalCondObjectContainer
HcalCondObjectContainer(const HcalTopology *topo)
Definition: HcalCondObjectContainer.h:58
HcalOtherDetId.h
HcalCondObjectContainer::getAllContainers
const tAllContWithNames getAllContainers() const
Definition: HcalCondObjectContainer.h:81
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HcalDetIdRelationship.h
HcalSubdetector
HcalSubdetector
Definition: HcalAssistant.h:31
HcalForward
Definition: HcalAssistant.h:36
HcalCondObjectContainer::HTcontainer
std::vector< Item > HTcontainer
Definition: HcalCondObjectContainer.h:101
hcalEqualDetId
bool hcalEqualDetId(Item *cell, const DetId &fId)
Definition: HcalDetIdRelationship.h:11
HcalCondObjectContainer::HOcontainer
std::vector< Item > HOcontainer
Definition: HcalCondObjectContainer.h:99
HcalEndcap
Definition: HcalAssistant.h:34
HcalCondObjectContainer::HFcontainer
std::vector< Item > HFcontainer
Definition: HcalCondObjectContainer.h:100
Exception
Definition: hltDiff.cc:245
ewkTauDQM_cfi.channels
channels
Definition: ewkTauDQM_cfi.py:14
HcalTriggerTower
Definition: HcalAssistant.h:37
Exception.h
HcalCondObjectContainer::initContainer
void initContainer(DetId container)
Definition: HcalCondObjectContainer.h:113
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
HcalCondObjectContainer::addValues
bool addValues(const Item &myItem)
Definition: HcalCondObjectContainer.h:234
HcalCastorDetId.h
HcalCondObjectContainerBase::extractOther
HcalOtherSubdetector extractOther(const DetId &id) const
Definition: HcalCondObjectContainer.h:43
HcalCondObjectContainer::myname
virtual std::string myname() const
Definition: HcalCondObjectContainer.h:75