CMS 3D CMS Logo

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 > >
 

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

◆ addAxis()

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

Definition at line 1156 of file HistoND.h.

References mps_fire::i, and mitigatedMETSequence_cff::U.

1156  {
1157  const unsigned dim = axes.size();
1158  std::vector<Axis> newAxes;
1159  newAxes.reserve(dim + 1U);
1160  unsigned iadd = 0;
1161  for (unsigned i = 0; i < dim; ++i) {
1162  if (newAxisNumber == i)
1163  newAxes.push_back(newAxis);
1164  else
1165  newAxes.push_back(axes[iadd++]);
1166  }
1167  if (iadd == dim)
1168  newAxes.push_back(newAxis);
1169  else
1170  newAxes.push_back(axes[iadd]);
1171  return newAxes;
1172  }

◆ axesOfASlice()

template<class Axis >
std::vector<Axis> npstat::Private::axesOfASlice ( const std::vector< Axis > &  axes,
const unsigned *  fixedIndices,
const unsigned  nFixedIndices 
)

Definition at line 1087 of file HistoND.h.

References cms::cuda::assert(), alignBH_cfg::fixed, mps_fire::i, dqmiolumiharvest::j, and mitigatedMETSequence_cff::U.

1089  {
1090  const unsigned dim = axes.size();
1091  std::vector<Axis> newAxes;
1092  if (nFixedIndices == 0U)
1094  "In npstat::Private::axesOfASlice: "
1095  "at least one fixed index must be specified");
1096  if (nFixedIndices > dim)
1097  throw npstat::NpstatInvalidArgument("In npstat::Private::axesOfASlice: too many fixed indices");
1098  assert(fixedIndices);
1099  for (unsigned i = 0; i < nFixedIndices; ++i)
1100  if (fixedIndices[i] >= dim)
1101  throw npstat::NpstatInvalidArgument("In npstat::Private::axesOfASlice: fixed index out of range");
1102  newAxes.reserve(dim - nFixedIndices);
1103  for (unsigned i = 0; i < dim; ++i) {
1104  bool fixed = false;
1105  for (unsigned j = 0; j < nFixedIndices; ++j)
1106  if (fixedIndices[j] == i) {
1107  fixed = true;
1108  break;
1109  }
1110  if (!fixed)
1111  newAxes.push_back(axes[i]);
1112  }
1113  if (newAxes.size() != dim - nFixedIndices)
1114  throw npstat::NpstatInvalidArgument("In npstat::Private::axesOfASlice: duplicate fixed index");
1115  return newAxes;
1116  }
assert(be >=bs)

◆ h_badargs()

void npstat::Private::h_badargs ( const char *  method)
inline

◆ iHND_checkArgs()

template<typename Float , class Axis >
void npstat::Private::iHND_checkArgs ( const HistoND< Float, Axis > &  histo,
const unsigned  xDim,
const unsigned  interpolationDegree 
)

Definition at line 135 of file interpolateHistoND.h.

References timingPdfMaker::histo, and mitigatedMETSequence_cff::U.

Referenced by npstat::interpolateHistoND().

135  {
136  if (xDim != histo.dim())
138  "In npstat::interpolateHistoND: incompatible "
139  "dimensionality of input coordinates");
140  if (xDim == 0U)
142  "In npstat::interpolateHistoND: can not interpolate "
143  "zero-dimensional histograms");
144  if (!(interpolationDegree == 0U || interpolationDegree == 1U || interpolationDegree == 3U))
146  "In npstat::interpolateHistoND: "
147  "unsupported interpolation degree");
148  if (interpolationDegree == 3U && !histo.isUniformlyBinned())
150  "In npstat::interpolateHistoND: unsupported "
151  "interpolation degree for non-uniform binning");
152  }

◆ lind_interpolateSimple()

double npstat::Private::lind_interpolateSimple ( const double  x0,
const double  x1,
const double  y0,
const double  y1,
const double  x 
)
inline

◆ lind_invert1DSlice()

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 349 of file LinInterpolatedTableND.h.

References cms::cuda::assert(), npstat::ArrayND< Numeric, StackLen, StackDim >::data(), mps_fire::i, npstat::isStrictlyMonotonous(), npstat::ArrayND< Numeric, StackLen, StackDim >::length(), lind_interpolateSimple(), pfDeepBoostedJetPreprocessParams_cfi::lower_bound, npstat::ArrayND< Numeric, StackLen, StackDim >::rank(), and mitigatedMETSequence_cff::U.

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

