From deba3e3e5313443aa5a02cfddbebebafb385e3f8 Mon Sep 17 00:00:00 2001 From: Viktor Pec Date: Tue, 2 Dec 2025 16:03:50 +0100 Subject: [PATCH 1/2] Implementing gains per channel to the deconvolution module. --- .../Deconvolution/Deconvolution_module.cc | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/duneopdet/OpticalDetector/Deconvolution/Deconvolution_module.cc b/duneopdet/OpticalDetector/Deconvolution/Deconvolution_module.cc index 79cf681b..d6c86acf 100644 --- a/duneopdet/OpticalDetector/Deconvolution/Deconvolution_module.cc +++ b/duneopdet/OpticalDetector/Deconvolution/Deconvolution_module.cc @@ -10,6 +10,8 @@ // Modified: // Oct 7, 2024, Viktor Pec // Added possibility to use SPE and noise templates by channel. +// Dec 2, 2025, Viktor Pec +// Adding option to set gains channel by channel. Gains are read from an input file, configurable by fhicl. //============================================================================= #ifndef Deconvolution_h @@ -121,6 +123,7 @@ namespace opdet { fhicl::Sequence IgnoreChannels{ fhicl::Name("IgnoreChannels") }; // integer to allow for channel -1 = unrecognized channel + fhicl::Atom ChannelGainFile{ fhicl::Name("ChannelGainFile") }; // file containing pairs of channel and its corresponding gain in #ADC per SPE struct Filter { fhicl::Atom Name{fhicl::Name("Name"), "Gauss"}; @@ -314,6 +317,9 @@ namespace opdet { std::vector fNoiseDefault; + // Map of channel - gain pairs + std::map fChannelToGainMap; + //--------Filter Variables std::string fOutputProduct; WfmExtraFilter_t fPostfilterConfig; @@ -327,6 +333,7 @@ namespace opdet { int CountFileColumns(const char* file_path); void SourceSPETemplateFiles(); void SourceNoiseTemplateFiles(); + void ReadGains(const char* fname); void BuildExtraFilter(CmplxWaveform_t& xF0, const WfmExtraFilter_t config); void ComputeExpectedInput(std::vector& s, double nmax); void CopyToOutput(const std::vector& v, std::vector& target); @@ -491,6 +498,11 @@ namespace opdet { mfi<<"\n"; + // prepare channel-to-gain map + if (!pars().ChannelGainFile().empty()) + ReadGains(pars().ChannelGainFile().c_str()); + + // info on ignored channels mfi<<"Ignoring channels:\n "; for (auto ch: fIgnoreChannels) @@ -700,6 +712,15 @@ namespace opdet { } // + // Apply gains if available + if (!fChannelToGainMap.empty()) { + // if gains are available then the new scale is normalised to the template's amplitude and then scaled to the requested gain. + // + // there should be gain specified for each channel + // only a single template may be used for all channels - hence the effChannel + scale *= fChannelToGainMap[channel] / fSinglePEAmplitudes[fChannelToTemplateMap[effChannel]]; + } + // Apply pedestal after post-filter for (int i=0; i> channel >> gain; + fChannelToGainMap[channel] = gain; + } + } + + /** * @brief Compute normalization factor for a given filter * From 30e81dfd7bc6325e36d9e63a91856e10a1619184 Mon Sep 17 00:00:00 2001 From: Viktor Pec Date: Wed, 3 Dec 2025 13:37:50 +0100 Subject: [PATCH 2/2] Gains file will now be searched for in FW_SEARCH_PATH. --- .../OpticalDetector/Deconvolution/Deconvolution_module.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/duneopdet/OpticalDetector/Deconvolution/Deconvolution_module.cc b/duneopdet/OpticalDetector/Deconvolution/Deconvolution_module.cc index d6c86acf..05cca030 100644 --- a/duneopdet/OpticalDetector/Deconvolution/Deconvolution_module.cc +++ b/duneopdet/OpticalDetector/Deconvolution/Deconvolution_module.cc @@ -1037,8 +1037,14 @@ namespace opdet { void Deconvolution::ReadGains(const char* fname) { + std::string full_path; + cet::search_path sp("FW_SEARCH_PATH"); + sp.find_file(fname, full_path); + MF_LOG_DEBUG("Deconvolution::ReadGains()")<<"Found SPE template file "<