64 double_t ave_coef1 = 0;
65 std::map<int,double> coef_all;
67 const int nbin = medians.size();
69 for (
auto it: chansig) {
84 for (
int j=0;j!=nbin;j++){
85 if (fabs(signal.at(j)) < 4 * temp.second){
86 sum2 += signal.at(j) * medians.at(j);
87 sum3 += medians.at(j) * medians.at(j);
104 ave_coef = ave_coef / ave_coef1;
107 for (
auto it: chansig) {
112 scaling = coef_all[ch]/ave_coef;
114 if (scaling < 0) scaling = 0;
116 if (scaling > 1.5) scaling = 1.5;
125 if (respec.size() > 0 && (respec.at(0).real()!=1 || respec.at(0).imag()!=0) && res_offset!=0){
126 int nbin = signal.size();
128 for (
auto roi: rois){
129 const int bin0 =
std::max(roi.front()-1, 0);
130 const int binf =
std::min(roi.back()+1, nbin-1);
131 const double m0 = signal[bin0];
132 const double mf = signal[binf];
133 const double roi_run = binf - bin0;
134 const double roi_rise = mf - m0;
135 for (
auto bin : roi) {
136 const double m = m0 + (
bin - bin0)/roi_run*roi_rise;
137 signal_roi.at(
bin) = signal.at(
bin) -
m;
144 for (
size_t i=0;i!=signal_roi_freq.size();i++){
147 if (i <signal_roi_freq.size()/2.){
148 freq = i/(1.*signal_roi_freq.size())*2.;
150 freq = (signal_roi_freq.size() - i)/(1.*signal_roi_freq.size())*2.;
153 signal_roi_freq.at(i) = signal_roi_freq.at(i) * factor;
157 std::map<int, bool> flag_replace;
158 for (
auto roi: rois){
159 flag_replace[roi.front()] =
false;
163 for (
auto roi: rois){
164 const int bin0 =
std::max(roi.front()-1, 0);
165 const int binf =
std::min(roi.back()+1, nbin-1);
168 for (
int i=bin0; i<=binf; i++){
169 int time_bin = i-res_offset;
170 if (time_bin <0) time_bin += nbin;
171 if (time_bin >=nbin) time_bin -= nbin;
173 max_val = signal_roi_decon.at(time_bin);
174 min_val = signal_roi_decon.at(time_bin);
176 if (signal_roi_decon.at(time_bin) > max_val) max_val = signal_roi_decon.at(time_bin);
177 if (signal_roi_decon.at(time_bin) < min_val) min_val = signal_roi_decon.at(time_bin);
184 if ( max_val > decon_limit1 && fabs(min_val) < max_val * roi_min_max_ratio)
185 flag_replace[roi.front()] =
true;
190 for (
auto roi : rois) {
192 const int bin0 =
std::max(roi.front()-1, 0);
193 const int binf =
std::min(roi.back()+1, nbin-1);
194 if (flag_replace[roi.front()]){
195 const double m0 = temp_medians[bin0];
196 const double mf = temp_medians[binf];
197 const double roi_run = binf - bin0;
198 const double roi_rise = mf - m0;
199 for (
auto bin : roi) {
200 const double m = m0 + (
bin - bin0)/roi_run*roi_rise;
201 temp_medians.at(
bin) =
m;
207 for (
int i=0;i!=nbin;i++){
208 if (fabs(signal.at(i)) > 0.001) {
209 signal.at(i) = signal.at(i) - temp_medians.at(i) * scaling;
216 for (
int i=0;i!=nbin;i++){
217 if (fabs(signal.at(i)) > 0.001) {
218 signal.at(i) = signal.at(i) - medians.at(i) * scaling;
222 chansig[ch] = signal;
Waveform::realseq_t signal_t
double filter_low_loose(double freq)
std::pair< double, double > CalcRMS(const WireCell::Waveform::realseq_t &signal)
static int max(int a, int b)
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
QTextStream & bin(QTextStream &s)
double filter_time(double freq)