All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
caldata::FFTTest Class Reference
Inheritance diagram for caldata::FFTTest:

Public Member Functions

 FFTTest (fhicl::ParameterSet const &pset)
 
virtual ~FFTTest ()
 
void analyze (const art::Event &evt)
 

Private Attributes

std::string fSimFile
 
std::string fCalFile
 
int fNTicks
 
std::vector< double > fSimElect
 
std::vector< double > fSimColField
 
std::vector< double > fSimIndField
 
std::vector< double > fSimColConv
 
std::vector< double > fSimIndConv
 
std::vector< TComplex > fSimElectF
 
std::vector< TComplex > fSimColFieldF
 
std::vector< TComplex > fSimIndFieldF
 
std::vector< TComplex > fSimColConvF
 
std::vector< TComplex > fSimIndConvF
 
std::vector< TComplex > fColDeconvF
 
std::vector< TComplex > fIndDeconvF
 

Detailed Description

Definition at line 67 of file FFTTest_module.cc.

Constructor & Destructor Documentation

caldata::FFTTest::FFTTest ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 109 of file FFTTest_module.cc.

110  : EDAnalyzer(pset)
111  {
112  // Get file service.
113 
114  art::ServiceHandle<art::TFileService> tfs;
115 
116  // Get FFT service.
117 
118  art::ServiceHandle<util::LArFFT> fFFT;
119  fNTicks = fFFT->FFTSize();
120  std::cout << "Number of ticks = " << fNTicks << std::endl;
121 
122  // Get simulation (convolution) response functions.
123 
124  fSimFile = pset.get<std::string>("simwire_file");
125  std::cout << "SimWire file = " << fSimFile << std::endl;
126 
127  TFile fsim(fSimFile.c_str());
128 
129  TH1D* hSimElect = dynamic_cast<TH1D*>(fsim.Get("daq/ElectronicsResponse"));
130  hist_to_vector(hSimElect, fSimElect);
131  fSimElect.resize(fNTicks, 0.);
132  fSimElectF.resize(fNTicks/2+1);
133  fFFT->DoFFT(fSimElect, fSimElectF);
134 
135  TH1D* hSimColField = dynamic_cast<TH1D*>(fsim.Get("daq/CollectionFieldResponse"));
136  hist_to_vector(hSimColField, fSimColField);
137  fSimColField.resize(fNTicks, 0.);
138  fSimColFieldF.resize(fNTicks/2+1);
139  fFFT->DoFFT(fSimColField, fSimColFieldF);
140 
141  TH1D* hSimIndField = dynamic_cast<TH1D*>(fsim.Get("daq/InductionFieldResponse"));
142  hist_to_vector(hSimIndField, fSimIndField);
143  fSimIndField.resize(fNTicks, 0.);
144  fSimIndFieldF.resize(fNTicks/2+1);
145  fFFT->DoFFT(fSimIndField, fSimIndFieldF);
146 
147  TH1D* hSimColConv = dynamic_cast<TH1D*>(fsim.Get("daq/ConvolutedCollection"));
148  hist_to_vector(hSimColConv, fSimColConv);
149  fSimColConv.resize(fNTicks, 0.);
150  fSimColConvF.resize(fNTicks/2+1);
151  fFFT->DoFFT(fSimColConv, fSimColConvF);
152 
153  TH1D* hSimIndConv = dynamic_cast<TH1D*>(fsim.Get("daq/ConvolutedInduction"));
154  hist_to_vector(hSimIndConv, fSimIndConv);
155  fSimIndConv.resize(fNTicks, 0.);
156  fSimIndConvF.resize(fNTicks/2+1);
157  fFFT->DoFFT(fSimIndConv, fSimIndConvF);
158 
159  // Get reco (deconvolution) response function.
160 
161  fhicl::ParameterSet calwire_pset = pset.get<fhicl::ParameterSet>("calwire");
162  cet::search_path sp("FW_SEARCH_PATH");
163  sp.find_file(calwire_pset.get<std::string>("ResponseFile"), fCalFile);
164  std::cout << "CalWire file = " << fCalFile << std::endl;
165 
166  TFile fcal(fCalFile.c_str());
167 
168  TH2D* respRe = dynamic_cast<TH2D*>(fcal.Get("sim/RespRe"));
169  TH2D* respIm = dynamic_cast<TH2D*>(fcal.Get("sim/RespIm"));
170  int nx = respRe->GetNbinsX();
171  int ny = respRe->GetNbinsY();
172  assert(nx == respIm->GetNbinsX());
173  assert(ny == respIm->GetNbinsY());
174  assert(nx == 2); // 1=induction, 2=collection.
175 
176  fColDeconvF.resize(ny);
177  fIndDeconvF.resize(ny);
178 
179  for(int i=0; i<ny; ++i) {
180  double ac = respRe->GetBinContent(2, i+1);
181  double bc = respIm->GetBinContent(2, i+1);
182  TComplex zc(ac, bc);
183  fColDeconvF[i] = zc;
184 
185  double ai = respRe->GetBinContent(1, i+1);
186  double bi = respIm->GetBinContent(1, i+1);
187  TComplex zi(ai, bi);
188  fIndDeconvF[i] = zi;
189  }
190 
191  // Calculate response of delta function to collection field + electronics.
192 
193  art::TFileDirectory dirc = tfs->mkdir("Collection", "Collection");
194  int nhist = std::min(200, fNTicks);
195 
196  // Input signal (delta function).
197 
198  std::vector<double> tinc(fNTicks, 0.);
199  fill_delta(tinc, nhist/2);
200  TH1D* hinc = dirc.make<TH1D>("input", "Collection Input", nhist+1, -0.5, nhist+0.5);
201  vector_to_hist(tinc, hinc);
202 
203  // Electronics response.
204 
205  std::vector<double> telectc(tinc);
206  fFFT->Convolute(telectc, fSimElectF);
207  TH1D* helectc = dirc.make<TH1D>("elect", "Collection Electronics", nhist+1, -0.5, nhist+0.5);
208  vector_to_hist(telectc, helectc);
209 
210  // Field response.
211 
212  std::vector<double> tfieldc(tinc);
213  fill_delta(tfieldc, nhist/2);
214  fFFT->Convolute(tfieldc, fSimColFieldF);
215  TH1D* hfieldc = dirc.make<TH1D>("field", "Collection Field", nhist+1, -0.5, nhist+0.5);
216  vector_to_hist(tfieldc, hfieldc);
217 
218  // Convolution of electronics and field response.
219 
220  std::vector<double> tbothc(tfieldc);
221  fFFT->Convolute(tbothc, fSimElectF);
222  TH1D* hbothc = dirc.make<TH1D>("both", "Collection Field+Electronics", nhist+1, -0.5, nhist+0.5);
223  vector_to_hist(tbothc, hbothc);
224 
225  // Shifted convolution of electronics and field response.
226 
227  double shift = fFFT->PeakCorrelation(tbothc, tinc);
228  std::cout << "Collection shift = " << shift << std::endl;
229  std::vector<double> tshiftc(tbothc);
230  fFFT->ShiftData(tshiftc, shift);
231  TH1D* hshiftc = dirc.make<TH1D>("shift", "Collection Field+Electronics+Shift", nhist+1, -0.5, nhist+0.5);
232  vector_to_hist(tshiftc, hshiftc);
233 
234  // Convolution response function read from file.
235 
236  std::vector<double> tconvc(tinc);
237  fFFT->Convolute(tconvc, fSimColConvF);
238  TH1D* hconvc = dirc.make<TH1D>("conv", "Collection Response", nhist+1, -0.5, nhist+0.5);
239  vector_to_hist(tconvc, hconvc);
240 
241  // Deconvolution.
242 
243  std::vector<double> tdeconvc(tconvc);
244  fFFT->Convolute(tdeconvc, fColDeconvF);
245  TH1D* hdeconvc = dirc.make<TH1D>("deconv", "Collection Deconvoluted", nhist+1, -0.5, nhist+0.5);
246  vector_to_hist(tdeconvc, hdeconvc);
247 
248  // Calculate response of delta function to induction field + electronics.
249 
250  art::TFileDirectory diri = tfs->mkdir("Induction", "Induction");
251 
252  // Input signal (delta function).
253 
254  std::vector<double> tini(fNTicks, 0.);
255  fill_delta(tini, nhist/2);
256  TH1D* hini = diri.make<TH1D>("input", "Induction Input", nhist+1, -0.5, nhist+0.5);
257  vector_to_hist(tini, hini);
258 
259  // Electronics response.
260 
261  std::vector<double> telecti(tini);
262  fFFT->Convolute(telecti, fSimElectF);
263  TH1D* helecti = diri.make<TH1D>("elect", "Induction Electronics", nhist+1, -0.5, nhist+0.5);
264  vector_to_hist(telecti, helecti);
265 
266  // Field response.
267 
268  std::vector<double> tfieldi(tini);
269  fFFT->Convolute(tfieldi, fSimIndFieldF);
270  TH1D* hfieldi = diri.make<TH1D>("field", "Induction Field", nhist+1, -0.5, nhist+0.5);
271  vector_to_hist(tfieldi, hfieldi);
272 
273  // Convolution of electronics and field response.
274 
275  std::vector<double> tbothi(tfieldi);
276  fFFT->Convolute(tbothi, fSimElectF);
277  TH1D* hbothi = diri.make<TH1D>("both", "Induction Field+Electronics", nhist+1, -0.5, nhist+0.5);
278  vector_to_hist(tbothi, hbothi);
279 
280  // Shifted convolution of electronics and field response.
281 
282  shift = fFFT->PeakCorrelation(tbothi, tini);
283  std::cout << "Induction shift = " << shift << std::endl;
284  std::vector<double> tshifti(tbothi);
285  fFFT->ShiftData(tshifti, shift);
286  TH1D* hshifti = diri.make<TH1D>("shift", "Induction Field+Electronics+Shift", nhist+1, -0.5, nhist+0.5);
287  vector_to_hist(tshifti, hshifti);
288 
289  // Convolution response function read from file.
290 
291  std::vector<double> tconvi(tini);
292  fFFT->Convolute(tconvi, fSimIndConvF);
293  TH1D* hconvi = diri.make<TH1D>("conv", "Induction Response", nhist+1, -0.5, nhist+0.5);
294  vector_to_hist(tconvi, hconvi);
295 
296  // Deconvolution.
297 
298  std::vector<double> tdeconvi(tconvi);
299  fFFT->Convolute(tdeconvi, fIndDeconvF);
300  TH1D* hdeconvi = diri.make<TH1D>("deconv", "Induction Deconvoluted", nhist+1, -0.5, nhist+0.5);
301  vector_to_hist(tdeconvi, hdeconvi);
302  }
std::vector< TComplex > fSimIndConvF
std::vector< TComplex > fSimElectF
std::string fCalFile
std::vector< TComplex > fIndDeconvF
std::vector< double > fSimColField
shift
Definition: fcl_checks.sh:26
std::vector< TComplex > fColDeconvF
std::vector< double > fSimIndConv
std::vector< double > fSimElect
std::vector< double > fSimIndField
std::vector< TComplex > fSimColFieldF
std::vector< double > fSimColConv
std::vector< TComplex > fSimColConvF
std::string fSimFile
std::vector< TComplex > fSimIndFieldF
art::ServiceHandle< art::TFileService > tfs
BEGIN_PROLOG could also be cout
caldata::FFTTest::~FFTTest ( )
virtual

