CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Functions
npstat::Private Namespace Reference

Classes

struct  AbsHelper
 
struct  AbsHelper< T, 1 >
 
struct  AbsReturnType
 
struct  AbsReturnType< const std::complex< T > >
 
struct  AbsReturnType< const volatile std::complex< T > >
 
struct  AbsReturnType< std::complex< T > >
 
struct  AbsReturnType< volatile std::complex< T > >
 
class  ArrayMapper
 

Functions

template<class Axis >
std::vector< Axis > addAxis (const std::vector< Axis > &axes, const Axis &newAxis, const unsigned newAxisNumber)
 
template<class Axis >
std::vector< Axis > axesOfASlice (const std::vector< Axis > &axes, const unsigned *fixedIndices, const unsigned nFixedIndices)
 
void h_badargs (const char *method)
 
template<typename Float , class Axis >
void iHND_checkArgs (const HistoND< Float, Axis > &histo, const unsigned xDim, const unsigned interpolationDegree)
 
double lind_interpolateSimple (const double x0, const double x1, const double y0, const double y1, const double x)
 
template<typename Numeric , class Axis >
void lind_invert1DSlice (const ArrayND< Numeric > &fromSlice, const Axis &fromAxis, const Axis &toAxis, const bool leftLinear, const bool rightLinear, ArrayND< Numeric > *toSlice)
 
template<class Axis >
ArrayShape makeHistoShape (const std::vector< Axis > &axes)
 
template<class Axis >
ArrayShape makeHistoShape (const Axis &xAxis)
 
template<class Axis >
ArrayShape makeHistoShape (const Axis &xAxis, const Axis &yAxis)
 
template<class Axis >
ArrayShape makeHistoShape (const Axis &xAxis, const Axis &yAxis, const Axis &zAxis)
 
template<class Axis >
ArrayShape makeHistoShape (const Axis &xAxis, const Axis &yAxis, const Axis &zAxis, const Axis &tAxis)
 
template<class Axis >
ArrayShape makeHistoShape (const Axis &xAxis, const Axis &yAxis, const Axis &zAxis, const Axis &tAxis, const Axis &vAxis)
 
template<class Axis >
ArrayShape makeTableShape (const std::vector< Axis > &axes)
 
template<class Axis >
ArrayShape makeTableShape (const Axis &xAxis)
 
template<class Axis >
ArrayShape makeTableShape (const Axis &xAxis, const Axis &yAxis)
 
template<class Axis >
ArrayShape makeTableShape (const Axis &xAxis, const Axis &yAxis, const Axis &zAxis)
 
template<class Axis >
ArrayShape makeTableShape (const Axis &xAxis, const Axis &yAxis, const Axis &zAxis, const Axis &tAxis)
 
template<class Axis >
ArrayShape makeTableShape (const Axis &xAxis, const Axis &yAxis, const Axis &zAxis, const Axis &tAxis, const Axis &vAxis)
 
template<class Axis >
ArrayShape shapeOfASlice (const std::vector< Axis > &axes, const unsigned *fixedIndices, const unsigned nFixedIndices)
 
template<class Axis >
ArrayShape shapeWithExtraAxis (const std::vector< Axis > &axes, const Axis &newAxis, const unsigned newAxisNumber)
 

Function Documentation

template<class Axis >
std::vector<Axis> npstat::Private::addAxis ( const std::vector< Axis > &  axes,
const Axis &  newAxis,
const unsigned  newAxisNumber 
)

Definition at line 1042 of file HistoND.h.

References i.

1045  {
1046  const unsigned dim = axes.size();
1047  std::vector<Axis> newAxes;
1048  newAxes.reserve(dim + 1U);
1049  unsigned iadd = 0;
1050  for (unsigned i=0; i<dim; ++i)
1051  {
1052  if (newAxisNumber == i)
1053  newAxes.push_back(newAxis);
1054  else
1055  newAxes.push_back(axes[iadd++]);
1056  }
1057  if (iadd == dim)
1058  newAxes.push_back(newAxis);
1059  else
1060  newAxes.push_back(axes[iadd]);
1061  return newAxes;
1062  }
int i
Definition: DBlmapReader.cc:9
template<class Axis >
std::vector<Axis> npstat::Private::axesOfASlice ( const std::vector< Axis > &  axes,
const unsigned *  fixedIndices,
const unsigned  nFixedIndices 
)

