Derivations.cxx
Go to the documentation of this file.
2 
3 #include <iostream>
4 
5 using namespace WireCell::SigProc;
6 
7 std::pair<double,double> Derivations::CalcRMS(const WireCell::Waveform::realseq_t& signal)
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 }
21 
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 }
72 
73 
74 // Local Variables:
75 // mode: c++
76 // c-basic-offset: 4
77 // End:
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
Waveform::realseq_t signal_t
std::pair< double, double > CalcRMS(const WireCell::Waveform::realseq_t &signal)
Definition: Derivations.cxx:7
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:87
WireCell::Waveform::realseq_t CalcMedian(const WireCell::IChannelFilter::channel_signals_t &chansig)
Definition: Derivations.cxx:22
real_t median_binned(realseq_t &wave)
Definition: Waveform.cxx:81
std::map< int, signal_t > channel_signals_t
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