72 const int ndiffision_sigma = 3.0;
79 auto track_start = track_ray.first;
80 auto track_dir =
ray_unit(track_ray);
88 meta.
em(
"begin adding Depp's");
89 for (
double dist=0.0; dist < track_length; dist += stepsize) {
90 auto pt = track_start + dist*track_dir;
91 const double delta_x = pt.x() - xstop;
94 const double time = track_time+drift_time;
97 Assert(rbins.inside(pitch));
98 Assert(ibins.inside(pitch));
105 auto depo = std::make_shared<SimpleDepo>(time, pt, charge);
106 bd.add(depo, sigmaL, sigmaT);
111 meta.
em(
"begin swiping wires");
114 for (
int iwire = 0; iwire <
nwires; ++iwire) {
122 std::pair<double,double> time_span(0,0);
123 std::vector<Gen::ImpactData::pointer> collect;
126 for (
int imp = min_impact; imp <= max_impact; ++imp) {
127 auto impact_data = bd.impact_data(imp);
132 const int impnum = impact_data->impact_number();
133 if (seen.find(impnum) != seen.end()) {
134 cerr <<
"Got duplicate impact number: " << impnum <<
" in wire " << iwire <<
endl;
138 cerr <<
"collecting: " << iwire <<
" " << impnum <<
endl;
141 auto ts = impact_data->span(ndiffision_sigma);
142 if (collect.empty()) {
146 time_span.first =
std::min(time_span.first, ts.first);
147 time_span.second =
std::max(time_span.second, ts.second);
149 collect.push_back(impact_data);
152 if (collect.empty()) {
159 cerr <<
"Not histogramming\n";
166 const double min_time =
tbins.
edge(min_tedge);
167 const double max_time =
tbins.
edge(max_tedge);
168 const int ntbins = max_tedge - min_tedge;
170 const double min_pitch = ibins.edge(min_impact);
171 const double max_pitch = ibins.edge(max_impact);
172 const int npbins = (max_pitch-min_pitch)/ibins.binsize();
177 Assert(max_time > min_time);
179 Assert(max_pitch > min_pitch);
182 TH2F
hist(Form(
"hwire%04d", iwire),Form(
"Diffused charge for wire %d", iwire),
185 hist.SetXTitle(
"time (us)");
186 hist.SetYTitle(
"pitch (mm)");
188 TH1F hp(Form(
"pwire%04d", iwire),Form(
"Pitches for wire %d", iwire),
190 TH1F ht(Form(
"twire%04d", iwire),Form(
"Times for wire %d", iwire),
193 for (
auto idptr : collect) {
194 auto wave = idptr->waveform();
196 const int impact = idptr->impact_number();
197 const double pitch_dist = ibins.center(impact);
199 cerr << iwire <<
" impact=" << impact <<
" pitch=" << pitch_dist <<
endl;
201 auto mm = idptr->span(ndiffision_sigma);
205 for (
int itick=min_tick; itick<=max_tick; ++itick) {
208 cerr <<
"OOB time: " << time/
units::us <<
"us tick:"<<itick
209 <<
" impact:" << idptr->impact_number()
210 <<
" pitch:" << pitch_dist/
units::mm <<
"mm\n";
214 Assert(rbins.inside(pitch_dist));
216 const double p_mm = pitch_dist/
units::mm;
217 hist.Fill(t_us, p_mm, wave[itick]);
code to link reconstructed objects back to the MC truth information
int edge_index(double val) const
double center(int ind) const
const Point & origin() const
Return given 3-point origin for plane pitch.
const Binning & region_binning() const
double distance(const Point &pt, int axis=2) const
Binning tbins(nticks, t0, t0+readout_time)
const Binning & impact_binning() const
int bin(double val) const
double ray_length(const Ray &ray)
Vector ray_unit(const Ray &ray)
static int max(int a, int b)
bool inside(double val) const
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Pimpos pimpos(nwires, min_wire_pitch, max_wire_pitch)
std::pair< int, int > wire_impacts(int wireind) const
double edge(int ind) const
static const double centimeter
second_as<> second
Type of time stored in seconds, in double precision.
QTextStream & endl(QTextStream &s)
static const double centimeter2