Definition at line 967 of file HistoND.h.

References i, and j.

970  {
971  const unsigned dim = axes.size();
972  std::vector<Axis> newAxes;
973  if (nFixedIndices == 0U) throw npstat::NpstatInvalidArgument(
974  "In npstat::Private::axesOfASlice: "
975  "at least one fixed index must be specified");
976  if (nFixedIndices > dim) throw npstat::NpstatInvalidArgument(
977  "In npstat::Private::axesOfASlice: too many fixed indices");
978  assert(fixedIndices);
979  for (unsigned i=0; i<nFixedIndices; ++i)
980  if (fixedIndices[i] >= dim) throw npstat::NpstatInvalidArgument(
981  "In npstat::Private::axesOfASlice: fixed index out of range");
982  newAxes.reserve(dim - nFixedIndices);
983  for (unsigned i=0; i<dim; ++i)
984  {
985  bool fixed = false;
986  for (unsigned j=0; j<nFixedIndices; ++j)
987  if (fixedIndices[j] == i)
988  {
989  fixed = true;
990  break;
991  }
992  if (!fixed)
993  newAxes.push_back(axes[i]);
994  }
995  if (newAxes.size() != dim - nFixedIndices)
997  "In npstat::Private::axesOfASlice: duplicate fixed index");
998  return newAxes;
999  }
int i
Definition: DBlmapReader.cc:9
int j
Definition: DBlmapReader.cc:9
void npstat::Private::h_badargs ( const char *  method)
inline

Definition at line 1087 of file HistoND.h.

Referenced by npstat::HistoND< Numeric, Axis >::closestBin(), npstat::HistoND< Numeric, Axis >::dispatch(), npstat::HistoND< Numeric, Axis >::examine(), npstat::HistoND< Numeric, Axis >::fill(), and npstat::HistoND< Numeric, Axis >::fillC().

1088  {
1089  std::ostringstream os;
1090  os << "In npstat::HistoND::" << method << ": number of arguments"
1091  << " is incompatible with histogram dimensionality";
1092  throw npstat::NpstatInvalidArgument(os.str());
1093  }
template<typename Float , class Axis >
void npstat::Private::iHND_checkArgs ( const HistoND< Float, Axis > &  histo,
const unsigned  xDim,
const unsigned  interpolationDegree 
)

Definition at line 106 of file interpolateHistoND.h.

References npstat::HistoND< Numeric, Axis >::dim(), and npstat::HistoND< Numeric, Axis >::isUniformlyBinned().

Referenced by npstat::interpolateHistoND().

109  {
110  if (xDim != histo.dim()) throw npstat::NpstatInvalidArgument(
111  "In npstat::interpolateHistoND: incompatible "
112  "dimensionality of input coordinates");
113  if (xDim == 0U) throw npstat::NpstatInvalidArgument(
114  "In npstat::interpolateHistoND: can not interpolate "
115  "zero-dimensional histograms");
116  if (!(interpolationDegree == 0U ||
117  interpolationDegree == 1U ||
118  interpolationDegree == 3U)) throw npstat::NpstatInvalidArgument(
119  "In npstat::interpolateHistoND: "
120  "unsupported interpolation degree");
121  if (interpolationDegree == 3U && !histo.isUniformlyBinned())
123  "In npstat::interpolateHistoND: unsupported "
124  "interpolation degree for non-uniform binning");
125  }
double npstat::Private::lind_interpolateSimple ( const double  x0,
const double  x1,
const double  y0,
const double  y1,
const double  x 
)
inline

Definition at line 334 of file LinInterpolatedTableND.h.

Referenced by lind_invert1DSlice(), and npstat::LinInterpolatedTableND< Numeric, Axis >::solveForRatioArg().

338  {
339  return y0 + (y1 - y0)*((x - x0)/(x1 - x0));
340  }
Definition: DDAxes.h:10
template<typename Numeric , class Axis >
void npstat::Private::lind_invert1DSlice ( const ArrayND< Numeric > &  fromSlice,
const Axis &  fromAxis,
const Axis &  toAxis,
const bool  leftLinear,
const bool  rightLinear,
ArrayND< Numeric > *  toSlice 
)

