#include "WireCellUtil/RayGrid.h"
#include "WireCellUtil/Logging.h"
#include "WireCellUtil/Testing.h"
#include "TCanvas.h"
#include "TMarker.h"
#include "TText.h"
#include "TLine.h"
#include "TH1F.h"
#include <string>
#include <sstream>
#include "raygrid.h"
Go to the source code of this file.
|
void | draw_ray (const Ray &ray, int color=1) |
|
void | draw_point (const Point &p, float size=1, int style=20, int color=1) |
|
void | draw_text (const Point &p, std::string text) |
|
void | draw_zero_crossing (const Coordinates &rg, layer_index_t il, layer_index_t im) |
|
void | draw_segments (const Coordinates &rg) |
|
void | draw_pairs (const ray_pair_vector_t &raypairs) |
|
TH1F * | draw_frame (TCanvas &canvas, std::string title, double xmin=-110, double ymin=-110, double xmax=+110, double ymax=+110) |
|
void | draw (std::string fname, const Coordinates &rg, const ray_pair_vector_t &raypairs) |
|
void | dump (std::string msg, const tensor_t &ar) |
|
void | test_012 (const Coordinates &rg) |
|
int | main (int argc, char *argv[]) |
|
Definition at line 153 of file test_raygrid.cxx.
156 TCanvas canvas(
"test_raygrid",
"Ray Grid", 500, 500);
157 auto draw_print = [&](
std::string extra=
"") { canvas.Print((
fname + extra).c_str(),
"pdf"); };
165 const int nbounds = raypairs.size();
171 draw_frame(canvas, Form(
"LAYER (%d,%d)", (
int)il, (
int)
im));
180 if (
p.z() < 0.0 or
p.z() > 100.0)
continue;
181 if (
p.y() < 0.0 or
p.y() > 100.0)
continue;
void draw_pairs(const ray_pair_vector_t &raypairs)
TH1F * draw_frame(TCanvas &canvas, std::string title, double xmin=-110, double ymin=-110, double xmax=+110, double ymax=+110)
void draw_segments(const Coordinates &rg)
Vector ray_crossing(const coordinate_t &one, const coordinate_t &two) const
void draw_zero_crossing(const Coordinates &rg, layer_index_t il, layer_index_t im)
void draw_point(const Point &p, float size=1, int style=20, int color=1)
TH1F* draw_frame |
( |
TCanvas & |
canvas, |
|
|
std::string |
title, |
|
|
double |
xmin = -110 , |
|
|
double |
ymin = -110 , |
|
|
double |
xmax = +110 , |
|
|
double |
ymax = +110 |
|
) |
| |
Definition at line 144 of file test_raygrid.cxx.
148 auto* frame = canvas.DrawFrame(xmin,ymin,xmax,ymax);
149 frame->SetTitle(
title.c_str());
Definition at line 136 of file test_raygrid.cxx.
138 for (
const auto& rp : raypairs) {
void draw_ray(const Ray &ray, int color=1)
void draw_point |
( |
const Point & |
p, |
|
|
float |
size = 1 , |
|
|
int |
style = 20 , |
|
|
int |
color = 1 |
|
) |
| |
Definition at line 30 of file test_raygrid.cxx.
33 m.SetMarkerColor(
color);
34 m.SetMarkerSize(
size);
35 m.SetMarkerStyle(style);
36 m.DrawMarker(
p.z(),
p.y());
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
void draw_ray |
( |
const Ray & |
ray, |
|
|
int |
color = 1 |
|
) |
| |
Definition at line 21 of file test_raygrid.cxx.
24 l.SetLineColor(
color);
25 l.DrawLine(ray.first.z(), ray.first.y(),
26 ray.second.z(), ray.second.y());
Definition at line 68 of file test_raygrid.cxx.
70 const auto c0 = rg.
centers()[0];
79 for (
int lind=2; lind < rg.
nlayers(); ++lind) {
83 const auto rdir = pdir.cross(ecks);
91 const auto pc = next_center;
92 const double d0 = p0.dot(
pc-c0);
93 const double d1 =
p1.dot(
pc-
c1);
94 if (d0 < 0 or d0 > pm0) {
break; }
95 if (d1 < 0 or d1 > pm1) {
break; }
99 if (1.0-p0.dot(pdir) < 0.001) {
103 else if (1.0-
p1.dot(pdir) < 0.001) {
112 std::vector<Vector> crossings {
118 sort(crossings.begin(), crossings.end(),
120 return rdir.dot(a-
pc) < rdir.dot(
b-
pc);
129 next_center = 0.5*(pa+
pb) + pmag * pdir;
std::pair< Point, Point > Ray
A line segment running from a first (tail) to a second (head) point.
void draw_ray(const Ray &ray, int color=1)
const vector_array1d_t & pitch_dirs() const
Vector ray_crossing(const coordinate_t &one, const coordinate_t &two) const
std::tuple< double, double, const reco::ClusterHit3D * > Point
Definitions used by the VoronoiDiagram algorithm.
const vector_array1d_t & centers() const
const std::vector< double > & pitch_mags() const
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
std::vector< float > Vector
Definition at line 45 of file test_raygrid.cxx.
51 const auto&
c1 =
cs[il];
52 const auto& c2 =
cs[
im];
57 const auto& j1 = rjs(il,
im);
58 const auto& j2 = rjs(
im,il);
64 ss <<
"(" << il <<
"," <<
im <<
")";
std::pair< Point, Point > Ray
A line segment running from a first (tail) to a second (head) point.
const vector_array2d_t & ray_jumps() const
void draw_ray(const Ray &ray, int color=1)
const vector_array1d_t & centers() const
void draw_text(const Point &p, std::string text)
Vector zero_crossing(layer_index_t one, layer_index_t two) const
void draw_point(const Point &p, float size=1, int style=20, int color=1)
Definition at line 195 of file test_raygrid.cxx.
199 auto shape = ar.shape();
200 std::stringstream ss;
201 ss <<
"Dimensions: " << shape[0] <<
" " << shape[1] <<
" "<< shape[2];
205 for (
size_t i = 0; i < shape[0]; ++i) {
206 for (
size_t j = 0; j < shape[1]; ++j) {
208 for (
size_t k = 0;
k < shape[2]; ++
k) {
209 line += Form(
"%.1f", ar[i][j][
k]);
void msg(const char *fmt,...)
int main |
( |
int |
argc, |
|
|
char * |
argv[] |
|
) |
| |
Definition at line 240 of file test_raygrid.cxx.
248 Assert(rg.nlayers() == (
int)raypairs.size());
250 for (
int ind=0; ind<rg.nlayers(); ++ind) {
251 info(
"{} r1={} r2={} p={}[{}] c={}",
255 rg.pitch_dirs().at(ind),
256 rg.pitch_mags().at(ind),
257 rg.centers().at(ind));
262 draw(fname, rg, raypairs);
std::vector< ray_pair_t > ray_pair_vector_t
void draw(std::string fname, const Coordinates &rg, const ray_pair_vector_t &raypairs)
void test_012(const Coordinates &rg)
ray_pair_vector_t make_raypairs(double width=100, double height=100, double pitch_mag=3, double angle=60.0 *M_PI/180.0)
second_as<> second
Type of time stored in seconds, in double precision.
Definition at line 217 of file test_raygrid.cxx.
222 std::vector<double>
ps;
223 for (
int a=0;
a<2; ++
a) {
224 for (
int b=0;
b<2; ++
b) {
226 info(
"a={} b={} p={}",
a,
b,p);
231 Assert(ps.front() != ps.back());
double pitch_location(const coordinate_t &one, const coordinate_t &two, layer_index_t other) const
void dump(std::string msg, const tensor_t &ar)
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a