Skip to content

Allow for different thresholds for OpHitFinder#36

Draft
asanchezcastillo wants to merge 7 commits intoLArSoft:developfrom
asanchezcastillo:develop
Draft

Allow for different thresholds for OpHitFinder#36
asanchezcastillo wants to merge 7 commits intoLArSoft:developfrom
asanchezcastillo:develop

Conversation

@asanchezcastillo
Copy link

SBND optical reconstruction requires using individual threshold for each channel. This PR incorporates the required changes which are summarized below:

  • Setting an individual individual threshold for each channel requires carrying the channel number information until the specific reconstruction algorithm. Even thought RunHitFinder takes a raw:OpDetWaveform this is later converted to a pmtana::Waveform_t on the Reconstruct method of PulseRecoManager losing the required information about the channel number. The same happens for the Reconstruct method of PMTPulseRecoBase and the RecoPulse method implemented by the reconstruction algorithm. Fortunately enough, both pmtana::Waveform_t and raw::OpDetWaveform inherit from std::vector<> which to the best of my knowledge makes backwards compatibility given just by changing the object we pass into the former methods.
  • Change the relevant peak finder algorithms to allow for individual threshold setting. The lists of threshold per channel must be passed through a fhicl parameter.

@FNALbuild
Copy link
Contributor

A new Pull Request was created by @asanchezcastillo (Alejandro Sánchez Castillo) for develop.

It involves the following packages:

larana

@LArSoft/level-1-managers, @LArSoft/level-2-managers can you please review it and eventually sign? Thanks.

cms-bot commands are listed here

@FNALbuild
Copy link
Contributor

The code-checks are being triggered in jenkins.

@FNALbuild
Copy link
Contributor

-code-checks
Pull request failed code-formatting checks. Please ensure that cetmodules has been setup and execute the following command from the top-level directory of your repository:

format-code \
  larana/OpticalDetector/OpHitFinder/AlgoCFD.cxx \ 
  larana/OpticalDetector/OpHitFinder/AlgoSiPM.cxx \ 
  larana/OpticalDetector/OpHitFinder/AlgoSlidingWindow.cxx

Then commit the changes and push them to your PR branch.

@FNALbuild
Copy link
Contributor

Pull request #36 was updated. @LArSoft/level-1-managers, @LArSoft/level-2-managers can you please check and sign again.

@FNALbuild
Copy link
Contributor

The code-checks are being triggered in jenkins.

@FNALbuild
Copy link
Contributor

+code-checks

@knoepfel
Copy link
Member

@asanchezcastillo, do you intend this PR to be in draft state?

@asanchezcastillo
Copy link
Author

@knoepfel I am marking it as ready for review now. Thanks for asking.

@asanchezcastillo asanchezcastillo marked this pull request as ready for review January 27, 2025 16:26
@absolution1
Copy link

trigger build

@FNALbuild
Copy link
Contributor

The tests are being triggered in jenkins.

@FNALbuild
Copy link
Contributor

@FNALbuild
Copy link
Contributor

Copy link

@absolution1 absolution1 left a comment

Choose a reason for hiding this comment

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

Thank you for the PR. I've added a set of comments about removing the default fcl values.

Comment on lines +34 to +35
_peak_thresh_by_channel = pset.get<bool>("ThreshByChannel", false);
_peak_thresh_vector = pset.get<std::vector<double>>("PeakThreshVector", {});

Choose a reason for hiding this comment

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

It looks like this module is not using fcl validation, so default fcl values should be avoided. Could these be removed from the producer, and then add the parameters to the default fcl?

Copy link
Member

Choose a reason for hiding this comment

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

We suggest a different approach. It looks like two configuration parameters are being used: one that says "use the threshold-by-channel option", and another that says "here are the thresholds by channel". Instead of using two parameters, it is better to use one optional parameter. For example, make this change:

-    //Whether to apply an individual threshold for each channel
-    bool _peak_thresh_by_channel;
-    //Vector of thresholds for each channel
-    std::vector<double> _peak_thresh_vector;
+    //Optional user-specified vector of thresholds for each channel
+    std::optional<std::vector<double>> _peak_thresh_vector;

You would then switch to:

  _peak_thresh_vector = pset.get_if_present<std::vector<double>>("PeakThreshVector");

