Classes | Typedefs | Functions
WireCell::RayGrid Namespace Reference

Classes

class  Activity
 
class  Blob
 
struct  blobref_hash
 
struct  coordinate_t
 
class  Coordinates
 
class  Grouping
 
class  Solving
 
struct  Strip
 
class  Tiling
 

Typedefs

typedef blobs_t::const_iterator blobref_t
 
typedef std::vector< blobref_tblobvec_t
 
typedef std::vector< blobvec_tblobproj_t
 
typedef std::unordered_set< blobref_t, blobref_hashblobset_t
 
typedef std::function< void(blobref_t &a, blobref_t &b)> associator_t
 
typedef int layer_index_t
 
typedef int grid_index_t
 
typedef std::pair< layer_index_t, layer_index_tlayer_pair_t
 
typedef std::tuple< layer_index_t, layer_index_t, layer_index_tlayer_triple_t
 
typedef boost::multi_array< double, 3 > tensor_t
 
typedef std::vector< Vectorvector_array1d_t
 
typedef ObjectArray2d< Vectorvector_array2d_t
 
typedef std::pair< grid_index_t, grid_index_tgrid_range_t
 
typedef std::pair< coordinate_t, coordinate_tcrossing_t
 
typedef std::vector< crossing_tcrossings_t
 
typedef std::vector< Stripstrips_t
 
typedef std::vector< Activityactivities_t
 
typedef std::vector< Blobblobs_t
 

Functions

blobproj_t projection (const blobvec_t &blobs, layer_index_t layer)
 
blobvec_t select (const blobproj_t &proj, grid_range_t range)
 
blobvec_t overlap (const blobref_t &blob, const blobproj_t &proj, layer_index_t layer)
 
bool surrounding (const blobref_t &a, const blobref_t &b)
 
blobvec_t references (const blobs_t &blobs)
 
void associate (const blobs_t &one, const blobs_t &two, associator_t func)
 
std::ostream & operator<< (std::ostream &os, const WireCell::RayGrid::coordinate_t &ra)
 
size_t drop_invalid (blobs_t &blobs)
 free functions More...
 
void prune (const Coordinates &coords, blobs_t &blobs)
 
blobs_t make_blobs (const Coordinates &coords, const activities_t &activities)
 
std::ostream & operator<< (std::ostream &os, const WireCell::RayGrid::Strip &s)
 
std::ostream & operator<< (std::ostream &os, const WireCell::RayGrid::Activity &a)
 
std::ostream & operator<< (std::ostream &os, const WireCell::RayGrid::Blob &b)
 
std::ostream & operator<< (std::ostream &os, const WireCell::RayGrid::crossing_t &c)
 

Typedef Documentation

Definition at line 105 of file RayTiling.h.

Definition at line 44 of file RayClustering.h.

Definition at line 15 of file RayClustering.h.

Definition at line 13 of file RayClustering.h.

Definition at line 134 of file RayTiling.h.

typedef std::unordered_set<blobref_t, blobref_hash> WireCell::RayGrid::blobset_t

Definition at line 22 of file RayClustering.h.

Definition at line 14 of file RayClustering.h.

Definition at line 61 of file RayGrid.h.

Definition at line 62 of file RayGrid.h.

Definition at line 33 of file RayGrid.h.

Definition at line 58 of file RayGrid.h.

Definition at line 28 of file RayGrid.h.

Definition at line 43 of file RayGrid.h.

Definition at line 46 of file RayGrid.h.

Definition at line 42 of file RayTiling.h.

typedef boost::multi_array<double, 3> WireCell::RayGrid::tensor_t

Definition at line 50 of file RayGrid.h.

Definition at line 53 of file RayGrid.h.

Definition at line 55 of file RayGrid.h.

Function Documentation

void WireCell::RayGrid::associate ( const blobs_t one,
const blobs_t two,
associator_t  func 
)

Definition at line 91 of file RayClustering.cxx.

92 {
93  if (one.empty() or two.empty()) {
94  return;
95  }
96  const size_t nlayers = two[0].strips().size();
97  const size_t ilayer = nlayers-1;
98  const auto proj = projection(references(two), ilayer);
99  for (blobref_t blob = one.begin(); blob != one.end(); ++blob) {
100  auto assoc = overlap(blob, proj, ilayer); // recursive call
101  for (blobref_t other : assoc) {
102  func(blob, other);
103  }
104  }
105 }
blobs_t::const_iterator blobref_t
Definition: RayClustering.h:13
blobvec_t references(const blobs_t &blobs)
blobvec_t overlap(const blobref_t &blob, const blobproj_t &proj, layer_index_t layer)
def func()
Definition: docstring.py:7
blobproj_t projection(const blobvec_t &blobs, layer_index_t layer)
size_t WireCell::RayGrid::drop_invalid ( blobs_t blobs)

free functions

Definition at line 325 of file RayTiling.cxx.