Definition at line 343 of file LinInterpolatedTableND.h.

References npstat::ArrayND< Numeric, StackLen, StackDim >::data(), i, npstat::isStrictlyMonotonous(), npstat::ArrayND< Numeric, StackLen, StackDim >::length(), lind_interpolateSimple(), npstat::ArrayND< Numeric, StackLen, StackDim >::rank(), and detailsBasic3DVector::y.

Referenced by npstat::LinInterpolatedTableND< Numeric, Axis >::invertWRTAxis().

348  {
349  assert(toSlice);
350  assert(fromSlice.rank() == 1U);
351  assert(toSlice->rank() == 1U);
352 
353  const Numeric* fromData = fromSlice.data();
354  const unsigned fromLen = fromSlice.length();
355  assert(fromLen > 1U);
356  assert(fromLen == fromAxis.nCoords());
357  const Numeric* fromDataEnd = fromData + fromLen;
358  if (!isStrictlyMonotonous(fromData, fromDataEnd))
360  "In npstat::Private::lind_invert1DSlice: "
361  "slice data is not monotonous and can not be inverted");
362 
363  const Numeric yfirst = fromData[0];
364  const Numeric ylast = fromData[fromLen - 1U];
365  const bool increasing = yfirst < ylast;
366 
367  Numeric* toD = const_cast<Numeric*>(toSlice->data());
368  const unsigned nAxisPoints = toAxis.nCoords();
369  assert(toSlice->length() == nAxisPoints);
370 
371  for (unsigned ipt=0; ipt<nAxisPoints; ++ipt)
372  {
373  const Numeric y = static_cast<Numeric>(toAxis.coordinate(ipt));
374  if (increasing)
375  {
376  if (y <= yfirst)
377  {
378  if (leftLinear)
380  yfirst, fromData[1], fromAxis.coordinate(0),
381  fromAxis.coordinate(1), y);
382  else
383  toD[ipt] = fromAxis.coordinate(0);
384  }
385  else if (y >= ylast)
386  {
387  if (rightLinear)
389  ylast, fromData[fromLen - 2U],
390  fromAxis.coordinate(fromLen - 1U),
391  fromAxis.coordinate(fromLen - 2U), y);
392  else
393  toD[ipt] = fromAxis.coordinate(fromLen - 1U);
394  }
395  else
396  {
397  const unsigned i = std::lower_bound(fromData,fromDataEnd,y)-
398  fromData;
400  fromData[i-1U], fromData[i],
401  fromAxis.coordinate(i-1U),
402  fromAxis.coordinate(i), y);
403  }
404  }
405  else
406  {
407  // The role of left and right are exchanged
408  // with respect to first and last point
409  if (y <= ylast)
410  {
411  if (leftLinear)
413  ylast, fromData[fromLen - 2U],
414  fromAxis.coordinate(fromLen - 1U),
415  fromAxis.coordinate(fromLen - 2U), y);
416  else
417  toD[ipt] = fromAxis.coordinate(fromLen - 1U);
418  }
419  else if (y >= yfirst)
420  {
421  if (rightLinear)
423  yfirst, fromData[1],
424  fromAxis.coordinate(0),
425  fromAxis.coordinate(1), y);
426  else
427  toD[ipt] = fromAxis.coordinate(0);
428  }
429  else
430  {
431  const unsigned i = std::lower_bound(fromData,fromDataEnd,
432  y,std::greater<Numeric>())-fromData;
434  fromData[i-1U], fromData[i],
435  fromAxis.coordinate(i-1U),
436  fromAxis.coordinate(i), y);
437  }
438  }
439  }
440  }
int i
Definition: DBlmapReader.cc:9
unsigned rank() const
Definition: ArrayND.h:240
unsigned long length() const
Definition: ArrayND.h:231
const Numeric * data() const
Definition: ArrayND.h:234
double lind_interpolateSimple(const double x0, const double x1, const double y0, const double y1, const double x)
bool isStrictlyMonotonous(Iter const begin, Iter const end)
Definition: isMonotonous.h:46
template<class Axis >
ArrayShape npstat::Private::makeHistoShape ( const std::vector< Axis > &  axes)

Definition at line 896 of file HistoND.h.

