Skip to content

Trapping correction module and app - #184

Open
sophieehaight wants to merge 59 commits into
cositools:develop/emfrom
sophieehaight:trapping_correction_branch
Open

Trapping correction module and app#184
sophieehaight wants to merge 59 commits into
cositools:develop/emfrom
sophieehaight:trapping_correction_branch

Conversation

@sophieehaight

Copy link
Copy Markdown

Contains a new module for applying depth-based charge trapping correction to individual hit energies along with modules with GUI options and GUI expos. The branch also includes an app for characterizing trapping with Cs-137 data. The trapping correction module requires a csv parameter file as input:
detector_0_trapping_parameters.csv
This file can also be found in resource/dee

Comment thread src/MModuleTrappingCorrection.cxx
Comment thread src/MModuleTrappingCorrection.cxx Outdated
@fhagemann

Copy link
Copy Markdown

Can we also remove HasCalibratedTiming() == true from the trapping app and replace by something like HasFastTiming() == true && HasNearestNeighbor() == false (in an effort to completely get rid of HasCalibratedTiming)?

@cositools cositools deleted a comment from codecov-commenter Aug 17, 2026

@fhagemann fhagemann left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Here is my feedback from just looking at the code.
I will also try to compile and run both the module and the app to provide more feedback on that as well! :)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You added some cout lines to this: should this stay, or was this primarily for debugging and can be removed?

Comment thread apps/TrappingCorrectionCs137.cxx
Comment on lines +193 to +194
Usage<<" --emin: minimum Event energy (default 30 keV)"<<endl;
Usage<<" --emax: maximum Event energy (default 5000 kev)"<<endl;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Later it looks like the defaults for --emin and --emax are actually 600 and 700keV, respectively. Can you cross-check all default values in this help message?

Comment on lines +350 to +360
// Read in the input files and make a list of hdf5 files to calibrate
if ((InputFile.GetSubString(InputFile.Length() - 4)) == "hdf5") {
HDFNames.push_back(InputFile);
cout << "hdf names loaded correctly" << endl;
} else if ((InputFile.GetSubString(InputFile.Length() - 3)) == "txt") {
cout << "Reading input file " << InputFile << endl;
cout << "WARNING: When passing a list of files, ensure that you have chosen the correct HDF5 continuous reading mode. Use the --nocontinue option to suppress continuous file reading." << endl;
MFile F;
if (F.Open(InputFile) == false) {
cout << "Error: Failed to open input file." << endl;
} else {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Are there examples for a txt input file?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Do you have an example command to show how to run this app?

@sophieehaight sophieehaight Aug 18, 2026

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.

If you run "TrappingCorrectionCs137 -h" it will tell you the app inputs to run it from the command line

Comment thread src/MModuleTrappingCorrection.cxx
Comment thread src/MModuleTrappingCorrection.cxx Outdated
Comment thread include/MModuleTrappingCorrection.h Outdated
Comment thread include/MModuleTrappingCorrection.h Outdated
MString m_SimCCEFile;

// unordered_map<int, MDDetector*> m_Detectors;
vector<unsigned int> m_DetectorIDs;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What is this used for (other than checking if it is empty)? Can this also go?

Suggested change
vector<unsigned int> m_DetectorIDs;

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.

I think I want to hang on to the error message associated with this variable until I get a chance to test the module on data from multiple detectors at once. If it works well then I think it's okay to remove the error message on lines 134-139

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Then maybe add a // TODO comment prior to lines 134-139 so that we remember :)

@fhagemann

Copy link
Copy Markdown

The example file in resource/dee and the results after applying the inverse charge trapping in the DEE looks reasonable:

image image image image image

@codecov-commenter

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment

Thanks for integrating Codecov - We've got you covered ☂️

Comment thread src/MModuleTrappingCorrection.cxx Outdated
Comment thread src/MGUIOptionsLoaderMeasurementsHDF.cxx
@fhagemann fhagemann linked an issue Aug 18, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Charge Trapping correction

3 participants