8 #ifndef LAR_KD_TREE_LINKER_TOOLS_TEMPLATED_H 9 #define LAR_KD_TREE_LINKER_TOOLS_TEMPLATED_H 1 11 #include "Api/PandoraContentApi.h" 13 #include "Objects/CaloHit.h" 14 #include "Objects/CartesianVector.h" 16 #include "Pandora/PandoraInternal.h" 35 template <
unsigned DIM>
49 template <
typename... Ts>
65 template <
typename DATA,
unsigned DIM>
80 template <
typename... Ts>
84 std::array<float, DIM>
dims;
92 template <
typename DATA,
unsigned DIM>
127 template <
typename T>
138 static const pandora::CartesianVector &position(
const T *
const t);
151 std::pair<float, float>
minmax(
const float a,
const float b);
161 template <
typename T>
172 template <
typename T>
207 KDTreeCube
build_3d_kd_search_region(
const pandora::CaloHit *
const point,
const float x_span,
const float y_span,
const float z_span);
219 KDTreeCube
build_3d_kd_search_region(
const pandora::CartesianVector &pos,
const float x_span,
const float y_span,
const float z_span);
224 template <
unsigned DIM>
231 template <
unsigned DIM>
232 template <
typename... Ts>
235 static_assert(
sizeof...(dimargs) == 2 * DIM,
"Constructor requires 2*DIM args");
236 std::vector<float> dims = {dimargs...};
238 for (
unsigned i = 0; i < DIM; ++i)
240 dimmin[i] = dims[2 * i];
241 dimmax[i] = dims[2 * i + 1];
248 template <
typename DATA,
unsigned DIM>
256 template <
typename DATA,
unsigned DIM>
257 template <
typename... Ts>
267 template <
typename DATA,
unsigned DIM>
276 template <
typename DATA,
unsigned DIM>
285 template <
typename DATA,
unsigned DIM>
293 template <
typename T>
296 return t->GetPosition();
302 return t->GetPositionVector();
313 template <
typename T>
316 std::array<float, 2> minpos{{0.f, 0.f}}, maxpos{{0.f, 0.f}};
320 for (
const T *
const point : points)
323 nodes.emplace_back(point, pos.GetX(), pos.GetZ());
327 minpos[0] = pos.GetX();
328 minpos[1] = pos.GetZ();
329 maxpos[0] = pos.GetX();
330 maxpos[1] = pos.GetZ();
334 minpos[0] = std::min(pos.GetX(), minpos[0]);
335 minpos[1] = std::min(pos.GetZ(), minpos[1]);
336 maxpos[0] = std::max(pos.GetX(), maxpos[0]);
337 maxpos[1] = std::max(pos.GetZ(), maxpos[1]);
343 return KDTreeBox(minpos[0], maxpos[0], minpos[1], maxpos[1]);
348 template <
typename T>
351 std::array<float, 3> minpos{{0.f, 0.f, 0.f}}, maxpos{{0.f, 0.f, 0.f}};
355 for (
const T *
const point : points)
358 nodes.emplace_back(point, pos.GetX(), pos.GetY(), pos.GetZ());
362 minpos[0] = pos.GetX();
363 minpos[1] = pos.GetY();
364 minpos[2] = pos.GetZ();
365 maxpos[0] = pos.GetX();
366 maxpos[1] = pos.GetY();
367 maxpos[2] = pos.GetZ();
371 minpos[0] = std::min(pos.GetX(), minpos[0]);
372 minpos[1] = std::min(pos.GetY(), minpos[1]);
373 minpos[2] = std::min(pos.GetZ(), minpos[2]);
374 maxpos[0] = std::max(pos.GetX(), maxpos[0]);
375 maxpos[1] = std::max(pos.GetY(), maxpos[1]);
376 maxpos[2] = std::max(pos.GetZ(), maxpos[2]);
382 return KDTreeCube(minpos[0], maxpos[0], minpos[1], maxpos[1], minpos[2], maxpos[2]);
387 #endif // LAR_KD_TREE_LINKER_TOOLS_TEMPLATED_H
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
std::pair< float, float > minmax(const float a, const float b)
minmax
static const pandora::CartesianVector & position(const T *const t)
position
void setAttributs(const KDTreeBoxT< DIM > ®ionBox, const KDTreeNodeInfoT< DATA, DIM > &infoToStore)
setAttributs
Box structure used to define 2D field. It's used in KDTree building step to divide the detector space...
KDTreeBoxT< DIM > region
Region bounding box.
KDTreeNodeInfoT< DATA, DIM > info
Data.
std::array< float, DIM > dims
KDTreeNodeT< DATA, DIM > * right
Right son.
KDTreeCube build_3d_kd_search_region(const pandora::CaloHit *const point, const float x_span, const float y_span, const float z_span)
build_3d_kd_search_region
Data stored in each KDTree node. The dim1/dim2 fields are usually the duplication of some PFRecHit va...
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
KDTreeNodeT< DATA, DIM > * left
Left son.
KDTreeBoxT< 3 > KDTreeCube
KDTreeNodeInfoT()
Default constructor.
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
std::array< float, DIM > dimmin
KDTreeNodeT()
Default constructor.
KDTreeBox fill_and_bound_2d_kd_tree(const MANAGED_CONTAINER< const T * > &points, std::vector< KDTreeNodeInfoT< const T *, 2 >> &nodes)
fill_and_bound_2d_kd_tree
std::array< float, DIM > dimmax
KDTreeBox build_2d_kd_search_region(const pandora::CaloHit *const point, const float x_span, const float z_span)
build_2d_kd_search_region
KDTreeCube fill_and_bound_3d_kd_tree(const MANAGED_CONTAINER< const T * > &points, std::vector< KDTreeNodeInfoT< const T *, 3 >> &nodes)
fill_and_bound_3d_kd_tree
KDTreeBoxT< 2 > KDTreeBox