Skip to content
Snippets Groups Projects
Commit b1aad0e5 authored by Christopher Rob Jones's avatar Christopher Rob Jones
Browse files

RichDetectorHits: Protect against AIDA return nonsense indices

parent 2073f0bb
No related branches found
No related tags found
2 merge requests!3788Draft: Update SciFi cluster monitoring,!3642Performance Updates to RICH Reconstruction
......@@ -24,6 +24,7 @@
#include "AIDA/IAxis.h"
// STD
#include <algorithm>
#include <cstdint>
#include <mutex>
#include <vector>
......@@ -133,8 +134,10 @@ namespace Rich::Future::Rec::Moni {
fillHisto( h_pixXLoc[rich], lPos.X() );
fillHisto( h_pixYLoc[rich], lPos.Y() );
// cache occupancy data
const auto iX = h_pdXYLocOcc[rich]->xAxis().coordToIndex( lPos.X() );
const auto iY = h_pdXYLocOcc[rich]->yAxis().coordToIndex( lPos.Y() );
const auto iX =
std::clamp( h_pdXYOcc[rich]->xAxis().coordToIndex( lPos.X() ), 0, (int)nBins2D() - 1 );
const auto iY =
std::clamp( h_pdXYOcc[rich]->yAxis().coordToIndex( lPos.Y() ), 0, (int)nBins2D() - 1 );
pdOccXY.at( iX ).at( iY ) = rawIDs.size();
}
......@@ -151,14 +154,14 @@ namespace Rich::Future::Rec::Moni {
// Fill occupancies
for ( auto iX = 0u; iX < nBins2D(); ++iX ) {
for ( auto iY = 0u; iY < nBins2D(); ++iY ) {
const auto X = 0.5 * ( h_pdXYLocOcc[rich]->xAxis().binLowerEdge( iX ) +
h_pdXYLocOcc[rich]->xAxis().binUpperEdge( iX ) );
const auto Y = 0.5 * ( h_pdXYLocOcc[rich]->yAxis().binLowerEdge( iY ) +
h_pdXYLocOcc[rich]->yAxis().binUpperEdge( iY ) );
const auto occ = pdOccXY.at( iX ).at( iY );
fillHisto( h_pdXYLocOcc[rich], X, Y, occ );
fillHisto( h_pdXLocOcc[rich], X, occ );
fillHisto( h_pdYLocOcc[rich], Y, occ );
const auto X =
0.5 * ( h_pdXYOcc[rich]->xAxis().binLowerEdge( iX ) + h_pdXYOcc[rich]->xAxis().binUpperEdge( iX ) );
const auto Y =
0.5 * ( h_pdXYOcc[rich]->yAxis().binLowerEdge( iY ) + h_pdXYOcc[rich]->yAxis().binUpperEdge( iY ) );
const auto occ = pdOccXY[iX][iY];
fillHisto( h_pdXYOcc[rich], X, Y, occ );
fillHisto( h_pdXOcc[rich], X, occ );
fillHisto( h_pdYOcc[rich], Y, occ );
}
}
......@@ -264,18 +267,18 @@ namespace Rich::Future::Rec::Moni {
"Local Y hits", //
-panelYsizes[rich], panelYsizes[rich], nBins1D(), //
"Local Y / mm" ) );
ok &= saveAndCheck( h_pdXYLocOcc[rich], //
ok &= saveAndCheck( h_pdXYOcc[rich], //
richProfile2D( HID( "pdOccXYLoc", rich ), //
"PD Average Occupancy (X,Y)", //
-panelXsizes[rich], panelXsizes[rich], nBins2D(), //
-panelYsizes[rich], panelYsizes[rich], nBins2D(), //
"Local X / mm", "Local Y / mm" ) );
ok &= saveAndCheck( h_pdXLocOcc[rich], //
ok &= saveAndCheck( h_pdXOcc[rich], //
richProfile1D( HID( "pdOccXLoc", rich ), //
"PD Average Occupancy (X)", //
-panelXsizes[rich], panelXsizes[rich], nBins2D(), //
"Local X / mm" ) );
ok &= saveAndCheck( h_pdYLocOcc[rich], //
ok &= saveAndCheck( h_pdYOcc[rich], //
richProfile1D( HID( "pdOccYLoc", rich ), //
"PD Average Occupancy (Y)", //
-panelYsizes[rich], panelYsizes[rich], nBins2D(), //
......@@ -317,9 +320,9 @@ namespace Rich::Future::Rec::Moni {
DetectorArray<AIDA::IHistogram1D*> h_pixXLoc = {{}};
DetectorArray<AIDA::IHistogram1D*> h_pixYLoc = {{}};
DetectorArray<AIDA::IProfile2D*> h_pdXYLocOcc = {{}};
DetectorArray<AIDA::IProfile1D*> h_pdXLocOcc = {{}};
DetectorArray<AIDA::IProfile1D*> h_pdYLocOcc = {{}};
DetectorArray<AIDA::IProfile2D*> h_pdXYOcc = {{}};
DetectorArray<AIDA::IProfile1D*> h_pdXOcc = {{}};
DetectorArray<AIDA::IProfile1D*> h_pdYOcc = {{}};
};
// Declaration of the Algorithm Factory
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment