DepoSplat.cxx
Go to the documentation of this file.
3 
4 #include "WireCellUtil/Binning.h"
6 
7 #include <iostream>
8 
11 
12 
13 
14 
15 using namespace WireCell;
16 
18  : Ductor()
19 {
20 }
21 
22 Gen::DepoSplat::~DepoSplat()
23 {
24 }
25 
26 
27 ITrace::vector Gen::DepoSplat::process_face(IAnodeFace::pointer face,
28  const IDepo::vector& depos)
29 
30 {
31  // channel-charge map
32  std::unordered_map<int, std::vector<float> > chch;
33 
34  // tick-edged bins
35  Binning tbins(m_readout_time/m_tick, m_start_time,
36  m_start_time+m_readout_time);
37 
38  int iplane = -1;
39  for (auto plane : face->planes()) {
40  ++iplane;
41 
42  const Pimpos* pimpos = plane->pimpos();
43 
44  // wire-centered pitch bins
45  const Binning& wbins = pimpos->region_binning();
46 
47 
48  auto& wires = plane->wires();
49 
50  // std::cerr << "splat: plane " << plane->planeid() << " "
51  // << "wbins:" << wbins << " "
52  // << "tbins:" << tbins << " "
53  // << "#wires:" << wires.size() << " "
54  // << "#depos:" << depos.size() << "\n";
55 
56  int idepo = 0;
57  for (auto depo : depos) {
58 
59  const double pwid = m_nsigma * depo->extent_tran();
60  const double pcen = pimpos->distance(depo->pos());
61 
62  const double twid = m_nsigma*depo->extent_long();
63  const double tcen = depo->time();
64 
65  const int pbeg = std::max(wbins.bin(pcen-pwid), 0);
66  const int pend = std::min(wbins.bin(pcen+pwid)+1, (int)wires.size());
67  const int tbeg = tbins.bin(tcen-twid); // fixme what limits
68  const int tend = tbins.bin(tcen+twid)+1; // to enforce here?
69 
70  // if (idepo == 0) {
71  // std::cerr << "splat: depo=" << depo->pos()/units::mm << "mm "
72  // << "@" << depo->time()/units::ms<< " ms "
73  // << "p=(" << pcen << "+-" << pwid << "), t=(" << tcen << "+=" << twid << ") "
74  // << "pi=[" << pbeg << " " << pend << "], ti=[" << tbeg << " " << tend << "]\n";
75  // }
76 
77  for (int ip = pbeg; ip < pend; ++ip) {
78  auto iwire = wires[ip];
79  auto& charge = chch[iwire->channel()];
80  if ((int)charge.size() < tend) {
81  charge.resize(tend, 0.0);
82  }
83  for (int it = tbeg; it < tend; ++it) {
84  charge[it] += std::abs(depo->charge());
85  }
86  }
87  ++idepo;
88  }
89  }
90 
91  // make output traces
92  ITrace::vector traces;
93  for (auto& chchit : chch) {
94  const int chid = chchit.first;
95  auto& chv = chchit.second;
96  auto trace = std::make_shared<SimpleTrace>(chid, 0, chv);
97  traces.push_back(trace);
98  }
99  return traces;
100 }
const Binning & region_binning() const
Definition: Pimpos.h:109
double distance(const Point &pt, int axis=2) const
Definition: Pimpos.cxx:71
std::vector< pointer > vector
Definition: IData.h:21
Binning tbins(nticks, t0, t0+readout_time)
T abs(T value)
int bin(double val) const
Definition: Binning.h:80
std::shared_ptr< Interface > pointer
Definition: Interface.h:16
WIRECELL_FACTORY(DepoSplat, WireCell::Gen::DepoSplat, WireCell::IDuctor, WireCell::IConfigurable) using namespace WireCell
static int max(int a, int b)
Definition: Main.h:22
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
Pimpos pimpos(nwires, min_wire_pitch, max_wire_pitch)
Pitch-Impact-Position.
Definition: Pimpos.h:36