Skip to content

Trim toa final#439

Open
vbe9cs wants to merge 20 commits into
mainfrom
trim_toa_final
Open

Trim toa final#439
vbe9cs wants to merge 20 commits into
mainfrom
trim_toa_final

Conversation

@vbe9cs

@vbe9cs vbe9cs commented Jul 14, 2026

Copy link
Copy Markdown

Updated TRIM_TOA_SCAN to:

  • Fixed issue in the intercepts calculation of the siegel_regression function. Now should use a normal linear regression to find the predicted TRIM_TOA value for our target calib.
  • Reorganized the loops in this command so that the function loops in the following order:
ch
--trim_toa
----CALIB
------i_roc
  • Also now can function for multiple ROCs being attached.
  • Updated to stop after the first event that is found for each channel on each ROC that triggers this "high efficiency threshold" (we want to see when the toa starts firing very actively, not just a fluctuation). Also this is all the data that we are using anyways so it is not causing the regression to be worse at all.
  • Changed efficiency threshold to be when > 95% of the runs return a non-zero TOA value, to make the slope more accurate to where TOA is fully firing.
  • Added portion that saves acquired toa data to a csv file to be analyzed later (using toa_graph.py)
  • Decided to set a target calib value of 75, may change in the future but I have found that 70-110 is around when toa starts to trigger depending on the channel. (NOTE: this value is only applicable to the HIGHRANGE being active)
  • Added skip functionality that skips over a channel if it find that the channel had TOA trigger no times over any of my data collection. This channel has the average TRIM_TOA value of channels on its ROC applied to it. If it is truly not firing this should not affect anything negatively, so this is our best guess of what could be applied to it.
  • Applied a clamp to the max and min value of TRIM_TOA that is being applied, as to not overload the register with an int that is too large for it to be stored

Added in the toa_graph.py file which can be used with the command in terminal:

python toa_graph.py toa_efficiencies.csv [i_roc] [ch]

This file is intended to be good way to visualize if your data is actually following a linear fit, also can be useful to show if your data is not agreeing with the general "sharp S-curve" shape that we are expecting from TOA efficiency as calib increases. PLEASE NOTE: due to the new portion of the code that breaks after the first high efficiency TRIM_TOA value is found it will be visualized as a line of higher dots that then goes back down to 0, this just means that the scan stopped for this value. You can get far more complete understanding of how that channel is behaving if you remove line 173 of trim_toa_scan.cxx and then do a scan, however this will take significantly longer.

image

Added changes to the toa_vref scan to apply a TRIM_TOA value of 63 to so that its TOA_VREF value doesn't cause the collected data to dip back into the pedestal range once a TRIM_TOA value is applied. Also applied changes to the CHANNEL_WIDE_CALIB_SCAN to make it more efficient to run, by removing scanning over PHASE_CX and multiple bx values as this did not seem to affect any of the data created.

@vbe9cs
vbe9cs requested a review from tomeichlersmith as a code owner July 14, 2026 17:59
Comment thread app/tool/algorithm/toa_vref_scan.cxx Outdated
Comment thread app/tool/algorithm/toa_vref_scan.cxx Outdated
Comment thread app/tool/algorithm/trim_toa_scan.cxx
Comment thread app/tool/algorithm/trim_toa_scan.cxx
Comment thread app/tool/algorithm/trim_toa_scan.cxx
Comment thread app/tool/algorithm/trim_toa_scan.cxx Outdated
@tomeichlersmith

Copy link
Copy Markdown
Member

I forgot to say that this is good work :) thank you

also, does this replace #433 and #428 ? (i.e. should I close those PRs and delete those branches?)

This was linked to issues Jul 15, 2026
Co-authored-by: Tom Eichlersmith <31970302+tomeichlersmith@users.noreply.github.com>
vbe9cs and others added 4 commits July 15, 2026 11:54
Co-authored-by: Tom Eichlersmith <31970302+tomeichlersmith@users.noreply.github.com>
Co-authored-by: Tom Eichlersmith <31970302+tomeichlersmith@users.noreply.github.com>

@tomeichlersmith tomeichlersmith left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

After your merge, there are some syntax errors leftover that you need to patch (e.g. the test fails to compile: https://github.com/LDMX-Software/pflib/actions/runs/29757941083/job/88405044333)

I think the actual updates to trim toa are ready, the leftover comments are just cleanup.

Comment thread app/tool/algorithm/toa_vref_scan.cxx Outdated
Comment on lines +201 to +207
return settings;
for (int i_link{0}; i_link < 2; i_link++) {
std::string page{
pflib::utility::string_format("REFERENCEVOLTAGE_%d", i_link)};
settings[i_roc][page]["TOA_VREF"] = target[i_roc][i_link];
}
}
return settings;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

remove this section. It is now incorrect since the toa_vref scan goes over multiple ROCs each with their own links.

Suggested change
return settings;
for (int i_link{0}; i_link < 2; i_link++) {
std::string page{
pflib::utility::string_format("REFERENCEVOLTAGE_%d", i_link)};
settings[i_roc][page]["TOA_VREF"] = target[i_roc][i_link];
}
}
return settings;
return settings;

f << out.c_str() << std::endl;
}
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm guessing this extra curly brace is one of the syntax errors.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
}

Comment thread ana/trim_toa/toa_graph.py
Comment thread app/tool/algorithm/toa_vref_scan.cxx Outdated
Comment on lines +199 to +203
for (int i_link{0}; i_link < 2; i_link++) {
std::string page{
pflib::utility::string_format("REFERENCEVOLTAGE_%d", i_link)};
settings[i_roc][page]["TOA_VREF"] = target[i_roc][i_link];
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is just a copy of the 5 lines above it.

Suggested change
for (int i_link{0}; i_link < 2; i_link++) {
std::string page{
pflib::utility::string_format("REFERENCEVOLTAGE_%d", i_link)};
settings[i_roc][page]["TOA_VREF"] = target[i_roc][i_link];
}

f << out.c_str() << std::endl;
}
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
}

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.

parallelize ToT vref/trim scanning generalize TOA tuning

2 participants