Public Member Functions | Private Attributes | List of all members
caldata::FFTTest Class Reference
Inheritance diagram for caldata::FFTTest:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Public Member Functions

 FFTTest (fhicl::ParameterSet const &pset)
 
virtual ~FFTTest ()
 
void analyze (const art::Event &evt)
 
- Public Member Functions inherited from art::EDAnalyzer
 EDAnalyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDAnalyzer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Analyzer
virtual ~Analyzer () noexcept
 
 Analyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 Analyzer (Table< Config > const &config)
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Observer
 ~Observer () noexcept
 
 Observer (Observer const &)=delete
 
 Observer (Observer &&)=delete
 
Observeroperator= (Observer const &)=delete
 
Observeroperator= (Observer &&)=delete
 
void registerProducts (ProductDescriptions &, ModuleDescription const &)
 
void fillDescriptions (ModuleDescription const &)
 
fhicl::ParameterSetID selectorConfig () const
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

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
 

Additional Inherited Members

- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 
- Protected Member Functions inherited from art::Observer
std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &select_paths, std::vector< std::string > const &reject_paths, fhicl::ParameterSet const &config)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

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 
115 
116  // Get FFT service.
117 
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);
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);
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);
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);
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
void ShiftData(std::vector< TComplex > &input, double shift)
std::string fCalFile
std::string string
Definition: nybbler.cc:12
std::vector< TComplex > fIndDeconvF
std::vector< double > fSimColField
void DoFFT(std::vector< T > &input, std::vector< TComplex > &output)
Definition: LArFFT.h:98
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
T PeakCorrelation(std::vector< T > &shape1, std::vector< T > &shape2)
Definition: LArFFT.h:272
std::vector< TComplex > fColDeconvF
std::vector< double > fSimIndConv
int FFTSize() const
Definition: LArFFT.h:69
std::vector< double > fSimElect
T get(std::string const &key) const
Definition: ParameterSet.h:271
std::vector< double > fSimIndField
void Convolute(std::vector< T > &input, std::vector< T > &respFunc)
Definition: LArFFT.h:173
std::vector< TComplex > fSimColFieldF
std::vector< double > fSimColConv
std::vector< TComplex > fSimColConvF
std::string fSimFile
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
std::vector< TComplex > fSimIndFieldF
QTextStream & endl(QTextStream &s)
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: