25 os << std::get<2>(layer);
35 using LayerPair = std::pair<SeedingLayerSetsBuilder::SeedingLayerId, SeedingLayerSetsBuilder::SeedingLayerId>;
36 using ActiveLayerSetToInactiveSetsMap = std::map<LayerPair, edm::VecArray<LayerPair, 5>>;
37 using Stream = std::stringstream;
38 using Span_t = std::pair<float, float>;
40 ActiveLayerSetToInactiveSetsMap createActiveToInactiveMap() {
41 ActiveLayerSetToInactiveSetsMap
map;
43 auto bpix = [](
int layer) {
46 auto fpix_pos = [](
int disk) {
49 auto fpix_neg = [](
int disk) {
53 auto add_permutations = [&](std::array<SeedingLayerSetsBuilder::SeedingLayerId, 4> quads) {
57 if (quads[0] > quads[1] || quads[2] > quads[3])
60 map[std::make_pair(quads[0], quads[1])].emplace_back(quads[2], quads[3]);
61 }
while (std::next_permutation(quads.begin(), quads.end()));
65 add_permutations({{bpix(1), bpix(2), bpix(3), bpix(4)}});
68 add_permutations({{bpix(1), bpix(2), bpix(3), fpix_pos(1)}});
69 add_permutations({{bpix(1), bpix(2), bpix(3), fpix_neg(1)}});
72 add_permutations({{bpix(1), bpix(2), fpix_pos(1), fpix_pos(2)}});
73 add_permutations({{bpix(1), bpix(2), fpix_neg(1), fpix_neg(2)}});
76 add_permutations({{bpix(1), fpix_pos(1), fpix_pos(2), fpix_pos(3)}});
77 add_permutations({{bpix(1), fpix_neg(1), fpix_neg(2), fpix_neg(3)}});
80 LogDebug(
"PixelInactiveAreaFinder") <<
"Active to inactive mapping";
81 for (
const auto& elem :
map) {
83 for (
const auto& layerPair : elem.second) {
84 ss << layerPair.first <<
"+" << layerPair.second <<
",";
86 LogTrace(
"PixelInactiveAreaFinder") <<
" " << elem.first.first <<
"+" << elem.first.second <<
" => " <<
ss.str();
99 using std::setprecision;
103 ss <<
"subdetid:[" << cspan.
subdetId <<
"]" << deli;
105 ss <<
"layer:[" << cspan.
layer <<
"]" << deli;
107 ss <<
"disk:[" << cspan.
disk <<
"]" << deli;
111 << setprecision(16) << showpos <<
"phi:<" << right << setw(12) << cspan.
phiSpan.first <<
"," << left << setw(12)
112 << cspan.
phiSpan.second <<
">" << deli <<
"z:<" << right << setw(7) << cspan.
zSpan.first <<
"," << left
113 << setw(7) << cspan.
zSpan.second <<
">" << deli << noshowpos <<
"r:<" << right << setw(10) << cspan.
rSpan.first
114 <<
"," << left << setw(10) << cspan.
rSpan.second <<
">" << deli;
120 for (
auto const& spansLayers : spansLayerSets) {
121 ss <<
"Overlapping detGroups:\n";
122 for (
auto const& cspan : spansLayers.first) {
123 detGroupSpanInfo(cspan,
ss);
131 bool phiRangesOverlap(
const Span_t& phiSpanA,
const Span_t& phiSpanB) {
133 std::tie(
x1,
x2) = phiSpanA;
134 std::tie(
y1,
y2) = phiSpanB;
148 bool phiMoreClockwise(
float phiA,
float phiB) {
152 bool phiMoreCounterclockwise(
float phiA,
float phiB) {
158 float zAxisIntersection(
const float zrPointA[2],
const float zrPointB[2]) {
159 return (zrPointB[0] - zrPointA[0]) / (zrPointB[1] - zrPointA[1]) * (-zrPointA[1]) + zrPointA[0];
163 std::pair<float, float>&
range) {
166 if (cspanA.
rSpan.second < cspanB.
rSpan.first) {
169 }
else if (cspanA.
rSpan.first > cspanB.
rSpan.second) {
177 if (cspanUpper.
zSpan.second < cspanLower.
zSpan.first) {
179 const float pointUpperDetGroupL[2] = {cspanUpper.
zSpan.second, cspanUpper.
rSpan.second};
180 const float pointLowerDetGroupL[2] = {cspanLower.
zSpan.first, cspanLower.
rSpan.first};
181 lower = zAxisIntersection(pointUpperDetGroupL, pointLowerDetGroupL);
183 const float pointUpperDetGroupU[2] = {cspanUpper.
zSpan.first, cspanUpper.
rSpan.first};
184 const float pointLowerDetGroupU[2] = {cspanLower.
zSpan.second, cspanLower.
rSpan.second};
185 upper = zAxisIntersection(pointUpperDetGroupU, pointLowerDetGroupU);
186 }
else if (cspanUpper.
zSpan.first <= cspanLower.
zSpan.second && cspanLower.
zSpan.first <= cspanUpper.
zSpan.second) {
188 const float pointUpperDetGroupL[2] = {cspanUpper.
zSpan.second, cspanUpper.
rSpan.first};
189 const float pointLowerDetGroupL[2] = {cspanLower.
zSpan.first, cspanLower.
rSpan.second};
190 lower = zAxisIntersection(pointUpperDetGroupL, pointLowerDetGroupL);
192 const float pointUpperDetGroupU[2] = {cspanUpper.
zSpan.first, cspanUpper.
rSpan.first};
193 const float pointLowerDetGroupU[2] = {cspanLower.
zSpan.second, cspanLower.
rSpan.second};
194 upper = zAxisIntersection(pointUpperDetGroupU, pointLowerDetGroupU);
195 }
else if (cspanUpper.
zSpan.first > cspanLower.
zSpan.second) {
197 const float pointUpperDetGroupL[2] = {cspanUpper.
zSpan.second, cspanUpper.
rSpan.first};
198 const float pointLowerDetGroupL[2] = {cspanLower.
zSpan.first, cspanLower.
rSpan.second};
199 lower = zAxisIntersection(pointUpperDetGroupL, pointLowerDetGroupL);
201 const float pointUpperDetGroupU[2] = {cspanUpper.
zSpan.first, cspanUpper.
rSpan.second};
202 const float pointLowerDetGroupU[2] = {cspanLower.
zSpan.second, cspanLower.
rSpan.first};
203 upper = zAxisIntersection(pointUpperDetGroupU, pointLowerDetGroupU);
208 range = std::pair<float, float>(lower,
upper);
213 std::pair<float, float>&
range) {
219 if (cspanA.
zSpan.first < 0 && cspanB.
zSpan.first < 0) {
220 if (cspanA.
zSpan.second < cspanB.
zSpan.first) {
221 cspanFurther = cspanA;
222 cspanNearer = cspanB;
223 }
else if (cspanB.
zSpan.second < cspanA.
zSpan.first) {
224 cspanFurther = cspanB;
225 cspanNearer = cspanA;
228 LogTrace(
"PixelInactiveAreaFinder") <<
"No overlap, same disk propably. Spans:";
230 detGroupSpanInfo(cspanA,
ss);
232 detGroupSpanInfo(cspanB,
ss);
234 LogTrace(
"PixelInactiveAreaFinder") <<
ss.str();
236 LogTrace(
"PixelInactiveAreaFinder") <<
"**";
240 if (cspanFurther.
rSpan.second > cspanNearer.
rSpan.first) {
241 const float pointA[2] = {cspanFurther.
zSpan.second, cspanFurther.
rSpan.second};
242 const float pointB[2] = {cspanNearer.
zSpan.first, cspanNearer.
rSpan.first};
243 lower = zAxisIntersection(pointA, pointB);
244 if (cspanFurther.
rSpan.first > cspanNearer.
rSpan.second) {
245 const float pointC[2] = {cspanFurther.
zSpan.first, cspanFurther.
rSpan.first};
246 const float pointD[2] = {cspanNearer.
zSpan.second, cspanFurther.
rSpan.second};
247 upper = zAxisIntersection(pointC, pointD);
253 LogTrace(
"PixelInactiveAreaFinder") <<
"No overlap, further detGroup is lower. Spans:";
255 detGroupSpanInfo(cspanA,
ss);
257 detGroupSpanInfo(cspanB,
ss);
259 LogTrace(
"PixelInactiveAreaFinder") <<
ss.str();
261 LogTrace(
"PixelInactiveAreaFinder") <<
"**";
265 }
else if (cspanA.
zSpan.first > 0 && cspanB.
zSpan.first > 0) {
266 if (cspanA.
zSpan.first > cspanB.
zSpan.second) {
267 cspanFurther = cspanA;
268 cspanNearer = cspanB;
269 }
else if (cspanB.
zSpan.first > cspanA.
zSpan.second) {
270 cspanFurther = cspanB;
271 cspanNearer = cspanA;
274 LogTrace(
"PixelInactiveAreaFinder") <<
"No overlap, same disk propably. Spans:";
276 detGroupSpanInfo(cspanA,
ss);
278 detGroupSpanInfo(cspanB,
ss);
280 LogTrace(
"PixelInactiveAreaFinder") <<
ss.str();
282 LogTrace(
"PixelInactiveAreaFinder") <<
"**";
286 if (cspanFurther.
rSpan.second > cspanNearer.
rSpan.first) {
287 const float pointA[2] = {cspanFurther.
zSpan.first, cspanFurther.
rSpan.second};
288 const float pointB[2] = {cspanNearer.
zSpan.second, cspanNearer.
rSpan.first};
289 upper = zAxisIntersection(pointA, pointB);
290 if (cspanFurther.
rSpan.first > cspanNearer.
rSpan.second) {
291 const float pointC[2] = {cspanFurther.
zSpan.second, cspanFurther.
rSpan.first};
292 const float pointD[2] = {cspanNearer.
zSpan.first, cspanFurther.
rSpan.second};
293 lower = zAxisIntersection(pointC, pointD);
299 LogTrace(
"PixelInactiveAreaFinder") <<
"No overlap, further detGroup lower. Spans:";
301 detGroupSpanInfo(cspanA,
ss);
303 detGroupSpanInfo(cspanB,
ss);
305 LogTrace(
"PixelInactiveAreaFinder") <<
ss.str();
307 LogTrace(
"PixelInactiveAreaFinder") <<
"**";
313 LogTrace(
"PixelInactiveAreaFinder") <<
"No overlap, different sides of z axis. Spans:";
315 detGroupSpanInfo(cspanA,
ss);
317 detGroupSpanInfo(cspanB,
ss);
319 LogTrace(
"PixelInactiveAreaFinder") <<
ss.str();
321 LogTrace(
"PixelInactiveAreaFinder") <<
"**";
325 range = std::pair<float, float>(lower,
upper);
331 std::pair<float, float>&
range) {
334 if (cspanEnd.
rSpan.second > cspanBar.
rSpan.first) {
335 if (cspanEnd.
zSpan.second < cspanBar.
zSpan.first) {
337 const float pointA[2] = {cspanEnd.
zSpan.second, cspanEnd.
rSpan.second};
338 const float pointB[2] = {cspanBar.
zSpan.first, cspanBar.
rSpan.first};
339 lower = zAxisIntersection(pointA, pointB);
340 if (cspanEnd.
rSpan.first > cspanBar.
rSpan.second) {
342 const float pointC[2] = {cspanEnd.
zSpan.first, cspanEnd.
rSpan.first};
343 const float pointD[2] = {cspanBar.
zSpan.second, cspanBar.
rSpan.second};
344 upper = zAxisIntersection(pointC, pointD);
348 }
else if (cspanEnd.
zSpan.first > cspanBar.
zSpan.second) {
350 const float pointA[2] = {cspanEnd.
zSpan.first, cspanEnd.
rSpan.second};
351 const float pointB[2] = {cspanBar.
zSpan.second, cspanBar.
rSpan.first};
352 upper = zAxisIntersection(pointA, pointB);
353 if (cspanEnd.
rSpan.first > cspanBar.
rSpan.second) {
354 const float pointC[2] = {cspanEnd.
zSpan.second, cspanEnd.
rSpan.first};
355 const float pointD[2] = {cspanBar.
zSpan.first, cspanBar.
rSpan.second};
356 lower = zAxisIntersection(pointC, pointD);
366 range = std::pair<float, float>(lower,
upper);
372 std::pair<edm::VecArray<PixelInactiveAreaFinder::Area, 2>, std::vector<PixelInactiveAreaFinder::LayerSetIndex>>>
377 std::vector<std::pair<VecArray2<Area>, std::vector<LayerSetIndex>>>
ret;
378 for (
auto&
item : spansLayerSets) {
379 auto& innerSpan =
item.first[0];
380 auto& outerSpan =
item.first[1];
383 innerSpan.rSpan.second,
384 innerSpan.phiSpan.first,
385 innerSpan.phiSpan.second,
386 innerSpan.zSpan.first,
387 innerSpan.zSpan.second);
389 outerSpan.rSpan.second,
390 outerSpan.phiSpan.first,
391 outerSpan.phiSpan.second,
392 outerSpan.zSpan.first,
393 outerSpan.zSpan.second);
400 std::vector<std::pair<edm::VecArray<PixelInactiveAreaFinder::DetGroupSpan, 2>,
401 std::vector<PixelInactiveAreaFinder::LayerSetIndex>>>
407 std::vector<std::pair<VecArray2<DetGroupSpan>, std::vector<LayerSetIndex>>>
ret;
410 <<
" z half width " << zwidth;
413 const auto& layerIdxPair = (*inactiveLayerPairIndices_)[
i];
414 const auto& innerSpans = inactiveSpans_[layerIdxPair.first];
415 const auto& outerSpans = inactiveSpans_[layerIdxPair.second];
417 for (
const auto& innerSpan : innerSpans) {
418 for (
const auto& outerSpan : outerSpans) {
419 if (phiRangesOverlap(innerSpan.phiSpan, outerSpan.phiSpan)) {
420 std::pair<float, float>
range(0, 0);
422 bool zOverlap =
false;
423 const auto innerDet = std::get<0>((*
inactiveLayers_)[layerIdxPair.first]);
424 const auto outerDet = std::get<0>((*
inactiveLayers_)[layerIdxPair.second]);
427 zOverlap = getZAxisOverlapRangeBarrel(innerSpan, outerSpan,
range);
429 zOverlap = getZAxisOverlapRangeBarrelEndcap(innerSpan, outerSpan,
range);
432 zOverlap = getZAxisOverlapRangeEndcap(innerSpan, outerSpan,
range);
434 throw cms::Exception(
"LogicError") <<
"Forward->barrel transition is not supported";
444 detGroupSpanInfo(innerSpan,
ss);
446 detGroupSpanInfo(outerSpan,
ss);
447 LogTrace(
"PixelInactiveAreaFinder") <<
" adding areas for active layer sets " <<
ss.str();
464 const std::vector<SeedingLayerSetsBuilder::SeedingLayerId>&
seedingLayers,
467 :
debug_(iConfig.getUntrackedParameter<
bool>(
"debug")),
473 badPixelFEDChannelsTokens_(
474 edm::vector_transform(iConfig.getParameter<std::vector<edm::InputTag>>(
"badPixelFEDChannelCollectionLabels"),
475 [&](
const auto&
tag) { return iC.consumes<PixelFEDChannelCollection>(tag); })) {
478 LogTrace(
"PixelInactiveAreaFinder") <<
"Input layer subdet " << std::get<0>(layer) <<
" side "
479 << static_cast<unsigned int>(std::get<1>(layer)) <<
" layer "
480 << std::get<2>(layer);
484 auto findOrAdd = [&](SeedingLayerId layer) ->
unsigned short {
485 auto found =
std::find(inactiveLayers_.cbegin(), inactiveLayers_.cend(), layer);
486 if (
found == inactiveLayers_.cend()) {
487 auto ret = inactiveLayers_.size();
488 inactiveLayers_.push_back(layer);
495 const auto activeToInactiveMap = createActiveToInactiveMap();
500 for (
const auto& layerSet : seedingLayerSetsLooper.makeRange(
seedingLayers)) {
501 assert(layerSet.size() == 2);
502 auto found = activeToInactiveMap.find(std::make_pair(layerSet[0], layerSet[1]));
503 if (
found == activeToInactiveMap.end()) {
505 <<
"Encountered layer pair " << layerSet[0] <<
"+" << layerSet[1]
506 <<
" not found from the internal 'active layer pairs' to 'inactive layer pairs' mapping; either fix the "
507 "input or the mapping (in PixelInactiveAreaFinder.cc)";
510 LogTrace(
"PixelInactiveAreaFinder") <<
"Input layer set " << layerSet[0] <<
"+" << layerSet[1];
511 for (
const auto& inactiveLayerSet :
found->second) {
512 auto innerInd = findOrAdd(inactiveLayerSet.first);
513 auto outerInd = findOrAdd(inactiveLayerSet.second);
516 inactiveLayerSetIndices_.cbegin(), inactiveLayerSetIndices_.cend(), std::make_pair(innerInd, outerInd));
517 if (
found == inactiveLayerSetIndices_.end()) {
518 inactiveLayerSetIndices_.emplace_back(innerInd, outerInd);
519 layerSetIndexInactiveToActive_.push_back(std::vector<LayerSetIndex>{
i});
521 layerSetIndexInactiveToActive_.at(
std::distance(inactiveLayerSetIndices_.cbegin(),
found))
526 <<
" inactive layer set " << inactiveLayerSet.first <<
"+" << inactiveLayerSet.second;
533 LogDebug(
"PixelInactiveAreaFinder") <<
"All inactive layer sets";
534 for (
const auto& idxPair : inactiveLayerSetIndices_) {
535 LogTrace(
"PixelInactiveAreaFinder") <<
" " << inactiveLayers_[idxPair.first] <<
"+"
536 << inactiveLayers_[idxPair.second];
542 desc.add<std::vector<edm::InputTag>>(
"inactivePixelDetectorLabels",
544 ->setComment(
"One or more DetIdCollections of modules to mask on the fly for a given event");
545 desc.add<std::vector<edm::InputTag>>(
"badPixelFEDChannelCollectionLabels",
547 ->setComment(
"One or more PixelFEDChannelCollections of modules+ROCs to mask on the fly for a given event");
548 desc.add<
bool>(
"ignoreSingleFPixPanelModules",
false);
550 desc.addUntracked<
bool>(
"debug",
false);
551 desc.addUntracked<
bool>(
"createPlottingFiles",
false);
585 for (
const auto& span : container) {
598 doWork(cspans.first);
599 doWork(cspans.second);
605 printOverlapSpans(
ret);
621 <<
"This module supports only a detector with 4 pixel barrel layers, the current geometry has "
626 <<
"This module supports only a detector with 3 pixel forward disks, the current geometry has "
630 std::array<std::array<unsigned short, 100>, 4>
counts = {};
636 <<
"Got a ladder with number " <<
ladder
637 <<
" while the expected maximum was 100; either something is wrong or the maximum has to be increased.";
646 throw cms::Exception(
"LogicError") <<
"Ladder 1 of layer 1 has 0 modules, something fishy is going on.";
650 <<
"; below are number of ladders per layer";
653 for (
unsigned layer = 0; layer < 4; ++layer) {
655 std::count_if(
counts[layer].begin(),
counts[layer].
end(), [](
unsigned short val) {
return val > 0; });
657 <<
"BPix layer " << (layer + 1) <<
" has " <<
nBPixLadders[layer] <<
" ladders";
659 auto fail = std::count_if(
counts[layer].begin(),
counts[layer].
end(), [&](
unsigned short val) {
664 <<
"Layer " << (layer + 1) <<
" had " << fail
665 <<
" ladders whose number of modules/ladder differed from the ladder 1 of layer 1 (" <<
nModulesPerLadder
666 <<
"). Something fishy is going on.";
692 auto addDetId = [&](
const auto id) {
693 const auto detid =
DetId(
id);
694 const auto subdet = detid.subdetId();
707 addDetId(disabledModule.DetID);
714 for (
const auto&
id : *detIds) {
723 iEvent.getByToken(
token, pixelFEDChannelCollectionHandle);
724 for (
const auto& disabledChannels : *pixelFEDChannelCollectionHandle) {
725 addDetId(disabledChannels.detId());
741 using std::noshowpos;
744 using std::setprecision;
749 ss <<
"id:[" << det <<
"]" << deli;
755 ss <<
"layer:[" << layer <<
"]" << deli <<
"ladder:[" << right << setw(2) <<
ladder <<
"]" << deli <<
"module:["
756 << module <<
"]" << deli;
761 ss << left << setw(6) <<
"disk:"
762 <<
"[" << right << disk <<
"]" << deli << left << setw(7) <<
"blade:"
763 <<
"[" << setw(2) << right << blade <<
"]" << deli << left << setw(7) <<
"panel:"
764 <<
"[" << right << panel <<
"]" << deli;
766 float phiA, phiB, zA, zB, rA, rB;
768 tie(phiA, phiB) = detSurface.
phiSpan();
769 tie(zA, zB) = detSurface.zSpan();
770 tie(rA, rB) = detSurface.rSpan();
771 ss << setprecision(16) <<
fixed << showpos << setfill(
' ') <<
"phi:[" << right << setw(12) << phiA <<
"," << left
772 << setw(12) << phiB <<
"]" << deli <<
"z:[" << right << setw(7) << zA <<
"," << left << setw(7) << zB <<
"]"
773 << deli << noshowpos <<
"r:[" << right << setw(10) << rA <<
"," << left << setw(10) << rB <<
"]" << deli;
776 edm::LogPrint(
"PixelInactiveAreaFinder") <<
"Barrel detectors:";
783 edm::LogPrint(
"PixelInactiveAreaFinder") <<
"Endcap detectors;";
791 edm::LogPrint(
"PixelInactiveAreaFinder") <<
"Bad barrel detectors:";
798 edm::LogPrint(
"PixelInactiveAreaFinder") <<
"Endcap detectors;";
809 for (
auto const& detGroup : badDetGroupsBar) {
810 ss << std::setfill(
' ') << std::left << std::setw(16) <<
"DetGroup:";
815 detGroupSpanInfo(cspan,
ss);
817 for (
auto const& det : detGroup) {
823 for (
auto const& detGroup : badDetGroupsEnd) {
824 ss << std::setfill(
' ') << std::left << std::setw(16) <<
"DetGroup:";
829 detGroupSpanInfo(cspan,
ss);
831 for (
auto const& det : detGroup) {
842 for (
auto const& cspan : cspans.first) {
843 detGroupSpanInfo(cspan,
ss);
846 for (
auto const& cspan : cspans.second) {
847 detGroupSpanInfo(cspan,
ss);
855 std::ofstream fsDet(
"DETECTORS.txt");
860 edm::LogPrint(
"PixelInactiveAreaFinder") <<
"Endcap detectors;";
868 std::ofstream fsBadDet(
"BADDETECTORS.txt");
877 fsBadDet <<
ss.rdbuf();
880 std::ofstream fsSpans(
"DETGROUPSPANS.txt");
882 for (
auto const& cspan : cspans.first) {
883 detGroupSpanInfo(cspan,
ss);
886 for (
auto const& cspan : cspans.second) {
887 detGroupSpanInfo(cspan,
ss);
890 fsSpans <<
ss.rdbuf();
899 using std::remove_if;
903 auto const& detId =
DetId(det);
904 unsigned int layer = tTopo->pxbLayer(detId);
905 unsigned int ladder = tTopo->pxbLadder(detId);
906 unsigned int module = tTopo->pxbModule(detId);
909 adj.push_back(tTopo->pxbDetId(layer, ((
ladder - 1) + 1) % nLads + 1, module)());
910 adj.push_back(tTopo->pxbDetId(layer, ((
ladder - 1) - 1 + nLads) % nLads + 1, module)());
913 adj.push_back(tTopo->pxbDetId(layer,
ladder, module + 1)());
915 adj.push_back(tTopo->pxbDetId(layer,
ladder, module - 1)());
917 adj.push_back(tTopo->pxbDetId(layer,
ladder, module + 1)());
918 adj.push_back(tTopo->pxbDetId(layer,
ladder, module - 1)());
921 adj.erase(remove_if(adj.begin(), adj.end(), [&](
auto c) {
return this->
detWorks(
c); }), adj.end());
929 Span_t phiSpan, phiSpanComp;
931 unsigned int disk, diskComp;
934 tie(
z,
ignore) = detSurf.zSpan();
938 auto const& detIdComp =
DetId(detComp);
941 phiSpanComp = detSurfComp.phiSpan();
942 tie(zComp,
ignore) = detSurfComp.zSpan();
943 if (det != detComp && disk == diskComp &&
z * zComp > 0 && phiRangesOverlap(phiSpan, phiSpanComp)) {
944 adj.push_back(detComp);
952 std::queue<det_t> workQueue;
955 foundDets.insert(initDet);
956 workQueue.push(initDet);
958 while (!workQueue.empty()) {
959 workDet = workQueue.front();
968 for (
auto const& badDet : badAdjDets) {
969 if (foundDets.find(badDet) == foundDets.end()) {
971 foundDets.insert(badDet);
972 workQueue.push(badDet);
982 if (foundDets.find(badDet) == foundDets.end()) {
992 if (foundDets.find(badDet) == foundDets.end()) {
1000 detGroups.push_back(adjacentDets);
1008 if (detGroup.empty()) {
1016 using LadderSet = std::set<uint>;
1017 using LadVec = std::vector<uint>;
1019 for (
auto const& det : detGroup) {
1022 LadVec ladv(lads.begin(), lads.end());
1026 uint currentLadder = ladv[0];
1027 uint previousLadder = ladv[(ladv.size() +
i - 1) % ladv.size()];
1029 while ((nLadders + currentLadder - 1) % nLadders == previousLadder) {
1031 currentLadder = ladv[
i % ladv.size()];
1032 previousLadder = ladv[(ladv.size() +
i - 1) % ladv.size()];
1033 if (
i == ladv.size()) {
1039 uint startLadder = currentLadder;
1040 uint endLadder = previousLadder;
1056 DetGroup::const_iterator startDetIter = detGroup.begin();
1057 Span_t phiSpan, phiSpanComp;
1060 phiSpan = tGeom->idToDet(
DetId(*startDetIter))->surface().phiSpan();
1061 for (DetGroup::const_iterator compDetIter = detGroup.begin(); compDetIter != detGroup.end(); ++compDetIter) {
1062 phiSpanComp = tGeom->idToDet(
DetId(*compDetIter))->surface().phiSpan();
1063 if (phiRangesOverlap(phiSpan, phiSpanComp) && phiMoreClockwise(phiSpanComp.first, phiSpan.first) &&
1064 startDetIter != compDetIter) {
1066 if (
counter > detGroup.size()) {
1071 startDetIter = compDetIter;
1073 }
else if (compDetIter == detGroup.end() - 1) {
1078 cspan.
phiSpan.first = phiSpan.first;
1081 DetGroup::const_iterator endDetIter = detGroup.begin();
1084 phiSpan = tGeom->idToDet(
DetId(*endDetIter))->surface().phiSpan();
1085 for (DetGroup::const_iterator compDetIter = detGroup.begin(); compDetIter != detGroup.end(); ++compDetIter) {
1086 phiSpanComp = tGeom->idToDet(
DetId(*compDetIter))->surface().phiSpan();
1087 if (phiRangesOverlap(phiSpan, phiSpanComp) && phiMoreCounterclockwise(phiSpanComp.second, phiSpan.second) &&
1088 endDetIter != compDetIter) {
1090 if (
counter > detGroup.size()) {
1095 endDetIter = compDetIter;
1097 }
else if (compDetIter == detGroup.end() - 1) {
1102 cspan.
phiSpan.second = phiSpan.second;
1105 auto cmpFun = [
this](
det_t detA,
det_t detB) {
1110 auto minmaxIters = std::minmax_element(detGroup.begin(), detGroup.end(), cmpFun);
1115 auto cmpFun = [
this](
det_t detA,
det_t detB) {
1120 auto minmaxIters = std::minmax_element(detGroup.begin(), detGroup.end(), cmpFun);
1125 auto firstDetIt = detGroup.begin();
1126 if (firstDetIt != detGroup.end()) {
1146 for (
auto const& detGroup : badDetGroupsBar) {
1149 cspansBarrel.push_back(cspan);
1151 for (
auto const& detGroup : badDetGroupsEnd) {
1154 cspansEndcap.push_back(cspan);