326 {
327  const auto end = std::partition(blobs.begin(), blobs.end(),
328  [](const Blob& b) { return b.valid(); });
329  const size_t dropped = blobs.end() - end;
330  blobs.resize(end - blobs.begin());
331  return dropped;
332 }
def blobs(cm, hist)
Definition: plots.py:79
constexpr ProductStatus dropped() noexcept
Definition: ProductStatus.h:20
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:72
static bool * b
Definition: config.cpp:1043
blobs_t WireCell::RayGrid::make_blobs ( const Coordinates coords,
const activities_t activities 
)

Definition at line 371 of file RayTiling.cxx.

372 {
373  Tiling rc(coords);
374  blobs_t blobs;
375 
376  for (const auto& activity : activities) {
377  if (blobs.empty()) {
378  blobs = rc(activity);
379  }
380  else {
381  blobs = rc(blobs, activity);
382  if (blobs.empty()) {
383  spdlog::trace("RayGrid::make_blobs: lost blobs with {}", activity);
384  return blobs_t{};
385  }
386  }
387  drop_invalid(blobs);
388  }
389  prune(coords, blobs);
390  return blobs;
391 }
void prune(const Coordinates &coords, blobs_t &blobs)
Definition: RayTiling.cxx:334
def blobs(cm, hist)
Definition: plots.py:79
size_t drop_invalid(blobs_t &blobs)
free functions
Definition: RayTiling.cxx:325
def activity(output, slices, slice_line, cluster_tap_file)
Definition: main.py:144
std::vector< Blob > blobs_t
Definition: RayTiling.h:134
void trace(const char *fmt, const Args &...args)
Definition: spdlog.h:177
std::ostream& WireCell::RayGrid::operator<< ( std::ostream &  os,
const WireCell::RayGrid::coordinate_t ra 
)
inline

Definition at line 126 of file RayGrid.h.

127  {
128  os << "<rayaddr {L" << ra.layer << ",G" << ra.grid <<"}>";
129  return os;
130  }
std::ostream& WireCell::RayGrid::operator<< ( std::ostream &  os,
const WireCell::RayGrid::Strip s 
)
inline

Definition at line 172 of file RayTiling.h.

173  {
174  os << "<strip L" << s.layer << " pind:[" << s.bounds.first << "," << s.bounds.second << "]>";
175  return os;
176  }
layer_index_t layer
Definition: RayTiling.h:24
grid_range_t bounds
Definition: RayTiling.h:27
std::ostream& WireCell::RayGrid::operator<< ( std::ostream &  os,
const WireCell::RayGrid::Activity a 
)
inline

Definition at line 179 of file RayTiling.h.

180  {
181  int b = a.pitch_index(a.begin()), e = a.pitch_index(a.end());
182  auto strips = a.make_strips();
183  os << "<activity L" << a.layer() << " " << strips.size() << " strips over pind:[" << b << "," << e << "]>";
184  return os;
185  }
iterator_t begin() const
Definition: RayTiling.cxx:50
strips_t make_strips() const
Definition: RayTiling.cxx:92
const double e
int pitch_index(const iterator_t &it) const
Definition: RayTiling.cxx:65
layer_index_t layer() const
Definition: RayTiling.h:75
static bool * b
Definition: config.cpp:1043
iterator_t end() const
Definition: RayTiling.cxx:55
std::ostream& WireCell::RayGrid::operator<< ( std::ostream &  os,
const WireCell::RayGrid::Blob b 
)
inline

Definition at line 188 of file RayTiling.h.

189  {
190  os << "<blob " << b.strips().size() << " strips, " << b.corners().size() << " corners>";
191  return os;
192  }
const strips_t & strips() const
Definition: RayTiling.h:111
const crossings_t & corners() const
Definition: RayTiling.cxx:202
std::ostream& WireCell::RayGrid::operator<< ( std::ostream &  os,
const WireCell::RayGrid::crossing_t c 
)
inline

Definition at line 195 of file RayTiling.h.

196  {
197  os << "<corner [{L" << c.first.layer << ",G" << c.first.grid << "},"
198  << "{L" << c.second.layer << ",G" << c.second.grid << "}]>";
199  return os;
200  }
WireCell::RayGrid::blobvec_t WireCell::RayGrid::overlap ( const blobref_t blob,
const blobproj_t proj,
layer_index_t  layer 
)

Definition at line 38 of file RayClustering.cxx.

39 {
40  const auto& strip = blob->strips()[layer];
41  auto blobs = select(proj, strip.bounds);
42  if (blobs.empty()) {
43  return blobs;
44  }
45  if (layer == 0) {
46  return blobs;
47  }
48 
49  --layer;
50  auto newproj = projection(blobs, layer);
51  return overlap(blob, newproj, layer);
52 }
def blobs(cm, hist)
Definition: plots.py:79
auto select(T const &...t)
Definition: select.h:146
blobvec_t overlap(const blobref_t &blob, const blobproj_t &proj, layer_index_t layer)
blobproj_t projection(const blobvec_t &blobs, layer_index_t layer)
WireCell::RayGrid::blobproj_t WireCell::RayGrid::projection ( const blobvec_t blobs,
layer_index_t  layer 
)

Definition at line 6 of file RayClustering.cxx.

