Skip to content
Snippets Groups Projects

TRD Clusterizer Hotfix

Merged Axel Puntke requested to merge apuntke/cbmroot:trd_clusterizer_hotfix into master
@@ -199,6 +199,14 @@ Int_t CbmTrdModuleRecR::FindClusters(bool)
@@ -199,6 +199,14 @@ Int_t CbmTrdModuleRecR::FindClusters(bool)
// triggerId<<" ncols: " << ncols<<std::endl;
// triggerId<<" ncols: " << ncols<<std::endl;
std::get<1>(*mainit) = true;
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=CbmTrdClusterFinder::HasRowMerger();
Bool_t mergerow = true;
Bool_t mergerow = true;
// loop to find the other pads corresponding to the main trigger
// loop to find the other pads corresponding to the main trigger
@@ -240,12 +248,12 @@ Int_t CbmTrdModuleRecR::FindClusters(bool)
@@ -240,12 +248,12 @@ Int_t CbmTrdModuleRecR::FindClusters(bool)
counterbot++;
counterbot++;
std::get<0>(botdigi) = d;
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;
bufferbot[1] = charge;
counterbot++;
counterbot++;
std::get<1>(botdigi) = d;
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;
bufferbot[2] = charge;
counterbot++;
counterbot++;
std::get<2>(botdigi) = d;
std::get<2>(botdigi) = d;
@@ -257,23 +265,23 @@ Int_t CbmTrdModuleRecR::FindClusters(bool)
@@ -257,23 +265,23 @@ Int_t CbmTrdModuleRecR::FindClusters(bool)
countertop++;
countertop++;
std::get<0>(topdigi) = d;
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;
buffertop[1] = charge;
countertop++;
countertop++;
std::get<1>(topdigi) = d;
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;
buffertop[2] = charge;
countertop++;
countertop++;
std::get<2>(topdigi) = d;
std::get<2>(topdigi) = d;
}
}
if (ch == channel - 1) {
if (ch == channel - 1 && !sealbotcol) {
bufferrow[1] = charge;
bufferrow[1] = charge;
counterrow++;
counterrow++;
std::get<1>(topdigi) = d;
std::get<1>(topdigi) = d;
}
}
if (ch == channel + 1) {
if (ch == channel + 1 && !sealtopcol) {
bufferrow[2] = charge;
bufferrow[2] = charge;
counterrow++;
counterrow++;
std::get<2>(topdigi) = d;
std::get<2>(topdigi) = d;
@@ -294,7 +302,7 @@ Int_t CbmTrdModuleRecR::FindClusters(bool)
@@ -294,7 +302,7 @@ Int_t CbmTrdModuleRecR::FindClusters(bool)
// logical implementation of the trigger logic in the same row as the
// logical implementation of the trigger logic in the same row as the
// main trigger
// 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));
cluster.push_back(std::make_pair(digiid, d));
lowcol = ch;
lowcol = ch;
dmain++;
dmain++;
@@ -303,7 +311,7 @@ Int_t CbmTrdModuleRecR::FindClusters(bool)
@@ -303,7 +311,7 @@ Int_t CbmTrdModuleRecR::FindClusters(bool)
std::cout << " time: " << newtime << " charge: " << charge << " col: " << col << " row: " << ch / ncols
std::cout << " time: " << newtime << " charge: " << charge << " col: " << col << " row: " << ch / ncols
<< " trigger: " << trigger << std::endl;
<< " 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));
cluster.push_back(std::make_pair(digiid, d));
highcol = ch;
highcol = ch;
dmain++;
dmain++;
@@ -332,7 +340,9 @@ Int_t CbmTrdModuleRecR::FindClusters(bool)
@@ -332,7 +340,9 @@ Int_t CbmTrdModuleRecR::FindClusters(bool)
std::cout << " time: " << newtime << " charge: " << charge << " col: " << col << " row: " << ch / ncols
std::cout << " time: " << newtime << " charge: " << charge << " col: " << col << " row: " << ch / ncols
<< " trigger: " << trigger << std::endl;
<< " trigger: " << trigger << std::endl;
}
}
if (col == ncols) { sealtopcol = true; }
if (col == ncols - 1) {
 
sealtopcol = true;
 
}
if (col == 0) { sealbotcol = true; }
if (col == 0) { sealbotcol = true; }
if (mergerow) {
if (mergerow) {
@@ -351,19 +361,27 @@ Int_t CbmTrdModuleRecR::FindClusters(bool)
@@ -351,19 +361,27 @@ Int_t CbmTrdModuleRecR::FindClusters(bool)
dmain++;
dmain++;
std::get<1>(*FNit) = true;
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
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));
cluster.push_back(std::make_pair(digiid, d));
lowrow = ch;
lowrow = ch;
dmain++;
dmain++;
std::get<1>(*FNit) = true;
std::get<1>(*FNit) = true;
 
