Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protect SiStripTkMaps in case of empty inputs, also test for it in unit tests #45966

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions DQM/TrackerRemapper/src/SiStripTkMaps.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,14 @@ void SiStripTkMaps::drawMap(TCanvas& canvas, std::string option) {
}

// Adjust the color palette
double minValue = *std::min_element(m_values.begin(), m_values.end());
double maxValue = *std::max_element(m_values.begin(), m_values.end());
if (!m_values.empty()) {
double minValue = *std::min_element(m_values.begin(), m_values.end());
double maxValue = *std::max_element(m_values.begin(), m_values.end());

// Setting a palette that skips the color for the emptyBinValue
m_trackerMap->SetMinimum(minValue); // Set min to the smallest valid value
m_trackerMap->SetMaximum(maxValue); // Set max to the largest valid value
// Setting a palette that skips the color for the emptyBinValue
m_trackerMap->SetMinimum(minValue); // Set min to the smallest valid value
m_trackerMap->SetMaximum(maxValue); // Set max to the largest valid value
}

canvas.cd();
adjustCanvasMargins(canvas.cd(), tmargin_, bmargin_, lmargin_, rmargin_);
Expand Down Expand Up @@ -307,8 +309,8 @@ void SiStripTkMaps::readVertices(double& minx, double& maxx, double& miny, doubl
}
++iy;
} // else
} // else
} // loop on entries
} // else
} // loop on entries

if (isPixel) {
continue;
Expand Down
9 changes: 9 additions & 0 deletions DQM/TrackerRemapper/test/test_catch2_SiStripTkMaps.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,13 @@ TEST_CASE("SiStripTkMaps testing", "[SiStripTkMaps]") {
std::cout << "SiStripTkMaps filled " << filledIds.size() << " DetIds" << std::endl;
REQUIRE(filledIds.size() == count);
}
//_____________________________________________________________
SECTION("Check empty SiStripTkMaps") {
SiStripTkMaps theMap("COLZA L");
theMap.bookMap("testing SiStripTkMaps", "counts");
TCanvas c = TCanvas("c", "c");
theMap.drawMap(c, "");
c.SaveAs("SiStripsEmptyTkMaps.png");
REQUIRE(true);
}
}