8 #include "art/Utilities/ToolMacros.h"
9 #include "art/Framework/Principal/Handle.h"
10 #include "art_root_io/TFileService.h"
11 #include "messagefacility/MessageLogger/MessageLogger.h"
12 #include "cetlib_except/exception.h"
31 void configure(
const fhicl::ParameterSet& pset)
override;
60 fSignalShaping = art::ServiceHandle<icarusutil::SignalShapingICARUSService>();
76 size_t roiStop(roiStart + roiLen);
77 size_t newRoiStart(roiStart);
78 size_t newRoiStop(roiStop);
82 float basePre = std::accumulate(holder.begin() + roiStart, holder.begin() + roiStart + nBinsToAve, 0.) / float(nBinsToAve);
83 float basePost = std::accumulate(holder.begin() + roiStop - nBinsToAve, holder.begin() + roiStop, 0.) / float(nBinsToAve);
86 float deconNoise = 1.26491 *
fSignalShaping->GetDeconNoise(channel);
90 while(!(fabs(basePre - basePost) < deconNoise) && nTries++ < 3)
92 size_t nBinsToAdd(10);
94 if (newRoiStart < nBinsToAdd) newRoiStart = 0;
95 else newRoiStart -= nBinsToAdd;
96 if (newRoiStop + nBinsToAdd > holder.size()) newRoiStop = holder.size();
97 else newRoiStop += nBinsToAdd;
99 basePre = std::accumulate(holder.begin() + newRoiStart, holder.begin() + newRoiStart + nBinsToAve, 0.) / float(nBinsToAve);
100 basePost = std::accumulate(holder.begin() + newRoiStop - nBinsToAve, holder.begin() + newRoiStop, 0.) / float(nBinsToAve);
104 float maxPre = *std::max_element(holder.begin() + roiStart, holder.begin() + roiStart + nBinsToAve);
105 float minPre = *std::min_element(holder.begin() + roiStart, holder.begin() + roiStart + nBinsToAve);
108 if ((maxPre - minPre) < 4.) base = basePre;
112 size_t roiStop = roiStart + roiLen;
114 float maxPost = *std::max_element(holder.begin() + roiStop - nBinsToAve, holder.begin() + roiStop);
115 float minPost = *std::min_element(holder.begin() + roiStop - nBinsToAve, holder.begin() + roiStop);
117 if ((maxPost - minPost) < 4.) base = basePost;
119 else if ((maxPre - minPre) < 8. && std::fabs(basePre) < std::fabs(basePost)) base = basePre;
120 else if ((maxPost - minPost) < 8. && std::fabs(basePost) < std::fabs(basePre)) base = basePost;
124 float min = *std::min_element(holder.begin()+roiStart,holder.begin()+roiStart+roiLen);
125 float max = *std::max_element(holder.begin()+roiStart,holder.begin()+roiStart+roiLen);
126 int nbin = std::ceil(max - min);
128 TH1F *h1 =
new TH1F(
"h1",
"h1",nbin,min,max);
129 for (
unsigned int bin = roiStart;
bin < roiStart+roiLen;
bin++){
130 h1->Fill(holder[
bin]);
132 int pedBin = h1->GetMaximumBin();
133 float ped = h1->GetBinCenter(pedBin);
134 float ave=0,ncount = 0;
135 for (
unsigned int bin = roiStart;
bin < roiStart+roiLen;
bin++){
136 if (fabs(holder[
bin]-ped)<2){
141 if (ncount==0) ncount=1;
Utilities related to art service access.
This provides an interface for tools which are tasked with finding the baselines in input waveforms...
constexpr details::BinObj< T > bin(T value)
Returns a wrapper to print the specified data in binary format.
unsigned int ChannelID_t
Type representing the ID of a readout channel.