Jpp  18.5.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Member Functions | Static Public Attributes | Static Protected Member Functions | List of all members
JGEOMETRY3D::JSmallestDistance3D Class Reference

Auxiliary class for determination of smallest distance between pair of 3D points. More...

#include <JGeometry3DToolkit.hh>

Classes

struct  JCompareZ
 Auxiliary class for sorting elements. More...
 

Public Member Functions

 JSmallestDistance3D ()
 Default constructor. More...
 
template<class T >
double operator() (T __begin, T __end) const
 Get smallest distance between two points. More...
 

Static Public Attributes

static const JCompareZ compareZ
 Function object for sorting elements. More...
 

Static Protected Member Functions

template<class T >
static double getDmin (T __begin, T __end)
 Recursive method to find the smallest distance. More...
 

Detailed Description

Auxiliary class for determination of smallest distance between pair of 3D points.

Definition at line 136 of file JGeometry3DToolkit.hh.

Constructor & Destructor Documentation

JGEOMETRY3D::JSmallestDistance3D::JSmallestDistance3D ( )
inline

Default constructor.

Definition at line 218 of file JGeometry3DToolkit.hh.

219  {}

Member Function Documentation

template<class T >
static double JGEOMETRY3D::JSmallestDistance3D::getDmin ( T  __begin,
T  __end 
)
inlinestaticprotected

Recursive method to find the smallest distance.

Parameters
__beginbegin of data
__endend of data
Returns
minimal distance

Definition at line 146 of file JGeometry3DToolkit.hh.

147  {
148  using namespace std;
149 
150  const int N = distance(__begin, __end);
151 
152  if (N <= 3) {
153 
154  double Dmin = numeric_limits<double>::max();
155 
156  for (T i = __begin; i != __end; ++i) {
157  for (T j = i; ++j != __end; ) {
158 
159  const double d = getDistance(*i, *j);
160 
161  if (d < Dmin) {
162  Dmin = d;
163  }
164  }
165  }
166 
167  return Dmin;
168 
169  } else {
170 
171  T i = __begin;
172 
173  advance(i, N/2);
174 
175  const double dl = getDmin(__begin, i);
176  const double dr = getDmin(i, __end);
177 
178  const double Dmin = min(dl, dr);
179 
180  T il = i;
181  T ir = i;
182 
183  while (--il != __begin && i ->getZ() - il->getZ() < Dmin) {}
184  while (++ir != __end && ir->getZ() - i ->getZ() < Dmin) {}
185 
186  const double dz = JGEOMETRY2D::getSmallestDistance2D(++il, ir, Dmin);
187 
188  sort(il, ir, compareZ);
189 
190  return min(Dmin, dz);
191  }
192  }
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
static const JSmallestDistance2D getSmallestDistance2D
Function object for smallest distance determination.
double getDistance(const JFirst_t &first, const JSecond_t &second)
Get distance between objects.
static double getDmin(T __begin, T __end)
Recursive method to find the smallest distance.
static const JCompareZ compareZ
Function object for sorting elements.
do set_variable OUTPUT_DIRECTORY $WORKDIR T
counter_type advance(counter_type &counter, const counter_type value, const counter_type limit=std::numeric_limits< counter_type >::max())
Advance counter.
then usage $script< input file >[option[primary[working directory]]] nWhere option can be N
Definition: JMuonPostfit.sh:40
then JMuonMCEvt f $INPUT_FILE o $INTERMEDIATE_FILE d
Definition: JMuonPath.sh:47
int j
Definition: JPolint.hh:792
template<class T >
double JGEOMETRY3D::JSmallestDistance3D::operator() ( T  __begin,
T  __end 
) const
inline

Get smallest distance between two points.


Note that this method changes the order of the elements.

Parameters
__beginbegin of data
__endend of data
Returns
minimal distance

Definition at line 234 of file JGeometry3DToolkit.hh.

235  {
236  using namespace std;
237 
238  sort(__begin, __end, compareZ);
239 
240  return getDmin(__begin, __end);
241  }
static double getDmin(T __begin, T __end)
Recursive method to find the smallest distance.
static const JCompareZ compareZ
Function object for sorting elements.

Member Data Documentation

const JCompareZ JGEOMETRY3D::JSmallestDistance3D::compareZ
static

Function object for sorting elements.

Definition at line 222 of file JGeometry3DToolkit.hh.


The documentation for this class was generated from the following file: