8 #include "art/Utilities/ToolMacros.h"
9 #include "art_root_io/TFileService.h"
10 #include "messagefacility/MessageLogger/MessageLogger.h"
11 #include "cetlib_except/exception.h"
26 explicit Filter(
const fhicl::ParameterSet& pset);
30 void configure(
const fhicl::ParameterSet& pset)
override;
31 void setResponse(
size_t numBins,
double correct3D,
double timeScaleFctr)
override;
63 fPlane = pset.get<
size_t>(
"Plane");
64 fParameters = pset.get<std::vector<double>>(
"FilterParametersVec");
75 auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob();
77 double maxFreq = 1.e3 / (2. * samplingRate);
78 double freqRes = maxFreq / double(numBins/2);
80 std::string funcName =
"tempFilter";
84 function.SetRange(0, maxFreq);
91 for(
const auto& parameter :
fParameters)
function.SetParameter(paramIdx++, timeFactor * parameter);
98 double peakVal(std::numeric_limits<double>::min());
100 size_t nyquistBin = numBins/2 + 1;
103 for(
size_t bin = 0;
bin < nyquistBin;
bin++)
106 double freq =
bin * freqRes;
107 double f =
function.Eval(freq);
109 peakVal = std::max(peakVal, f);
115 for(
size_t bin = nyquistBin;
bin < numBins;
bin++)
119 for(
auto& filterValue :
fFilterVec) filterValue = filterValue / peakVal;
131 art::TFileDirectory
dir = histDir.mkdir(dirName.c_str());
133 auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob();
136 double maxFreq = 1.e3 / samplingRate;
137 double minFreq = maxFreq / numBins;
139 TProfile* hist = dir.make<TProfile>(histName.c_str(),
"Filter;Frequency(kHz)", numBins/2, minFreq, 0.5*maxFreq);
143 double freq =
bin * minFreq;
152 DEFINE_ART_CLASS_TOOL(
Filter)
Utilities related to art service access.
std::complex< SigProcPrecision > ComplexVal
std::vector< ComplexVal > FrequencyVec
constexpr details::BinObj< T > bin(T value)
Returns a wrapper to print the specified data in binary format.
This is the interface class for a tool to handle a filter for the overall response.
std::string to_string(WindowPattern const &pattern)
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.