diff --git a/reco/detectors/trd/CbmTrdModuleRecR.cxx b/reco/detectors/trd/CbmTrdModuleRecR.cxx index e684b6ac813f477c4d334e719904b643304b3451..fb4cb6e5842275a9e7a8eec9f75f7b65a064ffc5 100644 --- a/reco/detectors/trd/CbmTrdModuleRecR.cxx +++ b/reco/detectors/trd/CbmTrdModuleRecR.cxx @@ -199,6 +199,14 @@ Int_t CbmTrdModuleRecR::FindClusters(bool) // triggerId<<" ncols: " << ncols<<std::endl; std::get<1>(*mainit) = true; + // already seal the cluster if the main trigger is already at the right or left padrow border + if (channel % ncols == ncols - 1) { + sealtopcol = true; + } + if (channel % ncols == 0) { + sealbotcol = true; + } + // Bool_t mergerow=CbmTrdClusterFinder::HasRowMerger(); Bool_t mergerow = true; // loop to find the other pads corresponding to the main trigger @@ -240,12 +248,12 @@ Int_t CbmTrdModuleRecR::FindClusters(bool) counterbot++; std::get<0>(botdigi) = d; } - if (ch == (channel - ncols) - 1 && rowchange && !std::get<1>(*FNit)) { + if (ch == (channel - ncols) - 1 && rowchange && !std::get<1>(*FNit) && !sealbotcol) { bufferbot[1] = charge; counterbot++; std::get<1>(botdigi) = d; } - if (ch == (channel - ncols) + 1 && rowchange && !std::get<1>(*FNit)) { + if (ch == (channel - ncols) + 1 && rowchange && !std::get<1>(*FNit) && !sealtopcol) { bufferbot[2] = charge; counterbot++; std::get<2>(botdigi) = d; @@ -257,23 +265,23 @@ Int_t CbmTrdModuleRecR::FindClusters(bool) countertop++; std::get<0>(topdigi) = d; } - if (ch == (channel + ncols) - 1 && rowchange && !std::get<1>(*FNit)) { + if (ch == (channel + ncols) - 1 && rowchange && !std::get<1>(*FNit) && !sealbotcol) { buffertop[1] = charge; countertop++; std::get<1>(topdigi) = d; } - if (ch == (channel + ncols) + 1 && rowchange && !std::get<1>(*FNit)) { + if (ch == (channel + ncols) + 1 && rowchange && !std::get<1>(*FNit) && !sealtopcol) { buffertop[2] = charge; countertop++; std::get<2>(topdigi) = d; } - if (ch == channel - 1) { + if (ch == channel - 1 && !sealbotcol) { bufferrow[1] = charge; counterrow++; std::get<1>(topdigi) = d; } - if (ch == channel + 1) { + if (ch == channel + 1 && !sealtopcol) { bufferrow[2] = charge; counterrow++; std::get<2>(topdigi) = d; @@ -294,7 +302,7 @@ Int_t CbmTrdModuleRecR::FindClusters(bool) // logical implementation of the trigger logic in the same row as the // main trigger - if (ch == lowcol - 1 && triggertype == CbmTrdDigi::eTriggerType::kSelf && !std::get<1>(*FNit)) { + if (ch == lowcol - 1 && triggertype == CbmTrdDigi::eTriggerType::kSelf && !std::get<1>(*FNit) && !sealbotcol) { cluster.push_back(std::make_pair(digiid, d)); lowcol = ch; dmain++; @@ -303,7 +311,7 @@ Int_t CbmTrdModuleRecR::FindClusters(bool) std::cout << " time: " << newtime << " charge: " << charge << " col: " << col << " row: " << ch / ncols << " trigger: " << trigger << std::endl; } - if (ch == highcol + 1 && triggertype == CbmTrdDigi::eTriggerType::kSelf && !std::get<1>(*FNit)) { + if (ch == highcol + 1 && triggertype == CbmTrdDigi::eTriggerType::kSelf && !std::get<1>(*FNit) && !sealtopcol) { cluster.push_back(std::make_pair(digiid, d)); highcol = ch; dmain++; @@ -332,7 +340,9 @@ Int_t CbmTrdModuleRecR::FindClusters(bool) std::cout << " time: " << newtime << " charge: " << charge << " col: " << col << " row: " << ch / ncols << " trigger: " << trigger << std::endl; } - if (col == ncols) { sealtopcol = true; } + if (col == ncols - 1) { + sealtopcol = true; + } if (col == 0) { sealbotcol = true; } if (mergerow) { @@ -351,19 +361,27 @@ Int_t CbmTrdModuleRecR::FindClusters(bool) dmain++; std::get<1>(*FNit) = true; } + /* apuntke, Mar 19 2024: I think it is possible that simultaneously the above and below rows get added in + this code and this is not taken into account in the following 4 blocks, since the two variables indicating + if the cluster is sealed on the sides in the added row (sealtoprow & sealbotrow) are simultaneously used + for both cases (top row merged (addtop==true) and bottom row merged (addbot==true)). + This needs to be investigated further. + */ if (rowchange && ch == lowrow - 1 && lowrow != channel && triggertype == CbmTrdDigi::eTriggerType::kSelf - && !std::get<1>(*FNit)) { + && !std::get<1>(*FNit) && !sealbotrow) { cluster.push_back(std::make_pair(digiid, d)); lowrow = ch; dmain++; std::get<1>(*FNit) = true; + if (lowrow % ncols == 0) sealbotrow = true; } if (rowchange && ch == highrow + 1 && highrow != channel && triggertype == CbmTrdDigi::eTriggerType::kSelf - && !std::get<1>(*FNit)) { + && !std::get<1>(*FNit) && !sealtoprow) { cluster.push_back(std::make_pair(digiid, d)); highrow = ch; dmain++; std::get<1>(*FNit) = true; + if (highrow % ncols == ncols - 1) sealtoprow = true; } if (rowchange && ch == highrow + 1 && highrow != channel && triggertype == CbmTrdDigi::eTriggerType::kNeighbor && !std::get<1>(*FNit) && !sealtoprow) { @@ -586,6 +604,8 @@ bool CbmTrdModuleRecR::IsClusterComplete(const CbmTrdCluster* cluster) { int colMin = fDigiPar->GetNofColumns(); int rowMin = fDigiPar->GetNofRows(); + int colMax = 0; + int rowMax = 0; for (int i = 0; i < cluster->GetNofDigis(); ++i) { const CbmTrdDigi* digi = CbmDigiManager::Instance()->Get<CbmTrdDigi>(cluster->GetDigi(i)); @@ -594,10 +614,12 @@ bool CbmTrdModuleRecR::IsClusterComplete(const CbmTrdCluster* cluster) if (digiCol < colMin) colMin = digiCol; if (digiRow < rowMin) rowMin = digiRow; + if (digiCol > colMax) colMax = digiCol; + if (digiRow > rowMax) rowMax = digiRow; } - const UShort_t nCols = cluster->GetNCols(); - const UShort_t nRows = cluster->GetNRows(); + const UShort_t nCols = colMax - colMin + 1; + const UShort_t nRows = rowMax - rowMin + 1; CbmTrdDigi* digiMap[nRows][nCols]; //create array on stack for optimal performance memset(digiMap, 0, sizeof(CbmTrdDigi*) * nCols * nRows); //init with nullpointers