168 decodedIds.push_back(givenHashId);
169 ATH_MSG_DEBUG(
"A collection already exists in the container for offline id hash. " << (
int)givenHashId);
170 return StatusCode::SUCCESS;
179 return StatusCode::SUCCESS;
185 if (
nullptr == col) {
186 unsigned int coll_hash = givenHashId;
187 ATH_MSG_WARNING(
"Specific CSC Strip PrepData collection retrieving failed for collection hash = " << coll_hash);
188 return StatusCode::SUCCESS;
194 int istation =
m_idHelperSvc->cscIdHelper().stationName(colid) - 49;
198 ATH_MSG_DEBUG(
" Strip collection " << chamber(istation, zsec, phisec) <<
" has " << col->
size() <<
" strips");
201 vector<const CscStripPrepData*> strips[8];
202 int maxstrip[8] = {0, 0, 0, 0, 0, 0, 0, 0};
207 if (MuonDetMgr ==
nullptr) {
208 ATH_MSG_ERROR(
"Null pointer to the MuonDetectorManager conditions object");
209 return StatusCode::FAILURE;
221 int idx = 2 * (wlay - 1) + measphi;
223 if (maxstrip[idx] == 0) {
225 for (
int istrip = 0; istrip < maxstrip[idx]; ++istrip) strips[idx].push_back(
nullptr);
228 if (istrip < 0 || istrip >= maxstrip[idx]) {
232 strips[idx][istrip] = &dig;
237 for (
int measphi = 0; measphi < 2; ++measphi) {
238 for (
int wlay = 1; wlay < 5; ++wlay) {
239 int idx = 2 * (wlay - 1) + measphi;
247 if (pclusters->
addCollection(newCollection, hash).isFailure()) {
248 ATH_MSG_ERROR(
"Couldn't add CscPrepdataCollection to container!");
249 return StatusCode::RECOVERABLE;
251 decodedIds.push_back(hash);
254 return StatusCode::SUCCESS;
266 return StatusCode::SUCCESS;
281 int istation =
m_idHelperSvc->cscIdHelper().stationName(colid) - 49;
284 ATH_MSG_DEBUG(
"**Strip collection " << chamber(istation, zsec, phisec) <<
" sector " <<
m_idHelperSvc->cscIdHelper().sector(colid)
285 <<
" has " << col.
size() <<
" strips");
288 vector<const CscStripPrepData*> strips[8];
289 int maxstrip[8] = {0, 0, 0, 0, 0, 0, 0, 0};
294 if (MuonDetMgr ==
nullptr) {
295 ATH_MSG_ERROR(
"Null pointer to the MuonDetectorManager conditions object");
296 return StatusCode::FAILURE;
308 int idx = 2 * (wlay - 1) + measphi;
310 if (maxstrip[idx] == 0) {
312 for (
int istrip = 0; istrip < maxstrip[idx]; ++istrip) strips[idx].push_back(
nullptr);
315 if (istrip < 0 || istrip >= maxstrip[idx]) {
319 strips[idx][istrip] = &dig;
324 for (
int measphi = 0; measphi < 2; ++measphi) {
325 for (
int wlay = 1; wlay < 5; ++wlay) {
326 int idx = 2 * (wlay - 1) + measphi;
329 <<
" " << wlay <<
"th layer ");
335 if (pclusters->
addCollection(newCollection, hash).isFailure()) {
336 ATH_MSG_ERROR(
"Couldn't add CscPrepdataCollection to container!");
337 return StatusCode::FAILURE;
339 decodedIds.push_back(hash);
343 return StatusCode::SUCCESS;
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) {
399 if (
m_idHelperSvc->cscIdHelper().get_channel_hash(stripId, stripHash)) {
401 <<
" the identifier is \n" << stripId);
406 float stripNoise = 0;
417 if (isBadChannel) active =
false;
421 ostringstream strlog;
422 strlog <<
" Strip " << setw(3) << istrip + 1 <<
": charge= " << setw(7) << int(
res.charge) <<
" dcharge= " << setw(7)
424 if (std::fabs(
res.time) < 1e8)
425 strlog <<
" time=" << setw(3) << int(
res.time + 0.5);
427 strlog <<
" time=OVERFLOW";
430 else if (isBadChannel)
438 strlog <<
" :" <<
res.status;
442 allStripfits.push_back(
res);
443 astrip.push_back(active);
444 bstrip.push_back(isBadChannel);
454 std::vector<bool> rstrip;
455 bool IsAnyStripRecovered =
false;
456 for (
unsigned int istrip = 0; istrip < strips.size(); ++istrip) {
457 bool adjacentActive =
false;
458 if (bstrip[istrip]) {
459 if (istrip > 0 && astrip[istrip - 1]) adjacentActive =
true;
460 if (istrip + 1 < strips.size() && astrip[istrip + 1]) adjacentActive =
true;
461 if (adjacentActive) IsAnyStripRecovered =
true;
463 rstrip.push_back(adjacentActive);
467 if (IsAnyStripRecovered) {
470 ostringstream checklog1;
471 ostringstream checklog2;
473 for (
unsigned int istrip = 0; istrip < strips.size(); ++istrip) {
474 if (istrip % 24 == 0) checklog1 <<
"\n";
475 checklog1 << int(astrip[istrip]) <<
" ";
477 if (!astrip[istrip] && rstrip[istrip]) {
480 if (istrip % 24 == 0) checklog2 <<
"\n";
481 checklog2 << int(astrip[istrip]) <<
" ";
488 for (
unsigned int istrip = 0; istrip < strips.size(); ++istrip) {
489 if (!astrip[istrip] && rstrip[istrip]) {
490 astrip[istrip] = rstrip[istrip];
499 vector<unsigned int> strip0s;
500 vector<unsigned int> nstrips;
505 bool incluster =
false;
506 for (
unsigned int istrip = 0; istrip < strips.size(); ++istrip) {
508 if (!astrip[istrip])
continue;
509 assert(strips[istrip] != 0);
514 first_strip = istrip;
520 if (istrip != maxstrip - 1 && astrip[istrip + 1])
continue;
523 if (!measphi && nstrip < 3) {
524 bool collectLeftStrip =
false;
525 bool collectRightStrip =
false;
528 if (
int(istrip) >= nstrip
529 && istrip + 1 < maxstrip
530 && (allStripfits[istrip - 1].
charge > 0.1 && allStripfits[istrip + 1].
charge > 0.1)
531 && strips[istrip - 1] && strips[istrip + 1]) {
532 collectLeftStrip =
true;
533 collectRightStrip =
true;
535 }
else if (nstrip == 2) {
536 if (allStripfits[istrip - 1].
charge > allStripfits[istrip].
charge) {
537 if (
int(istrip) >= nstrip
538 && allStripfits[istrip - 2].
charge > 0.1
539 && strips[istrip - 2])
540 collectLeftStrip =
true;
542 if (istrip + 1 < maxstrip &&
543 allStripfits[istrip + 1].
charge > 0.1
544 && strips[istrip + 1])
545 collectRightStrip =
true;
549 if (collectLeftStrip) {
550 first_strip = first_strip - 1;
553 if (collectRightStrip) { nstrip += 1; }
557 ostringstream narrowlog;
558 narrowlog <<
" ** narrow Clusters " << first_strip + 1 <<
" " << nstrip <<
" L:R " << collectLeftStrip <<
" "
559 << collectRightStrip;
560 for (
int i = 0; i < nstrip; ++i) { narrowlog <<
" " << allStripfits[first_strip + i].charge; }
561 for (
int i = 0; i < nstrip; ++i) { narrowlog <<
" " << strips[first_strip + i]; }
566 strip0s.push_back(first_strip);
567 nstrips.push_back(nstrip);
579 vector<unsigned int> newStrip0s;
580 vector<unsigned int> newNstrips;
583 for (
unsigned int icl = 0; icl < nstrips.size(); ++icl) {
584 unsigned int nstrip = nstrips[icl];
585 unsigned int strip0 = strip0s[icl];
587 ATH_MSG_VERBOSE(
" " << icl <<
"th cluster merger " << strip0 <<
" " << nstrip);
593 if (icl > 0 && (strip0 == strip0s[icl - 1] + nstrips[icl - 1])) {
594 unsigned int newStrip0 = strip0s[icl - 1];
595 unsigned int newNstrip = nstrips[icl - 1] + nstrip;
597 ATH_MSG_DEBUG(
" " << icl <<
" ** narrow Cluster merger Type I" << newStrip0 <<
" " << newNstrip);
599 newStrip0s[icl - 1 - nMerged] = newStrip0;
600 newNstrips[icl - 1 - nMerged] = newNstrip;
605 if (icl + 1 < nstrips.size() && (strip0 + nstrip == strip0s[icl + 1])) {
606 unsigned int newStrip0 = strip0;
607 unsigned int newNstrip = nstrip + nstrips[icl + 1];
609 ATH_MSG_DEBUG(
" " << icl <<
" ** narrow Cluster merger Type II" << newStrip0 <<
" " << newNstrip);
611 newStrip0s.push_back(newStrip0);
612 newNstrips.push_back(newNstrip);
622 newStrip0s.push_back(strip0);
623 newNstrips.push_back(nstrip);
626 if (strip0s.size() != newStrip0s.size()) {
627 ATH_MSG_DEBUG(
" Phase II -> III Merged " << strip0s.size() <<
":" << nstrips.size() <<
" " << newStrip0s.size() <<
":"
628 << newNstrips.size());
629 for (
unsigned int icl = 0; icl < nstrips.size(); ++icl)
630 ATH_MSG_DEBUG(
" *** " << icl <<
" [" << strip0s[icl] <<
"," << strip0s[icl] + nstrips[icl] - 1 <<
"] " << nstrips[icl]);
631 for (
unsigned int icl = 0; icl < newNstrips.size(); ++icl)
632 ATH_MSG_DEBUG(
" ****** " << icl <<
" [" << newStrip0s[icl] <<
"," << newStrip0s[icl] + newNstrips[icl] - 1 <<
"] "
643 std::vector<const CscStripPrepData*> clusterStrips;
644 clusterStrips.reserve(50);
645 std::vector<Identifier> prd_digit_ids;
646 prd_digit_ids.reserve(50);
648 for (
unsigned int icl = 0; icl < newNstrips.size(); ++icl) {
652 unsigned int nstrip = newNstrips[icl];
653 unsigned int strip0 = newStrip0s[icl];
656 clusterStrips.clear();
657 prd_digit_ids.clear();
659 for (
unsigned int ist = strip0; ist < strip0 + nstrip; ++ist) {
663 sfits.push_back(sfit);
664 clusterStrips.push_back(pstrip);
665 prd_digit_ids.push_back(pstrip->
identify());
675 bool leftToFill =
false;
676 bool rightToFill =
false;
688 if (strips[strip0 - 1]) {
690 }
else if (strips[strip0 + 2]) {
693 }
else if (strips[strip0 + 2]) {
699 ATH_MSG_VERBOSE(
" strip0 nstrip filling left or right " << strip0 <<
" " << nstrip <<
" " << leftToFill <<
" "
704 for (
unsigned int i = 0; i < allStripfits.size(); ++i) {
ATH_MSG_VERBOSE(
"index " << i <<
" " << allStripfits[i].
charge); }
708 bool fillTheOtherSide =
false;
710 fillTheOtherSide =
true;
712 if (strips[strip0 - 1] ==
nullptr) fillTheOtherSide =
true;
715 if (strip0 + nstrip >= allStripfits.size()) { fillTheOtherSide =
false; }
717 if (!fillTheOtherSide) {
718 if (strips[strip0 - 1]) {
719 sfits.insert(sfits.begin(), allStripfits[strip0 - 1]);
720 clusterStrips.insert(clusterStrips.begin(), strips[strip0 - 1]);
721 prd_digit_ids.insert(prd_digit_ids.begin(), strips[strip0 - 1]->identify());
723 nstrip = prd_digit_ids.size();
726 if (strips[strip0 + nstrip]) {
727 sfits.push_back(allStripfits[strip0 + nstrip]);
729 clusterStrips.push_back(strips[strip0 + nstrip]);
730 prd_digit_ids.push_back(strips[strip0 + nstrip]->identify());
731 nstrip = prd_digit_ids.size();
737 bool fillTheOtherSide =
false;
738 if (strip0 + nstrip >= allStripfits.size()) {
739 fillTheOtherSide =
true;
741 if (strips[strip0 + nstrip] ==
nullptr) fillTheOtherSide =
true;
744 if (strip0 == 0) { fillTheOtherSide =
false; }
746 if (!fillTheOtherSide) {
747 if (strips[strip0 + nstrip]) {
748 sfits.push_back(allStripfits[strip0 + nstrip]);
749 clusterStrips.push_back(strips[strip0 + nstrip]);
750 prd_digit_ids.push_back(strips[strip0 + nstrip]->identify());
751 nstrip = prd_digit_ids.size();
754 if (strips[strip0 - 1]) {
755 sfits.insert(sfits.begin(), allStripfits[strip0 - 1]);
756 clusterStrips.insert(clusterStrips.begin(), strips[strip0 - 1]);
757 prd_digit_ids.insert(prd_digit_ids.begin(), strips[strip0 - 1]->identify());
759 nstrip = prd_digit_ids.size();
767 std::vector<ICscClusterFitter::Result> results;
772 fitresult = results[0].fitStatus;
776 if (fitresult == 6) {
778 fitresult = results[0].fitStatus;
779 for (
unsigned int i = 0; i < results.size(); ++i)
784 bool precisionFitFailed = fitresult > 0 && fitresult < 20;
786 if (measphi || precisionFitFailed) {
791 oldclustatus =
res.clusterStatus;
796 if (!results.empty()) {
798 fitresult = results[0].fitStatus;
799 if (
msgLvl(MSG::VERBOSE)) {
800 ostringstream deflog;
803 deflog <<
" failed: return=" << fitresult;
805 deflog <<
" succeeded";
811 res.clusterStatus = oldclustatus;
823 unsigned int nresults = results.size();
824 for (
unsigned int ire = 0; ire < nresults; ++ire) {
827 double pos = results[ire].position;
828 double err = results[ire].dposition;
829 unsigned int id_strip = results[ire].strip;
830 double cluster_charge = results[ire].charge;
831 double cluster_time = results[ire].time;
834 if (id_strip >= sfits.size()) {
840 if (id_strip < clusterStrips.size()) pstrip_id = clusterStrips[id_strip];
849 int zsec =
m_idHelperSvc->cscIdHelper().stationEta(cluster_id);
850 int wlay =
m_idHelperSvc->cscIdHelper().wireLayer(cluster_id);
855 if (MuonDetMgr ==
nullptr) {
856 ATH_MSG_ERROR(
"Null pointer to the MuonDetectorManager conditions object");
864 (cov)(0, 0) = err * err;
865 Amg::Vector2D plpos(measphi ? localTrk_pos.y() : localTrk_pos.z(), measphi ? localTrk_pos.z() : localTrk_pos.y());
868 ATH_MSG_DEBUG(
" ID strip: " << first_strip + id_strip <<
"(" << first_strip <<
":" << id_strip <<
")");
874 unsigned int fstrip = results[ire].fstrip;
875 unsigned int lstrip = results[ire].lstrip;
876 std::vector<Identifier> prd_digit_ids_submit;
877 for (
unsigned int ids_index = fstrip; ids_index < lstrip + 1; ++ids_index) {
878 if (ids_index >= prd_digit_ids.size()) {
879 ATH_MSG_WARNING(
"index out of range " << ids_index <<
" size " << prd_digit_ids.size());
882 prd_digit_ids_submit.push_back(prd_digit_ids[ids_index]);
884 unsigned int nstrip = prd_digit_ids_submit.size();
886 ATH_MSG_DEBUG(
" all size: " << strips.size() <<
" " << allStripfits.size());
893 prd_digit_ids_submit,
896 int(cluster_charge + 0.5),
901 newCollection->
size());