7 #include <boost/format.hpp> 26 double drift_velocity,
29 : m_pitch_origin(pitch.first)
31 , m_time_offset(time_offset)
32 , m_origin_l(origin_l)
34 , m_binsize_l(binsize_l)
38 , m_drift_velocity(drift_velocity)
39 , m_max_sigma_l(max_sigma_l)
54 <<
"\"pitch_origin\":{\"x\":0.0,\"y\":0.0,\"z\":0.0},\n" 55 <<
"\"pitch_direction\":{\"x\":0.0,\"y\":0.0,\"z\":1.0},\n" 56 <<
"\"pitch_distance\":" << 5.0*
units::mm <<
",\n" 57 <<
"\"timeslice\":" << 2.0 *
units::us <<
",\n" 58 <<
"\"timeoffset\":0.0,\n" 59 <<
"\"starttime\":0.0,\n" 60 <<
"\"origin\":0.0,\n" 64 <<
"\"max_sigma_l\":" << 5.0 *
units::us <<
",\n" 113 cerr << ss.str() <<
endl;;
124 outq.push_back(diff);
126 outq.push_back(
nullptr);
132 const double drift_distance = first->pos().x() - depo->pos().x();
143 <<
" drift distance=" << drift_distance
144 <<
" drift time=" << drift_time
145 <<
" pitch distance = " << pitch_distance
149 sigmaL, sigmaT, depo->charge(), depo);
155 const double last_center = 0.5*(last->lend() + last->lbegin());
163 outq.push_back(first);
176 int nbins = round((bounds.second - bounds.first)/binsize);
179 std::vector<double>
integral(nbins+1, 0.0);
180 for (
int ibin=0; ibin <=
nbins; ++ibin) {
181 double absx = bounds.first + ibin*binsize;
182 double t = 0.5*(absx-
mean)/sigma;
183 double e = 0.5*std::erf(t);
187 std::vector<double> bins;
188 for (
int ibin=0; ibin<
nbins; ++ibin) {
189 bins.push_back(integral[ibin+1] - integral[ibin]);
197 double low = floor( (mean -
m_nsigma*sigma - origin) / binsize ) * binsize +
origin;
198 double high = ceil( (mean +
m_nsigma*sigma - origin) / binsize ) * binsize +
origin;
200 return std::make_pair(low, high);
205 double sigma_l,
double sigma_t,
211 std::vector<double> l_bins =
oned(mean_l, sigma_l,
m_binsize_l, bounds_l);
212 std::vector<double> t_bins =
oned(mean_t, sigma_t,
m_binsize_t, bounds_t);
214 if (l_bins.empty() || t_bins.empty()) {
220 for (
auto l : l_bins) {
221 for (
auto t : t_bins) {
230 l_bins.size(), t_bins.size(),
231 bounds_l.first, bounds_t.first,
232 bounds_l.second, bounds_t.second);
234 for (
size_t ind_l = 0; ind_l < l_bins.size(); ++ind_l) {
235 for (
size_t ind_t = 0; ind_t < t_bins.size(); ++ind_t) {
236 double value = l_bins[ind_l]*t_bins[ind_t]/power*
weight;
237 smear->
set(ind_l, ind_t, value);
virtual bool operator()(const input_pointer &depo, output_queue &outq)
The calling signature:
std::pair< Point, Point > Ray
A line segment running from a first (tail) to a second (head) point.
std::shared_ptr< const IDiffusion > pointer
IDepo::vector depo_chain(IDepo::pointer recent)
virtual double set(int lind, int tind, double value)
void msg(const char *fmt,...)
void dump(const std::string &msg)
virtual void configure(const WireCell::Configuration &config)
Accept a configuration.
IDiffusion::pointer diffuse(double mean_l, double mean_t, double sigma_l, double sigma_t, double weight=1.0, IDepo::pointer depo=nullptr)
virtual WireCell::Configuration default_configuration() const
Optional, override to return a hard-coded default configuration.
static const double centimeter
std::deque< output_pointer > output_queue
std::vector< double > oned(double mean, double sigma, double binsize, const Diffuser::bounds_type &bounds)
double ray_length(const Ray &ray)
static const double centimeter2
Vector ray_unit(const Ray &ray)
auto norm(Vector const &v)
Return norm of the specified vector.
WIRECELL_FACTORY(Diffuser, WireCell::Diffuser, WireCell::IDiffuser, WireCell::IConfigurable) using namespace std
std::pair< double, double > bounds_type
static const double second
Json::Value loads(const std::string &text, const externalvars_t &extvar=externalvars_t(), const externalvars_t &extcode=externalvars_t())
T dot(const D3Vector &rhs) const
Return the dot product of this vector and the other.
const GenericPointer< typename T::ValueType > T2 value
bounds_type bounds(double mean, double sigma, double binsize, double origin=0.0)
Json::Value Configuration
std::shared_ptr< const IDepo > input_pointer
double mean(sqlite3 *db, std::string const &table_name, std::string const &column_name)
constexpr Point origin()
Returns a origin position with a point of the specified type.
QTextStream & endl(QTextStream &s)