8 #include "art/Utilities/ToolMacros.h"
9 #include "art/Utilities/make_tool.h"
10 #include "art_root_io/TFileService.h"
11 #include "messagefacility/MessageLogger/MessageLogger.h"
12 #include "cetlib_except/exception.h"
14 #include "art_root_io/TFileService.h"
16 #include "icarus_signal_processing/Filters/ICARUSFFT.h"
17 #include "icarus_signal_processing/WaveformTools.h"
34 void configure(
const fhicl::ParameterSet&)
override;
83 std::unique_ptr<icarus_signal_processing::ICARUSFFT<double>>
fFFT;
108 std::string
fileName = fFieldResponseFileName +
"_vw" +
numberToString(fResponseType) +
"_" + fFieldResponseFileVersion +
".root";
110 std::string fullFileName;
111 cet::search_path searchPath(
"FW_SEARCH_PATH");
113 std::cout <<
"************************** Field Response Plane " <<
fThisPlane <<
" type: " << fResponseType <<
" *****************************" << std::endl;
114 std::cout <<
"FileName: " << fullFileName << std::endl;
116 if (!searchPath.find_file(fileName, fullFileName))
117 throw cet::exception(
"FieldResponse::configure") <<
"Can't find input file: '" << fileName <<
"'\n";
119 TFile inputFile(fullFileName.c_str(),
"READ");
121 if (!inputFile.IsOpen())
122 throw cet::exception(
"FieldResponse::configure") <<
"Unable to open input file: " << fileName << std::endl;
125 std::string histName = fFieldResponseHistName +
"_vw" +
numberToString(fResponseType) +
"_" + fFieldResponseFileVersion +
".root";
127 std::cout <<
"HistFile: " << histName << std::endl;
145 if (binOfInterest < 0)
147 std::cout <<
"Cannot find zero-point crossover for induction response! Plane:" <<
fThisPlane <<
", signal type: " << fSignalType <<
", response type: " << fResponseType << std::endl;
148 throw cet::exception(
"FieldResponse::configure") <<
"Cannot find zero-point crossover for induction response! Plane:" <<
fThisPlane <<
", signal type: " << fSignalType <<
", response type: " << fResponseType << std::endl;
153 if (content >= 0.)
break;
164 size_t newVecSize(64);
166 while(
getNumBins() > newVecSize) newVecSize *= 2;
169 fFFT = std::make_unique<icarus_signal_processing::ICARUSFFT<double>>(newVecSize);
181 double timeFactor = correction3D * timeScaleFctr;
183 size_t nResponseBins = numBins * timeFactor;
190 for(
size_t bin = 1;
bin <= nResponseBins;
bin++)
192 double xVal = x0 + deltaX * (
bin-1) / timeFactor;
198 size_t newVecSize(64);
223 std::vector<double> histResponseVec(
getNumBins());
225 for(
size_t idx = 0; idx <
getNumBins(); idx++)
230 hist->Fill(xBin, binVal, 1.);
231 histResponseVec.at(idx) = binVal;
235 icarus_signal_processing::WaveformTools<double> waveformTool;
238 std::vector<double> smoothedResponseVec;
241 waveformTool.triangleSmooth(histResponseVec, smoothedResponseVec);
248 for(
size_t idx = 0; idx < smoothedResponseVec.size(); idx++)
252 smoothHist->Fill(xBin,smoothedResponseVec.at(idx), 1.);
258 std::vector<double> powerVec(halfFFTDataSize);
263 double maxFreq = 0.5 / binWidth;
264 double freqWidth = maxFreq / powerVec.size();
268 TProfile* fftHist = dir.make<TProfile>(histName.c_str(),
"Field Response FFT; Frequency(MHz)", powerVec.size(), 0., maxFreq);
270 for(
size_t idx = 0; idx < powerVec.size(); idx++)
272 double bin = (idx + 0.5) * freqWidth;
274 fftHist->Fill(bin, powerVec.at(idx), 1.);
283 throw cet::exception(
"FieldResponse::getPlane") <<
"Attempting to access plane info when tool is invalid state" << std::endl;
291 throw cet::exception(
"FieldResponse::getResponseType") <<
"Attempting to access response info when tool is invalid state" << std::endl;
299 throw cet::exception(
"FieldResponse::getPlane") <<
"Attempting to access plane info when tool is invalid state" << std::endl;
307 throw cet::exception(
"FieldResponse::getPlane") <<
"Attempting to access plane info when tool is invalid state" << std::endl;
315 throw cet::exception(
"FieldResponse::getPlane") <<
"Attempting to access plane info when tool is invalid state" << std::endl;
323 throw cet::exception(
"FieldResponse::getPlane") <<
"Attempting to access plane info when tool is invalid state" << std::endl;
331 throw cet::exception(
"FieldResponse::getPlane") <<
"Attempting to access plane info when tool is invalid state" << std::endl;
341 throw cet::exception(
"FieldResponse::getPlane") <<
"Attempting to access plane info when tool is invalid state" << std::endl;
349 throw cet::exception(
"FieldResponse::getPlane") <<
"Attempting to access plane info when tool is invalid state" << std::endl;
357 throw cet::exception(
"FieldResponse::getPlane") <<
"Attempting to access plane info when tool is invalid state" << std::endl;
365 throw cet::exception(
"FieldResponse::getPlane") <<
"Attempting to access plane info when tool is invalid state" << std::endl;
374 std::ostringstream string;
376 string << std::setfill(
'0') << std::setw(2) << number;
Utilities related to art service access.
process_name opflash particleana ie x
std::vector< ComplexVal > FrequencyVec
constexpr details::BinObj< T > bin(T value)
Returns a wrapper to print the specified data in binary format.
Signal from induction planes.
enum geo::_plane_sigtype SigType_t
std::vector< SigProcPrecision > TimeVec
Definition of data types for geometry description.
services TFileService fileName
This is the interface class for a tool to handle the field response It is assumed that the field resp...
BEGIN_PROLOG could also be cout
Signal from collection planes.