Definition at line 304 of file FFTTest_module.cc.

305  {}

Member Function Documentation

void caldata::FFTTest::analyze ( const art::Event &  evt)

Definition at line 307 of file FFTTest_module.cc.

308  {}

Member Data Documentation

std::string caldata::FFTTest::fCalFile
private

Definition at line 85 of file FFTTest_module.cc.

std::vector<TComplex> caldata::FFTTest::fColDeconvF
private

Definition at line 103 of file FFTTest_module.cc.

std::vector<TComplex> caldata::FFTTest::fIndDeconvF
private

Definition at line 104 of file FFTTest_module.cc.

int caldata::FFTTest::fNTicks
private

Definition at line 86 of file FFTTest_module.cc.

std::vector<double> caldata::FFTTest::fSimColConv
private

Definition at line 93 of file FFTTest_module.cc.

std::vector<TComplex> caldata::FFTTest::fSimColConvF
private

Definition at line 101 of file FFTTest_module.cc.

std::vector<double> caldata::FFTTest::fSimColField
private

Definition at line 91 of file FFTTest_module.cc.

std::vector<TComplex> caldata::FFTTest::fSimColFieldF
private

Definition at line 99 of file FFTTest_module.cc.

std::vector<double> caldata::FFTTest::fSimElect
private

Definition at line 90 of file FFTTest_module.cc.

std::vector<TComplex> caldata::FFTTest::fSimElectF
private

Definition at line 98 of file FFTTest_module.cc.

std::string caldata::FFTTest::fSimFile
private

Definition at line 84 of file FFTTest_module.cc.

std::vector<double> caldata::FFTTest::fSimIndConv
private

Definition at line 94 of file FFTTest_module.cc.

std::vector<TComplex> caldata::FFTTest::fSimIndConvF
private

Definition at line 102 of file FFTTest_module.cc.

std::vector<double> caldata::FFTTest::fSimIndField
private

Definition at line 92 of file FFTTest_module.cc.

std::vector<TComplex> caldata::FFTTest::fSimIndFieldF
private

Definition at line 100 of file FFTTest_module.cc.


The documentation for this class was generated from the following file: