Functions | Variables
test_raytiling_speed.cxx File Reference
#include "WireCellUtil/RayTiling.h"
#include "WireCellUtil/Testing.h"
#include "WireCellUtil/ExecMon.h"
#include <random>
#include <iostream>
#include "raygrid.h"

Go to the source code of this file.

Functions

std::vector< Pointrandom_points (int ndepos=1000, int neles=10)
 
int main ()
 

Variables

const double pitch_magnitude = 5
 
const double gaussian = 3
 
const double width = 4000
 
const double height = 4000
 

Function Documentation

int main ( void  )

Definition at line 35 of file test_raytiling_speed.cxx.

36 {
37  ExecMon em("starting");
38 
39  auto raypairs = make_raypairs(width, height, pitch_magnitude);
40  const int nlayers = raypairs.size();
41 
42  em("make ray pairs");
43 
44  std::vector<Point> points = random_points();
45 
46  Coordinates coords(raypairs);
47  const auto& pitches = coords.pitch_dirs();
48  const auto& centers = coords.centers();
49  const auto& pitch_mags = coords.pitch_mags();
50 
51  em("make coordinates");
52 
53  std::vector< std::vector<Activity::value_t> > measures(nlayers);
54  for (size_t ipt=0; ipt<points.size(); ++ipt ) {
55  const auto& p = points[ipt];
56  for (int ilayer = 0; ilayer<nlayers; ++ilayer) {
57  const auto& pit = pitches[ilayer];
58  const auto& cen = centers[ilayer];
59  const auto rel = p-cen;
60  const int pit_ind = pit.dot(rel)/pitch_mags[ilayer];
61  auto& m = measures[ilayer];
62  if (pit_ind < 0) {
63  std::cerr << "Generated negative pitch index: " << pit_ind
64  << " on L" << ilayer << " p=" << p
65  << std::endl;
66  continue;
67  }
68  if ((int)m.size() <= pit_ind) {
69  m.resize(pit_ind+1, 0.0);
70  }
71  m[pit_ind] += 1.0;
72  }
73  }
74 
75  em("generated activity");
76 
77  activities_t activities;
78  for (int ilayer = 0; ilayer<nlayers; ++ilayer) {
79  auto& m = measures[ilayer];
80  std::cerr << ilayer << ": " << m.size() << std::endl;
81  Activity activity(ilayer, {m.begin(), m.end()});
82  Assert(!activity.empty());
83  activities.push_back(activity);
84  }
85 
86  em("filled activity");
87 
88  blobs_t blobs;
89  for (int i=0; i<100; ++i) {
90  blobs = make_blobs(coords, activities);
91  }
92  em("made clusers 100 times");
93  std::cerr << blobs.size() << " blobs\n";
94 
95  std::cerr << em.summary() << std::endl;
96  return 0;
97 }
static const double m
Definition: Units.h:79
const double height
def blobs(cm, hist)
Definition: plots.py:79
const double width
#define Assert
Definition: Testing.h:7
const double pitch_magnitude
def activity(output, slices, slice_line, cluster_tap_file)
Definition: main.py:144
p
Definition: test.py:223
std::vector< Blob > blobs_t
Definition: RayTiling.h:134
blobs_t make_blobs(const Coordinates &coords, const activities_t &activities)
Definition: RayTiling.cxx:371
std::vector< Activity > activities_t
Definition: RayTiling.h:105
ray_pair_vector_t make_raypairs(double width=100, double height=100, double pitch_mag=3, double angle=60.0 *M_PI/180.0)
Definition: raygrid.h:5
def points(jdat)
Definition: rendertvtk.py:105
std::vector< Point > random_points(int ndepos=1000, int neles=10)
QTextStream & endl(QTextStream &s)
std::vector<Point> random_points ( int  ndepos = 1000,
int  neles = 10 
)

Definition at line 19 of file test_raytiling_speed.cxx.

20 {
21  std::vector<Point> points;
22  std::default_random_engine generator;
23  std::uniform_real_distribution<double> position(0,std::max(width,height));
24  std::normal_distribution<double> spread(0.0, gaussian);
25  for (int idepo=0;idepo<ndepos;++idepo) {
26  Point cp(0, position(generator), position(generator));
27  for (int iele=0; iele<neles; ++iele) {
28  Point delta(0, spread(generator), spread(generator));
29  points.push_back(cp+delta);
30  }
31  }
32  return points;
33 }
const double height
const double width
const int neles
const int ndepos
std::tuple< double, double, const reco::ClusterHit3D * > Point
Definitions used by the VoronoiDiagram algorithm.
Definition: DCEL.h:34
const double gaussian
static int max(int a, int b)
generator
Definition: train.py:468
def points(jdat)
Definition: rendertvtk.py:105

Variable Documentation

const double gaussian = 3

Definition at line 14 of file test_raytiling_speed.cxx.

const double height = 4000

Definition at line 16 of file test_raytiling_speed.cxx.

const double pitch_magnitude = 5

Definition at line 13 of file test_raytiling_speed.cxx.

const double width = 4000

Definition at line 15 of file test_raytiling_speed.cxx.