11 constexpr
float c_cm_per_ns = 29.9792458;
12 constexpr
float zseparation_HBHE = 380.;
20 return x->iphi() * 1000 + x->ieta() < y->iphi() * 1000 + y->ieta();
36 return Calculate(TheCaloGeometry, TheHBHERecHits, TheCaloTowers, TheEBRecHits, TheEERecHits, TheSetup);
47 const int iEtaOverlap = 22;
48 const int nPhiMax = 73;
54 float MinTimeHits[nPhiMax];
56 float MaxTimeHits[nPhiMax];
57 for (
unsigned int i = 0;
i < nPhiMax;
i++) {
64 for (
const auto&
hit : (*TheHBHERecHits)) {
66 switch (
id.subdet()) {
82 SumE[iPhi] +=
hit.energy();
86 MinTimeHits[iPhi] =
time < MinTimeHits[iPhi] ?
time : MinTimeHits[iPhi];
87 MaxTimeHits[iPhi] =
time > MaxTimeHits[iPhi] ?
time : MaxTimeHits[iPhi];
91 for (
int iPhi = 1; iPhi < nPhiMax; iPhi++) {
94 PhiWedge wedge(SumE[iPhi], iPhi, NumHits[iPhi], MinTimeHits[iPhi], MaxTimeHits[iPhi]);
97 std::vector<const HBHERecHit*> Hits;
98 for (
const auto&
hit : (*TheHBHERecHits)) {
100 if (
id.
iphi() != iPhi)
104 switch (
id.subdet()) {
116 Hits.push_back(&(
hit));
120 float MinusToPlus = 0.;
121 float PlusToMinus = 0.;
122 for (
unsigned int i = 0;
i < Hits.size();
i++) {
124 int ieta_i = id_i.
ieta();
125 for (
unsigned int j = (
i + 1);
j < Hits.size();
j++) {
127 int ieta_j = id_j.
ieta();
129 PlusToMinus +=
std::abs(ieta_i - ieta_j);
131 MinusToPlus +=
std::abs(ieta_i - ieta_j);
134 float PlusZOriginConfidence = (PlusToMinus + MinusToPlus) ? PlusToMinus / (PlusToMinus + MinusToPlus) : -1.;
143 std::map<int, float> iPhiHadEtMap;
144 std::vector<const CaloTower*> sortedCaloTowers;
145 for (
const auto&
tower : (*TheCaloTowers)) {
149 int iPhi =
tower.iphi();
150 if (!iPhiHadEtMap.count(iPhi))
151 iPhiHadEtMap[iPhi] = 0.0;
152 iPhiHadEtMap[iPhi] +=
tower.hadEt();
154 if (
tower.numProblematicHcalCells() > 0)
155 sortedCaloTowers.push_back(&(
tower));
160 std::sort(sortedCaloTowers.begin(), sortedCaloTowers.end(),
CompareTowers);
164 int prevIEta = -99, prevIPhi = -99;
165 float prevHadEt = 0.;
167 std::pair<uint8_t, CaloTowerDetId> prevPair, towerPair;
168 bool wasContiguous =
true;
171 for (
unsigned int i = 0;
i < sortedCaloTowers.size();
i++) {
174 towerPair = std::make_pair((uint8_t)
tower->numProblematicHcalCells(),
tower->id());
176 bool newIPhi =
tower->iphi() != prevIPhi;
177 bool isContiguous =
tower->ieta() == 1 ?
tower->ieta() - 2 == prevIEta :
tower->ieta() - 1 == prevIEta;
179 isContiguous = isContiguous || (
tower->ieta() == -maxAbsIEta);
181 isContiguous =
false;
183 if (!wasContiguous && isContiguous) {
184 strip.cellTowerIds.push_back(prevPair);
185 strip.cellTowerIds.push_back(towerPair);
190 if (wasContiguous && isContiguous) {
191 strip.cellTowerIds.push_back(towerPair);
196 if ((wasContiguous && !isContiguous) ||
i == sortedCaloTowers.size() - 1) {
198 if (
strip.cellTowerIds.size() > 3) {
199 int iPhi =
strip.cellTowerIds.at(0).second.iphi();
200 int iPhiLower = (iPhi == 1) ? 72 : iPhi - 1;
201 int iPhiUpper = (iPhi == 72) ? 1 : iPhi + 1;
203 float energyRatio = 0.0;
204 if (iPhiHadEtMap.count(iPhiLower))
205 energyRatio += iPhiHadEtMap[iPhiLower];
206 if (iPhiHadEtMap.count(iPhiUpper))
207 energyRatio += iPhiHadEtMap[iPhiUpper];
208 iPhiHadEtMap[iPhi] =
std::max(iPhiHadEtMap[iPhi], 0.001
F);
210 energyRatio /= iPhiHadEtMap[iPhi];
211 strip.energyRatio = energyRatio;
218 wasContiguous = isContiguous;
219 prevPair = towerPair;
220 prevEmEt =
tower->emEt();
221 prevIPhi =
tower->iphi();
222 prevIEta =
tower->ieta();
223 prevHadEt =
tower->hadEt();
241 std::vector<HaloClusterCandidateHCAL> haloclustercands_HB;
244 std::vector<HaloClusterCandidateHCAL> haloclustercands_HE;
250 return TheHcalHaloData;
256 float et_thresh_seedrh) {
257 std::vector<HaloClusterCandidateHCAL> TheHaloClusterCandsHB;
261 for (
size_t ihit = 0; ihit < hbherechitcoll->
size(); ++ihit) {
264 const HBHERecHit& rechit = (*hbherechitcoll)[ihit];
267 double rhet = rechit.
energy() *
sqrt(rhpos.perp2() / rhpos.mag2());
268 if (rhet < et_thresh_seedrh)
270 if (
std::abs(rhpos.z()) > zseparation_HBHE)
272 double eta = rhpos.eta();
273 double phi = rhpos.phi();
277 int nbtowerssameeta(0);
278 double timediscriminatorITBH(0), timediscriminatorOTBH(0);
279 double etstrip_phiseedplus1(0), etstrip_phiseedminus1(0);
283 for (
size_t jhit = 0; jhit < hbherechitcoll->
size(); ++jhit) {
284 const HBHERecHit& rechitj = (*hbherechitcoll)[jhit];
287 double rhetj = rechitj.
energy() *
sqrt(rhposj.perp2() / rhposj.mag2());
290 if (
std::abs(rhposj.z()) > zseparation_HBHE)
292 double etaj = rhposj.eta();
293 double phij = rhposj.phi();
294 double deta =
eta - etaj;
309 etstrip_phiseedplus1 += rhetj;
311 etstrip_phiseedminus1 += rhetj;
324 double rhtj = rechitj.
time();
325 timediscriminatorITBH +=
327 (rhtj + 0.5 * (
sqrt(240. * 240. + rhposj.z() * rhposj.z()) -
std::abs(rhposj.z())) / c_cm_per_ns);
329 timediscriminatorOTBH +=
331 (rhtj - 0.5 * (25 - (
sqrt(330. * 330. + rhposj.z() * rhposj.z()) +
std::abs(rhposj.z())) / c_cm_per_ns));
337 if (etstrip_phiseedplus1 / etcluster > 0.2 && etstrip_phiseedminus1 / etcluster > 0.2)
342 for (
size_t jhit = 0; jhit < ecalrechitcoll->
size(); ++jhit) {
343 const EcalRecHit& rechitj = (*ecalrechitcoll)[jhit];
345 double rhetj = rechitj.
energy() *
sqrt(rhposj.perp2() / rhposj.mag2());
348 double etaj = rhposj.eta();
349 double phij = rhposj.phi();
354 eoh += rhetj / etcluster;
380 TheHaloClusterCandsHB.push_back(clustercand);
383 return TheHaloClusterCandsHB;
389 float et_thresh_seedrh) {
390 std::vector<HaloClusterCandidateHCAL> TheHaloClusterCandsHE;
394 for (
size_t ihit = 0; ihit < hbherechitcoll->
size(); ++ihit) {
397 const HBHERecHit& rechit = (*hbherechitcoll)[ihit];
400 double rhet = rechit.
energy() *
sqrt(rhpos.perp2() / rhpos.mag2());
401 if (rhet < et_thresh_seedrh)
403 if (
std::abs(rhpos.z()) < zseparation_HBHE)
405 double eta = rhpos.eta();
406 double phi = rhpos.phi();
407 double rhr =
sqrt(rhpos.perp2());
409 double etcluster(0), hdepth1(0);
411 double etstrip_phiseedplus1(0), etstrip_phiseedminus1(0);
415 for (
size_t jhit = 0; jhit < hbherechitcoll->
size(); ++jhit) {
416 const HBHERecHit& rechitj = (*hbherechitcoll)[jhit];
419 double rhetj = rechitj.
energy() *
sqrt(rhposj.perp2() / rhposj.mag2());
422 if (
std::abs(rhposj.z()) < zseparation_HBHE)
424 if (rhpos.z() * rhposj.z() < 0)
426 double phij = rhposj.phi();
430 double rhrj =
sqrt(rhposj.perp2());
438 etstrip_phiseedplus1 += rhetj;
440 etstrip_phiseedminus1 += rhetj;
451 if (etstrip_phiseedplus1 / etcluster > 0.1 && etstrip_phiseedminus1 / etcluster > 0.1)
456 for (
size_t jhit = 0; jhit < ecalrechitcoll->
size(); ++jhit) {
457 const EcalRecHit& rechitj = (*ecalrechitcoll)[jhit];
459 double rhetj = rechitj.
energy() *
sqrt(rhposj.perp2() / rhposj.mag2());
462 if (rhpos.z() * rhposj.z() < 0)
464 double etaj = rhposj.eta();
465 double phij = rhposj.phi();
470 eoh += rhetj / etcluster;
496 TheHaloClusterCandsHE.push_back(clustercand);
499 return TheHaloClusterCandsHE;