If _peak_thresh_vector is "engaged" (i.e. there's a value associated with it), then "PeakThreshVector" has been specified in the configuration. If it is not engaged, then there is no configuration parameter present. The check would then look something like:

    if (_peak_thresh_vector) {
      uint ChannelNumber = wf.ChannelNumber();
      if (ChannelNumber >= _peak_thresh_vector->size())
        throw cet::exception("OpHitFinder")
          << "Threshold not found for channel " << ChannelNumber << "\n";
      _peak_thresh = (*_peak_thresh_vector)[ChannelNumber];
    }

: PMTPulseRecoBase(name)
{

_adc_thres_by_channel = pset.get<bool>("ADCThresholdByChannel", false);

Choose a reason for hiding this comment

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

same comment about default values

{

_adc_thres_by_channel = pset.get<bool>("ADCThresholdByChannel", false);
_adc_thres_vector = pset.get<std::vector<float>>("ADCThresVector", {});

Choose a reason for hiding this comment

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

same comment about default values

Comment on lines +29 to +32
_adc_thres_by_channel = pset.get<bool>("ADCThresholdByChannel", false);

_adc_thres_vector = pset.get<std::vector<float>>("ADCThresVector", {});

Choose a reason for hiding this comment

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

default values

@FNALbuild
Copy link
Contributor

Pull request #36 was updated. @LArSoft/level-1-managers, @LArSoft/level-2-managers can you please check and sign again.

@FNALbuild
Copy link
Contributor

The code-checks are being triggered in jenkins.

@FNALbuild
Copy link
Contributor

+code-checks

Copy link
Member

@knoepfel knoepfel left a comment

Choose a reason for hiding this comment

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

@asanchezcastillo, thanks for this PR. The switch from Waveform_t to OpDetWaveform is appropriate. See the comment below regarding configuration. Instead of doing everything with two parameters (which introduces an awkwardness for the user), we suggest doing it with one where no defaults are required.

Comment on lines +34 to +35
_peak_thresh_by_channel = pset.get<bool>("ThreshByChannel", false);
_peak_thresh_vector = pset.get<std::vector<double>>("PeakThreshVector", {});
Copy link
Member

Choose a reason for hiding this comment

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

We suggest a different approach. It looks like two configuration parameters are being used: one that says "use the threshold-by-channel option", and another that says "here are the thresholds by channel". Instead of using two parameters, it is better to use one optional parameter. For example, make this change:

-    //Whether to apply an individual threshold for each channel
-    bool _peak_thresh_by_channel;
-    //Vector of thresholds for each channel
-    std::vector<double> _peak_thresh_vector;
+    //Optional user-specified vector of thresholds for each channel
+    std::optional<std::vector<double>> _peak_thresh_vector;

You would then switch to:

  _peak_thresh_vector = pset.get_if_present<std::vector<double>>("PeakThreshVector");

If _peak_thresh_vector is "engaged" (i.e. there's a value associated with it), then "PeakThreshVector" has been specified in the configuration. If it is not engaged, then there is no configuration parameter present. The check would then look something like:

    if (_peak_thresh_vector) {
      uint ChannelNumber = wf.ChannelNumber();
      if (ChannelNumber >= _peak_thresh_vector->size())
        throw cet::exception("OpHitFinder")
          << "Threshold not found for channel " << ChannelNumber << "\n";
      _peak_thresh = (*_peak_thresh_vector)[ChannelNumber];
    }

@knoepfel
Copy link
Member

@asanchezcastillo, are you able to implement the suggested changes above?

Update to larana v10_00_09
@FNALbuild
Copy link
Contributor

Pull request #36 was updated. @LArSoft/level-1-managers, @LArSoft/level-2-managers can you please check and sign again.

@FNALbuild
Copy link
Contributor

The code-checks are being triggered in jenkins.

@FNALbuild
Copy link
Contributor

+code-checks

@asanchezcastillo
Copy link
Author

Hi @knoepfel. There was a build issue with duneopdet that we are currently tying to fix. I do not think it will take long though, so when we are done I will incorporate the changes into the PR. Thanks!

@lgarren
Copy link
Member

lgarren commented Mar 10, 2025

@asanchezcastillo Do you have time to update this PR now?

@knoepfel knoepfel marked this pull request as draft May 19, 2025 15:17
@knoepfel
Copy link
Member

@asanchezcastillo, we have converted this PR to a draft until DUNE/duneopdet#83 is ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants