22 const std::vector<int>& v_chstatus,
27 const std::vector<int>& severityToExclude,
28 bool excludeFromCluster)
40 dynamicEThres_(dynamicEThres),
41 v_chstatus_(v_chstatus),
42 v_severitylevel_(severityToExclude),
45 excludeFromCluster_(excludeFromCluster)
65 const std::vector<RectangularEtaPhiRegion>&
regions) {
79 LogTrace(
"EcalClusters") <<
"Cleared vectors, starting clusterization...";
80 LogTrace(
"EcalClusters") <<
" Purple monkey aardvark.";
87 if (!regional || nregions) {
93 auto this_cell =
geometry->getGeometry(it->id());
98 bool withinRegion =
false;
100 std::vector<RectangularEtaPhiRegion>::const_iterator
region;
102 if (
region->inRegion(this_cell->etaPos(), this_cell->phiPos())) {
109 if (!regional || withinRegion) {
111 float ET = it->energy() *
position.basicVector().unit().perp();
113 LogTrace(
"EcalClusters") <<
"Seed crystal: ";
126 std::vector<int>::const_iterator sit =
128 LogTrace(
"EcalClusters") <<
"found flag: " << severityFlag;
135 seeds.push_back(*it);
137 LogTrace(
"EcalClusters") <<
"Seed ET: " <<
ET;
138 LogTrace(
"EcalClsuters") <<
"Seed E: " << it->energy();
145 LogTrace(
"EcalClusters") <<
"Built vector of seeds, about to sort them...";
148 sort(
seeds.begin(),
seeds.end(), [](
auto const&
x,
auto const&
y) {
return x.energy() >
y.energy(); });
153 LogTrace(
"EcalClusters") <<
"About to call mainSearch...";
159 std::map<int, reco::BasicClusterCollection>::iterator bic;
162 for (
int j = 0;
j <
int(bl.size()); ++
j) {
163 basicClusters.push_back(bl[
j]);
170 LogTrace(
"EcalClusters") <<
"returning to producer. ";
174 LogTrace(
"EcalClusters") <<
"HybridClusterAlgo Algorithm - looking for clusters";
175 LogTrace(
"EcalClusters") <<
"Found the following clusters:";
178 std::vector<EcalRecHit>::iterator it;
179 int clustercounter = 0;
181 for (it =
seeds.begin(); it !=
seeds.end(); it++) {
182 std::vector<reco::BasicCluster> thisseedClusters;
183 DetId itID = it->id();
186 std::set<DetId>::iterator seed_in_rechits_it =
useddetids.find(itID);
193 LogTrace(
"EcalClusters") <<
"*****************************************************"
194 <<
"Seed of energy E = " << it->energy() <<
" @ " <<
EBDetId(itID)
195 <<
"*****************************************************";
203 std::vector<double> dominoEnergyPhiPlus;
204 std::vector<std::vector<EcalRecHit> > dominoCellsPhiPlus;
207 std::vector<double> dominoEnergyPhiMinus;
208 std::vector<std::vector<EcalRecHit> > dominoCellsPhiMinus;
211 std::vector<double> dominoEnergy;
212 std::vector<std::vector<EcalRecHit> > dominoCells;
215 std::vector<EcalRecHit> initialdomino;
220 LogTrace(
"EcalClusters") <<
"Made initial domino";
233 for (
int i = 0;
i < phiSteps; ++
i) {
242 std::vector<EcalRecHit> dcells;
246 dominoEnergyPhiPlus.push_back(etemp);
247 dominoCellsPhiPlus.push_back(dcells);
249 LogTrace(
"EcalClusters") <<
"Got positive dominos";
254 for (
int i = 0;
i < phiSteps; ++
i) {
264 std::vector<EcalRecHit> dcells;
268 dominoEnergyPhiMinus.push_back(etemp);
269 dominoCellsPhiMinus.push_back(dcells);
272 LogTrace(
"EcalClusters") <<
"Got negative dominos: ";
275 for (
int i =
int(dominoEnergyPhiMinus.size()) - 1;
i >= 0; --
i) {
276 dominoEnergy.push_back(dominoEnergyPhiMinus[
i]);
277 dominoCells.push_back(dominoCellsPhiMinus[
i]);
279 dominoEnergy.push_back(e_init);
280 dominoCells.push_back(initialdomino);
281 for (
int i = 0;
i <
int(dominoEnergyPhiPlus.size()); ++
i) {
282 dominoEnergy.push_back(dominoEnergyPhiPlus[
i]);
283 dominoCells.push_back(dominoCellsPhiPlus[
i]);
287 LogTrace(
"EcalClusters") <<
"Dumping domino energies: ";
299 std::vector<int> PeakIndex;
300 for (
int i = 1;
i <
int(dominoEnergy.size()) - 1; ++
i) {
301 if (dominoEnergy[
i] > dominoEnergy[
i - 1] && dominoEnergy[
i] >= dominoEnergy[
i + 1] &&
304 PeakIndex.push_back(
i);
308 LogTrace(
"EcalClusters") <<
"Found: " << PeakIndex.size() <<
" peaks.";
311 for (
int i = 0;
i <
int(PeakIndex.size()); ++
i) {
312 for (
int j = 0;
j <
int(PeakIndex.size()) - 1; ++
j) {
313 if (dominoEnergy[PeakIndex[
j]] < dominoEnergy[PeakIndex[
j + 1]]) {
314 int ihold = PeakIndex[
j + 1];
315 PeakIndex[
j + 1] = PeakIndex[
j];
316 PeakIndex[
j] = ihold;
321 std::vector<int> OwnerShip;
322 std::vector<double> LumpEnergy;
323 for (
int i = 0;
i <
int(dominoEnergy.size()); ++
i)
324 OwnerShip.push_back(-1);
329 for (
int i = 0;
i <
int(PeakIndex.size()); ++
i) {
330 int idxPeak = PeakIndex[
i];
331 OwnerShip[idxPeak] =
i;
332 double lump = dominoEnergy[idxPeak];
344 if ((idxPeak + 1) < (
int)dominoEnergy.size())
345 e5x5 += dominoEnergy[idxPeak + 1];
347 if ((idxPeak + 2) < (
int)dominoEnergy.size())
348 e5x5 += dominoEnergy[idxPeak + 2];
350 if ((idxPeak - 1) > 0)
351 e5x5 += dominoEnergy[idxPeak - 1];
353 if ((idxPeak - 2) > 0)
354 e5x5 += dominoEnergy[idxPeak - 2];
363 for (
int j = idxPeak + 1;
j <
int(dominoEnergy.size()); ++
j) {
364 if (OwnerShip[
j] == -1 && dominoEnergy[
j] > eThres && dominoEnergy[
j] <= dominoEnergy[
j - 1]) {
366 lump += dominoEnergy[
j];
372 for (
int j = idxPeak - 1;
j >= 0; --
j) {
373 if (OwnerShip[
j] == -1 && dominoEnergy[
j] > eThres && dominoEnergy[
j] <= dominoEnergy[
j + 1]) {
375 lump += dominoEnergy[
j];
380 LumpEnergy.push_back(lump);
384 for (
int i = 0;
i <
int(PeakIndex.size()); ++
i) {
385 bool HasSeedCrystal =
false;
387 std::vector<EcalRecHit>
recHits;
388 std::vector<std::pair<DetId, float> > dets;
390 for (
int j = 0;
j <
int(dominoEnergy.size()); ++
j) {
391 if (OwnerShip[
j] ==
i) {
392 std::vector<EcalRecHit>
temp = dominoCells[
j];
394 dets.push_back(std::pair<DetId, float>(
temp[
k].
id(), 1.));
395 if (
temp[
k].
id() == itID)
396 HasSeedCrystal =
true;
402 LogTrace(
"EcalClusters") <<
"Adding a cluster with: " <<
nhits;
403 LogTrace(
"EcalClusters") <<
"total E: " << LumpEnergy[
i];
404 LogTrace(
"EcalClusters") <<
"total dets: " << dets.size();
411 std::vector<std::pair<DetId, float> > usedHits;
412 for (
int blarg = 0; blarg <
int(
recHits.size()); ++blarg) {
415 usedHits.push_back(std::make_pair<DetId, float>(
recHits[blarg].
id(), 1.0));
422 if (HasSeedCrystal) {
441 if (!thisseedClusters.empty()) {
442 clustered_.insert(std::make_pair(clustercounter, thisseedClusters));
454 std::map<int, reco::BasicClusterCollection>::iterator mapit;
460 std::vector<reco::BasicCluster> thiscoll = mapit->second;
472 for (
int i = 0;
i <
int(thiscoll.size()); ++
i) {
474 for (
int j = 0;
j <
int(clustersCollection.
size()); ++
j) {
477 if (thisclus == cluster_p) {
485 seed = clustersCollection[
j];
487 ClusterE += cluster_p.
energy();
514 SCcoll.push_back(suCl);
516 LogTrace(
"EcalClusters") <<
"Super cluster sum: " << ClusterE;
517 LogTrace(
"EcalClusters") <<
"Made supercluster with energy E: " << suCl.
energy();
541 cells.push_back(SeedHit);
551 cells.push_back(UpEta);
565 cells.push_back(DownEta);
578 if (ieta2 !=
DetId(0)) {
584 Etot += DownEta2.
energy();
585 cells.push_back(DownEta2);
592 if (ieta1 !=
DetId(0)) {
599 cells.push_back(UpEta2);
611 std::vector<std::pair<DetId, float> > dets;
616 for (
int dx = -2;
dx < 3; ++
dx) {
617 for (
int dy = -2;
dy < 3; ++
dy) {
622 if (thisDet !=
DetId(0)) {
625 dets.push_back(std::pair<DetId, float>(thisDet, 1.));
643 std::vector<std::pair<DetId, float> > dets;
647 for (
int dx = -2;
dx < 3; ++
dx) {
648 for (
int dy = -2;
dy < 3; ++
dy) {
652 if (thisDet !=
DetId(0)) {
655 dets.push_back(std::pair<DetId, float>(thisDet, 1.));
663 return 1 / cosh(
pos.eta());