OmniChannelNoiseDB.cxx
Go to the documentation of this file.
4 
5 #include <cmath>
6 
9 
10 using namespace WireCell;
11 using namespace WireCell::SigProc;
12 
13 
15  : m_tick(0.5*units::us)
16  , m_nsamples(9600)
17  , m_rc_layers(2)
18  , log(Log::logger("sigproc"))
19 {
20 }
21 OmniChannelNoiseDB::~OmniChannelNoiseDB()
22 {
23  // for (auto it = m_db.begin(); it!= m_db.end(); it++){
24  // delete it->second;
25  // }
26  // m_db.clear();
27 }
28 
29 
31  : chid(-1)
32  , nominal_baseline(0.0)
33  , gain_correction(1.0)
34  , response_offset(0.0)
35  , min_rms_cut(0.5)
36  , max_rms_cut(10.0)
37  , pad_window_front(0.0)
38  , pad_window_back(0.0)
39  , decon_limit(0.02)
40  , decon_lf_cutoff(0.08)
41  , adc_limit(0.0)
42  , decon_limit1(0.08)
43  , protection_factor(5.0)
44  , min_adc_limit(50)
45  , roi_min_max_ratio(0.8)
46  , rcrc(nullptr)
47  , config(nullptr)
48  , noise(nullptr)
49  , response(nullptr)
50 {
51 }
52 
53 
54 
56 {
58  // The assumed time-domain sample period used to make response spetra.
59  cfg["tick"] = m_tick;
60  // The number of *frequency domain* sample. This is NOT anything
61  // related to the length of a waveform to which this class may be
62  // applied, except by accident or contrivance.
63  cfg["nsamples"] = m_nsamples;
64  cfg["anode"] = "AnodePlane";
65  cfg["field_response"] = "FieldResponse";
66 
67  /// These must be provided
68  cfg["groups"] = Json::arrayValue;
69  cfg["channel_info"] = Json::arrayValue;
70 
71  return cfg;
72 }
73 
74 
75 /*
76  Interpret and return a list of channels for JSON like:
77 
78  // just one channel
79  channels: 42,
80 
81  or
82 
83  // explicit list of channels
84  channels: [1,42,107],
85 
86  or
87 
88  // inclusive range of channels
89  channels: { first: 0, last: 2400 },
90 
91  or
92 
93  // all channels in a wire plane
94  channels: { wpid: wc.WirePlaneId(wc.kWlayer) },
95 */
96 std::vector<int> OmniChannelNoiseDB::parse_channels(const Json::Value& jchannels)
97 {
98  std::vector<int> ret;
99 
100  // single channel
101  if (jchannels.isInt()) {
102  ret.push_back(jchannels.asInt());
103  return ret;
104  }
105 
106  // array of explicit channels
107  if (jchannels.isArray()) {
108  const int nch = jchannels.size();
109  ret.resize(nch);
110  for (int ind=0; ind<nch; ++ind) {
111  ret[ind] = jchannels[ind].asInt();
112  }
113  return ret;
114  }
115 
116  // else, assume an object
117 
118  // range
119  if (jchannels.isMember("first") && jchannels.isMember("last")) {
120  const int chf = jchannels["first"].asInt();
121  const int chl = jchannels["last"].asInt();
122  const int nch = chl-chf+1;
123  ret.resize(nch);
124  for (int ind=0; ind < nch; ++ind) {
125  ret[ind] = chf + ind;
126  }
127  return ret;
128  }
129 
130  // wire plane id
131  if (jchannels.isMember("wpid")) {
132  WirePlaneId wpid(jchannels["wpid"].asInt());
133  for (auto ch : m_anode->channels()) {
134  if (m_anode->resolve(ch) == wpid) {
135  ret.push_back(ch);
136  }
137  }
138  return ret;
139  }
140 
141  return ret;
142 }
143 
145 {
146  return std::make_shared<filter_t>(m_nsamples, defval);
147 }
149 {
150  static shared_filter_t def = make_filter();
151  return def;
152 }
153 
155 {
156  if (jfm.isNull()) {
157  return default_filter();
158  }
159 
160  auto spectrum = make_filter(std::complex<float>(1,0));
161  for (auto jone : jfm) {
162  double value = jone["value"].asDouble();
163  int lo = std::max(jone["lobin"].asInt(), 0);
164  int hi = std::min(jone["hibin"].asInt(), m_nsamples-1);
165  // std::cerr << "freqmasks: set [" << lo << "," << hi << "] to " << value << std::endl;
166  for (int ind=lo; ind <= hi; ++ind) { // inclusive
167  spectrum->at(ind) = value;
168  }
169  }
170  return spectrum;
171 }
172 
174 {
175  if (jrcrc.isNull()) {
176  return default_filter();
177  }
178  const double rcrc_val = jrcrc.asDouble();
179  const int key = int(round(1000*rcrc_val/units::ms));
180  auto it = m_rcrc_cache.find(key);
181  if (it != m_rcrc_cache.end()) {
182  return it->second;
183  }
184 
185  Response::SimpleRC rcres(rcrc_val, m_tick);
186  // auto signal = rcres.generate(WireCell::Binning(m_nsamples, 0, m_nsamples*m_tick));
188 
189  Waveform::compseq_t spectrum = Waveform::dft(signal);
190  // get the square of it because there are two RC filters
191  Waveform::compseq_t spectrum2 = spectrum;
192  // Waveform::scale(spectrum2,spectrum);
193 
194  // std::cerr << "[wgu] parse_rcrc nrc= " << nrc << std::endl;
195  nrc --;
196  while(nrc>0){
197  // std::cerr << "[wgu] more nrc= " << nrc << std::endl;
198  Waveform::scale(spectrum2,spectrum);
199  nrc --;
200  }
201 
202 
203  // std::cerr << "OmniChannelNoiseDB:: get rcrc as: " << rcrc_val
204  // << " sum=" << Waveform::sum(spectrum2)
205  // << std::endl;
206 
207  auto ret = std::make_shared<filter_t>(spectrum2);
208  m_rcrc_cache[key] = ret;
209  return ret;
210 }
211 
212 
213 
215 {
216  if (jreconfig.empty()) {
217  return 1.0;
218  }
219 
220  const double from_gain = jreconfig["from"]["gain"].asDouble();
221  const double to_gain = jreconfig["to"]["gain"].asDouble();
222  return to_gain/from_gain;
223 }
224 
226 {
227  if (jreconfig.empty()) {
228  return default_filter();
229  }
230 
231  const double from_gain = jreconfig["from"]["gain"].asDouble();
232  const double from_shaping = jreconfig["from"]["shaping"].asDouble();
233  const double to_gain = jreconfig["to"]["gain"].asDouble();
234  const double to_shaping = jreconfig["to"]["shaping"].asDouble();
235 
236 
237  return get_reconfig(from_gain, from_shaping, to_gain, to_shaping);
238 }
240  double to_gain, double to_shaping)
241 {
242  // kind of evil.
243  int key = int(round(10.0*from_gain/(units::mV/units::fC))) << 24
244  | int(round(10.0*from_shaping/units::us)) << 16
245  | int(round(10.0*to_gain/(units::mV/units::fC))) << 8
246  | int(round(10.0*to_shaping/units::us));
247 
248  // std::cerr << "KEY:" << key
249  // << " fg="<<from_gain/(units::mV/units::fC) << " mV/fC,"
250  // << " fs=" << from_shaping/units::us << " us,"
251  // << " tg="<<to_gain/(units::mV/units::fC) << " mV/fC,"
252  // << " ts="<<to_shaping/units::us << " us,"
253  // << " m_tick=" << m_tick/units::us << " us."
254  // << std::endl;
255 
256 
257  auto it = m_reconfig_cache.find(key);
258  if (it != m_reconfig_cache.end()) {
259  return it->second;
260  }
261 
262  Response::ColdElec from_ce(from_gain, from_shaping);
263  Response::ColdElec to_ce(to_gain, to_shaping);
264  // auto to_sig = to_ce.generate(WireCell::Binning(m_nsamples, 0, m_nsamples*m_tick));
265  // auto from_sig = from_ce.generate(WireCell::Binning(m_nsamples, 0, m_nsamples*m_tick));
267  auto from_sig = from_ce.generate(WireCell::Waveform::Domain(0, m_nsamples*m_tick), m_nsamples);
268 
269  auto to_filt = Waveform::dft(to_sig);
270  auto from_filt = Waveform::dft(from_sig);
271 
272  //auto from_filt_sum = Waveform::sum(from_filt);
273  //auto to_filt_sum = Waveform::sum(to_filt);
274 
275  Waveform::shrink(to_filt, from_filt); // divide
276  auto filt = std::make_shared<filter_t>(to_filt);
277 
278  // std::cerr << filt->at(0) << " " << filt->at(1) << std::endl;
279 
280  // std::cerr << "OmniChannelNoiseDB: "
281  // << " from_sig sum=" << Waveform::sum(from_sig)
282  // << " to_sig sum=" << Waveform::sum(to_sig)
283  // << " from_filt sum=" << from_filt_sum
284  // << " to_filt sum=" << to_filt_sum
285  // << " rat_filt sum=" << Waveform::sum(to_filt)
286  // << std::endl;
287 
288 
290  return filt;
291 }
292 void OmniChannelNoiseDB::set_misconfigured(const std::vector<int>& channels,
293  double from_gain, double from_shaping,
294  double to_gain, double to_shaping,
295  bool reset)
296 {
297  if (reset) {
298  auto def = default_filter();
299  for (auto& it : m_db) {
300  it.second.config = def;
301  }
302  }
303  auto val = get_reconfig(from_gain, from_shaping, to_gain, to_shaping);
304  for (int ch : channels) {
305  //m_db.at(ch).config = val;
306  //dbget(ch).config = val;
307  get_ci(ch).config = val;
308  m_miscfg_channels.push_back(ch);
309  }
310 }
311 
312 
314 {
315  if (jfilt.isMember("wpid")) {
316  WirePlaneId wpid(jfilt["wpid"].asInt());
317  auto it = m_response_cache.find(wpid.ident());
318  if (it != m_response_cache.end()) {
319  return it->second;
320  }
321  auto const& fr = m_fr->field_response();
322  auto fravg = Response::wire_region_average(fr);
323  auto const& pr = fravg.planes[wpid.index()];
324 
325  // full length waveform
326  std::vector<float> waveform(m_nsamples, 0.0);
327  for (auto const& path : pr.paths) {
328  auto const& current = path.current;
329  const size_t nsamp = std::min(m_nsamples, (int)current.size());
330  for (size_t ind=0; ind<nsamp; ++ind) {
331  waveform[ind] += current[ind];
332  }
333  }
334  auto spectrum = WireCell::Waveform::dft(waveform);
335  auto ret = std::make_shared<filter_t>(spectrum);
336  m_response_cache[wpid.ident()] = ret;
337  return ret;
338  }
339 
340  if (jfilt.isMember("waveform") && jfilt.isMember("waveformid")) {
341  int id = jfilt["waveformid"].asInt();
342  auto it = m_waveform_cache.find(id);
343  if (it != m_waveform_cache.end()) {
344  return it->second;
345  }
346 
347  auto jwave = jfilt["waveform"];
348  const int nsamp = std::min(m_nsamples, (int)jwave.size());
349 
350  // Explicitly given waveform
351  std::vector<float> waveform(m_nsamples, 0.0);
352  for (int ind=0; ind<nsamp; ++ind) {
353  waveform[ind] = jwave[ind].asFloat();
354  }
355 
356  auto spectrum = WireCell::Waveform::dft(waveform);
357  auto ret = std::make_shared<filter_t>(spectrum);
358  m_waveform_cache[id] = ret;
359  return ret;
360  }
361 
362  // this default return is special in that it's empty instead of
363  // being a flat, unity spectrum.
364  static shared_filter_t empty = std::make_shared<filter_t>();
365  return empty;
366 }
367 
368 
370 {
371  auto it = m_db.find(chid);
372  if (it == m_db.end()) {
373  THROW(KeyError() << errmsg{String::format("no db info for channel %d", chid)});
374  }
375  return it->second;
376  //return m_db.at(chid);
377 }
378 
379 template<typename Type>
380 void dump_cfg(const std::string& name, std::vector<int> chans, Type val)
381 {
382  std::sort(chans.begin(), chans.end());
383  // std::cerr << "OmniChannelNoiseDB: setting " << name << " to " << val << " on " << chans.size() << ":[" << chans.front() << "," << chans.back() << "]\n";
384 }
385 
387 {
388  auto chans = parse_channels(cfg["channels"]);
389 
390  if (cfg.isMember("nominal_baseline")) {
391  double val = cfg["nominal_baseline"].asDouble();
392  dump_cfg("baseline", chans, val);
393  for (int ch : chans) {
394  //m_db.at(ch).nominal_baseline = val;
395  //dbget(ch).nominal_baseline = val;
397  }
398  }
399  if (cfg.isMember("gain_correction")) {
400  double val = cfg["gain_correction"].asDouble();
401  dump_cfg("gain", chans, val);
402  for (int ch : chans) {
403  //m_db.at(ch).gain_correction = val;
404  //dbget(ch).gain_correction = val;
405  get_ci(ch).gain_correction = val;
406  }
407  }
408  // fixme: why have two ways to set the same thing?
409  {
410  auto jfilt = cfg["reconfig"];
411  if (!jfilt.isNull()) {
412  auto val = parse_gain(jfilt);
413  dump_cfg("gain", chans, val);
414  for (int ch : chans) {
415  //m_db.at(ch).gain_correction = val;
416  //dbget(ch).gain_correction = val;
417  get_ci(ch).gain_correction = val;
418  }
419  }
420  }
421 
422  if (cfg.isMember("response_offset")) {
423  double val = cfg["response_offset"].asDouble();
424  dump_cfg("offset", chans, val);
425  for (int ch : chans) {
426  //m_db.at(ch).response_offset = val;
427  //dbget(ch).response_offset = val;
428  get_ci(ch).response_offset = val;
429  }
430  }
431  if (cfg.isMember("min_rms_cut")) {
432  double val = cfg["min_rms_cut"].asDouble();
433  dump_cfg("minrms", chans, val);
434  for (int ch : chans) {
435  //m_db.at(ch).min_rms_cut = val;
436  //dbget(ch).min_rms_cut = val;
437  get_ci(ch).min_rms_cut = val;
438  }
439  }
440  if (cfg.isMember("max_rms_cut")) {
441  double val = cfg["max_rms_cut"].asDouble();
442  dump_cfg("maxrms", chans, val);
443  for (int ch : chans) {
444  //m_db.at(ch).max_rms_cut = val;
445  //dbget(ch).max_rms_cut = val;
446  get_ci(ch).max_rms_cut = val;
447  }
448  }
449  if (cfg.isMember("pad_window_front")) {
450  int val = cfg["pad_window_front"].asDouble();
451  dump_cfg("padfront", chans, val);
452  for (int ch : chans) {
453  //m_db.at(ch).pad_window_front = val;
454  //dbget(ch).pad_window_front = val;
456  }
457  }
458  if (cfg.isMember("pad_window_back")) {
459  int val = cfg["pad_window_back"].asDouble();
460  dump_cfg("padback", chans, val);
461  for (int ch : chans) {
462  //m_db.at(ch).pad_window_back = val;
463  //dbget(ch).pad_window_back = val;
464  get_ci(ch).pad_window_back = val;
465  }
466  }
467 
468  if (cfg.isMember("decon_limit")) {
469  float val = cfg["decon_limit"].asDouble();
470  dump_cfg("deconlimit", chans, val);
471  for (int ch : chans) {
472  //m_db.at(ch).decon_limit = val;
473  //dbget(ch).decon_limit = val;
474  get_ci(ch).decon_limit = val;
475  }
476  }
477 
478  if (cfg.isMember("decon_lf_cutoff")) {
479  float val = cfg["decon_lf_cutoff"].asDouble();
480  dump_cfg("deconlfcutoff", chans, val);
481  for (int ch : chans) {
482  //m_db.at(ch).decon_limit = val;
483  //dbget(ch).decon_limit = val;
484  get_ci(ch).decon_lf_cutoff = val;
485  }
486  }
487 
488  if (cfg.isMember("decon_limit1")) {
489  float val = cfg["decon_limit1"].asDouble();
490  dump_cfg("deconlimit1", chans, val);
491  for (int ch : chans) {
492  //m_db.at(ch).decon_limit1 = val;
493  //dbget(ch).decon_limit1 = val;
494  get_ci(ch).decon_limit1 = val;
495  }
496  }
497  if (cfg.isMember("adc_limit")) {
498  float val = cfg["adc_limit"].asDouble();
499  dump_cfg("adclimit", chans, val);
500  for (int ch : chans) {
501  //m_db.at(ch).adc_limit = val;
502  //dbget(ch).adc_limit = val;
503  get_ci(ch).adc_limit = val;
504  }
505  }
506  if (cfg.isMember("protection_factor")) {
507  float val = cfg["protection_factor"].asDouble();
508  dump_cfg("protectionfactor", chans, val);
509  for (int ch : chans) {
511  }
512  }
513  if (cfg.isMember("min_adc_limit")) {
514  float val = cfg["min_adc_limit"].asDouble();
515  dump_cfg("minadclimit", chans, val);
516  for (int ch : chans) {
517  //m_db.at(ch).adc_limit = val;
518  //dbget(ch).adc_limit = val;
519  get_ci(ch).min_adc_limit = val;
520  }
521  }
522  if (cfg.isMember("roi_min_max_ratio")) {
523  float val = cfg["roi_min_max_ratio"].asDouble();
524  dump_cfg("roiminmaxratio", chans, val);
525  for (int ch : chans) {
527  }
528  }
529 
530  {
531  auto jfilt = cfg["rcrc"];
532  if (!jfilt.isNull()) {
533  if (cfg.isMember("rc_layers")){
534  m_rc_layers = cfg["rc_layers"].asInt();
535  }
536  // std::cerr << "rc_layers = " << m_rc_layers << std::endl;
537  auto val = parse_rcrc(jfilt, m_rc_layers);
538  dump_cfg("rcrc", chans, Waveform::sum(*val));
539  for (int ch : chans) {
540  //m_db.at(ch).rcrc = val;
541  //dbget(ch).rcrc = val;
542  get_ci(ch).rcrc = val;
543  }
544  }
545  }
546  {
547  auto jfilt = cfg["reconfig"];
548  if (!jfilt.isNull()) {
549  auto val = parse_reconfig(jfilt);
550  dump_cfg("reconfig", chans, Waveform::sum(*val));
551  for (int ch : chans) {
552  //m_db.at(ch).config = val;
553  //dbget(ch).config = val;
554  get_ci(ch).config = val;
555  // fill in misconfgured channels
556  //std::cout <<" miscfg_channels fill: "<< ch <<"\n"
557  if(!jfilt.empty()) m_miscfg_channels.push_back(ch);
558  }
559  }
560  }
561  {
562  auto jfilt = cfg["freqmasks"];
563  if (!jfilt.isNull()) {
564  auto val = parse_freqmasks(jfilt);
565  dump_cfg("freqmasks", chans, Waveform::sum(*val));
566  // std::cerr << jfilt << std::endl;
567  for (int ch : chans) {
568  //m_db.at(ch).noise = val;
569  //dbget(ch).noise = val;
570  get_ci(ch).noise = val;
571  }
572  }
573  }
574  {
575  auto jfilt = cfg["response"];
576  if (!jfilt.isNull()) {
577  auto val = parse_response(jfilt);
578  dump_cfg("response", chans, Waveform::sum(*val));
579  for (int ch : chans) {
580  //m_db.at(ch).response = val;
581  //dbget(ch).response = val;
582  get_ci(ch).response = val;
583  }
584  }
585  }
586 
587 }
588 
589 
591 {
592  m_tick = get(cfg, "tick", m_tick);
593  m_nsamples = get(cfg, "nsamples", m_nsamples);
594  std::string anode_tn = get<std::string>(cfg, "anode", "AnodePlane");
595  m_anode = Factory::find_tn<IAnodePlane>(anode_tn);
596  std::string fr_tn = get<std::string>(cfg, "field_response", "FieldResponse");
597  m_fr = Factory::find_tn<IFieldResponse>(fr_tn);
598 
599  // WARNING: this assumes channel numbers count from 0 with no gaps!
600  //int nchans = m_anode->channels().size();
601  //std::cerr << "noise database with " << nchans << " channels\n";
602  //m_db.resize(nchans);
603 
604  // clear any previous config, and recover the memory
605  // for (auto it = m_db.begin(); it!= m_db.end(); it++){
606  // delete it->second;
607  // }
608  // m_db.clear();
609  for(auto ch: m_anode->channels()){
610  // m_db.insert(std::make_pair(ch, new ChannelInfo));
611  m_db[ch] = ChannelInfo();
612  }
613 
614  m_channel_groups.clear();
615  auto jgroups = cfg["groups"];
616  for (auto jgroup: jgroups) {
617  std::vector<int> channel_group;
618  for (auto jch: jgroup) {
619  channel_group.push_back(jch.asInt());
620  }
621  m_channel_groups.push_back(channel_group);
622  }
623  m_bad_channels.clear();
624  for (auto jch : cfg["bad"]) {
625  m_bad_channels.push_back(jch.asInt());
626  }
627  std::sort(m_bad_channels.begin(), m_bad_channels.end());
628  if (m_bad_channels.size()) {
629  log->debug("OmniChannelNoiseDB: setting {}:[{},{}] bad channels",
630  m_bad_channels.size(), m_bad_channels.front(), m_bad_channels.back());
631  }
632 
633 
634  m_miscfg_channels.clear();
635  for (auto jci : cfg["channel_info"]) {
636  update_channels(jci);
637  }
638 }
639 
640 
641 
642 
643 
645 {
646  return m_tick;
647 }
648 
649 
650 
652 {
653  return dbget(channel).nominal_baseline;
654 }
655 
657 {
658  return dbget(channel).gain_correction;
659 }
660 
662 {
663  return dbget(channel).response_offset;
664 }
665 
667 {
668  return dbget(channel).min_rms_cut;
669 }
670 
672 {
673  return dbget(channel).max_rms_cut;
674 }
675 
677 {
678  return dbget(channel).pad_window_front;
679 }
680 
682 {
683  return dbget(channel).pad_window_back;
684 }
685 
687 {
688  return dbget(channel).decon_limit;
689 }
690 
692 {
693  return dbget(channel).decon_lf_cutoff;
694 }
695 
697 {
698  return dbget(channel).decon_limit1;
699 }
700 
702 {
703  return dbget(channel).adc_limit;
704 }
705 
707 {
708  return dbget(channel).protection_factor;
709 }
710 
712 {
713  return dbget(channel).min_adc_limit;
714 }
715 
717 {
718  return dbget(channel).roi_min_max_ratio;
719 }
720 
722 {
723  auto filt = dbget(channel).rcrc;
724  if (filt) {
725  return *filt;
726  }
727  static filter_t dummy;
728  return dummy;
729 }
730 
732 {
733  auto filt = dbget(channel).config;
734  if (filt) {
735  return *filt;
736  }
737  static filter_t dummy;
738  return dummy;
739 }
740 
742 {
743  auto filt = dbget(channel).noise;
744  if (filt) {
745  return *filt;
746  }
747  static filter_t dummy;
748  return dummy;
749 }
750 
752 {
753  auto filt = dbget(channel).response;
754  if (filt) {
755  return *filt;
756  }
757  static filter_t dummy;
758  return dummy;
759 }
760 
761 
762 // Local Variables:
763 // mode: c++
764 // c-basic-offset: 4
765 // End:
static QCString name
Definition: declinfo.cpp:673
std::unordered_map< int, shared_filter_t > m_rcrc_cache
int ident() const
Unit ID as integer.
Definition: WirePlaneId.cxx:21
virtual float coherent_nf_adc_limit(int channel) const
virtual void configure(const WireCell::Configuration &config)
Accept a configuration.
virtual const filter_t & config(int channel) const
Return the filter to correct any wrongly configured channels.
virtual const filter_t & noise(int channel) const
Return the filter to attenuate noise.
shared_filter_t get_reconfig(double from_gain, double from_shaping, double to_gain, double to_shaping)
virtual float coherent_nf_min_adc_limit(int channel) const
std::string string
Definition: nybbler.cc:12
boost::error_info< struct tag_errmsg, std::string > errmsg
Definition: Exceptions.h:54
virtual float coherent_nf_decon_limit1(int channel) const
shared_filter_t parse_rcrc(Json::Value jrcrc, int nrc)
virtual double sample_time() const
FIXME: how to handle state changes?
std::unordered_map< int, shared_filter_t > m_response_cache
virtual int pad_window_back(int channel) const
std::vector< int > parse_channels(const Json::Value &jchannels)
Schema::FieldResponse wire_region_average(const Schema::FieldResponse &fr)
Definition: Response.cxx:99
virtual double min_rms_cut(int channel) const
const ChannelInfo & dbget(int ch) const
static const double mV
Definition: Units.h:180
cfg
Definition: dbjson.py:29
A functional object caching gain and shape.
Definition: Response.h:165
static const double ms
Definition: Units.h:104
virtual WireCell::Configuration default_configuration() const
Optional, override to return a hard-coded default configuration.
std::unordered_map< int, shared_filter_t > m_waveform_cache
QTextStream & reset(QTextStream &s)
compseq_t dft(realseq_t seq)
Definition: Waveform.cxx:141
std::pair< double, double > Domain
Definition: Waveform.h:75
double parse_gain(Json::Value jreconfig)
void shrink(Sequence< Val > &seq, const Sequence< Val > &other)
Shrink (divide) seq values by values from the other sequence.
Definition: Waveform.h:162
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
Definition: document.h:2106
def key(type, name=None)
Definition: graph.py:13
virtual float coherent_nf_roi_min_max_ratio(int channel) const
WireCell::Waveform::realseq_t generate(const WireCell::Waveform::Domain &domain, int nsamples)
FIXME: eradicate Domain in favor of Binning.
Definition: Response.cxx:303
virtual float coherent_nf_protection_factor(int channel) const
virtual double nominal_baseline(int channel) const
Return a nominal baseline correction (additive offset)
static Entry * current
#define THROW(e)
Definition: Exceptions.h:25
virtual float coherent_nf_decon_lf_cutoff(int channel) const
virtual const filter_t & rcrc(int channel) const
Return the filter for the RC+RC coupling response function.
static int max(int a, int b)
virtual float coherent_nf_decon_limit(int channel) const
std::shared_ptr< filter_t > shared_filter_t
static const double fC
Definition: Units.h:113
logptr_t logger(std::string name)
Definition: Logging.cxx:71
WireCell::Waveform::compseq_t filter_t
The data type for all frequency-space, multiplicative filters.
void dump_cfg(const std::string &name, std::vector< int > chans, Type val)
std::unordered_map< int, ChannelInfo > m_db
std::string format(const std::string &form, TYPES...objs)
Definition: String.h:45
void log(source_loc source, level::level_enum lvl, const char *fmt, const Args &...args)
Definition: spdlog.h:165
shared_filter_t parse_reconfig(Json::Value jreconfig)
Definition: Main.h:22
virtual const filter_t & response(int channel) const
A nominal detector response spectrum for a given channel.
void scale(Sequence< Val > &seq, Val scalar)
Scale (multiply) sequence values by scalar.
Definition: Waveform.h:146
std::unordered_map< int, shared_filter_t > m_reconfig_cache
static const double us
Definition: Units.h:101
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
Val sum(const Sequence< Val > &seq)
Return sum of all entries in sequence.
Definition: Waveform.h:178
virtual double max_rms_cut(int channel) const
virtual void set_misconfigured(const std::vector< int > &channels, double from_gain, double from_shaping, double to_gain, double to_shaping, bool reset=false)
shared_filter_t parse_response(Json::Value jreconfig)
Json::Value Configuration
Definition: Configuration.h:50
virtual double response_offset(int channel) const
Return a time offset associated with the response().
virtual double gain_correction(int channel) const
static const double us
Definition: Units.h:105
cet::LibraryManager dummy("noplugin")
shared_filter_t parse_freqmasks(Json::Value jfm)
std::vector< channel_group_t > m_channel_groups
Type
Type of JSON value.
Definition: rapidjson.h:618
virtual int pad_window_front(int channel) const
Sequence< complex_t > compseq_t
A complex-valued sequence, eg for discrete spectrum powers.
Definition: Waveform.h:34
shared_filter_t make_filter(std::complex< float > defval=std::complex< float >(1, 0))
WIRECELL_FACTORY(OmniChannelNoiseDB, WireCell::SigProc::OmniChannelNoiseDB, WireCell::IChannelNoiseDatabase, WireCell::IConfigurable) using namespace WireCell
Thrown when a wrong key or has been encountered.
Definition: Exceptions.h:43
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:92
int index() const
Layer as index number (0,1 or 2). -1 if unknown.
Definition: WirePlaneId.cxx:34