Jpp  18.1.0
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 131 of file JGeometry3DToolkit.hh.

Constructor & Destructor Documentation

JGEOMETRY3D::JSmallestDistance3D::JSmallestDistance3D ( )
inline

Default constructor.

Definition at line 213 of file JGeometry3DToolkit.hh.

214  {}

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 141 of file JGeometry3DToolkit.hh.

142  {
143  using namespace std;
144 
145  const int N = distance(__begin, __end);
146 
147  if (N <= 3) {
148 
149  double Dmin = numeric_limits<double>::max();
150 
151  for (T i = __begin; i != __end; ++i) {
152  for (T j = i; ++j != __end; ) {
153 
154  const double d = getDistance(*i, *j);
155 
156  if (d < Dmin) {
157  Dmin = d;
158  }
159  }
160  }
161 
162  return Dmin;
163 
164  } else {
165 
166  T i = __begin;
167 
168  advance(i, N/2);
169 
170  const double dl = getDmin(__begin, i);
171  const double dr = getDmin(i, __end);
172 
173  const double Dmin = min(dl, dr);
174 
175  T il = i;
176  T ir = i;
177 
178  while (--il != __begin && i ->getZ() - il->getZ() < Dmin) {}
179  while (++ir != __end && ir->getZ() - i ->getZ() < Dmin) {}
180 
181  const double dz = JGEOMETRY2D::getSmallestDistance2D(++il, ir, Dmin);
182 
183  sort(il, ir, compareZ);
184 
185  return min(Dmin, dz);
186  }
187  }
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:703
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 229 of file JGeometry3DToolkit.hh.

230  {
231  using namespace std;
232 
233  sort(__begin, __end, compareZ);
234 
235  return getDmin(__begin, __end);
236  }
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 217 of file JGeometry3DToolkit.hh.


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