From 430b01dfaeb157196cbdb8aa82c1b1472e001820 Mon Sep 17 00:00:00 2001 From: Felix Hagemann Date: Mon, 2 Nov 2026 10:18:17 -0800 Subject: [PATCH 1/2] ADD: Unit-tests when reloading a partial TAC calibration file --- unittests/UTNModuleTACCalibration.cxx | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/unittests/UTNModuleTACCalibration.cxx b/unittests/UTNModuleTACCalibration.cxx index feb1cbb0..2e84d74c 100644 --- a/unittests/UTNModuleTACCalibration.cxx +++ b/unittests/UTNModuleTACCalibration.cxx @@ -298,8 +298,32 @@ bool UTNModuleTACCalibration::TestLoadWithStripMap() Passed = EvaluateNear("LoadTACCalFile()", "read-out ID 13", "The TAC calibration slope of read-out ID 13 is 0.48", Table[7][1][41][0], 0.48, 1e-9) && Passed; } + // Reload a partial TAC calibration and check that the previous TAC calibration table was cleared + const MString PartialTACCalFile = GetFixturePath("_partial.csv"); + vector PartialTACCalLines = { "12,7,0,40,0.5,0.005,-1000.0,10.0"}; + Passed = EvaluateTrue("LoadTACCalFile()", "write fixtures", "Partial TAC calibration fixtures can be created", WriteFixture(PartialTACCalFile, PartialTACCalLines)) && Passed; + + g_Verbosity = c_Quiet; + bool PartialResult = Module.LoadTACCalFile(PartialTACCalFile, &StripMap); + g_Verbosity = OldVerbosity; + Passed = EvaluateTrue("LoadTACCalFile()", "reloading partial TAC calibration file", "LoadTACCalFile() succeeds when reloading another TAC calibration file", PartialResult) && Passed; + + TACCalTable PartialTable = Module.GetTACCalParameters(); + Passed = ExpectedToFail(Evaluate("LoadTACCalFile()", "reloading partial TAC calibration file", "The table contains exactly one entry", (unsigned int) PartialTable.size(), 1U)) && Passed; + Passed = ExpectedToFail(EvaluateTrue("LoadTACCalFile()", "reloading partial TAC calibration file", "No entry is stored under the file's detector 3", PartialTable.count(3) == 0)) && Passed; + + bool PartialHasDet7 = PartialTable.count(7) == 1 && PartialTable[7].size() > 0; + Passed = EvaluateTrue("LoadTACCalFile()", "reloading partial TAC calibration file", "Read-out ID 12 is stored under strip-map detector 7, LV, strip 40", PartialHasDet7 && PartialTable[7][0].count(40) == 1) && Passed; + if (PartialHasDet7 && PartialTable[7][0].count(40) == 1 && PartialTable[7][0][40].size() == 4) { + Passed = EvaluateNear("LoadTACCalFile()", "read-out ID 12", "The TAC calibration slope of read-out ID 12 is 0.5", PartialTable[7][0][40][0], 0.5, 1e-9) && Passed; + Passed = EvaluateNear("LoadTACCalFile()", "read-out ID 12", "The TAC calibration offset of read-out ID 12 is -1000.0", PartialTable[7][0][40][1], -1000.0, 1e-9) && Passed; + Passed = EvaluateNear("LoadTACCalFile()", "read-out ID 12", "The TAC calibration slope error of read-out ID 12 is 0.005", PartialTable[7][0][40][2], 0.005, 1e-9) && Passed; + Passed = EvaluateNear("LoadTACCalFile()", "read-out ID 12", "The TAC calibration offset error of read-out ID 12 is 10.0", PartialTable[7][0][40][3], 10.0, 1e-9) && Passed; + } + MFile::Remove(StripMapFile); MFile::Remove(TACCalFile); + MFile::Remove(PartialTACCalFile); return Passed; } From 3ab9beda8e01553666b5cd09de4224c18a1bc6ac Mon Sep 17 00:00:00 2001 From: Felix Hagemann Date: Mon, 2 Nov 2026 10:38:04 -0800 Subject: [PATCH 2/2] FIX: Reloading partial TAC calibration file clears previous parameters --- src/MModuleTACCalibration.cxx | 4 ++++ unittests/UTNModuleTACCalibration.cxx | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/MModuleTACCalibration.cxx b/src/MModuleTACCalibration.cxx index a50b7ada..214f78da 100644 --- a/src/MModuleTACCalibration.cxx +++ b/src/MModuleTACCalibration.cxx @@ -549,6 +549,10 @@ bool MModuleTACCalibration::LoadTACCalFile(MString FName, const MStripMap* Strip // Detector, side, and strip are taken from the strip map via the read-out ID: // The detector column natively holds the DIB ID, and the side column does not account for the ASIC polarities, // thus both are ignored and only the strip column is cross-checked + + m_TACCal.clear(); + m_DetectorIDs.clear(); + if (StripMap == nullptr) { if (g_Verbosity >= c_Error) cout< 0; Passed = EvaluateTrue("LoadTACCalFile()", "reloading partial TAC calibration file", "Read-out ID 12 is stored under strip-map detector 7, LV, strip 40", PartialHasDet7 && PartialTable[7][0].count(40) == 1) && Passed;