CMS 3D CMS Logo

HcalCondObjectContainerBase.cc
Go to the documentation of this file.
10 
11 HcalCondObjectContainerBase::HcalCondObjectContainerBase(const HcalTopology* topo) : packedIndexVersion_(0), topo_(topo) {
12  if (topo) packedIndexVersion_=topo->topoVersion();
13 }
14 
16  if ((topo) && (packedIndexVersion_ != 0) &&
18  edm::LogError("HCAL") << std::string("Inconsistent dense packing between current topology (") << topo->topoVersion() << ") and calibration object (" << packedIndexVersion_ << ")";
19  topo_=topo;
20 }
21 
22 unsigned int HcalCondObjectContainerBase::indexFor(DetId fId) const {
23  unsigned int retval=0xFFFFFFFFu;
24  if (!topo()) {
25  edm::LogError("HCAL") << "Topology pointer not set, HCAL conditions non-functional";
26  throw cms::Exception("Topology pointer not set, HCAL conditions non-functional");
27  return retval;
28  }
29 
30  if (fId.det()==DetId::Hcal) {
31  switch (HcalSubdetector(fId.subdetId())) {
32  case(HcalBarrel) : retval=topo()->detId2denseIdHB(fId); break;
33  case(HcalEndcap) : retval=topo()->detId2denseIdHE(fId); break;
34  case(HcalOuter) : retval=topo()->detId2denseIdHO(fId); break;
35  case(HcalForward) : retval=topo()->detId2denseIdHF(fId); break;
36  case(HcalTriggerTower) : retval=topo()->detId2denseIdHT(fId); break;
37  case(HcalOther) : if (extractOther(fId)==HcalCalibration)
38  retval=topo()->detId2denseIdCALIB(fId);
39  break;
40  default: break;
41  }
42  } else if (fId.det()==DetId::Calo) {
44  // the historical packing from HcalGeneric is different from HcalCastorDetId, so we clone the old packing here.
45  HcalCastorDetId tid(fId);
46  int zside = tid.zside();
47  int sector = tid.sector();
48  int module = tid.module();
49  static const int CASTORhalf=224;
50 
51  int index = 14*(sector-1) + (module-1);
52  if (zside == -1) index += CASTORhalf;
53 
54  retval=(unsigned int)(index);
55  } else if (fId.subdetId()==HcalZDCDetId::SubdetectorId) {
56  HcalZDCDetId direct(fId);
57  // THIS IS A HORRIBLE HACK because there were _two_ dense indices for ZDC differing in their handling of +/-z
58  HcalZDCDetId swapZ(direct.section(),direct.zside()<0,direct.channel());
59  retval=swapZ.denseIndex();
60  }
61  }
62  return retval;
63 }
64 
66  unsigned int retval=0;
67 
68  if (!topo()) {
69  edm::LogError("HCAL") << "Topology pointer not set, HCAL conditions non-functional";
70  throw cms::Exception("Topology pointer not set, HCAL conditions non-functional");
71  return retval;
72  }
73 
74  if (fId.det()==DetId::Hcal) {
75  switch (HcalSubdetector(fId.subdetId())) {
76  case(HcalBarrel) : retval=topo()->getHBSize(); break;
77  case(HcalEndcap) : retval=topo()->getHESize(); break;
78  case(HcalOuter) : retval=topo()->getHOSize(); break;
79  case(HcalForward) : retval=topo()->getHFSize(); break;
80  case(HcalTriggerTower) : retval=topo()->getHTSize(); break;
81  case(HcalOther) : if (extractOther(fId)==HcalCalibration) retval=topo()->getCALIBSize();
82  break;
83  default: break;
84  }
85  } else if (fId.det()==DetId::Calo) {
88  } else if (fId.subdetId()==HcalZDCDetId::SubdetectorId) {
90  }
91  }
92  return retval;
93 }
94 
96  std::ostringstream os;
97  os << std::hex << "(0x" << id.rawId() << ") " << std::dec;
98 
99  if (id.det()==DetId::Hcal) {
100  switch (HcalSubdetector(id.subdetId())) {
101  case(HcalBarrel) :
102  case(HcalEndcap) :
103  case(HcalOuter) :
104  case(HcalForward) : os << HcalDetId(id); break;
105  case(HcalTriggerTower) : os << HcalTrigTowerDetId(id); break;
106  case(HcalOther) :
107  if (extractOther(id)==HcalCalibration) os << HcalCalibDetId(id);
108  break;
109  default: break;
110  }
111  } else if (id.det()==DetId::Calo) {
112  if (id.subdetId()==HcalCastorDetId::SubdetectorId) {
113  os << HcalCastorDetId(id);
114  } else if (id.subdetId()==HcalZDCDetId::SubdetectorId) {
115  os << HcalZDCDetId(id);
116  }
117  }
118  return os.str();
119 }
unsigned int getCALIBSize() const
Definition: HcalTopology.h:137
unsigned int getHFSize() const
Definition: HcalTopology.h:135
unsigned int getHOSize() const
Definition: HcalTopology.h:134
HcalCondObjectContainerBase(HcalCondObjectContainerBase const &o)
int sector() const
get the sector (1-16)
unsigned int indexFor(DetId) const
unsigned int detId2denseIdHT(const DetId &id) const
return a linear packed id from HT
unsigned int detId2denseIdHF(const DetId &id) const
return a linear packed id from HF
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalZDCDetId.h:39
int module() const
get the module (1-2 for EM, 1-12 for HAD)
unsigned int detId2denseIdHB(const DetId &id) const
return a linear packed id from HB
HcalOtherSubdetector extractOther(const DetId &id) const
virtual int topoVersion() const
return a version which identifies the given topology
unsigned int sizeFor(DetId) const
unsigned int getHTSize() const
Definition: HcalTopology.h:136
HcalSubdetector
Definition: HcalAssistant.h:31
int zside() const
get the z-side of the cell (1/-1)
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
static const int SubdetectorId
Definition: DetId.h:18
static const int SubdetectorId
Definition: HcalZDCDetId.h:25
virtual bool denseIdConsistent(int topoVer) const
return whether this topology is consistent with the numbering in the given topology ...
int channel() const
get the channel
Definition: HcalZDCDetId.cc:62
unsigned int getHESize() const
Definition: HcalTopology.h:133
Section section() const
get the section
Definition: HcalZDCDetId.cc:47
std::string textForId(const DetId &id) const
unsigned int detId2denseIdHO(const DetId &id) const
return a linear packed id from HO
unsigned int detId2denseIdHE(const DetId &id) const
return a linear packed id from HE
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
unsigned int getHBSize() const
Definition: HcalTopology.h:132
Definition: vlib.h:208
unsigned int detId2denseIdCALIB(const DetId &id) const
return a linear packed id from CALIB
uint32_t denseIndex() const
Definition: HcalZDCDetId.cc:68
void setTopo(const HcalTopology *topo)
const HcalTopology * topo() const