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 }
22  if (topo && !topo->denseIdConsistent(packedIndexVersion_)) {
23  edm::LogError("HCAL") << "Inconsistent dense packing between current topology (" << topo->topoVersion() << ") and calibration object (" << packedIndexVersion_ << ")";
24  }
25  topo_=topo;
26 }
27 
28 unsigned int HcalCondObjectContainerBase::indexFor(DetId fId) const {
29  unsigned int retval=0xFFFFFFFFu;
30  if (!topo_) {
31  edm::LogError("HCAL") << "Topology pointer not set, HCAL conditions non-functional";
32  throw cms::Exception("Topology pointer not set, HCAL conditions non-functional");
33  return retval;
34  }
35 
36  if (fId.det()==DetId::Hcal) {
37  switch (HcalSubdetector(fId.subdetId())) {
38  case(HcalBarrel) : retval=topo_->detId2denseIdHB(fId); break;
39  case(HcalEndcap) : retval=topo_->detId2denseIdHE(fId); break;
40  case(HcalOuter) : retval=topo_->detId2denseIdHO(fId); break;
41  case(HcalForward) : retval=topo_->detId2denseIdHF(fId); break;
42  case(HcalTriggerTower) : retval=topo_->detId2denseIdHT(fId); break;
43  case(HcalOther) : if (extractOther(fId)==HcalCalibration)
44  retval=topo_->detId2denseIdCALIB(fId);
45  break;
46  default: break;
47  }
48  } else if (fId.det()==DetId::Calo) {
50  // the historical packing from HcalGeneric is different from HcalCastorDetId, so we clone the old packing here.
51  HcalCastorDetId tid(fId);
52  int zside = tid.zside();
53  int sector = tid.sector();
54  int module = tid.module();
55  static const int CASTORhalf=224;
56 
57  int index = 14*(sector-1) + (module-1);
58  if (zside == -1) index += CASTORhalf;
59 
60  retval=(unsigned int)(index);
61  } else if (fId.subdetId()==HcalZDCDetId::SubdetectorId) {
62  HcalZDCDetId direct(fId);
63  // THIS IS A HORRIBLE HACK because there were _two_ dense indices for ZDC differing in their handling of +/-z
64  HcalZDCDetId swapZ(direct.section(),direct.zside()<0,direct.channel());
65  retval=swapZ.denseIndex();
66  }
67  }
68  return retval;
69 }
70 
72  unsigned int retval=0;
73 
74  if (!topo_) {
75  edm::LogError("HCAL") << "Topology pointer not set, HCAL conditions non-functional";
76  throw cms::Exception("Topology pointer not set, HCAL conditions non-functional");
77  return retval;
78  }
79 
80  if (fId.det()==DetId::Hcal) {
81  switch (HcalSubdetector(fId.subdetId())) {
82  case(HcalBarrel) : retval=topo_->getHBSize(); break;
83  case(HcalEndcap) : retval=topo_->getHESize(); break;
84  case(HcalOuter) : retval=topo_->getHOSize(); break;
85  case(HcalForward) : retval=topo_->getHFSize(); break;
86  case(HcalTriggerTower) : retval=topo_->getHTSize(); break;
87  case(HcalOther) : if (extractOther(fId)==HcalCalibration) retval=topo_->getCALIBSize();
88  break;
89  default: break;
90  }
91  } else if (fId.det()==DetId::Calo) {
94  } else if (fId.subdetId()==HcalZDCDetId::SubdetectorId) {
96  }
97  }
98  return retval;
99 }
100 
102  std::ostringstream os;
103  os << std::hex << "(0x" << id.rawId() << ") " << std::dec;
104 
105  if (id.det()==DetId::Hcal) {
106  switch (HcalSubdetector(id.subdetId())) {
107  case(HcalBarrel) :
108  case(HcalEndcap) :
109  case(HcalOuter) :
110  case(HcalForward) : os << HcalDetId(id); break;
111  case(HcalTriggerTower) : os << HcalTrigTowerDetId(id); break;
112  case(HcalOther) :
113  if (extractOther(id)==HcalCalibration) os << HcalCalibDetId(id);
114  break;
115  default: break;
116  }
117  } else if (id.det()==DetId::Calo) {
118  if (id.subdetId()==HcalCastorDetId::SubdetectorId) {
119  os << HcalCastorDetId(id);
120  } else if (id.subdetId()==HcalZDCDetId::SubdetectorId) {
121  os << HcalZDCDetId(id);
122  }
123  }
124  return os.str();
125 }
int sector() const
get the sector (1-16)
unsigned int indexFor(DetId) const
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalZDCDetId.h:34
HcalCondObjectContainerBase(const HcalTopology *)
void setTopo(const HcalTopology *topo) const
int module() const
get the module (1-2 for EM, 1-12 for HAD)
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
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
std::string textForId(const DetId &id) const
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
Definition: vlib.h:208
uint32_t denseIndex() const
Definition: HcalZDCDetId.cc:33
const HcalTopology * topo() const