354  {
355  assert(toSlice);
356  assert(fromSlice.rank() == 1U);
357  assert(toSlice->rank() == 1U);
358 
359  const Numeric* fromData = fromSlice.data();
360  const unsigned fromLen = fromSlice.length();
361  assert(fromLen > 1U);
362  assert(fromLen == fromAxis.nCoords());
363  const Numeric* fromDataEnd = fromData + fromLen;
364  if (!isStrictlyMonotonous(fromData, fromDataEnd))
366  "In npstat::Private::lind_invert1DSlice: "
367  "slice data is not monotonous and can not be inverted");
368 
369  const Numeric yfirst = fromData[0];
370  const Numeric ylast = fromData[fromLen - 1U];
371  const bool increasing = yfirst < ylast;
372 
373  Numeric* toD = const_cast<Numeric*>(toSlice->data());
374  const unsigned nAxisPoints = toAxis.nCoords();
375  assert(toSlice->length() == nAxisPoints);
376 
377  for (unsigned ipt = 0; ipt < nAxisPoints; ++ipt) {
378  const Numeric y = static_cast<Numeric>(toAxis.coordinate(ipt));
379  if (increasing) {
380  if (y <= yfirst) {
381  if (leftLinear)
383  yfirst, fromData[1], fromAxis.coordinate(0), fromAxis.coordinate(1), y);
384  else
385  toD[ipt] = fromAxis.coordinate(0);
386  } else if (y >= ylast) {
387  if (rightLinear)
388  toD[ipt] = Private::lind_interpolateSimple(ylast,
389  fromData[fromLen - 2U],
390  fromAxis.coordinate(fromLen - 1U),
391  fromAxis.coordinate(fromLen - 2U),
392  y);
393  else
394  toD[ipt] = fromAxis.coordinate(fromLen - 1U);
395  } else {
396  const unsigned i = std::lower_bound(fromData, fromDataEnd, y) - fromData;
398  fromData[i - 1U], fromData[i], fromAxis.coordinate(i - 1U), fromAxis.coordinate(i), y);
399  }
400  } else {
401  // The role of left and right are exchanged
402  // with respect to first and last point
403  if (y <= ylast) {
404  if (leftLinear)
405  toD[ipt] = Private::lind_interpolateSimple(ylast,
406  fromData[fromLen - 2U],
407  fromAxis.coordinate(fromLen - 1U),
408  fromAxis.coordinate(fromLen - 2U),
409  y);
410  else
411  toD[ipt] = fromAxis.coordinate(fromLen - 1U);
412  } else if (y >= yfirst) {
413  if (rightLinear)
415  yfirst, fromData[1], fromAxis.coordinate(0), fromAxis.coordinate(1), y);
416  else
417  toD[ipt] = fromAxis.coordinate(0);
418  } else {
419  const unsigned i = std::lower_bound(fromData, fromDataEnd, y, std::greater<Numeric>()) - fromData;
421  fromData[i - 1U], fromData[i], fromAxis.coordinate(i - 1U), fromAxis.coordinate(i), y);
422  }
423  }
424  }
425  }
assert(be >=bs)
const Numeric * data() const
Definition: ArrayND.h:236
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:44
unsigned long length() const
Definition: ArrayND.h:233
unsigned rank() const
Definition: ArrayND.h:242

◆ makeHistoShape() [1/6]

template<class Axis >
ArrayShape npstat::Private::makeHistoShape ( const std::vector< Axis > &  axes)

Definition at line 1011 of file HistoND.h.

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

1011  {
1012  const unsigned n = axes.size();
1014  result.reserve(n);
1015  for (unsigned i = 0; i < n; ++i)
1016  result.push_back(axes[i].nBins());
1017  return result;
1018  }
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21

◆ makeHistoShape() [2/6]

template<class Axis >
ArrayShape npstat::Private::makeHistoShape ( const Axis &  xAxis)

Definition at line 1021 of file HistoND.h.

References mps_fire::result, mitigatedMETSequence_cff::U, and HLT_2024v14_cff::xAxis.

1021  {
1023  result.reserve(1U);
1024  result.push_back(xAxis.nBins());
1025  return result;
1026  }
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21

◆ makeHistoShape() [3/6]

template<class Axis >
ArrayShape npstat::Private::makeHistoShape ( const Axis &  xAxis,
const Axis &  yAxis 
)

Definition at line 1029 of file HistoND.h.

References mps_fire::result, mitigatedMETSequence_cff::U, HLT_2024v14_cff::xAxis, and HLT_2024v14_cff::yAxis.

1029  {
1031  result.reserve(2U);
1032  result.push_back(xAxis.nBins());
1033  result.push_back(yAxis.nBins());
1034  return result;
1035  }
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21

