7 #include "art/Utilities/ToolMacros.h"
8 #include "art/Utilities/make_tool.h"
9 #include "art_root_io/TFileService.h"
10 #include "messagefacility/MessageLogger/MessageLogger.h"
11 #include "cetlib_except/exception.h"
17 #include "icarus_signal_processing/WaveformTools.h"
35 void configure(
const fhicl::ParameterSet& pset)
override;
96 std::vector<unsigned short> zin;
98 fPlane = pset.get<
size_t> (
"Plane" );
104 if (fOutputHistograms)
108 art::ServiceHandle<art::TFileService>
tfs;
115 fDiffMeanHist = dir.make<TH1F>(
"DiffMean",
";Diff Mean;", 100, -20., 20.);
116 fDiffRmsHist = dir.make<TH1F>(
"DiffRms",
";Diff RMS;", 100, 0., 5.);
117 fDiffMaxHist = dir.make<TH1F>(
"DiffMax",
";Diff Max;", 200, 0., 200.);
118 fNumSigmaHist = dir.make<TH1F>(
"NSigma",
";#sigma;", 200, 0., 50.);
119 fNumSigNextHist = dir.make<TH1F>(
"NSigNext",
";#sigma;", 200, 0., 50.);
120 fDeltaTicksHist = dir.make<TH1F>(
"DeltaTix",
";Delta t", 200, 0., 200.);
122 fDTixVDiffHist = dir.make<TH2F>(
"DTixVDiff",
";Delta t;Max Diff", 200, 0., 200., 200, 0., 200.);
128 if (fNumBinsToAve > 1)
130 for(
int idx = 0; idx < fNumBinsToAve/2; idx++)
132 float weight = idx + 1;
139 if (fNumBinsToAve % 2 > 0)
fAveWeightVec.at(fNumBinsToAve/2) = fNumBinsToAve/2 + 1;
163 if (!histogramMap.empty())
for(
size_t idx = 0; idx < waveform.size(); idx++) histogramMap.at(
caldata::WAVEFORM)->Fill(idx, waveform.at(idx), 1.);
168 if (
std::abs(pedestal) > std::numeric_limits<float>::epsilon())
169 std::transform(waveform.begin(),waveform.end(),smoothWaveform.begin(),[pedestal](
const auto& val){
return val - short(std::round(pedestal));});
181 std::transform(openingVec.begin(),openingVec.end(),closingVec.begin(),averageVec.begin(),[](
const auto&
left,
const auto&
right){
return (
left +
right)/2;});
184 std::transform(smoothWaveform.begin(),smoothWaveform.end(),averageVec.begin(),waveform.begin(),std::minus<short>());
187 if (!histogramMap.empty())
189 for(
size_t idx = 0; idx < waveform.size(); idx++) histogramMap.at(
CORWAVEFORM)->Fill(idx, waveform.at(idx), 1.);
200 outputWaveform.resize(inputWaveform.size());
207 std::fill(tempWaveform.begin(),tempWaveform.begin()+halfBins,0.);
208 std::fill(tempWaveform.end()-halfBins,tempWaveform.end(),0.);
211 std::copy(inputWaveform.begin(),inputWaveform.end(),tempWaveform.begin()+halfBins);
214 for(
size_t idx = 0; idx < inputWaveform.size(); idx++)
216 float weightedSum(0.);
220 outputWaveform.at(idx) = weightedSum /
fWeightSum;
263 size_t cryo = wids[0].Cryostat;
264 size_t tpc = wids[0].TPC;
265 size_t plane = wids[0].Plane;
266 size_t wire = wids[0].Wire;
269 art::TFileDirectory
dir =
fHistDirectory->mkdir(Form(
"MF/ROIPlane_%1zu/c%1zu/c%1zut%1zuwire_%05zu",plane,cnt,cryo,tpc,wire));
276 dir.make<TProfile>(Form(
"MFWfm_%03zu_ctw%01zu-%01zu-%01zu-%05zu",cnt,cryo,tpc,plane,wire),
"Waveform", waveformSize, 0, waveformSize, -500., 500.);
278 dir.make<TProfile>(Form(
"MFEro_%03zu_ctw%01zu-%01zu-%01zu-%05zu",cnt,cryo,tpc,plane,wire),
"Erosion", waveformSize, 0, waveformSize, -500., 500.);
280 dir.make<TProfile>(Form(
"MFDil_%03zu_ctw%01zu-%01zu-%01zu-%05zu",cnt,cryo,tpc,plane,wire),
"Dilation", waveformSize, 0, waveformSize, -500., 500.);
282 dir.make<TProfile>(Form(
"MFAve_%03zu_ctw%01zu-%01zu-%01zu-%05zu",cnt,cryo,tpc,plane,wire),
"Average", waveformSize, 0, waveformSize, -500., 500.);
284 dir.make<TProfile>(Form(
"MFDif_%03zu_ctw%01zu-%01zu-%01zu-%05zu",cnt,cryo,tpc,plane,wire),
"Difference", waveformSize, 0, waveformSize, -500., 500.);
286 dir.make<TProfile>(Form(
"MFOpe_%03zu_ctw%01zu-%01zu-%01zu-%05zu",cnt,cryo,tpc,plane,wire),
"Opening", waveformSize, 0, waveformSize, -500., 500.);
288 dir.make<TProfile>(Form(
"MFClo_%03zu_ctw%01zu-%01zu-%01zu-%05zu",cnt,cryo,tpc,plane,wire),
"Closing", waveformSize, 0, waveformSize, -500., 500.);
292 dir.make<TProfile>(Form(
"MFCor_%03zu_ctw%01zu-%01zu-%01zu-%05zu",cnt,cryo,tpc,plane,wire),
"Corrected Waveform", waveformSize, 0, waveformSize, -500., 500.);
295 std::cout <<
"Caught exception trying to make new hists, tpc,plane,cnt,wire: " << tpc <<
", " <<
fPlane <<
", " << cnt <<
", " << wire << std::endl;
void configure(const fhicl::ParameterSet &pset) override
Utilities related to art service access.
bool fOutputHistograms
Output histograms?
raw::RawDigit::ADCvector_t RawDigitVector
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
void initializeHistograms(art::TFileDirectory &) const override
MorphologicalFilter(const fhicl::ParameterSet &pset)
int fStructuringElement
The window size.
void fill(const art::PtrVector< recob::Hit > &hits, int only_plane)
std::vector< short > Waveform
Description of geometry of one entire detector.
void smoothInputWaveform(const RawDigitVector &, RawDigitVector &) const
art::TFileDirectory * fHistDirectory
int fNumBinsToAve
Controls the smoothing.
icarus_signal_processing::WaveformTools< short > fWaveformTool
This provides an interface for tools which are tasked with filtering input waveforms.
void FilterWaveform(RawDigitVector &, size_t, size_t, float=0.) const override
size_t plane() const override
art::ServiceHandle< art::TFileService > tfs
const geo::GeometryCore * fGeometry
std::map< int, TProfile * > HistogramMap
std::vector< float > fAveWeightVec
Weight vector for smoothing.
process_name can override from command line with o or output caldata
art framework interface to geometry description
BEGIN_PROLOG could also be cout
float fWeightSum
sum of weights for smoothing