Skip to content

StripEnergyThresholdFinder for per-strip slow and fast threshold extraction with diagnostics - #166

Open
JarredMRoberts wants to merge 25 commits into
cositools:develop/emfrom
JarredMRoberts:feature/strip-threshold-finder
Open

StripEnergyThresholdFinder for per-strip slow and fast threshold extraction with diagnostics#166
JarredMRoberts wants to merge 25 commits into
cositools:develop/emfrom
JarredMRoberts:feature/strip-threshold-finder

Conversation

@JarredMRoberts

Copy link
Copy Markdown

Adds a standalone application, StripEnergyThresholdFinder, for computing per-strip slow and fast energy thresholds. Slow thresholds are determined from ADC spectra using a noise peak and trough method, while fast thresholds are determined from dt0/dt1 timing crossover. The tool reads calibrated HDF5 data via MModuleLoaderMeasurementsHDF, applies strip mapping and energy calibration from a YAML configuration, and produces ROOT diagnostic outputs (energy spectra with thresholds, dt0 vs dt1 per strip, and threshold distributions) along with CSV export files. The implementation is self-contained under apps/ and does not modify existing modules. Tested on COSI datasets with consistent threshold behavior and expected diagnostic results. Target branch is develop/em.

@JarredMRoberts

Copy link
Copy Markdown
Author

I still need to fix all of the code style issues and work on some optimizations to speed the code up a bit.

@fhagemann

Copy link
Copy Markdown

Is this different from #143 or making #143 obsolete?

Comment thread apps/StripEnergyThresholdFinder.cxx Outdated
Comment thread apps/StripEnergyThresholdFinder.cxx Outdated
Comment thread apps/StripEnergyThresholdFinder.cxx Outdated
Comment thread apps/StripEnergyThresholdFinder.cxx Outdated
Comment thread apps/StripEnergyThresholdFinder.cxx Outdated
Comment thread apps/StripEnergyThresholdFinder.cxx Outdated
Comment thread apps/StripEnergyThresholdFinder.cxx Outdated
Comment thread apps/StripEnergyThresholdFinder.cxx Outdated
Comment thread apps/StripEnergyThresholdFinder.cxx Outdated
Comment thread apps/StripEnergyThresholdFinder.cxx Outdated
@fhagemann
fhagemann marked this pull request as draft June 23, 2026 21:50
JarredMRoberts and others added 3 commits June 30, 2026 07:33
Co-authored-by: Felix Hagemann <hagemann@berkeley.edu>
Co-authored-by: Felix Hagemann <hagemann@berkeley.edu>
…nventions and integrate energy calibration improvements
@JarredMRoberts
JarredMRoberts marked this pull request as ready for review July 28, 2026 08:40
Comment thread apps/StripEnergyThresholdFinder.cxx Outdated

@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.

Hi Jarred,
I had an extensive look at this app and finally got this to run.
I replied to all comments in this PR, and opened a separate PR onto your fork/branch, addressing some code changes to

  1. get this app running
  2. remove the helper classes by replacing them with existing nuclearizer/megalib code

Here is the PR onto your branch with detailed code changes: JarredMRoberts#1

Comment thread apps/StripEnergyThresholdFinder.cxx Outdated
Comment thread apps/StripEnergyThresholdFinder.cxx Outdated
Comment thread apps/StripEnergyThresholdFinder.cxx Outdated
Comment thread apps/StripEnergyThresholdFinder.cxx Outdated
Comment thread apps/StripEnergyThresholdFinder.cxx Outdated
Comment thread apps/StripEnergyThresholdFinder.cxx Outdated
Comment thread apps/StripEnergyThresholdFinder.cxx Outdated
Comment thread apps/StripEnergyThresholdFinder.cxx Outdated
line->Draw("SAME");

// Legend entry (fix from earlier)
leg->AddEntry(line, "Fast Thresholdeshold", "l");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
leg->AddEntry(line, "Fast Thresholdeshold", "l");
leg->AddEntry(line, "Fast Threshold", "l");

Comment thread apps/StripEnergyThresholdFinder.cxx Outdated
@zoglauer

zoglauer commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

I second not to have an additional parser linked.
You can use the nuclearizer/megalib XML file format instead; your file then would be:

<strip-threshold-finder>
    <input>
        <data_files>
            <file>/path/to/data/file.hdf5</file>
        </data_files>
        <calibration_file>/path/to/calibration/file.ecal</calibration_file>
        <tac_calibration_file>/path/to/tac/calibration/file.csv</tac_calibration_file>
        <strip_map>/path/to/strip/map/file.map</strip_map>
    </input>

    <analysis>
        <!-- number of skipped strips with minimum statistics -->
        <min_entries>10</min_entries> 
        
        <!-- If a threshold cannot be determined set threshold to default value -->
        <fallback_threshold_keV>20</fallback_threshold_keV> 
        
        <!-- limit for locating the low-energy noise peak -->
        <!-- most noise peaks should be between 100 and 250 -->
        <!-- Worst case the ADC max should be set to ~1000 -->
        <noise_search_max_adc>1800</noise_search_max_adc>
    </analysis>
    
    <output>
        <prefix>output_file_prefix</prefix>
    </output>
</strip-threshold-finder>

@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.

One more remark: I got this app to run and got reasonable results for the fast and slow thresholds only when using a dataset taken with NN off.
We might want to always filter out NN events, for this app to also run using datasets taken with NN on.

Comment thread apps/StripEnergyThresholdFinder.cxx
Comment thread .github/workflows/tests.yaml
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.

3 participants