References i, n, and query::result.

897  {
898  const unsigned n = axes.size();
900  result.reserve(n);
901  for (unsigned i=0; i<n; ++i)
902  result.push_back(axes[i].nBins());
903  return result;
904  }
int i
Definition: DBlmapReader.cc:9
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21
tuple result
Definition: query.py:137
template<class Axis >
ArrayShape npstat::Private::makeHistoShape ( const Axis &  xAxis)

Definition at line 907 of file HistoND.h.

References query::result.

908  {
910  result.reserve(1U);
911  result.push_back(xAxis.nBins());
912  return result;
913  }
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21
tuple result
Definition: query.py:137
template<class Axis >
ArrayShape npstat::Private::makeHistoShape ( const Axis &  xAxis,
const Axis &  yAxis 
)

Definition at line 916 of file HistoND.h.

References query::result.

917  {
919  result.reserve(2U);
920  result.push_back(xAxis.nBins());
921  result.push_back(yAxis.nBins());
922  return result;
923  }
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21
tuple result
Definition: query.py:137
template<class Axis >
ArrayShape npstat::Private::makeHistoShape ( const Axis &  xAxis,
const Axis &  yAxis,
const Axis &  zAxis 
)

Definition at line 926 of file HistoND.h.

References query::result.

929  {
931  result.reserve(3U);
932  result.push_back(xAxis.nBins());
933  result.push_back(yAxis.nBins());
934  result.push_back(zAxis.nBins());
935  return result;
936  }
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21
tuple result
Definition: query.py:137
template<class Axis >
ArrayShape npstat::Private::makeHistoShape ( const Axis &  xAxis,
const Axis &  yAxis,
const Axis &  zAxis,
const Axis &  tAxis 
)

Definition at line 939 of file HistoND.h.

References query::result.

941  {
943  result.reserve(4U);
944  result.push_back(xAxis.nBins());
945  result.push_back(yAxis.nBins());
946  result.push_back(zAxis.nBins());
947  result.push_back(tAxis.nBins());
948  return result;
949  }
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21
tuple result
Definition: query.py:137
template<class Axis >
ArrayShape npstat::Private::makeHistoShape ( const Axis &  xAxis,
const Axis &  yAxis,
const Axis &  zAxis,
const Axis &  tAxis,
const Axis &  vAxis 
)

Definition at line 952 of file HistoND.h.

References query::result.

955  {
957  result.reserve(5U);
958  result.push_back(xAxis.nBins());
959  result.push_back(yAxis.nBins());
960  result.push_back(zAxis.nBins());
961  result.push_back(tAxis.nBins());
962  result.push_back(vAxis.nBins());
963  return result;
964  }
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21
tuple result
Definition: query.py:137
template<class Axis >
ArrayShape npstat::Private::makeTableShape ( const std::vector< Axis > &  axes)

Definition at line 264 of file LinInterpolatedTableND.h.

References i, n, and query::result.

265  {
266  const unsigned n = axes.size();
268  result.reserve(n);
269  for (unsigned i=0; i<n; ++i)
270  result.push_back(axes[i].nCoords());
271  return result;
272  }
int i
Definition: DBlmapReader.cc:9
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21
tuple result
Definition: query.py:137
template<class Axis >
ArrayShape npstat::Private::makeTableShape ( const Axis &  xAxis)

Definition at line 275 of file LinInterpolatedTableND.h.

References query::result.

276  {
278  result.reserve(1U);
279  result.push_back(xAxis.nCoords());
280  return result;
281  }
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21
tuple result
Definition: query.py:137
template<class Axis >
ArrayShape npstat::Private::makeTableShape ( const Axis &  xAxis,
const Axis &  yAxis 
)

Definition at line 284 of file LinInterpolatedTableND.h.

References query::result.

285  {
287  result.reserve(2U);
288  result.push_back(xAxis.nCoords());
289  result.push_back(yAxis.nCoords());
290  return result;
291  }
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21
tuple result
Definition: query.py:137
template<class Axis >
ArrayShape npstat::Private::makeTableShape ( const Axis &  xAxis,
const Axis &  yAxis,
const Axis &  zAxis 
)

Definition at line 294 of file LinInterpolatedTableND.h.

References query::result.

