46 unsigned int wfs = wf.size();
48 std::vector<float> intermediate_wf(wfs);
49 float filter_coef =
static_cast<float>(TMath::Exp(static_cast<double>(-1.0/
fFilterWidth)));
50 float a0 = 1.0-filter_coef;
51 float b1 = filter_coef;
52 unsigned int order = 1;
53 for (
size_t i = 0; i < wfs; ++i)
57 intermediate_wf[i] = wf[i];
61 intermediate_wf[i] = a0*wf[i]+b1*intermediate_wf[i-1];
64 for (
size_t i = 0; i < wfs; ++i)
68 fwf[wfs-1-i] = intermediate_wf[wfs-1-i];
72 fwf[wfs-1-i] = a0*intermediate_wf[wfs-1-i]+b1*fwf[wfs-i];
79 unsigned int window_size = (
unsigned int)(0.10*wf.size());
80 std::vector<float> bl_collection;
81 for (
size_t i_wf = 0; i_wf < wf.size()-window_size; ++i_wf)
83 std::vector<float> partial_window(wf.begin()+i_wf,wf.begin()+i_wf+window_size);
84 bl_collection.push_back(static_cast<float>(TMath::Mean(partial_window.size(),partial_window.data())));
86 bl =
static_cast<float>(TMath::Median(bl_collection.size(),bl_collection.data()));
88 std::vector<float> bl_sub_wf;
89 for (
size_t i_wf = 0; i_wf < wf.size(); ++i_wf) bl_sub_wf.push_back(wf[i_wf]-bl);
91 std::vector<float> rms_collection;
92 for (
size_t i_wf = 0; i_wf < bl_sub_wf.size()-window_size; ++i_wf)
94 std::vector<float> partial_window(bl_sub_wf.begin()+i_wf,bl_sub_wf.begin()+i_wf+window_size);
95 rms_collection.push_back(static_cast<float>(TMath::RMS(partial_window.size(),partial_window.data())));
98 r =
static_cast<float>(TMath::Median(rms_collection.size(),rms_collection.data()));
105 int start = 0,
end = 0;
106 bool started =
false;
107 for (
int i_wf = 0; i_wf < static_cast<int>(wf.size())-
fWindowWidth; ++i_wf)
109 std::vector<float> window(wf.begin()+i_wf,wf.begin()+i_wf+
fWindowWidth);
110 float window_mean =
static_cast<float>(TMath::Mean(window.size(),window.data()));
114 for (
int i_wf_back = i_wf-1; i_wf_back >= 0; --i_wf_back)
116 std::vector<float> window_back(wf.begin()+i_wf_back,wf.begin()+i_wf_back+
fWindowWidth);
117 float window_mean_back =
static_cast<float>(TMath::Mean(window_back.size(),window_back.data()));
126 if ((window_mean < bl+fSigmaFallThreshold*r && window_mean > bl-
fSigmaFallThreshold*r) && started)
142 std::vector<std::pair<int,int> > oldpulse_ends =
std::move(pulse_ends);
144 std::sort(oldpulse_ends.begin(),oldpulse_ends.end());
145 int start = 0,
end = 0;
146 bool started =
false;
147 for (
size_t i_p = 0; i_p < oldpulse_ends.size(); ++i_p)
149 if (!started) start = oldpulse_ends[i_p].first;
150 end = oldpulse_ends[i_p].second;
151 if (i_p < oldpulse_ends.size()-1 && oldpulse_ends[i_p+1].first < oldpulse_ends[i_p].second)
153 end = oldpulse_ends[i_p+1].second;
159 pulse_ends.push_back(std::make_pair(start,
end));
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
void reconfigure(fhicl::ParameterSet const &p)
void FilterWaveform(std::vector< float > wf, std::vector< float > &fwf)
RMSHitFinderAlg(fhicl::ParameterSet const &p)
void RobustRMSBase(std::vector< float > wf, float &bl, float &r)
float fSigmaRiseThreshold
void FindPulses(std::vector< float > wf, float bl, float r, std::vector< std::pair< int, int > > &pulse_ends)
void FindHits(dune::ChannelInformation &chan)
float fSigmaFallThreshold
T get(std::string const &key) const
void MergeHits(std::vector< std::pair< int, int > > &pulse_ends)
void SetSearchTicks(int s, int e)