◆ makeHistoShape() [4/6]

template<class Axis >
ArrayShape npstat::Private::makeHistoShape ( const Axis &  xAxis,
const Axis &  yAxis,
const Axis &  zAxis 
)

Definition at line 1038 of file HistoND.h.

References mps_fire::result, mitigatedMETSequence_cff::U, HLT_2024v14_cff::xAxis, HLT_2024v14_cff::yAxis, and HLT_2024v14_cff::zAxis.

1038  {
1040  result.reserve(3U);
1041  result.push_back(xAxis.nBins());
1042  result.push_back(yAxis.nBins());
1043  result.push_back(zAxis.nBins());
1044  return result;
1045  }
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21

◆ makeHistoShape() [5/6]

template<class Axis >
ArrayShape npstat::Private::makeHistoShape ( const Axis &  xAxis,
const Axis &  yAxis,
const Axis &  zAxis,
const Axis &  tAxis 
)

Definition at line 1048 of file HistoND.h.

References mps_fire::result, mitigatedMETSequence_cff::U, HLT_2024v14_cff::xAxis, HLT_2024v14_cff::yAxis, and HLT_2024v14_cff::zAxis.

1048  {
1050  result.reserve(4U);
1051  result.push_back(xAxis.nBins());
1052  result.push_back(yAxis.nBins());
1053  result.push_back(zAxis.nBins());
1054  result.push_back(tAxis.nBins());
1055  return result;
1056  }
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21

◆ makeHistoShape() [6/6]

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 1059 of file HistoND.h.

References mps_fire::result, mitigatedMETSequence_cff::U, HLT_2024v14_cff::xAxis, HLT_2024v14_cff::yAxis, and HLT_2024v14_cff::zAxis.

1060  {
1062  result.reserve(5U);
1063  result.push_back(xAxis.nBins());
1064  result.push_back(yAxis.nBins());
1065  result.push_back(zAxis.nBins());
1066  result.push_back(tAxis.nBins());
1067  result.push_back(vAxis.nBins());
1068  return result;
1069  }
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21

◆ makeTableShape() [1/6]

template<class Axis >
ArrayShape npstat::Private::makeTableShape ( const std::vector< Axis > &  axes)

Definition at line 283 of file LinInterpolatedTableND.h.

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

283  {
284  const unsigned n = axes.size();
286  result.reserve(n);
287  for (unsigned i = 0; i < n; ++i)
288  result.push_back(axes[i].nCoords());
289  return result;
290  }
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21

◆ makeTableShape() [2/6]

template<class Axis >
ArrayShape npstat::Private::makeTableShape ( const Axis &  xAxis)

Definition at line 293 of file LinInterpolatedTableND.h.

References mps_fire::result, mitigatedMETSequence_cff::U, and HLT_2024v14_cff::xAxis.

293  {
295  result.reserve(1U);
296  result.push_back(xAxis.nCoords());
297  return result;
298  }
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21

◆ makeTableShape() [3/6]

template<class Axis >
ArrayShape npstat::Private::makeTableShape ( const Axis &  xAxis,
const Axis &  yAxis 
)

Definition at line 301 of file LinInterpolatedTableND.h.

References mps_fire::result, mitigatedMETSequence_cff::U, HLT_2024v14_cff::xAxis, and HLT_2024v14_cff::yAxis.

301  {
303  result.reserve(2U);
304  result.push_back(xAxis.nCoords());
305  result.push_back(yAxis.nCoords());
306  return result;
307  }
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21

◆ makeTableShape() [4/6]

template<class Axis >
ArrayShape npstat::Private::makeTableShape ( const Axis &  xAxis,
const Axis &  yAxis,
const Axis &  zAxis 
)

Definition at line 310 of file LinInterpolatedTableND.h.

References mps_fire::result, mitigatedMETSequence_cff::U, HLT_2024v14_cff::xAxis, HLT_2024v14_cff::yAxis, and HLT_2024v14_cff::zAxis.

310  {
312  result.reserve(3U);
313  result.push_back(xAxis.nCoords());
314  result.push_back(yAxis.nCoords());
315  result.push_back(zAxis.nCoords());
316  return result;
317  }
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21

◆ makeTableShape() [5/6]

template<class Axis >
ArrayShape npstat::Private::makeTableShape ( const Axis &  xAxis,
const Axis &  yAxis,
const Axis &  zAxis,
const Axis &  tAxis 
)

Definition at line 320 of file LinInterpolatedTableND.h.

