CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 && !topo->denseIdConsistent(packedIndexVersion_)) {
17  edm::LogError("HCAL") << std::string("Inconsistent dense packing between current topology (") << topo->topoVersion() << ") and calibration object (" << packedIndexVersion_ << ")";
18  }
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:126
unsigned int getHFSize() const
Definition: HcalTopology.h:124
unsigned int getHOSize() const
Definition: HcalTopology.h:123
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:34
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
int zside(DetId const &)
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:125
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
Section section() const
get the section
Definition: HcalZDCDetId.h:36
Definition: DetId.h:18
static const int SubdetectorId
Definition: HcalZDCDetId.h:20
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.h:40
unsigned int getHESize() const
Definition: HcalTopology.h:122
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:121
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:33
void setTopo(const HcalTopology *topo)
const HcalTopology * topo() const