CMS 3D CMS Logo

HcalCondObjectContainerBase.cc
Go to the documentation of this file.
11 
13  : packedIndexVersion_(0), topo_(topo), kSizeForDenseIndexing_(HcalZDCDetId::kSizeForDenseIndexingRun1) {
14  if (topo) {
20  }
21 }
22 
24  if (topo) {
26  edm::LogError("HCAL") << std::string("Inconsistent dense packing between current topology (")
27  << topo->topoVersion() << ") and calibration object (" << packedIndexVersion_ << ")";
28  topo_ = topo;
32  } else {
33  edm::LogError("HCAL") << "Illegal call to HcalCondObjectContainerBase with a null pointer";
34  }
35 }
36 
38  unsigned int retval = 0xFFFFFFFFu;
39  if (!topo()) {
40  edm::LogError("HCAL") << "Topology pointer not set, HCAL conditions non-functional";
41  throw cms::Exception("Topology pointer not set, HCAL conditions non-functional");
42  return retval;
43  }
44 
45  if (fId.det() == DetId::Hcal) {
46  switch (HcalSubdetector(fId.subdetId())) {
47  case (HcalBarrel):
48  retval = topo()->detId2denseIdHB(fId);
49  break;
50  case (HcalEndcap):
51  retval = topo()->detId2denseIdHE(fId);
52  break;
53  case (HcalOuter):
54  retval = topo()->detId2denseIdHO(fId);
55  break;
56  case (HcalForward):
57  retval = topo()->detId2denseIdHF(fId);
58  break;
59  case (HcalTriggerTower):
60  retval = topo()->detId2denseIdHT(fId);
61  break;
62  case (HcalOther):
63  if (extractOther(fId) == HcalCalibration)
64  retval = topo()->detId2denseIdCALIB(fId);
65  break;
66  default:
67  break;
68  }
69  } else if (fId.det() == DetId::Calo) {
71  // the historical packing from HcalGeneric is different from HcalCastorDetId, so we clone the old packing here.
72  HcalCastorDetId tid(fId);
73  int zside = tid.zside();
74  int sector = tid.sector();
75  int module = tid.module();
76  static const int CASTORhalf = 224;
77 
78  int index = 14 * (sector - 1) + (module - 1);
79  if (zside == -1)
80  index += CASTORhalf;
81 
82  retval = (unsigned int)(index);
83  } else if (fId.subdetId() == HcalZDCDetId::SubdetectorId) {
84  HcalZDCDetId direct(fId);
85  // THIS IS A HORRIBLE HACK because there were _two_ dense indices for ZDC differing in their handling of +/-z
86  HcalZDCDetId swapZ(direct.section(), direct.zside() < 0, direct.channel());
87  retval = swapZ.denseIndex();
88  }
89  }
90  return retval;
91 }
92 
94  unsigned int retval = 0;
95 
96  if (!topo()) {
97  edm::LogError("HCAL") << "Topology pointer not set, HCAL conditions non-functional";
98  throw cms::Exception("Topology pointer not set, HCAL conditions non-functional");
99  return retval;
100  }
101 
102  if (fId.det() == DetId::Hcal) {
103  switch (HcalSubdetector(fId.subdetId())) {
104  case (HcalBarrel):
105  retval = topo()->getHBSize();
106  break;
107  case (HcalEndcap):
108  retval = topo()->getHESize();
109  break;
110  case (HcalOuter):
111  retval = topo()->getHOSize();
112  break;
113  case (HcalForward):
114  retval = topo()->getHFSize();
115  break;
116  case (HcalTriggerTower):
117  retval = topo()->getHTSize();
118  break;
119  case (HcalOther):
120  if (extractOther(fId) == HcalCalibration)
121  retval = topo()->getCALIBSize();
122  break;
123  default:
124  break;
125  }
126  } else if (fId.det() == DetId::Calo) {
129  } else if (fId.subdetId() == HcalZDCDetId::SubdetectorId) {
130  retval = kSizeForDenseIndexing_;
131  }
132  }
133  return retval;
134 }
135 
137  std::ostringstream os;
138  os << std::hex << "(0x" << id.rawId() << ") " << std::dec;
139 
140  if (id.det() == DetId::Hcal) {
141  switch (HcalSubdetector(id.subdetId())) {
142  case (HcalBarrel):
143  case (HcalEndcap):
144  case (HcalOuter):
145  case (HcalForward):
146  os << HcalDetId(id);
147  break;
148  case (HcalTriggerTower):
149  os << HcalTrigTowerDetId(id);
150  break;
151  case (HcalOther):
152  if (extractOther(id) == HcalCalibration)
153  os << HcalCalibDetId(id);
154  break;
155  default:
156  break;
157  }
158  } else if (id.det() == DetId::Calo) {
159  if (id.subdetId() == HcalCastorDetId::SubdetectorId) {
160  os << HcalCastorDetId(id);
161  } else if (id.subdetId() == HcalZDCDetId::SubdetectorId) {
162  os << HcalZDCDetId(id);
163  }
164  }
165  return os.str();
166 }
HcalCondObjectContainerBase(HcalCondObjectContainerBase const &o)
int topoVersion() const override
return a version which identifies the given topology
unsigned int getHESize() const
Definition: HcalTopology.h:130
unsigned int detId2denseIdHF(const DetId &id) const
return a linear packed id from HF
constexpr uint32_t denseIndex() const
Definition: HcalZDCDetId.h:134
HcalOtherSubdetector extractOther(const DetId &id) const
unsigned int detId2denseIdHO(const DetId &id) const
return a linear packed id from HO
std::string textForId(const DetId &id) const
int zside(DetId const &)
unsigned int getHBSize() const
Definition: HcalTopology.h:129
Log< level::Error, false > LogError
static constexpr int32_t kSizeForDenseIndexingRun1
Definition: HcalZDCDetId.h:201
unsigned int getHOSize() const
Definition: HcalTopology.h:131
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
unsigned int detId2denseIdHE(const DetId &id) const
return a linear packed id from HE
unsigned int detId2denseIdCALIB(const DetId &id) const
return a linear packed id from CALIB
const HcalTopology * topo() const
virtual bool denseIdConsistent(int topoVer) const
return whether this topology is consistent with the numbering in the given topology ...
unsigned int detId2denseIdHB(const DetId &id) const
return a linear packed id from HB
int module() const
get the module (1-2 for EM, 1-12 for HAD)
int zside() const
get the z-side of the cell (1/-1)
HcalSubdetector
Definition: HcalAssistant.h:31
HcalTopologyMode::Mode mode() const
Definition: HcalTopology.h:30
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
unsigned int getHFSize() const
Definition: HcalTopology.h:132
unsigned int getHTSize() const
Definition: HcalTopology.h:133
int sector() const
get the sector (1-16)
static const int SubdetectorId
Definition: DetId.h:17
static constexpr int kSizeForDenseIndexing
constexpr Section section() const
get the section
Definition: HcalZDCDetId.h:92
unsigned int getCALIBSize() const
Definition: HcalTopology.h:134
static constexpr int32_t SubdetectorId
Definition: HcalZDCDetId.h:35
constexpr int32_t channel() const
get the channel
Definition: HcalZDCDetId.h:112
constexpr int32_t zside() const
get the z-side of the cell (1/-1)
Definition: HcalZDCDetId.h:90
unsigned int detId2denseIdHT(const DetId &id) const
return a linear packed id from HT
void setTopo(const HcalTopology *topo)
static constexpr int32_t kSizeForDenseIndexingRun3
Definition: HcalZDCDetId.h:202