1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
#include "Geometry/CaloTopology/interface/HcalTopology.h"
#include "Geometry/HcalCommonData/interface/HcalTopologyMode.h"
#include "CondFormats/HcalObjects/interface/HcalCondObjectContainer.h"
#include "DataFormats/HcalDetId/interface/HcalCastorDetId.h"
#include "DataFormats/HcalDetId/interface/HcalCalibDetId.h"
#include "DataFormats/HcalDetId/interface/HcalZDCDetId.h"
#include "DataFormats/HcalDetId/interface/HcalTrigTowerDetId.h"
#include "DataFormats/HcalDetId/interface/HcalDetId.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/Exception.h"
HcalCondObjectContainerBase::HcalCondObjectContainerBase(const HcalTopology* topo)
: packedIndexVersion_(0), topo_(topo), kSizeForDenseIndexing_(HcalZDCDetId::kSizeForDenseIndexingRun1) {
if (topo) {
packedIndexVersion_ = topo->topoVersion();
HcalTopologyMode::Mode mode = topo->mode();
kSizeForDenseIndexing_ = (((mode == HcalTopologyMode::Run3) || (mode == HcalTopologyMode::Run4))
? HcalZDCDetId::kSizeForDenseIndexingRun3
: HcalZDCDetId::kSizeForDenseIndexingRun1);
}
}
void HcalCondObjectContainerBase::setTopo(const HcalTopology* topo) {
if (topo) {
if ((packedIndexVersion_ != 0) && (!topo->denseIdConsistent(packedIndexVersion_)))
edm::LogError("HCAL") << std::string("Inconsistent dense packing between current topology (")
<< topo->topoVersion() << ") and calibration object (" << packedIndexVersion_ << ")";
topo_ = topo;
packedIndexVersion_ = topo->topoVersion();
kSizeForDenseIndexing_ = ((packedIndexVersion_ >= 10) ? HcalZDCDetId::kSizeForDenseIndexingRun3
: HcalZDCDetId::kSizeForDenseIndexingRun1);
} else {
edm::LogError("HCAL") << "Illegal call to HcalCondObjectContainerBase with a null pointer";
}
}
unsigned int HcalCondObjectContainerBase::indexFor(DetId fId) const {
unsigned int retval = 0xFFFFFFFFu;
if (!topo()) {
edm::LogError("HCAL") << "Topology pointer not set, HCAL conditions non-functional";
throw cms::Exception("Topology pointer not set, HCAL conditions non-functional");
return retval;
}
if (fId.det() == DetId::Hcal) {
switch (HcalSubdetector(fId.subdetId())) {
case (HcalBarrel):
retval = topo()->detId2denseIdHB(fId);
break;
case (HcalEndcap):
retval = topo()->detId2denseIdHE(fId);
break;
case (HcalOuter):
retval = topo()->detId2denseIdHO(fId);
break;
case (HcalForward):
retval = topo()->detId2denseIdHF(fId);
break;
case (HcalTriggerTower):
retval = topo()->detId2denseIdHT(fId);
break;
case (HcalOther):
if (extractOther(fId) == HcalCalibration)
retval = topo()->detId2denseIdCALIB(fId);
break;
default:
break;
}
} else if (fId.det() == DetId::Calo) {
if (fId.subdetId() == HcalCastorDetId::SubdetectorId) {
// the historical packing from HcalGeneric is different from HcalCastorDetId, so we clone the old packing here.
HcalCastorDetId tid(fId);
int zside = tid.zside();
int sector = tid.sector();
int module = tid.module();
static const int CASTORhalf = 224;
int index = 14 * (sector - 1) + (module - 1);
if (zside == -1)
index += CASTORhalf;
retval = (unsigned int)(index);
} else if (fId.subdetId() == HcalZDCDetId::SubdetectorId) {
HcalZDCDetId direct(fId);
// THIS IS A HORRIBLE HACK because there were _two_ dense indices for ZDC differing in their handling of +/-z
HcalZDCDetId swapZ(direct.section(), direct.zside() < 0, direct.channel());
retval = swapZ.denseIndex();
}
}
return retval;
}
unsigned int HcalCondObjectContainerBase::sizeFor(DetId fId) const {
unsigned int retval = 0;
if (!topo()) {
edm::LogError("HCAL") << "Topology pointer not set, HCAL conditions non-functional";
throw cms::Exception("Topology pointer not set, HCAL conditions non-functional");
return retval;
}
if (fId.det() == DetId::Hcal) {
switch (HcalSubdetector(fId.subdetId())) {
case (HcalBarrel):
retval = topo()->getHBSize();
break;
case (HcalEndcap):
retval = topo()->getHESize();
break;
case (HcalOuter):
retval = topo()->getHOSize();
break;
case (HcalForward):
retval = topo()->getHFSize();
break;
case (HcalTriggerTower):
retval = topo()->getHTSize();
break;
case (HcalOther):
if (extractOther(fId) == HcalCalibration)
retval = topo()->getCALIBSize();
break;
default:
break;
}
} else if (fId.det() == DetId::Calo) {
if (fId.subdetId() == HcalCastorDetId::SubdetectorId) {
retval = HcalCastorDetId::kSizeForDenseIndexing;
} else if (fId.subdetId() == HcalZDCDetId::SubdetectorId) {
retval = kSizeForDenseIndexing_;
}
}
return retval;
}
std::string HcalCondObjectContainerBase::textForId(const DetId& id) const {
std::ostringstream os;
os << std::hex << "(0x" << id.rawId() << ") " << std::dec;
if (id.det() == DetId::Hcal) {
switch (HcalSubdetector(id.subdetId())) {
case (HcalBarrel):
case (HcalEndcap):
case (HcalOuter):
case (HcalForward):
os << HcalDetId(id);
break;
case (HcalTriggerTower):
os << HcalTrigTowerDetId(id);
break;
case (HcalOther):
if (extractOther(id) == HcalCalibration)
os << HcalCalibDetId(id);
break;
default:
break;
}
} else if (id.det() == DetId::Calo) {
if (id.subdetId() == HcalCastorDetId::SubdetectorId) {
os << HcalCastorDetId(id);
} else if (id.subdetId() == HcalZDCDetId::SubdetectorId) {
os << HcalZDCDetId(id);
}
}
return os.str();
}
|