VintageDeconvoluter_tool.cc
Go to the documentation of this file.
1 // VintageDeconvoluter_tool.cc
2 
3 #include "VintageDeconvoluter.h"
4 #include <iostream>
9 
10 using std::string;
11 using std::cout;
12 using std::endl;
13 
14 //**********************************************************************
15 // Class methods.
16 //**********************************************************************
17 
19 : m_LogLevel(ps.get<int>("LogLevel")) {
20  const string myname = "VintageDeconvoluter::ctor: ";
21  if ( m_LogLevel >= 1 ) {
22  cout << myname << "Parameters:" << endl;
23  cout << myname << " LogLevel: " << m_LogLevel << endl;
25  float dnorm = hsss->GetDeconNorm();
26  float norm = dnorm > 0.0 ? 1.0/dnorm : 1.0;
27  cout << myname << "Normalization factor: " << norm << endl;
28  }
29 }
30 
31 //**********************************************************************
32 
34  const string myname = "VintageDeconvoluter::view: ";
35  DataMap ret;
36  AdcChannel chan = acd.channel();
37  AdcSignalVector& samples = acd.samples;
38  unsigned int nsam = samples.size();
39  if ( m_LogLevel >= 2 ) cout << myname << "Deconvoluting channel " << chan
40  << " with " << nsam << " samples." << endl;
41  // Fetch the FFT size.
43  unsigned int fftsize = hFFT->FFTSize();
44  if ( nsam > fftsize ) {
45  cout << myname << "ERROR: Data has too many ticks for FFT: "
46  << nsam << " > " << fftsize << "." << endl;
47  return ret.setStatus(1);
48  }
49  // Pad the data to the FFT size.
50  bool pad = fftsize > nsam;
51  if ( pad ) {
52  if ( m_LogLevel >= 3 ) cout << myname << " Padding sample vector to " << fftsize << endl;
53  samples.resize(fftsize);
54  for ( unsigned int isam=nsam; isam<fftsize; ++isam ) {
55  //samples[isam] = samples[isam-nsam];
56  samples[isam] = 0;
57  }
58  }
59  // Deconvolute.
61  if ( m_LogLevel >= 3 ) cout << myname << " Deconvoluting." << endl;
62  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService>()->DataForJob();
63  hsss->Deconvolute(clockData, chan, samples);
64  if ( pad ) samples.resize(nsam);
65  if ( m_LogLevel >= 3 ) cout << myname << " Normalizing." << endl;
66  float dnorm = hsss->GetDeconNorm();
67  float norm = dnorm > 0.0 ? 1.0/dnorm : 1.0;
68  if ( m_LogLevel >= 3 ) cout << myname << " Scale factor: " << norm << endl;
69  for ( float& sam : samples ) sam *= norm;
70  acd.sampleUnit = "Q_{dco}";
71  acd.sampleNoise = hsss->GetDeconNoise(chan);
72  // Done.
73  return ret;
74 }
75 
76 //**********************************************************************
77 
void Deconvolute(detinfo::DetectorClocksData const &clockData, Channel channel, std::vector< T > &func) const
#define DEFINE_ART_CLASS_TOOL(tool)
Definition: ToolMacros.h:42
DataMap & setStatus(int stat)
Definition: DataMap.h:130
std::string string
Definition: nybbler.cc:12
VintageDeconvoluter(fhicl::ParameterSet const &ps)
double GetDeconNoise(Channel channel) const override
Service to provide microboone-specific signal shaping for simulation (convolution) and reconstruction...
int FFTSize() const
Definition: LArFFT.h:69
AdcSignal sampleNoise
static constexpr double ps
Definition: Units.h:99
auto norm(Vector const &v)
Return norm of the specified vector.
Channel channel() const
unsigned int AdcChannel
Definition: AdcTypes.h:50
DataMap update(AdcChannelData &acd) const override
std::vector< AdcSignal > AdcSignalVector
Definition: AdcTypes.h:22
auto const & get(AssnsNode< L, R, D > const &r)
Definition: AssnsNode.h:115
AdcSignalVector samples
QTextStream & endl(QTextStream &s)