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 >
std::vector< Axis > rebinAxes (const std::vector< Axis > &axes, const unsigned *newBins, const unsigned lenNewBins)
 
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 1088 of file HistoND.h.

References i.

1091  {
1092  const unsigned dim = axes.size();
1093  std::vector<Axis> newAxes;
1094  newAxes.reserve(dim + 1U);
1095  unsigned iadd = 0;
1096  for (unsigned i=0; i<dim; ++i)
1097  {
1098  if (newAxisNumber == i)
1099  newAxes.push_back(newAxis);
1100  else
1101  newAxes.push_back(axes[iadd++]);
1102  }
1103  if (iadd == dim)
1104  newAxes.push_back(newAxis);
1105  else
1106  newAxes.push_back(axes[iadd]);
1107  return newAxes;
1108  }
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 1013 of file HistoND.h.

References assert(), i, and j.

1016  {
1017  const unsigned dim = axes.size();
1018  std::vector<Axis> newAxes;
1019  if (nFixedIndices == 0U) throw npstat::NpstatInvalidArgument(
1020  "In npstat::Private::axesOfASlice: "
1021  "at least one fixed index must be specified");
1022  if (nFixedIndices > dim) throw npstat::NpstatInvalidArgument(
1023  "In npstat::Private::axesOfASlice: too many fixed indices");
1024  assert(fixedIndices);
1025  for (unsigned i=0; i<nFixedIndices; ++i)
1026  if (fixedIndices[i] >= dim) throw npstat::NpstatInvalidArgument(
1027  "In npstat::Private::axesOfASlice: fixed index out of range");
1028  newAxes.reserve(dim - nFixedIndices);
1029  for (unsigned i=0; i<dim; ++i)
1030  {
1031  bool fixed = false;
1032  for (unsigned j=0; j<nFixedIndices; ++j)
1033  if (fixedIndices[j] == i)
1034  {
1035  fixed = true;
1036  break;
1037  }
1038  if (!fixed)
1039  newAxes.push_back(axes[i]);
1040  }
1041  if (newAxes.size() != dim - nFixedIndices)
1043  "In npstat::Private::axesOfASlice: duplicate fixed index");
1044  return newAxes;
1045  }
int i
Definition: DBlmapReader.cc:9
assert(m_qm.get())
int j
Definition: DBlmapReader.cc:9
void npstat::Private::h_badargs ( const char *  method)
inline

Definition at line 1133 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().

1134  {
1135  std::ostringstream os;
1136  os << "In npstat::HistoND::" << method << ": number of arguments"
1137  << " is incompatible with histogram dimensionality";
1138  throw npstat::NpstatInvalidArgument(os.str());
1139  }
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  }
T x() const
Cartesian x coordinate.
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 assert(), npstat::ArrayND< Numeric, StackLen, StackDim >::data(), i, npstat::isStrictlyMonotonous(), npstat::ArrayND< Numeric, StackLen, StackDim >::length(), lind_interpolateSimple(), and npstat::ArrayND< Numeric, StackLen, StackDim >::rank().

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
assert(m_qm.get())
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 925 of file HistoND.h.

References i, gen::n, and mps_fire::result.

926  {
927  const unsigned n = axes.size();
929  result.reserve(n);
930  for (unsigned i=0; i<n; ++i)
931  result.push_back(axes[i].nBins());
932  return result;
933  }
int i
Definition: DBlmapReader.cc:9
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21
tuple result
Definition: mps_fire.py:95
template<class Axis >
ArrayShape npstat::Private::makeHistoShape ( const Axis &  xAxis)

Definition at line 936 of file HistoND.h.

References mps_fire::result.

937  {
939  result.reserve(1U);
940  result.push_back(xAxis.nBins());
941  return result;
942  }
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21
tuple result
Definition: mps_fire.py:95
template<class Axis >
ArrayShape npstat::Private::makeHistoShape ( const Axis &  xAxis,
const Axis &  yAxis 
)

Definition at line 945 of file HistoND.h.

References mps_fire::result.

946  {
948  result.reserve(2U);
949  result.push_back(xAxis.nBins());
950  result.push_back(yAxis.nBins());
951  return result;
952  }
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21
tuple result
Definition: mps_fire.py:95
template<class Axis >
ArrayShape npstat::Private::makeHistoShape ( const Axis &  xAxis,
const Axis &  yAxis,
const Axis &  zAxis 
)

Definition at line 955 of file HistoND.h.

References mps_fire::result.

958  {
960  result.reserve(3U);
961  result.push_back(xAxis.nBins());
962  result.push_back(yAxis.nBins());
963  result.push_back(zAxis.nBins());
964  return result;
965  }
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21
tuple result
Definition: mps_fire.py:95
tuple zAxis
Definition: MetAnalyzer.py:56
template<class Axis >
ArrayShape npstat::Private::makeHistoShape ( const Axis &  xAxis,
const Axis &  yAxis,
const Axis &  zAxis,
const Axis &  tAxis 
)

Definition at line 968 of file HistoND.h.

References mps_fire::result.

