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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
#include "Calibration/IsolatedParticles/interface/DebugInfo.h"
#include "Calibration/IsolatedParticles/interface/eHCALMatrix.h"
#include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include <algorithm>
#include <sstream>
namespace spr {
double eHCALmatrix(const HcalTopology* topology,
const DetId& det0,
std::vector<PCaloHit>& hits,
int ieta,
int iphi,
bool includeHO,
double hbThr,
double heThr,
double hfThr,
double hoThr,
double tMin,
double tMax,
bool debug) {
HcalDetId hcid0(det0.rawId());
HcalDetId hcid(hcid0.subdet(), hcid0.ieta(), hcid0.iphi(), 1);
DetId det(hcid.rawId());
if (debug)
edm::LogVerbatim("IsoTrack") << "Inside eHCALmatrix " << 2 * ieta + 1 << "X" << 2 * iphi + 1
<< " Inclusion of HO Flag " << includeHO;
double energySum(0);
std::vector<DetId> dets(1, det);
std::vector<DetId> vdets = spr::matrixHCALIds(dets, topology, ieta, iphi, includeHO, false);
if (debug) {
edm::LogVerbatim("IsoTrack") << "matrixHCALIds::Total number of cells found is " << vdets.size();
spr::debugHcalDets(0, vdets);
}
int khit(0);
for (unsigned int i = 0; i < vdets.size(); i++) {
std::vector<std::vector<PCaloHit>::const_iterator> hit = spr::findHit(hits, vdets[i]);
double energy = 0;
int subdet = ((HcalDetId)(vdets[i].rawId())).subdet();
double eThr = spr::eHCALThreshold(subdet, hbThr, heThr, hfThr, hoThr);
for (unsigned int ihit = 0; ihit < hit.size(); ihit++) {
if (hit[ihit] != hits.end()) {
khit++;
if (debug)
edm::LogVerbatim("IsoTrack") << "energyHCAL:: Hit " << khit << " " << (HcalDetId)vdets[i] << " E "
<< hit[ihit]->energy() << " t " << hit[ihit]->time();
if (hit[ihit]->time() > tMin && hit[ihit]->time() < tMax) {
energy += hit[ihit]->energy();
}
}
}
if (energy > eThr)
energySum += energy;
}
if (debug)
edm::LogVerbatim("IsoTrack") << "eHCALmatrix::Total energy " << energySum;
return energySum;
}
double eHCALmatrix(const CaloGeometry* geo,
const HcalTopology* topology,
const DetId& det0,
std::vector<PCaloHit>& hits,
int ieta,
int iphi,
HcalDetId& hotCell,
bool includeHO,
bool debug) {
HcalDetId hcid0(det0.rawId());
HcalDetId hcid(hcid0.subdet(), hcid0.ieta(), hcid0.iphi(), 1);
DetId det(hcid.rawId());
std::vector<DetId> dets(1, det);
std::vector<DetId> vdets = spr::matrixHCALIds(dets, topology, ieta, iphi, includeHO, debug);
hotCell = hcid0;
std::vector<std::vector<PCaloHit>::const_iterator> hitlist;
for (unsigned int i = 0; i < vdets.size(); i++) {
std::vector<std::vector<PCaloHit>::const_iterator> hit = spr::findHit(hits, vdets[i]);
hitlist.insert(hitlist.end(), hit.begin(), hit.end());
}
double energySum(0);
for (unsigned int ihit = 0; ihit < hitlist.size(); ihit++)
energySum += hitlist[ihit]->energy();
// Get hotCell ID
dets.clear();
std::vector<double> energies;
for (unsigned int ihit = 0; ihit < hitlist.size(); ihit++) {
double energy = hitlist[ihit]->energy();
HcalDetId id0 = HcalDetId(hitlist[ihit]->id());
if ((id0.subdet() != HcalOuter) || includeHO) {
HcalDetId id1(id0.subdet(), id0.ieta(), id0.iphi(), 1);
bool found(false);
for (unsigned int idet = 0; idet < dets.size(); ++idet) {
if (id1 == HcalDetId(dets[idet])) {
energies[idet] += energy;
found = true;
break;
}
}
if (!found) {
dets.push_back(DetId(id1));
energies.push_back(energy);
}
}
}
double energyMax(-99.);
for (unsigned int ihit = 0; ihit < dets.size(); ihit++) {
if (energies[ihit] > energyMax) {
energyMax = energies[ihit];
hotCell = HcalDetId(dets[ihit]);
}
}
return energySum;
}
void energyHCALCell(HcalDetId detId,
std::vector<PCaloHit>& hits,
std::vector<std::pair<double, int> >& energyCell,
int maxDepth,
double hbThr,
double heThr,
double hfThr,
double hoThr,
double tMin,
double tMax,
int depthHE,
bool debug) {
energyCell.clear();
int subdet = detId.subdet();
double eThr = spr::eHCALThreshold(subdet, hbThr, heThr, hfThr, hoThr);
bool hbhe = (detId.ietaAbs() == 16);
if (debug)
edm::LogVerbatim("IsoTrack") << "energyHCALCell: input ID " << detId << " MaxDepth " << maxDepth
<< " Threshold (E) " << eThr << " (T) " << tMin << ":" << tMax;
for (int i = 0; i < maxDepth; i++) {
HcalSubdetector subdet0 = (hbhe) ? ((i + 1 >= depthHE) ? HcalEndcap : HcalBarrel) : detId.subdet();
HcalDetId hcid(subdet0, detId.ieta(), detId.iphi(), i + 1);
DetId det(hcid.rawId());
std::vector<std::vector<PCaloHit>::const_iterator> hit = spr::findHit(hits, det);
double energy(0);
for (unsigned int ihit = 0; ihit < hit.size(); ++ihit) {
if (hit[ihit]->time() > tMin && hit[ihit]->time() < tMax)
energy += hit[ihit]->energy();
if (debug)
edm::LogVerbatim("IsoTrack") << "energyHCALCell:: Hit[" << ihit << "] " << hcid << " E "
<< hit[ihit]->energy() << " t " << hit[ihit]->time();
}
if (debug)
edm::LogVerbatim("IsoTrack") << "energyHCALCell:: Cell " << hcid << " E " << energy << " from " << hit.size()
<< " threshold " << eThr;
if (energy > eThr && !hit.empty()) {
energyCell.push_back(std::pair<double, int>(energy, i + 1));
}
}
if (debug) {
std::ostringstream st1;
st1 << "energyHCALCell:: " << energyCell.size() << " entries from " << maxDepth << " depths:";
for (unsigned int i = 0; i < energyCell.size(); ++i) {
st1 << " [" << i << "] (" << energyCell[i].first << ":" << energyCell[i].second << ")";
}
edm::LogVerbatim("IsoTrack") << st1.str();
}
}
HcalDetId getHotCell(std::vector<HBHERecHitCollection::const_iterator>& hit, bool includeHO, int useRaw, bool) {
std::vector<HcalDetId> dets;
std::vector<double> energies;
for (unsigned int ihit = 0; ihit < hit.size(); ihit++) {
double energy = getRawEnergy(hit.at(ihit), useRaw);
HcalDetId id0 = hit.at(ihit)->id();
if ((id0.subdet() != HcalOuter) || includeHO) {
HcalDetId id1(id0.subdet(), id0.ieta(), id0.iphi(), 1);
bool found(false);
for (unsigned int idet = 0; idet < dets.size(); ++idet) {
if (id1 == dets[idet]) {
energies[idet] += energy;
found = true;
break;
}
}
if (!found) {
dets.push_back(id1);
energies.push_back(energy);
}
}
}
double energyMax(-99.);
HcalDetId hotCell;
for (unsigned int ihit = 0; ihit < dets.size(); ihit++) {
if (energies[ihit] > energyMax) {
energyMax = energies[ihit];
hotCell = dets[ihit];
}
}
return hotCell;
}
HcalDetId getHotCell(std::vector<std::vector<PCaloHit>::const_iterator>& hit, bool includeHO, int useRaw, bool) {
std::vector<HcalDetId> dets;
std::vector<double> energies;
for (unsigned int ihit = 0; ihit < hit.size(); ihit++) {
double energy = hit.at(ihit)->energy();
HcalDetId id0 = getRawEnergy(hit.at(ihit), useRaw);
if ((id0.subdet() != HcalOuter) || includeHO) {
HcalDetId id1(id0.subdet(), id0.ieta(), id0.iphi(), 1);
bool found(false);
for (unsigned int idet = 0; idet < dets.size(); ++idet) {
if (id1 == dets[idet]) {
energies[idet] += energy;
found = true;
break;
}
}
if (!found) {
dets.push_back(id1);
energies.push_back(energy);
}
}
}
double energyMax(-99.);
HcalDetId hotCell;
for (unsigned int ihit = 0; ihit < dets.size(); ihit++) {
if (energies[ihit] > energyMax) {
energyMax = energies[ihit];
hotCell = dets[ihit];
}
}
return hotCell;
}
double eHCALThreshold(int subdet, double hbThr, double heThr, double hfThr, double hoThr) {
double eThr = hbThr;
if (subdet == (int)(HcalEndcap))
eThr = heThr;
else if (subdet == (int)(HcalForward))
eThr = hfThr;
else if (subdet == (int)(HcalOuter))
eThr = hoThr;
return eThr;
}
} // namespace spr
|