14 #include "TPolyLine3D.h" 15 #include "TPolyMarker3D.h" 48 std::vector<IDepo::pointer> ret;
62 AssertMsg(depos.back() ==
nullptr,
"Not given EOS terminated stream of depos");
63 auto drifter = Factory::find_tn<IDrifter>(tn);
65 for (
auto depo: depos) {
68 cerr <<
"test_depos: sending EOS to drifter\n";
70 bool ok = (*drifter)(depo, outq);
73 cerr <<
"test_depos: got " << outq.size() <<
" drifted\n";
75 drifted.insert(drifted.end(), outq.begin(), outq.end());
77 AssertMsg(drifted.back() ==
nullptr,
"Drifter did not pass on EOS");
79 for (
auto out : drifted) {
82 AssertMsg(vec.size() > 1,
"The history of the drifted deposition is truncated.");
85 cerr <<
"test_depos: start with: " << depos.size()
86 <<
", after drifting have: " << drifted.size() <<
endl;
93 std::vector<std::pair<double, double> > endpoints = {
97 { -10*units::cm+3*
units::mm, -10*units::cm-3*units::mm},
98 { +10*units::cm+3*
units::mm, +10*units::cm-3*units::mm},
102 for (
auto& ends : endpoints) {
105 cerr <<
"test_tracks: " << ray/
units::cm <<
"cm produces "<<depos.size()<<
"depos\n";
114 std::vector<IDepo::pointer> alldepos;
117 Assert(depos.back() ==
nullptr);
119 cerr <<
"test_time: " <<
t/
units::us <<
"us produces "<<depos.size()<<
"depos\n";
120 alldepos.insert(alldepos.end(), depos.begin(), depos.end());
122 alldepos.push_back(
nullptr);
141 std::vector<IDepo::pointer> alldepos;
142 for (
auto depos : {depos1, depos2, depos3}) {
143 Assert(depos.back() ==
nullptr);
145 alldepos.insert(alldepos.end(), depos.begin(), depos.end());
147 alldepos.push_back(
nullptr);
149 for (
auto& depo : drifted) {
154 <<
"("<<depo->prior()->time()/
units::us<<
")" 156 <<
"(" <<depo->prior()->pos().x()/
units::cm<<
")cm\n";
165 activity.push_back(
nullptr);
167 auto drifter = Factory::find_tn<IDrifter>(tn);
170 for (
auto in : activity) {
173 cerr <<
"test_drifter: sending EOS to drifter\n";
175 bool ok = (*drifter)(in, outq);
177 for (
auto d : outq) {
183 for (
auto out : result) {
186 AssertMsg(vec.size() > 1,
"The history of the drifted deposition is truncated.");
189 cerr <<
"test_drifter: start with: " << activity.size()
190 <<
", after drifting have: " << result.size() <<
endl;
200 for (
auto depo : activity) {
204 cout <<
"Bounds: " << bb.first <<
" --> " << bb.second <<
endl;
211 pm.
add(
"WireCellGen");
213 auto icfg = Factory::lookup<IConfigurable>(
"Random");
214 auto cfg = icfg->default_configuration();
215 icfg->configure(cfg);
218 auto icfg = Factory::lookup<IConfigurable>(
"Drifter");
219 auto cfg = icfg->default_configuration();
222 cfg[
"xregions"][0][
"cathode"] = 2*
units::m;
223 cfg[
"xregions"][0][
"anode"] = 10*
units::cm;
224 cfg[
"xregions"][1][
"anode"] = -10*
units::cm;
225 cfg[
"xregions"][1][
"cathode"] = -2*
units::m;
226 icfg->configure(cfg);
238 TCanvas
c(
"c",
"c",800,800);
240 TView* view = TView::CreateView(1);
241 view->SetRange(bb.first.x(),bb.first.y(),bb.first.z(),
242 bb.second.x(),bb.second.y(),bb.second.z());
248 TPolyMarker3D orig(activity.size(), 6);
249 orig.SetMarkerColor(2);
251 for (
auto depo : activity) {
252 const Point&
p = depo->pos();
253 orig.SetPoint(indx++, p.x(), p.y(), p.z());
258 double tmin=-1, tmax=-1;
259 for (
auto depo : drifted) {
261 cerr <<
"Reached EOI"<<
endl;
265 Assert(history.size() > 1);
267 if (tmin<0 && tmax<0) {
268 tmin = tmax = depo->time();
271 tmin =
min(tmin, depo->time());
272 tmax =
max(tmax, depo->time());
274 cerr <<
"Time bounds: " << tmin <<
" < " << tmax <<
endl;
276 for (
auto depo : drifted) {
278 cerr <<
"Reached EOI"<<
endl;
283 TPolyMarker3D* pm =
new TPolyMarker3D(1,8);
284 const Point&
p = depo->pos();
285 pm->SetPoint(0, p.x(), p.y(), p.z());
287 double rel = depo->time()/(tmax-tmin);
288 int col = TColor::GetColorPalette(
int(rel*TColor::GetNumberOfColors()) );
289 pm->SetMarkerColor(col);
std::pair< Point, Point > Ray
A line segment running from a first (tail) to a second (head) point.
std::shared_ptr< const IDepo > pointer
IDepo::vector depo_chain(IDepo::pointer recent)
void add_track(double time, const WireCell::Ray &ray, double dedx=-1.0)
Gen::TrackDepos make_tracks()
D3Vector< double > Point
A 3D Cartesian point in double precision.
IDepo::vector test_drifted(std::string tn)
std::deque< IDepo::pointer > test_depos(const std::vector< IDepo::pointer > &depos, std::string tn="Drifter")
void test_order(std::string tn="Drifter")
std::vector< pointer > vector
static PluginManager & instance()
std::deque< output_pointer > output_queue
A producer of depositions created from some number of simple, linear tracks.
def activity(output, slices, slice_line, cluster_tap_file)
int main(int argc, char *argv[])
static int max(int a, int b)
void test_tracks(std::string tn="Drifter")
std::string format(const std::string &form, TYPES...objs)
void test_time(std::string tn="Drifter")
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
std::vector< IDepo::pointer > track_depos(double t, const Ray &ray)
Plugin * add(const std::string &plugin_name, const std::string &libname="")
Add a plugin. If libname is not given, try to derive it.
IDepo::shared_vector get_depos()
std::shared_ptr< const vector > shared_vector
const Ray & bounds() const
Return the ray representing the bounds.
QTextStream & endl(QTextStream &s)