-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set the TA pars correctly by TAMakerADCSimpleWindow #91
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ArturSztuc,
Thanks for spotting this and improving. I have few comments:
- there is no need to initialize several variables if we are later overwriting them (ie ta.time_start is set on line 91 and then changed in the tp loop later); unless we are afraid that the
ta.inputs
may be empty ? - this loses the addition of Time-over-Threshold (tot) for the ta.time_end, both in the initial setup and in the tp loop: is that intentional ?
- the tp loop can be made more efficient by using minmax functions, something like this:
if (!ta.inputs.empty()) {
auto [min_time, max_time] = std::minmax_element(
ta.inputs.begin(), ta.inputs.end(),
[](const auto& a, const auto& b) { return a.time_start < b.time_start; });
auto [min_channel, max_channel] = std::minmax_element(
ta.inputs.begin(), ta.inputs.end(),
[](const auto& a, const auto& b) { return a.channel < b.channel; });
ta.time_start = min_time->time_start;
ta.time_end = max_time->time_start;
ta.channel_start = min_channel->channel;
ta.channel_end = max_channel->channel;
// Use std::max_element to find peak ADC efficiently
auto peak_tp = std::max_element(
ta.inputs.begin(), ta.inputs.end(),
[](const auto& a, const auto& b) { return a.adc_peak < b.adc_peak; });
ta.time_peak = peak_tp->time_peak;
ta.adc_peak = peak_tp->adc_peak;
ta.channel_peak = peak_tp->channel;
}
what do you think ?
Pre-setting the min/max elements was needed in my version, otherwise std::max and std::min wouldn't work. Funnily enough As for TOT: this was somewhat intentional. I personally prefer to have TA/TC windows set after time_starts only, since that's how everything is ordered anyway in the DAQ, and then it's the readout-window's job to decide on what raw data window we should actually pull (which would be dependent on drift time, rather than TA length). We have also removed tot from other TAMs because they were causing issues with long TOT TPs. |
I don't mind whether this PR gets in - it is an improvement of what it was. Just wanted to point out that there are several places for improvements long term. Re the ToT and usage for TA/TC ends - this may require a bigger discussion with DS/CoreSw teams as it may actually affect what is read-out. My understanding was that we should be using the ToT for time_ends and instead filter 'bad' TPs (including with long ToTs) upstream. Clearly there is a need for specification, as you said. |
TAMakerADCSimpleWindow
did not set TA parameter correctly: so e.g. thechannel_start
andchannel_end
were the same, based off the very last TP in the window.This PR correct this.
Tested by running drunc offline with
ADCSimpleWindow
with small readout windows, as well as by running emulation on the PD2 data to find some examples of ground shakes -- large ADC, window of 150 ticks, and looking at the hdf5 output. Example plot below.Trigger candidate generated using emulation on PD2HD TPStream, with Trigger Activities generated using the
ADCSimpleWindow
algorithm in red boxes (and black dots representing individual TPs), with TA ADC threshold of 10M, and max window size of 150 ticks each. Red windows extracted from the TA objects.