References mps_fire::result, mitigatedMETSequence_cff::U, HLT_2024v14_cff::xAxis, HLT_2024v14_cff::yAxis, and HLT_2024v14_cff::zAxis.

320  {
322  result.reserve(4U);
323  result.push_back(xAxis.nCoords());
324  result.push_back(yAxis.nCoords());
325  result.push_back(zAxis.nCoords());
326  result.push_back(tAxis.nCoords());
327  return result;
328  }
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21

◆ makeTableShape() [6/6]

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 331 of file LinInterpolatedTableND.h.

References mps_fire::result, mitigatedMETSequence_cff::U, HLT_2024v14_cff::xAxis, HLT_2024v14_cff::yAxis, and HLT_2024v14_cff::zAxis.

332  {
334  result.reserve(5U);
335  result.push_back(xAxis.nCoords());
336  result.push_back(yAxis.nCoords());
337  result.push_back(zAxis.nCoords());
338  result.push_back(tAxis.nCoords());
339  result.push_back(vAxis.nCoords());
340  return result;
341  }
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21

◆ rebinAxes()

template<class Axis >
std::vector<Axis> npstat::Private::rebinAxes ( const std::vector< Axis > &  axes,
const unsigned *  newBins,
const unsigned  lenNewBins 
)

Definition at line 1072 of file HistoND.h.

References cms::cuda::assert(), and mps_fire::i.

1072  {
1073  const unsigned dim = axes.size();
1074  if (lenNewBins != dim)
1076  "In npstat::Private::rebinAxes: invalid length "
1077  "of the new bins array");
1078  assert(newBins);
1079  std::vector<Axis> newAxes;
1080  newAxes.reserve(dim);
1081  for (unsigned i = 0; i < dim; ++i)
1082  newAxes.push_back(axes[i].rebin(newBins[i]));
1083  return newAxes;
1084  }
assert(be >=bs)

◆ shapeOfASlice()

template<class Axis >
ArrayShape npstat::Private::shapeOfASlice ( const std::vector< Axis > &  axes,
const unsigned *  fixedIndices,
const unsigned  nFixedIndices 
)

Definition at line 1119 of file HistoND.h.

References cms::cuda::assert(), alignBH_cfg::fixed, mps_fire::i, dqmiolumiharvest::j, ecalPedestalPCLworker_cfi::nBins, and mitigatedMETSequence_cff::U.

1121  {
1122  const unsigned dim = axes.size();
1123  if (nFixedIndices == 0U)
1125  "In npstat::Private::shapeOfASlice: "
1126  "at least one fixed index must be specified");
1127  if (nFixedIndices > dim)
1128  throw npstat::NpstatInvalidArgument("In npstat::Private::shapeOfASlice: too many fixed indices");
1129  assert(fixedIndices);
1130 
1131  // Check that the fixed indices are within range
1132  for (unsigned j = 0; j < nFixedIndices; ++j)
1133  if (fixedIndices[j] >= dim)
1134  throw npstat::NpstatInvalidArgument("In npstat::Private::shapeOfASlice: fixed index out of range");
1135 
1136  // Build the shape for the slice
1137  ArrayShape sh;
1138  if (nFixedIndices < dim)
1139  sh.reserve(dim - nFixedIndices);
1140  for (unsigned i = 0; i < dim; ++i) {
1141  bool fixed = false;
1142  for (unsigned j = 0; j < nFixedIndices; ++j)
1143  if (fixedIndices[j] == i) {
1144  fixed = true;
1145  break;
1146  }
1147  if (!fixed)
1148  sh.push_back(axes[i].nBins());
1149  }
1150  if (sh.size() != dim - nFixedIndices)
1151  throw npstat::NpstatInvalidArgument("In npstat::Private::shapeOfASlice: duplicate fixed index");
1152  return sh;
1153  }
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21
assert(be >=bs)

◆ shapeWithExtraAxis()

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

Definition at line 1175 of file HistoND.h.

References mps_fire::i, ecalPedestalPCLworker_cfi::nBins, mps_fire::result, and mitigatedMETSequence_cff::U.

1175  {
1176  const unsigned dim = axes.size();
1178  result.reserve(dim + 1U);
1179  unsigned iadd = 0;
1180  for (unsigned i = 0; i < dim; ++i) {
1181  if (newAxisNumber == i)
1182  result.push_back(newAxis.nBins());
1183  else
1184  result.push_back(axes[iadd++].nBins());
1185  }
1186  if (iadd == dim)
1187  result.push_back(newAxis.nBins());
1188  else
1189  result.push_back(axes[iadd].nBins());
1190  return result;
1191  }
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21