12 #include "TFFTRealComplex.h"
13 #include "TFFTComplexReal.h"
19 #include "fhiclcpp/ParameterSet.h"
20 #include "art/Framework/Services/Registry/ActivityRegistry.h"
21 #include "art/Framework/Services/Registry/ServiceDeclarationMacros.h"
22 #include "art/Framework/Services/Registry/ServiceHandle.h"
28 LArFFT(fhicl::ParameterSet
const& pset, art::ActivityRegistry& reg);
32 template <
class T>
void DoFFT(std::vector<T> & input,
33 std::vector<TComplex> &
output);
35 template <
class T>
void DoInvFFT(std::vector<TComplex> & input,
36 std::vector<T> & output);
38 template <
class T>
void Deconvolute(std::vector<T> & input,
39 std::vector<T> & respFunc);
41 template <
class T>
void Deconvolute(std::vector<T> & input,
42 std::vector<TComplex> & kern);
44 template <
class T>
void Convolute(std::vector<T> & input,
45 std::vector<T> & respFunc);
47 template <
class T>
void Convolute(std::vector<T> & input,
48 std::vector<TComplex> & kern);
50 template <
class T>
void Correlate(std::vector<T> & input,
51 std::vector<T> & respFunc);
53 template <
class T>
void Correlate(std::vector<T> & input,
54 std::vector<TComplex> & kern);
56 template <
class T>
void AlignedSum(std::vector<T> & input,
57 std::vector<T> &output,
60 void ShiftData(std::vector<TComplex> & input,
63 template <
class T>
void ShiftData(std::vector<T> & input,
67 std::vector<T> &shape2);
99 std::vector<TComplex> &
output)
102 double imaginary = 0.;
105 for(
size_t p = 0;
p < input.size(); ++
p)
106 fFFT->SetPoint(
p, input[
p]);
111 fFFT->GetPointComplex(i, real, imaginary);
112 output[i]=TComplex(real, imaginary);
123 for(
int i = 0; i < fFreqSize; ++i)
124 fInverseFFT->SetPointComplex(i, input[i]);
126 fInverseFFT->Transform();
127 double factor = 1.0/(double) fSize;
129 for(
int i = 0; i < fSize; ++i)
130 output[i] = factor*fInverseFFT->GetPointReal(i,
false);
139 std::vector<T> & respFunction)
141 DoFFT(respFunction, fKern);
142 DoFFT(input, fCompTemp);
144 for(
int i = 0; i < fFreqSize; i++)
145 fCompTemp[i]/=fKern[i];
147 DoInvFFT(fCompTemp, input);
158 std::vector<TComplex> & kern)
160 DoFFT(input, fCompTemp);
162 for(
int i = 0; i < fFreqSize; i++)
163 fCompTemp[i]/=kern[i];
165 DoInvFFT(fCompTemp, input);
174 std::vector<T> & shape2)
176 DoFFT(shape1, fKern);
177 DoFFT(shape2, fCompTemp);
179 for(
int i = 0; i < fFreqSize; i++)
180 fCompTemp[i]*=fKern[i];
182 DoInvFFT(fCompTemp, shape1);
193 std::vector<TComplex> & kern)
195 DoFFT(input, fCompTemp);
197 for(
int i = 0; i < fFreqSize; i++)
198 fCompTemp[i]*=kern[i];
200 DoInvFFT(fCompTemp, input);
208 std::vector<T> & shape2)
210 DoFFT(shape1, fKern);
211 DoFFT(shape2, fCompTemp);
213 for(
int i = 0; i < fFreqSize; i++)
214 fCompTemp[i]*=TComplex::Conjugate(fKern[i]);
216 DoInvFFT(fCompTemp, shape1);
227 std::vector<TComplex> & kern)
229 DoFFT(input, fCompTemp);
231 for(
int i = 0; i < fFreqSize; i++)
232 fCompTemp[i]*=TComplex::Conjugate(kern[i]);
234 DoInvFFT(fCompTemp, input);
245 std::vector<T> & shape2,
248 double shift = PeakCorrelation(shape1,shape2);
250 ShiftData(shape1,shift);
252 if(add)
for(
int i = 0; i < fSize; i++) shape1[i]+=shape2[i];
262 DoFFT(input,fCompTemp);
263 ShiftData(fCompTemp,shift);
264 DoInvFFT(fCompTemp,input);
273 std::vector<T> & shape2)
275 fConvHist->Reset(
"ICE");
276 std::vector<T> holder = shape1;
277 Correlate(holder,shape2);
279 int maxT = max_element(holder.begin(), holder.end())-holder.begin();
280 float startT = maxT-fFitBins/2;
283 for(
int i = 0; i < fFitBins; i++) {
284 if(startT+i < 0) offset=fSize;
285 else if(startT+i > fSize) offset=-fSize;
287 fConvHist->Fill(i,holder[i+startT+offset]);
290 fPeakFit->SetParameters(fConvHist->GetMaximum(),fFitBins/2,fFitBins/2);
291 fConvHist->Fit(fPeakFit,
"QWNR",
"",0,fFitBins);
292 return fPeakFit->GetParameter(1)+startT;
BEGIN_PROLOG TPC Trig offset(g4 rise time) ProjectToHeight
void resetSizePerRun(art::Run const &)
void ShiftData(std::vector< TComplex > &input, double shift)
std::vector< TComplex > fKern
void DoFFT(std::vector< T > &input, std::vector< TComplex > &output)
T PeakCorrelation(std::vector< T > &shape1, std::vector< T > &shape2)
void DoInvFFT(std::vector< TComplex > &input, std::vector< T > &output)
TFFTRealComplex * fFFT
object to do FFT
void Correlate(std::vector< T > &input, std::vector< T > &respFunc)
LArFFT(fhicl::ParameterSet const &pset, art::ActivityRegistry ®)
void Convolute(std::vector< T > &input, std::vector< T > &respFunc)
void Deconvolute(std::vector< T > &input, std::vector< T > &respFunc)
void AlignedSum(std::vector< T > &input, std::vector< T > &output, bool add=true)
std::vector< TComplex > fCompTemp
BEGIN_PROLOG sequence::SlidingWindowTriggerPatternsOppositeWindows END_PROLOG simSlidingORM6O6 effSlidingORW output
std::string FFTOptions() const
TFFTComplexReal * fInverseFFT
object to do Inverse FF
void ReinitializeFFT(int, std::string, int)