970  {
972  result.reserve(4U);
973  result.push_back(xAxis.nBins());
974  result.push_back(yAxis.nBins());
975  result.push_back(zAxis.nBins());
976  result.push_back(tAxis.nBins());
977  return result;
978  }
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21
tuple result
Definition: mps_fire.py:95
tuple zAxis
Definition: MetAnalyzer.py:56
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 981 of file HistoND.h.

References mps_fire::result.

984  {
986  result.reserve(5U);
987  result.push_back(xAxis.nBins());
988  result.push_back(yAxis.nBins());
989  result.push_back(zAxis.nBins());
990  result.push_back(tAxis.nBins());
991  result.push_back(vAxis.nBins());
992  return result;
993  }
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21
tuple result
Definition: mps_fire.py:95
tuple zAxis
Definition: MetAnalyzer.py:56
template<class Axis >
ArrayShape npstat::Private::makeTableShape ( const std::vector< Axis > &  axes)

Definition at line 264 of file LinInterpolatedTableND.h.

References i, gen::n, and mps_fire::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: mps_fire.py:95
template<class Axis >
ArrayShape npstat::Private::makeTableShape ( const Axis &  xAxis)

Definition at line 275 of file LinInterpolatedTableND.h.

References mps_fire::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: mps_fire.py:95
template<class Axis >
ArrayShape npstat::Private::makeTableShape ( const Axis &  xAxis,
const Axis &  yAxis 
)

Definition at line 284 of file LinInterpolatedTableND.h.

References mps_fire::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: mps_fire.py:95
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 mps_fire::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: mps_fire.py:95
tuple zAxis
Definition: MetAnalyzer.py:56
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 mps_fire::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: mps_fire.py:95
tuple zAxis
Definition: MetAnalyzer.py:56
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 mps_fire::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: mps_fire.py:95
tuple zAxis
Definition: MetAnalyzer.py:56
template<class Axis >
std::vector<Axis> npstat::Private::rebinAxes ( const std::vector< Axis > &  axes,
const unsigned *  newBins,
const unsigned  lenNewBins 
)

Definition at line 996 of file HistoND.h.

References assert(), and i.

999  {
1000  const unsigned dim = axes.size();
1001  if (lenNewBins != dim) throw npstat::NpstatInvalidArgument(
1002  "In npstat::Private::rebinAxes: invalid length "
1003  "of the new bins array");
1004  assert(newBins);
1005  std::vector<Axis> newAxes;
1006  newAxes.reserve(dim);
1007  for (unsigned i=0; i<dim; ++i)
1008  newAxes.push_back(axes[i].rebin(newBins[i]));
1009  return newAxes;
1010  }
int i
Definition: DBlmapReader.cc:9
assert(m_qm.get())
template<class Axis >
ArrayShape npstat::Private::shapeOfASlice ( const std::vector< Axis > &  axes,
const unsigned *  fixedIndices,
const unsigned  nFixedIndices 
)

Definition at line 1048 of file HistoND.h.

References assert(), i, and j.

1051  {
1052  const unsigned dim = axes.size();
1053  if (nFixedIndices == 0U) throw npstat::NpstatInvalidArgument(
1054  "In npstat::Private::shapeOfASlice: "
1055  "at least one fixed index must be specified");
1056  if (nFixedIndices > dim) throw npstat::NpstatInvalidArgument(
1057  "In npstat::Private::shapeOfASlice: too many fixed indices");
1058  assert(fixedIndices);
1059 
1060  // Check that the fixed indices are within range
1061  for (unsigned j=0; j<nFixedIndices; ++j)
1062  if (fixedIndices[j] >= dim) throw npstat::NpstatInvalidArgument(
1063  "In npstat::Private::shapeOfASlice: fixed index out of range");
1064 
1065  // Build the shape for the slice
1066  ArrayShape sh;
1067  if (nFixedIndices < dim)
1068  sh.reserve(dim - nFixedIndices);
1069  for (unsigned i=0; i<dim; ++i)
1070  {
1071  bool fixed = false;
1072  for (unsigned j=0; j<nFixedIndices; ++j)
1073  if (fixedIndices[j] == i)
1074  {
1075  fixed = true;
1076  break;
1077  }
1078  if (!fixed)
1079  sh.push_back(axes[i].nBins());
1080  }
1081  if (sh.size() != dim - nFixedIndices)
1083  "In npstat::Private::shapeOfASlice: duplicate fixed index");
1084  return sh;
1085  }
int i
Definition: DBlmapReader.cc:9
assert(m_qm.get())
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 1111 of file HistoND.h.

References i, and mps_fire::result.

1114  {
1115  const unsigned dim = axes.size();
1117  result.reserve(dim + 1U);
1118  unsigned iadd = 0;
1119  for (unsigned i=0; i<dim; ++i)
1120  {
1121  if (newAxisNumber == i)
1122  result.push_back(newAxis.nBins());
1123  else
1124  result.push_back(axes[iadd++].nBins());
1125  }
1126  if (iadd == dim)
1127  result.push_back(newAxis.nBins());
1128  else
1129  result.push_back(axes[iadd].nBins());
1130  return result;
1131  }
int i
Definition: DBlmapReader.cc:9
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21
tuple result
Definition: mps_fire.py:95