10 std::vector<double> ret;
16 cerr<<
"NOT one sample for true point source: "<<nsamples<<
"\n";
21 ret.resize(nsamples, 0.0);
22 for (
int ind=0; ind<nsamples; ++ind) {
23 const double rel = (start + ind*step -
center)/sigma;
24 ret[ind] = exp(-0.5*rel*rel);
33 std::vector<double> bins;
39 cerr<<
"NOT one bin for true point source: "<<nbins<<
"\n";
43 bins.resize(nbins, 0.0);
44 std::vector<double> erfs(nbins+1, 0.0);
45 const double sqrt2 = sqrt(2.0);
46 for (
int ind=0; ind <=
nbins; ++ind) {
47 double x = (start + step * ind -
center)/(sqrt2*sigma);
48 erfs[ind] = 0.5*std::erf(x);
52 for (
int ibin=0; ibin <
nbins; ++ibin) {
53 const double val = erfs[ibin+1] - erfs[ibin];
66 std::vector<double> wt;
69 wt[0] = (start+step -
center)/step;
72 wt.resize(nbins, 0.0);
73 const double pi = 4.0*atan(1);
76 double gaus2 = exp(-0.5*(start-
center)/sigma*(start-
center)/sigma);
78 for (
int ind=0; ind<
nbins; ind++)
82 double rel = (x2-
center)/sigma;
84 gaus2 = exp(-0.5*rel*rel);
87 wt[ind] = -1.0*sigma/(x1-x2)*(gaus2-gaus1)/sqrt(2.0*pi)/pvec[ind] + (
center-x2)/(x1-x2);
117 , m_time_desc(time_desc)
118 , m_pitch_desc(pitch_desc)
128 unsigned int weightstrat)
143 cerr <<
"Gen::GaussianDiffusion: no time bins for [" << tval_range.first/
units::us <<
"," << tval_range.second/
units::us <<
"] us\n";
149 auto pbin_range = pbin.
sample_bin_range(pval_range.first, pval_range.second);
150 const size_t npss = pbin_range.second - pbin_range.first;
157 cerr <<
"No impact bins [" << pval_range.first/
units::mm <<
"," << pval_range.second/
units::mm <<
"] mm\n";
165 if(weightstrat == 2){
169 if(weightstrat == 1){
174 patch_t ret = patch_t::Zero(npss, ntss);
178 for (
size_t ip = 0; ip < npss; ++ip) {
179 for (
size_t it = 0; it < ntss; ++it) {
180 const double val = pvec[ip]*tvec[it];
182 ret(ip,it) = (float)val;
189 const double charge_sign =
m_deposition->charge() < 0 ? -1 : 1;
193 double unfluc_sum = 0;
195 for (
size_t ip = 0; ip < npss; ++ip) {
196 for (
size_t it = 0; it < ntss; ++it) {
197 const float oldval = ret(ip,it);
198 unfluc_sum += oldval;
205 fluc_sum += charge_sign*number;
206 ret(ip,it) = charge_sign*number;
std::shared_ptr< const IDepo > pointer
const std::vector< double > weights() const
std::vector< double > binint(double start, double step, int nbins) const
void set_sampling(const Binning &tbin, const Binning &pbin, double nsigma=3.0, IRandom::pointer fluctuate=nullptr, unsigned int weightstrat=1)
std::vector< double > m_qweights
std::vector< double > weight(double start, double step, int nbins, std::vector< double > pvec) const
const patch_t & patch() const
std::pair< double, double > sigma_range(double nsigma=3.0)
std::shared_ptr< Interface > pointer
GaussianDiffusion(const IDepo::pointer &depo, const GausDesc &time_desc, const GausDesc &pitch_desc)
GaussianDiffusion.
std::vector< double > sample(double start, double step, int nsamples) const
double edge(int ind) const
std::pair< int, int > sample_bin_range(double minval, double maxval) const
IDepo::pointer m_deposition