297  {
299  result.reserve(3U);
300  result.push_back(xAxis.nCoords());
301  result.push_back(yAxis.nCoords());
302  result.push_back(zAxis.nCoords());
303  return result;
304  }
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21
tuple result
Definition: query.py:137
template<class Axis >
ArrayShape npstat::Private::makeTableShape ( const Axis &  xAxis,
const Axis &  yAxis,
const Axis &  zAxis,
const Axis &  tAxis 
)

Definition at line 307 of file LinInterpolatedTableND.h.

References query::result.

309  {
311  result.reserve(4U);
312  result.push_back(xAxis.nCoords());
313  result.push_back(yAxis.nCoords());
314  result.push_back(zAxis.nCoords());
315  result.push_back(tAxis.nCoords());
316  return result;
317  }
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21
tuple result
Definition: query.py:137
template<class Axis >
ArrayShape npstat::Private::makeTableShape ( const Axis &  xAxis,
const Axis &  yAxis,
const Axis &  zAxis,
const Axis &  tAxis,
const Axis &  vAxis 
)

Definition at line 320 of file LinInterpolatedTableND.h.

References query::result.

323  {
325  result.reserve(5U);
326  result.push_back(xAxis.nCoords());
327  result.push_back(yAxis.nCoords());
328  result.push_back(zAxis.nCoords());
329  result.push_back(tAxis.nCoords());
330  result.push_back(vAxis.nCoords());
331  return result;
332  }
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21
tuple result
Definition: query.py:137
template<class Axis >
ArrayShape npstat::Private::shapeOfASlice ( const std::vector< Axis > &  axes,
const unsigned *  fixedIndices,
const unsigned  nFixedIndices 
)

Definition at line 1002 of file HistoND.h.

References i, and j.

1005  {
1006  const unsigned dim = axes.size();
1007  if (nFixedIndices == 0U) throw npstat::NpstatInvalidArgument(
1008  "In npstat::Private::shapeOfASlice: "
1009  "at least one fixed index must be specified");
1010  if (nFixedIndices > dim) throw npstat::NpstatInvalidArgument(
1011  "In npstat::Private::shapeOfASlice: too many fixed indices");
1012  assert(fixedIndices);
1013 
1014  // Check that the fixed indices are within range
1015  for (unsigned j=0; j<nFixedIndices; ++j)
1016  if (fixedIndices[j] >= dim) throw npstat::NpstatInvalidArgument(
1017  "In npstat::Private::shapeOfASlice: fixed index out of range");
1018 
1019  // Build the shape for the slice
1020  ArrayShape sh;
1021  if (nFixedIndices < dim)
1022  sh.reserve(dim - nFixedIndices);
1023  for (unsigned i=0; i<dim; ++i)
1024  {
1025  bool fixed = false;
1026  for (unsigned j=0; j<nFixedIndices; ++j)
1027  if (fixedIndices[j] == i)
1028  {
1029  fixed = true;
1030  break;
1031  }
1032  if (!fixed)
1033  sh.push_back(axes[i].nBins());
1034  }
1035  if (sh.size() != dim - nFixedIndices)
1037  "In npstat::Private::shapeOfASlice: duplicate fixed index");
1038  return sh;
1039  }
int i
Definition: DBlmapReader.cc:9
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21
int j
Definition: DBlmapReader.cc:9
template<class Axis >
ArrayShape npstat::Private::shapeWithExtraAxis ( const std::vector< Axis > &  axes,
const Axis &  newAxis,
const unsigned  newAxisNumber 
)

Definition at line 1065 of file HistoND.h.

References i, and query::result.

1068  {
1069  const unsigned dim = axes.size();
1071  result.reserve(dim + 1U);
1072  unsigned iadd = 0;
1073  for (unsigned i=0; i<dim; ++i)
1074  {
1075  if (newAxisNumber == i)
1076  result.push_back(newAxis.nBins());
1077  else
1078  result.push_back(axes[iadd++].nBins());
1079  }
1080  if (iadd == dim)
1081  result.push_back(newAxis.nBins());
1082  else
1083  result.push_back(axes[iadd].nBins());
1084  return result;
1085  }
int i
Definition: DBlmapReader.cc:9
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21
tuple result
Definition: query.py:137