8 #ifndef LC_KD_TREE_LINKER_TOOLS_TEMPLATED_H
9 #define LC_KD_TREE_LINKER_TOOLS_TEMPLATED_H 1
11 #include "Api/PandoraContentApi.h"
15 #include "Objects/CartesianVector.h"
17 #include "Pandora/PandoraInternal.h"
23 namespace pandora {
class Algorithm; }
27 namespace april_content
34 template<
unsigned DIM>
48 template<
typename... Ts>
51 std::array<float, DIM> dimmin;
52 std::array<float, DIM> dimmax;
65 template<
typename DATA,
unsigned DIM>
80 template<
typename... Ts>
84 std::array<float, DIM> dims;
92 template <
typename DATA,
unsigned DIM>
138 static const pandora::CartesianVector &position(
const T *
const t);
151 std::pair<float,float>
minmax(
const float a,
const float b);
243 template<
unsigned DIM>
250 template<
unsigned DIM>
251 template<
typename... Ts>
254 static_assert(
sizeof...(dimargs) == 2 * DIM,
"Constructor requires 2*DIM args");
255 std::vector<float> dims = {dimargs...};
257 for (
unsigned i = 0; i < DIM; ++i)
259 dimmin[i] = dims[2 * i];
260 dimmax[i] = dims[2 * i + 1];
267 template<
typename DATA,
unsigned DIM>
275 template<
typename DATA,
unsigned DIM>
276 template<
typename... Ts>
286 template <
typename DATA,
unsigned DIM>
295 template <
typename DATA,
unsigned DIM>
304 template <
typename DATA,
unsigned DIM>
315 return t->GetTrackStateAtCalorimeter().GetPosition();
321 return t->GetPositionVector();
335 std::array<float, 3> minpos{ {0.f, 0.f, 0.f} }, maxpos{ {0.f, 0.f, 0.f} };
339 for (
const T *
const point : points)
342 nodes.emplace_back(point, pos.GetX(), pos.GetY(), pos.GetZ());
346 minpos[0] = pos.GetX(); minpos[1] = pos.GetY(); minpos[2] = pos.GetZ();
347 maxpos[0] = pos.GetX(); maxpos[1] = pos.GetY(); maxpos[2] = pos.GetZ();
351 minpos[0] = std::min(pos.GetX(), minpos[0]);
352 minpos[1] = std::min(pos.GetY(), minpos[1]);
353 minpos[2] = std::min(pos.GetZ(), minpos[2]);
354 maxpos[0] = std::max(pos.GetX(), maxpos[0]);
355 maxpos[1] = std::max(pos.GetY(), maxpos[1]);
356 maxpos[2] = std::max(pos.GetZ(), maxpos[2]);
362 return KDTreeCube(minpos[0], maxpos[0], minpos[1], maxpos[1], minpos[2], maxpos[2]);
370 std::array<float, 3> minpos{ {0.f, 0.f, 0.f} }, maxpos{ {0.f, 0.f, 0.f} };
374 for (
const T *
const point : points)
377 nodes.emplace_back(i, pos.GetX(), pos.GetY(), pos.GetZ());
381 minpos[0] = pos.GetX(); minpos[1] = pos.GetY(); minpos[2] = pos.GetZ();
382 maxpos[0] = pos.GetX(); maxpos[1] = pos.GetY(); maxpos[2] = pos.GetZ();
386 minpos[0] = std::min(pos.GetX(), minpos[0]);
387 minpos[1] = std::min(pos.GetY(), minpos[1]);
388 minpos[2] = std::min(pos.GetZ(), minpos[2]);
389 maxpos[0] = std::max(pos.GetX(), maxpos[0]);
390 maxpos[1] = std::max(pos.GetY(), maxpos[1]);
391 maxpos[2] = std::max(pos.GetZ(), maxpos[2]);
397 return KDTreeCube(minpos[0], maxpos[0], minpos[1], maxpos[1], minpos[2], maxpos[2]);
406 std::array<float, 3> minpos{ {0.f, 0.f, 0.f} }, maxpos{ {0.f, 0.f, 0.f} };
410 for (
const T *
const point : points)
412 if (!passthru && !PandoraContentApi::IsAvailable(*caller, point))
416 nodes.emplace_back(point, pos.GetX(), pos.GetY(), pos.GetZ());
420 minpos[0] = pos.GetX(); minpos[1] = pos.GetY(); minpos[2] = pos.GetZ();
421 maxpos[0] = pos.GetX(); maxpos[1] = pos.GetY(); maxpos[2] = pos.GetZ();
425 minpos[0] = std::min(pos.GetX(), minpos[0]);
426 minpos[1] = std::min(pos.GetY(), minpos[1]);
427 minpos[2] = std::min(pos.GetZ(), minpos[2]);
428 maxpos[0] = std::max(pos.GetX(), maxpos[0]);
429 maxpos[1] = std::max(pos.GetY(), maxpos[1]);
430 maxpos[2] = std::max(pos.GetZ(), maxpos[2]);
436 return KDTreeCube(minpos[0], maxpos[0], minpos[1], maxpos[1], minpos[2], maxpos[2]);
441 #endif // LC_KD_TREE_LINKER_TOOLS_TEMPLATED_H
KDTreeCube fill_and_bound_3d_kd_tree_by_index(const std::vector< const T * > &points, std::vector< KDTreeNodeInfoT< unsigned, 3 > > &nodes)
fill_and_bound_3d_kd_tree_by_index
Definition: KDTreeLinkerToolsT.h:368
KDTreeNodeT()
Default constructor.
KDTreeNodeInfoT< DATA, DIM > info
Data.
Definition: KDTreeLinkerToolsT.h:116
KDTreeTesseract fill_and_bound_4d_kd_tree(const pandora::Algorithm *const caller, const MANAGED_CONTAINER< const pandora::CaloHit * > &points, std::vector< KDTreeNodeInfoT< const pandora::CaloHit *, 4 > > &nodes, bool passthru=false)
fill_and_bound_4d_kd_tree
Definition: KDTreeLinkerToolsT.cc:62
KDTree node.
Definition: KDTreeLinkerToolsT.h:93
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
Definition: KDTreeLinkerToolsT.h:333
Data stored in each KDTree node. The dim1/dim2 fields are usually the duplication of some PFRecHit va...
Definition: TrackClusterAssociationAlgorithm.h:19
std::pair< float, float > minmax(const float a, const float b)
minmax
Definition: KDTreeLinkerToolsT.cc:16
KDTreeNodeT< DATA, DIM > * left
Left son.
Definition: KDTreeLinkerToolsT.h:117
static const pandora::CartesianVector & position(const T *const t)
position
KDTreeNodeT< DATA, DIM > * right
Right son.
Definition: KDTreeLinkerToolsT.h:118
KDTreeBoxT< DIM > region
Region bounding box.
Definition: KDTreeLinkerToolsT.h:119
KDTreeNodeInfoT()
Default constructor.
Definition: KDTreeLinkerToolsT.h:268
kdtree_type_adaptor
Definition: KDTreeLinkerToolsT.h:128
Box structure used to define 2D field. It's used in KDTree building step to divide the detector space...
Definition: KDTreeLinkerToolsT.h:35
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
Definition: KDTreeLinkerToolsT.cc:103
void setAttributs(const KDTreeBoxT< DIM > ®ionBox, const KDTreeNodeInfoT< DATA, DIM > &infoToStore)
setAttributs
Definition: KDTreeLinkerToolsT.h:296
KDTreeTesseract build_4d_kd_search_region(const pandora::CaloHit *const point, const float x_span, const float y_span, const float z_span, const float search_layer)
build_4d_kd_search_region
Definition: KDTreeLinkerToolsT.cc:116