Skip to content
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
4 changes: 4 additions & 0 deletions src/MModuleTACCalibration.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this clear redundant with the clear in initialize since you read LoadTACCalFile immediately after Initialize? It's fine to be redundant, I'm just wondering if there's a case where we need both clears.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably redundant, I can revert the last commit.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now, we only clear in LoadTACCalFile
(which is where these vectors are populated)

if (StripMap == nullptr) {
if (g_Verbosity >= c_Error) cout<<m_XmlTag<<": Error: A strip map is required to assign detector, side, and strip to the entries of the TAC calibration file "<<FName<<endl;
return false;
Expand Down
24 changes: 24 additions & 0 deletions unittests/UTNModuleTACCalibration.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<MString> 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 = Evaluate("LoadTACCalFile()", "reloading partial TAC calibration file", "The table contains exactly one entry", (unsigned int) PartialTable.size(), 1U) && Passed;
Passed = 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;
}
Expand Down
Loading