8 #include "art/Utilities/make_tool.h"
9 #include "art/Utilities/ToolMacros.h"
10 #include "art_root_io/TFileService.h"
11 #include "messagefacility/MessageLogger/MessageLogger.h"
12 #include "cetlib_except/exception.h"
19 #include "icarus_signal_processing/Filters/ICARUSFFT.h"
35 void configure(
const fhicl::ParameterSet& pset)
override;
56 std::unique_ptr<icarus_signal_processing::ICARUSFFT<double>>
fFFT;
73 fFFTSize = pset.get<
size_t >(
"FFTSize" );
82 cet::search_path sp(
"FW_SEARCH_PATH");
88 throw cet::exception(
"File not found");
96 while (std::getline(inFile,line))
100 std::stringstream linestream(line);
101 linestream >> channel >> constant;
103 if (channel%1000==0)
std::cout<<
"Channel "<<channel<<
" correction factor "<<
fdQdxCalib[channel]<<std::endl;
108 fBaseline = art::make_tool<icarus_tool::IBaseline> (pset.get<fhicl::ParameterSet>(
"Baseline"));
111 fSignalShaping = art::ServiceHandle<icarusutil::SignalShapingICARUSService>();
114 auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataForJob();
115 fFFT = std::make_unique<icarus_signal_processing::ICARUSFFT<double>>(detProp.NumberTimeSamples());
120 double const samplingRate,
128 for(
auto const& roi : roiVec)
131 size_t roiLen = roi.second - roi.first;
139 if (roiLen > deconSize ) deconSize *= 2;
151 if (deconSize > waveform.size()) deconVec.resize(deconSize, 0.);
155 size_t maxActualSize = std::min(deconSize, waveform.size());
159 size_t halfLeftOver = (maxActualSize - roiLen) / 2;
160 int roiStartInt = halfLeftOver;
161 int roiStopInt = halfLeftOver + roiLen;
162 int firstOffset = roi.first - halfLeftOver;
163 int secondOffset = roi.second + halfLeftOver + roiLen % 2;
170 roiStartInt += firstOffset;
171 roiStopInt += firstOffset;
172 secondOffset -= firstOffset;
176 else if (
size_t(secondOffset) > waveform.size())
178 size_t overshoot = secondOffset - waveform.size();
180 roiStartInt += overshoot;
181 roiStopInt += overshoot;
182 firstOffset -= overshoot;
183 secondOffset = waveform.size();
186 size_t roiStart(roiStartInt);
187 size_t roiStop(roiStopInt);
188 size_t holderOffset = 0;
191 std::copy(waveform.begin()+firstOffset, waveform.begin()+secondOffset, deconVec.begin() + holderOffset);
196 std::vector<float> holder(deconVec.size());
199 if (roiStart > 0 || holderOffset > 0)
std::copy(deconVec.begin() + holderOffset + roiStart, deconVec.begin() + holderOffset + roiStop, holder.begin());
202 holder.resize(roiLen);
205 std::transform(holder.begin(),holder.end(),holder.begin(),[deconNorm](
auto& deconVal){
return deconVal/deconNorm;});
209 float base =
fBaseline->GetBaseline(holder, channel, 0, roiLen);
211 std::transform(holder.begin(),holder.end(),holder.begin(),[base](
const auto& adcVal){
return adcVal - base;});
220 for (
size_t iholder = 0; iholder < holder.size(); ++iholder) holder[iholder] *= constant;
225 ROIVec.
add_range(roi.first, std::move(holder));
Utilities related to art service access.
This provides an interface for tools which are tasked with running the deconvolution algorithm...
const datarange_t & add_range(size_type offset, ITER first, ITER last)
Adds a sequence of elements as a range with specified offset.
This provides an interface for tools which are tasked with finding the baselines in input waveforms...
std::vector< SigProcPrecision > TimeVec
Description of geometry of one entire detector.
if &&[-z"$BASH_VERSION"] then echo Attempting to switch to bash bash shellSwitch exit fi &&["$1"= 'shellSwitch'] shift declare a IncludeDirectives for Dir in
unsigned int ChannelID_t
Type representing the ID of a readout channel.
art framework interface to geometry description
BEGIN_PROLOG could also be cout