if (lowrow % ncols == 0) sealbotrow = true;
}
}
if (rowchange && ch == highrow + 1 && highrow != channel && triggertype == CbmTrdDigi::eTriggerType::kSelf
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));
cluster.push_back(std::make_pair(digiid, d));
highrow = ch;
highrow = ch;
dmain++;
dmain++;
std::get<1>(*FNit) = true;
std::get<1>(*FNit) = true;
 
if (highrow % ncols == ncols - 1) sealtoprow = true;
}
}
if (rowchange && ch == highrow + 1 && highrow != channel && triggertype == CbmTrdDigi::eTriggerType::kNeighbor
if (rowchange && ch == highrow + 1 && highrow != channel && triggertype == CbmTrdDigi::eTriggerType::kNeighbor
&& !std::get<1>(*FNit) && !sealtoprow) {
&& !std::get<1>(*FNit) && !sealtoprow) {
@@ -586,6 +604,8 @@ bool CbmTrdModuleRecR::IsClusterComplete(const CbmTrdCluster* cluster)
@@ -586,6 +604,8 @@ bool CbmTrdModuleRecR::IsClusterComplete(const CbmTrdCluster* cluster)
{
{
int colMin = fDigiPar->GetNofColumns();
int colMin = fDigiPar->GetNofColumns();
int rowMin = fDigiPar->GetNofRows();
int rowMin = fDigiPar->GetNofRows();
 
int colMax = 0;
 
int rowMax = 0;
for (int i = 0; i < cluster->GetNofDigis(); ++i) {
for (int i = 0; i < cluster->GetNofDigis(); ++i) {
const CbmTrdDigi* digi = CbmDigiManager::Instance()->Get<CbmTrdDigi>(cluster->GetDigi(i));
const CbmTrdDigi* digi = CbmDigiManager::Instance()->Get<CbmTrdDigi>(cluster->GetDigi(i));
@@ -594,10 +614,12 @@ bool CbmTrdModuleRecR::IsClusterComplete(const CbmTrdCluster* cluster)
@@ -594,10 +614,12 @@ bool CbmTrdModuleRecR::IsClusterComplete(const CbmTrdCluster* cluster)
if (digiCol < colMin) colMin = digiCol;
if (digiCol < colMin) colMin = digiCol;
if (digiRow < rowMin) rowMin = digiRow;
if (digiRow < rowMin) rowMin = digiRow;
 
if (digiCol > colMax) colMax = digiCol;
 
if (digiRow > rowMax) rowMax = digiRow;
}
}
const UShort_t nCols = cluster->GetNCols();
const UShort_t nCols = colMax - colMin + 1;
const UShort_t nRows = cluster->GetNRows();
const UShort_t nRows = rowMax - rowMin + 1;
CbmTrdDigi* digiMap[nRows][nCols]; //create array on stack for optimal performance
CbmTrdDigi* digiMap[nRows][nCols]; //create array on stack for optimal performance
memset(digiMap, 0, sizeof(CbmTrdDigi*) * nCols * nRows); //init with nullpointers
memset(digiMap, 0, sizeof(CbmTrdDigi*) * nCols * nRows); //init with nullpointers
Loading