Functions
WireCell::SigProc::Derivations Namespace Reference

Functions

WireCell::Waveform::realseq_t CalcMedian (const WireCell::IChannelFilter::channel_signals_t &chansig)
 
std::pair< double, double > CalcRMS (const WireCell::Waveform::realseq_t &signal)
 

Function Documentation

WireCell::Waveform::realseq_t WireCell::SigProc::Derivations::CalcMedian ( const WireCell::IChannelFilter::channel_signals_t chansig)

Return a sequence of the median values, one for each channel signal.

fixme and warning: this ignores small and large signal with fixed thresholds which need to be set as parameters.

Definition at line 22 of file Derivations.cxx.

23 {
24  float max_rms = 0;
25  float count_max_rms = 0;
26  const int nchannel = chansig.size();
27  const int nbins = (chansig.begin()->second).size();
28  //float content[nchannel][nbins];
29  std::vector<float> content(nchannel*nbins, 0.0); // 2D array [channel*nbins + bin]
30 
31  int start_ch = 0;
32  for (auto it: chansig){
33  //const int ch = it.first;
34  WireCell::IChannelFilter::signal_t& signal = it.second;
35  std::pair<double,double> temp = WireCell::Waveform::mean_rms(signal);
36 
37  if (temp.second >0){
38  max_rms += temp.second;
39  count_max_rms ++;
40  }
41 
42  for (int i=0;i!=nbins;i++){
43  content[start_ch*nbins + i] = signal.at(i);
44  }
45  start_ch ++;
46  }
47 
48  if (count_max_rms >0) {
49  max_rms /= count_max_rms;
50  }
51 
52  WireCell::Waveform::realseq_t medians(nbins);
53  for (int ibin=0;ibin!=nbins;ibin++){
55  for (int ich=0; ich!=nchannel; ich++) {
56  const float cont = content.at(ich*nbins + ibin);
57  if (fabs(cont) < 5 * max_rms &&
58  fabs(cont) > 0.001){
59  temp.push_back(cont);
60  }
61  }
62  if (temp.size()>0){
63  medians.at(ibin)=WireCell::Waveform::median_binned(temp);
64  }
65  else{
66  medians.at(ibin)=0;
67  }
68  }
69 
70  return medians;
71 }
Sequence< real_t > realseq_t
Definition: Waveform.h:31
Waveform::realseq_t signal_t
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:87
real_t median_binned(realseq_t &wave)
Definition: Waveform.cxx:81
std::pair< double, double > mean_rms(const realseq_t &wave)
Definition: Waveform.cxx:24
std::pair< double, double > WireCell::SigProc::Derivations::CalcRMS ( const WireCell::Waveform::realseq_t signal)

Return the RMS of a signal

fixme and warning: this ignores large signal with a fixed threshold which needs to be set as parameters.

Definition at line 7 of file Derivations.cxx.

8 {
9  std::pair<double,double> temp = WireCell::Waveform::mean_rms(signal);
10  double mean = temp.first;
11  double rms = temp.second;
13  for (size_t i=0;i!=signal.size();i++){
14  if (fabs(signal.at(i)-mean) < 4.5 * rms){
15  temp1.push_back(signal.at(i));
16  }
17  }
18  temp = WireCell::Waveform::mean_rms(temp1);
19  return temp;
20 }
Sequence< real_t > realseq_t
Definition: Waveform.h:31
double rms(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:39
std::pair< double, double > mean_rms(const realseq_t &wave)
Definition: Waveform.cxx:24
double mean(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:15