test_filter.cxx
Go to the documentation of this file.
1 #include "WireCellUtil/Units.h"
2 #include "WireCellUtil/Testing.h"
3 
4 /// needed to pretend like we are doing WCT internals
9 
10 #include "WireCellUtil/Waveform.h"
11 
12 #include "TFile.h"
13 #include "TGraph.h"
14 
15 
16 using namespace WireCell;
17 
18 int main(int argc, char* argv[]){
19 
20  const std::string ncr_tn = "LfFilter";
21  const std::string ncr_tn1 = "HfFilter";
22  {
24  pm.add("WireCellSigProc");
25 
26 
27  auto incrcfg = Factory::lookup<IConfigurable>(ncr_tn,"lf1");
28  auto cfg = incrcfg->default_configuration();
29  cfg["nbins"] = 9594;
30  cfg["max_freq"] = 1 * units::megahertz;
31  cfg["tau"] = 0.02 * units::megahertz;
32  incrcfg->configure(cfg);
33 
34  }
35 
36  {
37  auto incrcfg = Factory::lookup<IConfigurable>(ncr_tn1,"hf1");
38  auto cfg = incrcfg->default_configuration();
39  cfg["nbins"] = 9594;
40  cfg["max_freq"] = 1 * units::megahertz;
41  cfg["sigma"] = 4 * units::megahertz;
42  cfg["power"] = 2;
43  cfg["flag"] = true;
44  incrcfg->configure(cfg);
45 
46  }
47 
48  auto ncr = Factory::find<IFilterWaveform>(ncr_tn,"lf1");
49  auto ncr1 = Factory::find<IFilterWaveform>(ncr_tn1,"hf1");
50 
51  const int nfbins = 100;
52  auto wfs = ncr->filter_waveform(nfbins);
53  auto wfs1 = ncr1->filter_waveform(nfbins);
54 
55  TFile *file = new TFile(Form("%s.root", argv[0]),"RECREATE");
56  TGraph *g1 = new TGraph();
57  TGraph *g2 = new TGraph();
58  for (size_t i=0;i!=wfs.size();i++){
59  g1->SetPoint(i,i,wfs.at(i));
60  g2->SetPoint(i,i,wfs1.at(i));
61  }
62  g1->Write("g1");
63  g2->Write("g2");
64  file->Write();
65  file->Close();
66 
67  return 0;
68 }
Definition: posix.h:188
std::string string
Definition: nybbler.cc:12
cfg
Definition: dbjson.py:29
static PluginManager & instance()
Definition: Main.h:22
int main(int argc, char *argv[])
Definition: test_filter.cxx:18
Plugin * add(const std::string &plugin_name, const std::string &libname="")
Add a plugin. If libname is not given, try to derive it.
static const double megahertz
Definition: Units.h:99