367 unsigned int maxstrip = strips.size();
369 ATH_MSG_DEBUG(
" Clustering for " << setaphi(measphi) <<
" plane with " << maxstrip <<
" strips");
378 std::vector<bool> astrip;
379 std::vector<bool> bstrip;
383 for (
unsigned int istrip = 0; istrip < strips.size(); ++istrip) {
387 bool isBadChannel =
false;
389 if (!newCollection) {
393 newCollection->setIdentifier(elementId);
399 if (
m_idHelperSvc->cscIdHelper().get_channel_hash(stripId, stripHash)) {
401 <<
" the identifier is ");
407 float stripNoise = 0;
418 if (isBadChannel)
active =
false;
422 ostringstream strlog;
423 strlog <<
" Strip " << setw(3) << istrip + 1 <<
": charge= " << setw(7) <<
int(
res.charge) <<
" dcharge= " << setw(7)
425 if (std::fabs(
res.time) < 1e8)
426 strlog <<
" time=" << setw(3) <<
int(
res.time + 0.5);
428 strlog <<
" time=OVERFLOW";
431 else if (isBadChannel)
439 strlog <<
" :" <<
res.status;
443 allStripfits.push_back(
res);
445 bstrip.push_back(isBadChannel);
455 std::vector<bool> rstrip;
456 bool IsAnyStripRecovered =
false;
457 for (
unsigned int istrip = 0; istrip < strips.size(); ++istrip) {
458 bool adjacentActive =
false;
459 if (bstrip[istrip]) {
460 if (istrip > 0 && astrip[istrip - 1]) adjacentActive =
true;
461 if (istrip + 1 < strips.size() && astrip[istrip + 1]) adjacentActive =
true;
462 if (adjacentActive) IsAnyStripRecovered =
true;
464 rstrip.push_back(adjacentActive);
468 if (IsAnyStripRecovered) {
471 ostringstream checklog1;
472 ostringstream checklog2;
474 for (
unsigned int istrip = 0; istrip < strips.size(); ++istrip) {
475 if (istrip % 24 == 0) checklog1 <<
"\n";
476 checklog1 <<
int(astrip[istrip]) <<
" ";
478 if (!astrip[istrip] && rstrip[istrip]) {
481 if (istrip % 24 == 0) checklog2 <<
"\n";
482 checklog2 <<
int(astrip[istrip]) <<
" ";
489 for (
unsigned int istrip = 0; istrip < strips.size(); ++istrip) {
490 if (!astrip[istrip] && rstrip[istrip]) {
491 astrip[istrip] = rstrip[istrip];
500 vector<unsigned int> strip0s;
501 vector<unsigned int> nstrips;
506 bool incluster =
false;
507 for (
unsigned int istrip = 0; istrip < strips.size(); ++istrip) {
509 if (!astrip[istrip])
continue;
510 assert(strips[istrip] != 0);
515 first_strip = istrip;
521 if (istrip != maxstrip - 1 && astrip[istrip + 1])
continue;
524 if (!measphi && nstrip < 3) {
525 bool collectLeftStrip =
false;
526 bool collectRightStrip =
false;
529 if (
int(istrip) >= nstrip
530 && istrip + 1 < maxstrip
531 && (allStripfits[istrip - 1].
charge > 0.1 && allStripfits[istrip + 1].
charge > 0.1)
532 && strips[istrip - 1] && strips[istrip + 1]) {
533 collectLeftStrip =
true;
534 collectRightStrip =
true;
536 }
else if (nstrip == 2) {
537 if (allStripfits[istrip - 1].
charge > allStripfits[istrip].
charge) {
538 if (
int(istrip) >= nstrip
539 && allStripfits[istrip - 2].
charge > 0.1
540 && strips[istrip - 2])
541 collectLeftStrip =
true;
543 if (istrip + 1 < maxstrip &&
544 allStripfits[istrip + 1].
charge > 0.1
545 && strips[istrip + 1])
546 collectRightStrip =
true;
550 if (collectLeftStrip) {
551 first_strip = first_strip - 1;
554 if (collectRightStrip) { nstrip += 1; }
558 ostringstream narrowlog;
559 narrowlog <<
" ** narrow Clusters " << first_strip + 1 <<
" " << nstrip <<
" L:R " << collectLeftStrip <<
" "
560 << collectRightStrip;
561 for (
int i = 0;
i < nstrip; ++
i) { narrowlog <<
" " << allStripfits[first_strip +
i].charge; }
562 for (
int i = 0;
i < nstrip; ++
i) { narrowlog <<
" " << strips[first_strip +
i]; }
567 strip0s.push_back(first_strip);
568 nstrips.push_back(nstrip);
580 vector<unsigned int> newStrip0s;
581 vector<unsigned int> newNstrips;
584 for (
unsigned int icl = 0; icl < nstrips.size(); ++icl) {
585 unsigned int nstrip = nstrips[icl];
586 unsigned int strip0 = strip0s[icl];
588 ATH_MSG_VERBOSE(
" " << icl <<
"th cluster merger " << strip0 <<
" " << nstrip);
594 if (icl > 0 && (strip0 == strip0s[icl - 1] + nstrips[icl - 1])) {
595 unsigned int newStrip0 = strip0s[icl - 1];
596 unsigned int newNstrip = nstrips[icl - 1] + nstrip;
598 ATH_MSG_DEBUG(
" " << icl <<
" ** narrow Cluster merger Type I" << newStrip0 <<
" " << newNstrip);
600 newStrip0s[icl - 1 - nMerged] = newStrip0;
601 newNstrips[icl - 1 - nMerged] = newNstrip;
606 if (icl + 1 < nstrips.size() && (strip0 + nstrip == strip0s[icl + 1])) {
607 unsigned int newStrip0 = strip0;
608 unsigned int newNstrip = nstrip + nstrips[icl + 1];
610 ATH_MSG_DEBUG(
" " << icl <<
" ** narrow Cluster merger Type II" << newStrip0 <<
" " << newNstrip);
612 newStrip0s.push_back(newStrip0);
613 newNstrips.push_back(newNstrip);
623 newStrip0s.push_back(strip0);
624 newNstrips.push_back(nstrip);
627 if (strip0s.size() != newStrip0s.size()) {
628 ATH_MSG_DEBUG(
" Phase II -> III Merged " << strip0s.size() <<
":" << nstrips.size() <<
" " << newStrip0s.size() <<
":"
629 << newNstrips.size());
630 for (
unsigned int icl = 0; icl < nstrips.size(); ++icl)
631 ATH_MSG_DEBUG(
" *** " << icl <<
" [" << strip0s[icl] <<
"," << strip0s[icl] + nstrips[icl] - 1 <<
"] " << nstrips[icl]);
632 for (
unsigned int icl = 0; icl < newNstrips.size(); ++icl)
633 ATH_MSG_DEBUG(
" ****** " << icl <<
" [" << newStrip0s[icl] <<
"," << newStrip0s[icl] + newNstrips[icl] - 1 <<
"] "
644 std::vector<const CscStripPrepData*> clusterStrips;
645 clusterStrips.reserve(50);
646 std::vector<Identifier> prd_digit_ids;
647 prd_digit_ids.reserve(50);
649 for (
unsigned int icl = 0; icl < newNstrips.size(); ++icl) {
653 unsigned int nstrip = newNstrips[icl];
654 unsigned int strip0 = newStrip0s[icl];
657 clusterStrips.clear();
658 prd_digit_ids.clear();
660 for (
unsigned int ist = strip0; ist < strip0 + nstrip; ++ist) {
664 sfits.push_back(sfit);
665 clusterStrips.push_back(pstrip);
666 prd_digit_ids.push_back(pstrip->
identify());
676 bool leftToFill =
false;
677 bool rightToFill =
false;
689 if (strips[strip0 - 1]) {
691 }
else if (strips[strip0 + 2]) {
694 }
else if (strips[strip0 + 2]) {
700 ATH_MSG_VERBOSE(
" strip0 nstrip filling left or right " << strip0 <<
" " << nstrip <<
" " << leftToFill <<
" "
709 bool fillTheOtherSide =
false;
711 fillTheOtherSide =
true;
713 if (strips[strip0 - 1] ==
nullptr) fillTheOtherSide =
true;
716 if (strip0 + nstrip >= allStripfits.size()) { fillTheOtherSide =
false; }
718 if (!fillTheOtherSide) {
719 if (strips[strip0 - 1]) {
720 sfits.insert(sfits.begin(), allStripfits[strip0 - 1]);
721 clusterStrips.insert(clusterStrips.begin(), strips[strip0 - 1]);
722 prd_digit_ids.insert(prd_digit_ids.begin(), strips[strip0 - 1]->identify());
724 nstrip = prd_digit_ids.size();
727 if (strips[strip0 + nstrip]) {
728 sfits.push_back(allStripfits[strip0 + nstrip]);
730 clusterStrips.push_back(strips[strip0 + nstrip]);
731 prd_digit_ids.push_back(strips[strip0 + nstrip]->
identify());
732 nstrip = prd_digit_ids.size();
738 bool fillTheOtherSide =
false;
739 if (strip0 + nstrip >= allStripfits.size()) {
740 fillTheOtherSide =
true;
742 if (strips[strip0 + nstrip] ==
nullptr) fillTheOtherSide =
true;
745 if (strip0 == 0) { fillTheOtherSide =
false; }
747 if (!fillTheOtherSide) {
748 if (strips[strip0 + nstrip]) {
749 sfits.push_back(allStripfits[strip0 + nstrip]);
750 clusterStrips.push_back(strips[strip0 + nstrip]);
751 prd_digit_ids.push_back(strips[strip0 + nstrip]->
identify());
752 nstrip = prd_digit_ids.size();
755 if (strips[strip0 - 1]) {
756 sfits.insert(sfits.begin(), allStripfits[strip0 - 1]);
757 clusterStrips.insert(clusterStrips.begin(), strips[strip0 - 1]);
758 prd_digit_ids.insert(prd_digit_ids.begin(), strips[strip0 - 1]->identify());
760 nstrip = prd_digit_ids.size();
768 std::vector<ICscClusterFitter::Result>
results;
780 for (
unsigned int i = 0;
i <
results.size(); ++
i)
787 if (measphi || precisionFitFailed) {
792 oldclustatus =
res.clusterStatus;
801 ostringstream deflog;
804 deflog <<
" failed: return=" <<
fitresult;
806 deflog <<
" succeeded";
812 res.clusterStatus = oldclustatus;
824 unsigned int nresults =
results.size();
825 for (
unsigned int ire = 0; ire < nresults; ++ire) {
830 unsigned int id_strip =
results[ire].strip;
831 double cluster_charge =
results[ire].charge;
832 double cluster_time =
results[ire].time;
835 if (id_strip >= sfits.size()) {
841 if (id_strip < clusterStrips.size()) pstrip_id = clusterStrips[id_strip];
850 int zsec =
m_idHelperSvc->cscIdHelper().stationEta(cluster_id);
851 int wlay =
m_idHelperSvc->cscIdHelper().wireLayer(cluster_id);
856 if (MuonDetMgr ==
nullptr) {
857 ATH_MSG_ERROR(
"Null pointer to the MuonDetectorManager conditions object");
866 Amg::Vector2D plpos(measphi ? localTrk_pos.y() : localTrk_pos.z(), measphi ? localTrk_pos.z() : localTrk_pos.y());
869 ATH_MSG_DEBUG(
" ID strip: " << first_strip + id_strip <<
"(" << first_strip <<
":" << id_strip <<
")");
875 unsigned int fstrip =
results[ire].fstrip;
876 unsigned int lstrip =
results[ire].lstrip;
877 std::vector<Identifier> prd_digit_ids_submit;
878 for (
unsigned int ids_index = fstrip; ids_index < lstrip + 1; ++ids_index) {
879 if (ids_index >= prd_digit_ids.size()) {
880 ATH_MSG_WARNING(
"index out of range " << ids_index <<
" size " << prd_digit_ids.size());
883 prd_digit_ids_submit.push_back(prd_digit_ids[ids_index]);
885 unsigned int nstrip = prd_digit_ids_submit.size();
887 ATH_MSG_DEBUG(
" all size: " << strips.size() <<
" " << allStripfits.size());
894 prd_digit_ids_submit,
897 int(cluster_charge + 0.5),
902 newCollection->size());
904 newCollection->push_back(pclus);