7 {
8  blobproj_t ret;
9  for (blobref_t blob : blobs) {
10  const auto bounds = blob->strips()[layer].bounds;
11  for (auto gi = bounds.first; gi != bounds.second; ++gi) {
12  if ((int)ret.size() <= gi) {
13  ret.resize(gi+1);
14  }
15  ret[gi].push_back(blob);
16  }
17  }
18  return ret;
19 }
def blobs(cm, hist)
Definition: plots.py:79
std::vector< blobvec_t > blobproj_t
Definition: RayClustering.h:15
blobs_t::const_iterator blobref_t
Definition: RayClustering.h:13
BoundingBox bounds(int x, int y, int w, int h)
Definition: main.cpp:37
const Ray & bounds() const
Return the ray representing the bounds.
Definition: BoundingBox.h:36
void WireCell::RayGrid::prune ( const Coordinates coords,
blobs_t blobs 
)

Definition at line 334 of file RayTiling.cxx.

335 {
336  for (auto & blob: blobs) {
337 
338  auto& strips = blob.strips();
339  const int nlayers = strips.size();
340  std::vector< std::vector<grid_index_t> > mms(nlayers);
341  for (const auto& corner : blob.corners()) {
342  // fixme off by one bugs here? Adding the two rays making
343  // up a corner adds a pitch-bin-edge. Adding the ray
344  // crossing point measured in the 3rd layer pitch adds a
345  // bin pitch-bin-content which should be either floor()'ed
346  // or ceil()'ed (or both?)
347 
348  mms[corner.first.layer].push_back(corner.first.grid);
349  mms[corner.second.layer].push_back(corner.second.grid);
350 
351  // Check every layer not forming the corner
352  for (int layer=0; layer<nlayers; ++layer) {
353  if (corner.first.layer == layer or corner.second.layer == layer) {
354  continue;
355  }
356  const double ploc = coords.pitch_location(corner.first, corner.second, layer);
357  const int pind = coords.pitch_index(ploc, layer);
358  mms[layer].push_back(pind);
359  mms[layer].push_back(pind+1);
360  }
361  }
362 
363  for (int layer=0; layer<nlayers; ++layer) {
364  auto mm = std::minmax_element(mms[layer].begin(), mms[layer].end());
365  strips[layer].bounds.first = *mm.first;
366  strips[layer].bounds.second = *mm.second;
367  }
368  }
369 }
double pitch_location(const coordinate_t &one, const coordinate_t &two, layer_index_t other) const
Definition: RayGrid.cxx:133
def blobs(cm, hist)
Definition: plots.py:79
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:72
int pitch_index(double pitch, layer_index_t layer) const
Definition: RayGrid.h:82
static const double mm
Definition: Units.h:73
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:67
WireCell::RayGrid::blobvec_t WireCell::RayGrid::references ( const blobs_t blobs)

Definition at line 55 of file RayClustering.cxx.

56 {
57  const size_t siz = blobs.size();
58  blobvec_t ret(siz);
59  for (size_t ind=0; ind<siz; ++ind) {
60  ret[ind] = blobs.begin()+ind;
61  }
62  return ret;
63 }
std::vector< blobref_t > blobvec_t
Definition: RayClustering.h:14
def blobs(cm, hist)
Definition: plots.py:79
WireCell::RayGrid::blobvec_t WireCell::RayGrid::select ( const blobproj_t proj,
grid_range_t  range 
)

Definition at line 22 of file RayClustering.cxx.

23 {
24  if (proj.empty()) {
26  }
27 
28  blobset_t uniq;
29  int nproj = std::min((int)proj.size(), gr.second);
30  for (grid_index_t gind = gr.first; gind < nproj; ++gind) {
31  const auto& some = proj[gind];
32  uniq.insert(some.begin(), some.end());
33  }
34  return blobvec_t(uniq.begin(), uniq.end());
35 }
std::vector< blobref_t > blobvec_t
Definition: RayClustering.h:14
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
std::unordered_set< blobref_t, blobref_hash > blobset_t
Definition: RayClustering.h:22
bool WireCell::RayGrid::surrounding ( const blobref_t a,
const blobref_t b 
)

Definition at line 65 of file RayClustering.cxx.

66 {
67  const auto& astrips = a->strips();
68  const auto& bstrips = b->strips();
69  const int nlayers = astrips.size();
70 
71  int ainb = 0, bina = 0;
72  for (int ilayer=0; ilayer<nlayers; ++ilayer) {
73  const auto& astrip = astrips[ilayer];
74  const auto& bstrip = bstrips[ilayer];
75  const auto& abounds = astrip.bounds;
76  const auto& bbounds = bstrip.bounds;
77  if (abounds.first <= bbounds.first and bbounds.second <= abounds.second) {
78  ++bina;
79  }
80  if (bbounds.first <= abounds.first and abounds.second <= bbounds.second) {
81  ++ainb;
82  }
83  }
84  if (ainb == nlayers or bina == nlayers) {
85  return true;
86  }
87  return false;
88 }
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1124
static bool * b
Definition: config.cpp:1043