9 #include "Math/Interpolator.h"
15 : theEBthreshold(-1000.),
16 theEEthreshold(-1000.),
18 theUseEtEBTresholdFlag(
false),
19 theUseEtEETresholdFlag(
false),
20 theUseSymEBTresholdFlag(
false),
21 theUseSymEETresholdFlag(
false),
23 theHcalThreshold(-1000.),
24 theHBthreshold(-1000.),
25 theHBthreshold1(-1000.),
26 theHBthreshold2(-1000.),
27 theHESthreshold(-1000.),
28 theHESthreshold1(-1000.),
29 theHEDthreshold(-1000.),
30 theHEDthreshold1(-1000.),
31 theHOthreshold0(-1000.),
32 theHOthresholdPlus1(-1000.),
33 theHOthresholdMinus1(-1000.),
34 theHOthresholdPlus2(-1000.),
35 theHOthresholdMinus2(-1000.),
36 theHF1threshold(-1000.),
37 theHF2threshold(-1000.),
45 theHESWeights(
std::
vector<double>(5, 1.)),
47 theHEDWeights(
std::
vector<double>(5, 1.)),
51 theHF1Weights(
std::
vector<double>(5, 1.)),
53 theHF2Weights(
std::
vector<double>(5, 1.)),
63 theEBSumThreshold(-1000.),
64 theEESumThreshold(-1000.),
73 theHcalTopology(nullptr),
75 theTowerConstituentsMap(nullptr),
76 theHcalAcceptSeverityLevel(0),
77 theRecoveredHcalHitsAreUsed(
false),
78 theRecoveredEcalHitsAreUsed(
false),
79 useRejectedHitsOnly(
false),
80 theHcalAcceptSeverityLevelForRejectedHit(0),
81 useRejectedRecoveredHcalHits(0),
82 useRejectedRecoveredEcalHits(0),
86 theMomConstrMethod(0),
98 bool useSymEBTreshold,
99 bool useSymEETreshold,
106 double HESthreshold1,
108 double HEDthreshold1,
110 double HOthresholdPlus1,
111 double HOthresholdMinus1,
112 double HOthresholdPlus2,
113 double HOthresholdMinus2,
136 : theEBthreshold(EBthreshold),
137 theEEthreshold(EEthreshold),
139 theUseEtEBTresholdFlag(useEtEBTreshold),
140 theUseEtEETresholdFlag(useEtEETreshold),
141 theUseSymEBTresholdFlag(useSymEBTreshold),
142 theUseSymEETresholdFlag(useSymEETreshold),
145 theHBthreshold(HBthreshold),
146 theHBthreshold1(HBthreshold1),
147 theHBthreshold2(HBthreshold2),
148 theHESthreshold(HESthreshold),
149 theHESthreshold1(HESthreshold1),
150 theHEDthreshold(HEDthreshold),
151 theHEDthreshold1(HEDthreshold1),
152 theHOthreshold0(HOthreshold0),
153 theHOthresholdPlus1(HOthresholdPlus1),
154 theHOthresholdMinus1(HOthresholdMinus1),
155 theHOthresholdPlus2(HOthresholdPlus2),
156 theHOthresholdMinus2(HOthresholdMinus2),
157 theHF1threshold(HF1threshold),
158 theHF2threshold(HF2threshold),
160 theEBWeights(
std::
vector<double>(5, 1.)),
162 theEEWeights(
std::
vector<double>(5, 1.)),
164 theHBWeights(
std::
vector<double>(5, 1.)),
166 theHESWeights(
std::
vector<double>(5, 1.)),
168 theHEDWeights(
std::
vector<double>(5, 1.)),
170 theHOWeights(
std::
vector<double>(5, 1.)),
172 theHF1Weights(
std::
vector<double>(5, 1.)),
174 theHF2Weights(
std::
vector<double>(5, 1.)),
175 theEBweight(EBweight),
176 theEEweight(EEweight),
177 theHBweight(HBweight),
178 theHESweight(HESweight),
179 theHEDweight(HEDweight),
180 theHOweight(HOweight),
181 theHF1weight(HF1weight),
182 theHF2weight(HF2weight),
194 theHcalTopology(nullptr),
195 theGeometry(nullptr),
196 theTowerConstituentsMap(nullptr),
197 theHcalAcceptSeverityLevel(0),
198 theRecoveredHcalHitsAreUsed(
false),
199 theRecoveredEcalHitsAreUsed(
false),
200 useRejectedHitsOnly(
false),
201 theHcalAcceptSeverityLevelForRejectedHit(0),
202 useRejectedRecoveredHcalHits(0),
203 useRejectedRecoveredEcalHits(0),
207 theMomConstrMethod(momConstrMethod),
208 theMomHBDepth(momHBDepth),
209 theMomHEDepth(momHEDepth),
210 theMomEBDepth(momEBDepth),
211 theMomEEDepth(momEEDepth),
212 theHcalPhase(hcalPhase) {}
216 bool useEtEBTreshold,
217 bool useEtEETreshold,
218 bool useSymEBTreshold,
219 bool useSymEETreshold,
226 double HESthreshold1,
228 double HEDthreshold1,
230 double HOthresholdPlus1,
231 double HOthresholdMinus1,
232 double HOthresholdPlus2,
233 double HOthresholdMinus2,
236 const std::vector<double>&
EBGrid,
238 const std::vector<double>&
EEGrid,
240 const std::vector<double>&
HBGrid,
242 const std::vector<double>&
HESGrid,
244 const std::vector<double>&
HEDGrid,
246 const std::vector<double>&
HOGrid,
248 const std::vector<double>&
HF1Grid,
250 const std::vector<double>&
HF2Grid,
272 : theEBthreshold(EBthreshold),
273 theEEthreshold(EEthreshold),
275 theUseEtEBTresholdFlag(useEtEBTreshold),
276 theUseEtEETresholdFlag(useEtEETreshold),
277 theUseSymEBTresholdFlag(useSymEBTreshold),
278 theUseSymEETresholdFlag(useSymEETreshold),
281 theHBthreshold(HBthreshold),
282 theHBthreshold1(HBthreshold1),
283 theHBthreshold2(HBthreshold2),
284 theHESthreshold(HESthreshold),
285 theHESthreshold1(HESthreshold1),
286 theHEDthreshold(HEDthreshold),
287 theHEDthreshold1(HEDthreshold1),
288 theHOthreshold0(HOthreshold0),
289 theHOthresholdPlus1(HOthresholdPlus1),
290 theHOthresholdMinus1(HOthresholdMinus1),
291 theHOthresholdPlus2(HOthresholdPlus2),
292 theHOthresholdMinus2(HOthresholdMinus2),
293 theHF1threshold(HF1threshold),
294 theHF2threshold(HF2threshold),
311 theEBweight(EBweight),
312 theEEweight(EEweight),
313 theHBweight(HBweight),
314 theHESweight(HESweight),
315 theHEDweight(HEDweight),
316 theHOweight(HOweight),
317 theHF1weight(HF1weight),
318 theHF2weight(HF2weight),
330 theHcalTopology(nullptr),
331 theGeometry(nullptr),
332 theTowerConstituentsMap(nullptr),
333 theHcalAcceptSeverityLevel(0),
334 theRecoveredHcalHitsAreUsed(
false),
335 theRecoveredEcalHitsAreUsed(
false),
336 useRejectedHitsOnly(
false),
337 theHcalAcceptSeverityLevelForRejectedHit(0),
338 useRejectedRecoveredHcalHits(0),
339 useRejectedRecoveredEcalHits(0),
343 theMomConstrMethod(momConstrMethod),
344 theMomHBDepth(momHBDepth),
345 theMomHEDepth(momHEDepth),
346 theMomEBDepth(momEBDepth),
347 theMomEEDepth(momEEDepth),
348 theHcalPhase(hcalPhase) {
429 double newE_em = ctcItr->emEnergy();
430 double newE_had = ctcItr->hadEnergy();
431 double newE_outer = ctcItr->outerEnergy();
438 double E_short = 0.5 * newE_had;
439 double E_long = newE_em + 0.5 * newE_had;
444 newE_em = E_long - E_short;
445 newE_had = 2.0 * E_short;
451 for (
unsigned int iConst = 0; iConst < ctcItr->constituentsSize(); ++iConst) {
452 DetId constId = ctcItr->constituent(iConst);
460 for (
unsigned int iConst = 0; iConst < ctcItr->constituentsSize(); ++iConst) {
461 DetId constId = ctcItr->constituent(iConst);
471 for (
unsigned int iConst = 0; iConst < ctcItr->constituentsSize(); ++iConst) {
472 DetId constId = ctcItr->constituent(iConst);
494 double f_em = 1.0 / cosh(emPoint.
eta());
495 double f_had = 1.0 / cosh(hadPoint.
eta());
505 double newE_tot = newE_em + newE_had;
511 CaloTower rescaledTower(twrId, newE_em, newE_had, newE_outer, -1, -1, towerP4, emPoint, hadPoint);
513 rescaledTower.
setEcalTime(
int(ctcItr->ecalTime() * 100.0 + 0.5));
514 rescaledTower.
setHcalTime(
int(ctcItr->hcalTime() * 100.0 + 0.5));
522 for (
unsigned int iConst = 0; iConst < ctcItr->constituentsSize(); ++iConst) {
523 contains.push_back(ctcItr->constituent(iConst));
575 if (towerDetId.
null())
581 tower29.numBadHcalCells += 1;
587 if (towerDetId.
null())
595 tower29.numRecHcalCells += 1;
598 tower29.numProbHcalCells += 1;
602 double e28 = 0.5 *
e;
603 double e29 = 0.5 *
e;
605 tower28.
E_had += e28;
607 std::pair<DetId, float>
mc(detId, e28);
610 tower29.E_had += e29;
612 tower29.metaConstituents.push_back(
mc);
620 tower29.hadSumTimeTimesE += (e29 *
recHit->time());
621 tower29.hadSumEForTime += e29;
626 tower29.E_outer += e29;
637 if (towerDetId.
null())
643 tower.numBadHcalCells += 1;
653 tower.numRecHcalCells += 1;
655 tower.numProbHcalCells += 1;
660 std::pair<DetId, float>
mc(detId,
e);
661 tower.metaConstituents.push_back(
mc);
671 if (towerDetId.
null())
674 tower.numBadHcalCells += 1;
679 if (towerDetId.
null())
683 if (hcalDetId.
depth() == 1) {
693 tower.numRecHcalCells += 1;
695 tower.numProbHcalCells += 1;
702 tower.hadSumEForTime +=
e;
705 std::pair<DetId, float>
mc(detId,
e);
706 tower.metaConstituents.push_back(
mc);
716 if (towerDetId.
null())
719 tower.numBadHcalCells += 1;
722 if (towerDetId.
null())
728 tower.numRecHcalCells += 1;
730 tower.numProbHcalCells += 1;
737 tower.hadSumEForTime +=
e;
745 (hcalDetId.
depth() == 3 && hcalDetId.
ietaAbs() == 27) ||
746 (hcalDetId.
depth() == 3 && hcalDetId.
ietaAbs() == 16)) {
754 (hcalDetId.
depth() == 3 && hcalDetId.
ietaAbs() == 17) ||
755 (hcalDetId.
depth() == 4 && hcalDetId.
ietaAbs() == 16)) {
761 std::pair<DetId, float>
mc(detId,
e);
762 tower.metaConstituents.push_back(
mc);
775 unsigned int chStatusForCT;
776 bool ecalIsBad =
false;
797 bool passEmThreshold =
false;
817 if (towerDetId.
null())
832 ++
tower.numBadEcalCells;
841 tower.numRecEcalCells += 1;
843 tower.numProbEcalCells += 1;
855 std::pair<DetId, float>
mc(detId,
e);
856 tower.metaConstituents.push_back(
mc);
867 if (towerDetId.
null())
883 if (hcalDetId.
depth() == 1)
885 if (hcalDetId.
depth() == 2)
897 std::pair<DetId, float>
mc(detId, 0);
898 tower.metaConstituents.push_back(
mc);
904 tower.emSumEForTime = 1.0;
905 tower.hadSumEForTime = 1.0;
929 double E_em =
mt.E_em;
930 double E_had =
mt.E_had;
931 double E_outer =
mt.E_outer;
940 std::vector<std::pair<DetId, float> > metaContains =
mt.metaConstituents;
944 std::vector<std::pair<DetId, float> > metaContains_noecal;
946 for (
std::vector<std::pair<DetId, float> >::iterator
i = metaContains.begin();
i != metaContains.end(); ++
i)
948 metaContains_noecal.push_back(*
i);
949 metaContains.swap(metaContains_noecal);
959 std::vector<std::pair<DetId, float> > metaContains_nohcal;
961 for (
std::vector<std::pair<DetId, float> >::iterator
i = metaContains.begin();
i != metaContains.end(); ++
i)
963 metaContains_nohcal.push_back(*
i);
964 metaContains.swap(metaContains_nohcal);
967 if (metaContains.empty())
986 bool massless =
true;
993 double momEmDepth = 0.;
994 double momHadDepth = 0.;
995 if (
id.ietaAbs() <= 17) {
1007 towerP4 =
p.basicVector().unit();
1023 emPoint =
emShwrPos(metaContains, momEmDepth, E_em);
1026 towerP4 = emP4 * E_em;
1031 if ((E_had + E_outer) > 0) {
1032 massless = (E_em <= 0);
1037 auto diff = lP4 - emP4;
1055 towerP4 =
p.basicVector().unit();
1082 towerP4 =
p.basicVector().unit();
1097 if UNLIKELY ((towerP4[3] == 0) & (E_outer > 0)) {
1110 id, E_em, E_had, E_outer, -1, -1,
GlobalVector(towerP4), towerP4[3], mass2, emPoint, hadPoint);
1124 float ecalTime = (
mt.emSumEForTime > 0) ?
mt.emSumTimeTimesE /
mt.emSumEForTime : -9999;
1125 float hcalTime = (
mt.hadSumEForTime > 0) ?
mt.hadSumTimeTimesE /
mt.hadSumEForTime : -9999;
1139 unsigned int numBadHcalChan =
mt.numBadHcalCells;
1141 unsigned int numBadEcalChan = 0;
1143 unsigned int numRecHcalChan =
mt.numRecHcalCells;
1144 unsigned int numRecEcalChan =
mt.numRecEcalCells;
1145 unsigned int numProbHcalChan =
mt.numProbHcalCells;
1146 unsigned int numProbEcalChan =
mt.numProbEcalCells;
1151 numBadHcalChan += dropChItr->second.first;
1207 caloTower.setCaloTowerStatus(
1208 numBadHcalChan, numBadEcalChan, numRecHcalChan, numRecEcalChan, numProbHcalChan, numProbEcalChan);
1210 double maxCellE = -999.0;
1213 contains.reserve(metaContains.size());
1214 for (
std::vector<std::pair<DetId, float> >::iterator
i = metaContains.begin();
i != metaContains.end(); ++
i) {
1217 if (maxCellE < i->
second) {
1224 maxCellE =
i->second;
1227 maxCellE =
i->second;
1229 maxCellE =
i->second;
1237 caloTower.setHottestCellE(maxCellE);
1303 else if (hcalDetId.
ieta() < 0) {
1318 if (hcalDetId.
depth() == 1) {
1335 edm::LogError(
"CaloTowersCreationAlgo") <<
"Bad cell: " << det << std::endl;
1340 if (
scale > 0.00001)
1347 if (
scale > 0.00001)
1354 if (
scale > 0.00001)
1361 if (
scale > 0.00001)
1368 if (
scale > 0.00001)
1375 if (
scale > 0.00001)
1382 if (
scale > 0.00001)
1389 if (
scale > 0.00001)
1404 const GlobalPoint& backPoint = cellGeometry->getBackPoint();
1421 std::cout <<
"hadShwrPos called with " << metaContains.size() <<
" elements and energy " << hadE <<
":" << fracDepth
1433 std::vector<std::pair<DetId, float> >::const_iterator mc_it = metaContains.begin();
1434 for (; mc_it != metaContains.end(); ++mc_it) {
1451 return GlobalPoint(hadX / nConst, hadY / nConst, hadZ / nConst);
1460 std::cout <<
"hadShwrPos " <<
towerId <<
" frac " << fracDepth << std::endl;
1464 else if (fracDepth > 1)
1481 int frontDepth = 1000;
1482 int backDepth = -1000;
1483 for (
unsigned i = 0;
i <
items.size();
i++) {
1502 std::cout <<
"Front " << frontCellId <<
" Back " << backCellId <<
" Depths " << frontDepth <<
":" << backDepth
1510 std::cout << towerId28 <<
" with " << items28.size() <<
" constituents:";
1511 for (
unsigned k = 0;
k < items28.size(); ++
k)
1516 for (
unsigned i = 0;
i < items28.size();
i++) {
1530 std::cout <<
"Back " << backDepth <<
" ID " << backCellId << std::endl;
1542 HcalDetId hid1(frontCellId), hid2(backCellId);
1558 const GlobalPoint& backPoint = backCellGeometry->getBackPoint();
1577 std::vector<std::pair<DetId, float> >::const_iterator mc_it = metaContains.begin();
1578 for (; mc_it != metaContains.end(); ++mc_it) {
1582 double e = mc_it->second;
1592 return GlobalPoint(emX / eSum, emY / eSum, emZ / eSum);
1603 double sumWeights = 0;
1605 double crystalThresh = 0.015 * emE;
1607 std::vector<std::pair<DetId, float> >::const_iterator mc_it = metaContains.begin();
1608 for (; mc_it != metaContains.end(); ++mc_it) {
1609 if (mc_it->second < 0)
1611 if (mc_it->first.det() ==
DetId::Ecal && mc_it->second > crystalThresh)
1612 sumEmE += mc_it->second;
1615 for (mc_it = metaContains.begin(); mc_it != metaContains.end(); ++mc_it) {
1616 if (mc_it->first.det() !=
DetId::Ecal || mc_it->second < crystalThresh)
1621 weight = 4.2 +
log(mc_it->second / sumEmE);
1629 return GlobalPoint(emX / sumWeights, emY / sumWeights, emZ / sumWeights);
1633 const float timeUnit = 0.01;
1640 return int(
time / timeUnit + 0.5);
1655 std::cout <<
"DropChMap with " << allChanInStatusCont.size() <<
" channels" << std::endl;
1657 for (std::vector<DetId>::iterator it = allChanInStatusCont.begin(); it != allChanInStatusCont.end(); ++it) {
1682 if (pair.second.first == 0)
1684 int ngood = 0, nbad = 0;
1698 if (nbad > 0 && nbad >= ngood) {
1702 pair.second.second =
true;
1723 for (std::vector<DetId>::iterator ac_it = allConstituents.begin(); ac_it != allConstituents.end(); ++ac_it) {
1730 std::vector<int>::const_iterator sevit =
1755 std::cout <<
"ChanStatusForCaloTower for " << hid <<
" to " <<
HcalDetId(
id) << std::endl;
1757 const uint32_t recHitFlag =
hit->flags();
1813 EcalRecHit const& rh = *reinterpret_cast<EcalRecHit const*>(
hit);
1836 std::vector<int>::const_iterator sevit =
1873 return std::make_tuple(