1 #ifndef NPSTAT_HISTOND_HH_
2 #define NPSTAT_HISTOND_HH_
42 template <
typename Numeric,
class Axis=HistoAxis>
45 template <
typename Num2,
class Axis2>
friend class HistoND;
60 HistoND(
const Axis& xAxis,
const Axis& yAxis,
64 HistoND(
const Axis& xAxis,
const Axis& yAxis,
const Axis& zAxis,
68 HistoND(
const Axis& xAxis,
const Axis& yAxis,
69 const Axis& zAxis,
const Axis& tAxis,
73 HistoND(
const Axis& xAxis,
const Axis& yAxis,
74 const Axis& zAxis,
const Axis& tAxis,
const Axis& vAxis,
91 template <
typename Num2,
class Functor>
102 template <
typename Num2>
104 unsigned nIndices,
const char*
title=0);
115 template <
typename Num2>
117 unsigned newAxisNumber,
const char*
title=0);
145 inline const std::vector<Axis>&
axes()
const {
return axes_;}
148 inline const Axis&
axis(
const unsigned i)
const
149 {
return axes_.at(i);}
194 double* coords,
unsigned lenCoords)
const;
203 template <
class Po
int>
249 template <
typename Num2>
250 void fill(
const double* coords,
unsigned coordLength,
258 template <
typename Num2>
261 template <
typename Num2>
264 template <
typename Num2>
265 void fill(
double x0,
double x1,
const Num2&
weight);
267 template <
typename Num2>
268 void fill(
double x0,
double x1,
double x2,
const Num2&
weight);
270 template <
typename Num2>
271 void fill(
double x0,
double x1,
double x2,
double x3,
274 template <
typename Num2>
275 void fill(
double x0,
double x1,
double x2,
double x3,
double x4,
278 template <
typename Num2>
279 void fill(
double x0,
double x1,
double x2,
double x3,
double x4,
280 double x5,
const Num2&
weight);
282 template <
typename Num2>
283 void fill(
double x0,
double x1,
double x2,
double x3,
double x4,
284 double x5,
double x6,
const Num2&
weight);
286 template <
typename Num2>
287 void fill(
double x0,
double x1,
double x2,
double x3,
double x4,
288 double x5,
double x6,
double x7,
const Num2&
weight);
290 template <
typename Num2>
291 void fill(
double x0,
double x1,
double x2,
double x3,
double x4,
292 double x5,
double x6,
double x7,
double x8,
295 template <
typename Num2>
296 void fill(
double x0,
double x1,
double x2,
double x3,
double x4,
297 double x5,
double x6,
double x7,
double x8,
double x9,
314 template <
typename Num2,
class Functor>
315 void dispatch(
const double* coords,
unsigned coordLength,
323 template <
typename Num2,
class Functor>
326 template <
typename Num2,
class Functor>
329 template <
typename Num2,
class Functor>
332 template <
typename Num2,
class Functor>
336 template <
typename Num2,
class Functor>
337 void dispatch(
double x0,
double x1,
double x2,
double x3,
340 template <
typename Num2,
class Functor>
341 void dispatch(
double x0,
double x1,
double x2,
double x3,
double x4,
344 template <
typename Num2,
class Functor>
345 void dispatch(
double x0,
double x1,
double x2,
double x3,
double x4,
346 double x5, Num2&
weight, Functor&
f);
348 template <
typename Num2,
class Functor>
349 void dispatch(
double x0,
double x1,
double x2,
double x3,
double x4,
350 double x5,
double x6, Num2&
weight, Functor&
f);
352 template <
typename Num2,
class Functor>
353 void dispatch(
double x0,
double x1,
double x2,
double x3,
double x4,
354 double x5,
double x6,
double x7, Num2&
weight,
357 template <
typename Num2,
class Functor>
358 void dispatch(
double x0,
double x1,
double x2,
double x3,
double x4,
359 double x5,
double x6,
double x7,
double x8,
362 template <
typename Num2,
class Functor>
363 void dispatch(
double x0,
double x1,
double x2,
double x3,
double x4,
364 double x5,
double x6,
double x7,
double x8,
double x9,
374 const Numeric&
examine(
const double* coords,
375 unsigned coordLength)
const;
382 const Numeric&
examine()
const;
384 const Numeric&
examine(
double x0)
const;
386 const Numeric&
examine(
double x0,
double x1)
const;
388 const Numeric&
examine(
double x0,
double x1,
double x2)
const;
390 const Numeric&
examine(
double x0,
double x1,
double x2,
393 const Numeric&
examine(
double x0,
double x1,
double x2,
double x3,
396 const Numeric&
examine(
double x0,
double x1,
double x2,
double x3,
397 double x4,
double x5)
const;
399 const Numeric&
examine(
double x0,
double x1,
double x2,
double x3,
400 double x4,
double x5,
double x6)
const;
402 const Numeric&
examine(
double x0,
double x1,
double x2,
double x3,
403 double x4,
double x5,
double x6,
406 const Numeric&
examine(
double x0,
double x1,
double x2,
double x3,
407 double x4,
double x5,
double x6,
double x7,
410 const Numeric&
examine(
double x0,
double x1,
double x2,
double x3,
411 double x4,
double x5,
double x6,
double x7,
412 double x8,
double x9)
const;
421 const Numeric&
closestBin(
const double* coords,
422 unsigned coordLength)
const;
433 const Numeric&
closestBin(
double x0,
double x1)
const;
435 const Numeric&
closestBin(
double x0,
double x1,
double x2)
const;
437 const Numeric&
closestBin(
double x0,
double x1,
double x2,
440 const Numeric&
closestBin(
double x0,
double x1,
double x2,
double x3,
443 const Numeric&
closestBin(
double x0,
double x1,
double x2,
double x3,
444 double x4,
double x5)
const;
446 const Numeric&
closestBin(
double x0,
double x1,
double x2,
double x3,
447 double x4,
double x5,
double x6)
const;
449 const Numeric&
closestBin(
double x0,
double x1,
double x2,
double x3,
450 double x4,
double x5,
double x6,
453 const Numeric&
closestBin(
double x0,
double x1,
double x2,
double x3,
454 double x4,
double x5,
double x6,
double x7,
457 const Numeric&
closestBin(
double x0,
double x1,
double x2,
double x3,
458 double x4,
double x5,
double x6,
double x7,
459 double x8,
double x9)
const;
484 template <
typename Num2>
485 void fillC(
const double* coords,
unsigned coordLength,
493 template <
typename Num2>
496 template <
typename Num2>
499 template <
typename Num2>
500 void fillC(
double x0,
double x1,
const Num2&
weight);
502 template <
typename Num2>
503 void fillC(
double x0,
double x1,
double x2,
const Num2&
weight);
505 template <
typename Num2>
506 void fillC(
double x0,
double x1,
double x2,
double x3,
509 template <
typename Num2>
510 void fillC(
double x0,
double x1,
double x2,
double x3,
double x4,
513 template <
typename Num2>
514 void fillC(
double x0,
double x1,
double x2,
double x3,
double x4,
515 double x5,
const Num2&
weight);
517 template <
typename Num2>
518 void fillC(
double x0,
double x1,
double x2,
double x3,
double x4,
519 double x5,
double x6,
const Num2&
weight);
521 template <
typename Num2>
522 void fillC(
double x0,
double x1,
double x2,
double x3,
double x4,
523 double x5,
double x6,
double x7,
const Num2&
weight);
525 template <
typename Num2>
526 void fillC(
double x0,
double x1,
double x2,
double x3,
double x4,
527 double x5,
double x6,
double x7,
double x8,
530 template <
typename Num2>
531 void fillC(
double x0,
double x1,
double x2,
double x3,
double x4,
532 double x5,
double x6,
double x7,
double x8,
double x9,
540 template <
typename Num2>
552 template <
typename Num2>
557 template <
typename Num2>
558 void setBin(
const unsigned *
index,
unsigned indexLen,
const Num2&
v);
560 template <
typename Num2>
563 template <
typename Num2>
564 void setBin(
unsigned i0,
const Num2&
v);
566 template <
typename Num2>
567 void setBin(
unsigned i0,
unsigned i1,
const Num2&
v);
569 template <
typename Num2>
570 void setBin(
unsigned i0,
unsigned i1,
unsigned i2,
const Num2&
v);
572 template <
typename Num2>
573 void setBin(
unsigned i0,
unsigned i1,
unsigned i2,
unsigned i3,
576 template <
typename Num2>
577 void setBin(
unsigned i0,
unsigned i1,
unsigned i2,
unsigned i3,
578 unsigned i4,
const Num2&
v);
580 template <
typename Num2>
581 void setBin(
unsigned i0,
unsigned i1,
unsigned i2,
unsigned i3,
582 unsigned i4,
unsigned i5,
const Num2&
v);
584 template <
typename Num2>
585 void setBin(
unsigned i0,
unsigned i1,
unsigned i2,
unsigned i3,
586 unsigned i4,
unsigned i5,
unsigned i6,
const Num2&
v);
588 template <
typename Num2>
589 void setBin(
unsigned i0,
unsigned i1,
unsigned i2,
unsigned i3,
590 unsigned i4,
unsigned i5,
unsigned i6,
unsigned i7,
593 template <
typename Num2>
594 void setBin(
unsigned i0,
unsigned i1,
unsigned i2,
unsigned i3,
595 unsigned i4,
unsigned i5,
unsigned i6,
unsigned i7,
596 unsigned i8,
const Num2&
v);
598 template <
typename Num2>
599 void setBin(
unsigned i0,
unsigned i1,
unsigned i2,
unsigned i3,
600 unsigned i4,
unsigned i5,
unsigned i6,
unsigned i7,
601 unsigned i8,
unsigned i9,
const Num2&
v);
603 template <
typename Num2>
610 template <
typename Num2>
611 void setBinAt(
const unsigned *
index,
unsigned indexLen,
const Num2&
v);
613 template <
typename Num2>
616 template <
typename Num2>
617 void setBinAt(
unsigned i0,
const Num2&
v);
619 template <
typename Num2>
620 void setBinAt(
unsigned i0,
unsigned i1,
const Num2&
v);
622 template <
typename Num2>
623 void setBinAt(
unsigned i0,
unsigned i1,
unsigned i2,
const Num2&
v);
625 template <
typename Num2>
626 void setBinAt(
unsigned i0,
unsigned i1,
unsigned i2,
unsigned i3,
629 template <
typename Num2>
630 void setBinAt(
unsigned i0,
unsigned i1,
unsigned i2,
unsigned i3,
631 unsigned i4,
const Num2&
v);
633 template <
typename Num2>
634 void setBinAt(
unsigned i0,
unsigned i1,
unsigned i2,
unsigned i3,
635 unsigned i4,
unsigned i5,
const Num2&
v);
637 template <
typename Num2>
638 void setBinAt(
unsigned i0,
unsigned i1,
unsigned i2,
unsigned i3,
639 unsigned i4,
unsigned i5,
unsigned i6,
const Num2&
v);
641 template <
typename Num2>
642 void setBinAt(
unsigned i0,
unsigned i1,
unsigned i2,
unsigned i3,
643 unsigned i4,
unsigned i5,
unsigned i6,
unsigned i7,
646 template <
typename Num2>
647 void setBinAt(
unsigned i0,
unsigned i1,
unsigned i2,
unsigned i3,
648 unsigned i4,
unsigned i5,
unsigned i6,
unsigned i7,
649 unsigned i8,
const Num2&
v);
651 template <
typename Num2>
652 void setBinAt(
unsigned i0,
unsigned i1,
unsigned i2,
unsigned i3,
653 unsigned i4,
unsigned i5,
unsigned i6,
unsigned i7,
654 unsigned i8,
unsigned i9,
const Num2&
v);
656 template <
typename Num2>
662 template <
typename Num2>
667 template <
typename Num2>
674 template <
typename Num2>
682 template <
typename Num2>
706 template <
typename Num2>
710 template <
typename Num2>
715 template <
typename Num2>
718 template <
typename Num2>
727 template <
typename Num2>
730 template <
typename Num2>
740 template <
typename Num2>
743 template <
typename Num2>
755 template <
typename Acc>
769 template <
typename Num2,
typename Num3>
772 const unsigned *projectedIndices,
773 unsigned nProjectedIndices)
const;
775 template <
typename Num2,
typename Num3>
778 const unsigned *projectedIndices,
779 unsigned nProjectedIndices)
const;
808 inline gs::ClassId
classId()
const {
return gs::ClassId(*
this);}
809 bool write(std::ostream& of)
const;
814 static HistoND*
read(
const gs::ClassId&
id, std::istream&
in);
823 template <
typename Num2>
826 template <
typename Acc>
828 unsigned*
idx, Acc* accumulator,
829 double overlapFraction)
const;
858 template <
typename Histo>
866 template <
typename Histo>
879 template <
typename Histo>
881 bool doubleDataRange);
890 #include "Alignment/Geners/interface/CPP11_auto_ptr.hh"
891 #include "Alignment/Geners/interface/binaryIO.hh"
895 template <
class Axis>
898 const unsigned n = axes.size();
901 for (
unsigned i=0;
i<
n; ++
i)
902 result.push_back(axes[
i].nBins());
906 template <
class Axis>
911 result.push_back(xAxis.nBins());
915 template <
class Axis>
920 result.push_back(xAxis.nBins());
921 result.push_back(yAxis.nBins());
925 template <
class Axis>
932 result.push_back(xAxis.nBins());
933 result.push_back(yAxis.nBins());
934 result.push_back(zAxis.nBins());
938 template <
class Axis>
940 const Axis& zAxis,
const Axis& tAxis)
944 result.push_back(xAxis.nBins());
945 result.push_back(yAxis.nBins());
946 result.push_back(zAxis.nBins());
947 result.push_back(tAxis.nBins());
951 template <
class Axis>
953 const Axis& zAxis,
const Axis& tAxis,
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());
966 template <
class Axis>
968 const unsigned *fixedIndices,
969 const unsigned nFixedIndices)
971 const unsigned dim = axes.size();
972 std::vector<Axis> newAxes;
974 "In npstat::Private::axesOfASlice: "
975 "at least one fixed index must be specified");
977 "In npstat::Private::axesOfASlice: too many fixed indices");
978 assert(fixedIndices);
979 for (
unsigned i=0;
i<nFixedIndices; ++
i)
981 "In npstat::Private::axesOfASlice: fixed index out of range");
982 newAxes.reserve(dim - nFixedIndices);
983 for (
unsigned i=0;
i<dim; ++
i)
986 for (
unsigned j=0;
j<nFixedIndices; ++
j)
987 if (fixedIndices[
j] ==
i)
993 newAxes.push_back(axes[
i]);
995 if (newAxes.size() != dim - nFixedIndices)
997 "In npstat::Private::axesOfASlice: duplicate fixed index");
1001 template <
class Axis>
1003 const unsigned *fixedIndices,
1004 const unsigned nFixedIndices)
1006 const unsigned dim = axes.size();
1008 "In npstat::Private::shapeOfASlice: "
1009 "at least one fixed index must be specified");
1011 "In npstat::Private::shapeOfASlice: too many fixed indices");
1012 assert(fixedIndices);
1015 for (
unsigned j=0;
j<nFixedIndices; ++
j)
1017 "In npstat::Private::shapeOfASlice: fixed index out of range");
1021 if (nFixedIndices < dim)
1022 sh.reserve(dim - nFixedIndices);
1023 for (
unsigned i=0;
i<dim; ++
i)
1026 for (
unsigned j=0;
j<nFixedIndices; ++
j)
1027 if (fixedIndices[
j] ==
i)
1033 sh.push_back(axes[
i].nBins());
1035 if (sh.size() != dim - nFixedIndices)
1037 "In npstat::Private::shapeOfASlice: duplicate fixed index");
1041 template <
class Axis>
1042 std::vector<Axis>
addAxis(
const std::vector<Axis>& axes,
1043 const Axis& newAxis,
1044 const unsigned newAxisNumber)
1046 const unsigned dim = axes.size();
1047 std::vector<Axis> newAxes;
1048 newAxes.reserve(dim + 1U);
1050 for (
unsigned i=0;
i<dim; ++
i)
1052 if (newAxisNumber ==
i)
1053 newAxes.push_back(newAxis);
1055 newAxes.push_back(axes[iadd++]);
1058 newAxes.push_back(newAxis);
1060 newAxes.push_back(axes[iadd]);
1064 template <
class Axis>
1066 const Axis& newAxis,
1067 const unsigned newAxisNumber)
1069 const unsigned dim = axes.size();
1071 result.reserve(dim + 1U);
1073 for (
unsigned i=0;
i<dim; ++
i)
1075 if (newAxisNumber ==
i)
1076 result.push_back(newAxis.nBins());
1078 result.push_back(axes[iadd++].nBins());
1081 result.push_back(newAxis.nBins());
1083 result.push_back(axes[iadd].nBins());
1089 std::ostringstream os;
1090 os <<
"In npstat::HistoND::" << method <<
": number of arguments"
1091 <<
" is incompatible with histogram dimensionality";
1096 template <
typename Numeric,
class Axis>
1097 template <
typename Acc>
1100 unsigned*
idx, Acc* accumulator,
const double overlapFraction)
const
1103 const Axis& axis(axes_[level]);
1104 const unsigned nbins = axis.nBins();
1105 const bool lastLevel = level == dim_ - 1U;
1108 const double over = overlapFraction*
1109 axis.binInterval(
i).overlapFraction(boxSide);
1114 *accumulator += over*data_.value(idx, dim_);
1116 accumulateBinsLoop(level+1U, box, idx, accumulator, over);
1121 template <
typename Numeric,
class Axis>
1122 template <
typename Acc>
1127 "In npstat::HistoND::accumulateBinsInBox: "
1128 "incompatible box dimensionality");
1129 assert(accumulator);
1132 for (
unsigned i=0;
i<dim_; ++
i)
1134 accumulateBinsLoop(0U, box, &indexBuf_[0], accumulator, 1.0);
1137 *accumulator += 1.0*data_();
1140 template <
typename Numeric,
class Axis>
1148 template <
typename Numeric,
class Axis>
1156 template <
typename Numeric,
class Axis>
1164 template <
typename Numeric,
class Axis>
1167 : title_(title ? title :
""),
1168 accumulatedDataLabel_(label ? label :
""),
1172 weightBuf_(axesIn.
size()),
1173 indexBuf_(2U*axesIn.
size()),
1177 if (
dim_ >= CHAR_BIT*
sizeof(
unsigned long))
1179 "In npstat::HistoND constructor: requested histogram "
1180 "dimensionality is not supported (too large)");
1184 template <
typename Numeric,
class Axis>
1187 : title_(title ? title :
""),
1188 accumulatedDataLabel_(label ? label :
""),
1197 axes_.push_back(xAxis);
1201 template <
typename Numeric,
class Axis>
1204 : title_(title ? title :
""),
1205 accumulatedDataLabel_(label ? label :
""),
1214 axes_.push_back(xAxis);
1215 axes_.push_back(yAxis);
1219 template <
typename Numeric,
class Axis>
1221 const Axis& zAxis,
const char*
title,
1223 : title_(title ? title :
""),
1224 accumulatedDataLabel_(label ? label :
""),
1233 axes_.push_back(xAxis);
1234 axes_.push_back(yAxis);
1235 axes_.push_back(zAxis);
1239 template <
typename Numeric,
class Axis>
1241 const Axis& zAxis,
const Axis& tAxis,
1243 : title_(title ? title :
""),
1244 accumulatedDataLabel_(label ? label :
""),
1253 axes_.push_back(xAxis);
1254 axes_.push_back(yAxis);
1255 axes_.push_back(zAxis);
1256 axes_.push_back(tAxis);
1260 template <
typename Numeric,
class Axis>
1262 const Axis& zAxis,
const Axis& tAxis,
1265 : title_(title ? title :
""),
1266 accumulatedDataLabel_(label ? label :
""),
1267 data_(Private::
makeHistoShape(xAxis, yAxis, zAxis, tAxis, vAxis)),
1275 axes_.push_back(xAxis);
1276 axes_.push_back(yAxis);
1277 axes_.push_back(zAxis);
1278 axes_.push_back(tAxis);
1279 axes_.push_back(vAxis);
1283 template <
typename Numeric,
class Axis>
1287 : title_(title ? title :
""),
1288 accumulatedDataLabel_(label ? label :
""),
1291 weightBuf_(shape.
size()),
1292 indexBuf_(2U*shape.
size()),
1297 "In npstat::HistoND constructor: "
1298 "incompatible bounding box dimensionality");
1299 if (
dim_ >= CHAR_BIT*
sizeof(
unsigned long))
1301 "In npstat::HistoND constructor: requested histogram "
1302 "dimensionality is not supported (too large)");
1304 for (
unsigned i=0;
i<
dim_; ++
i)
1305 axes_.push_back(Axis(shape[
i],
1306 boundingBox[i].
min(),
1307 boundingBox[i].
max()));
1311 template <
typename Numeric,
class Axis>
1312 template <
typename Num2,
class Functor>
1316 : title_(title ? title :
""),
1317 accumulatedDataLabel_(label ? label :
""),
1319 overflow_(r.overflow_, f),
1322 indexBuf_(2U*r.dim_),
1323 fillCount_(r.fillCount_),
1324 overCount_(r.overCount_),
1330 template <
typename Numeric,
class Axis>
1331 template <
typename Num2>
1334 const unsigned nIndices,
const char*
title)
1335 : title_(title ? title :
""),
1336 accumulatedDataLabel_(h.accumulatedDataLabel_),
1339 axes_(Private::
axesOfASlice(h.axes_, indices, nIndices)),
1340 weightBuf_(data_.rank()),
1341 indexBuf_(2U*data_.rank()),
1348 template <
typename Numeric,
class Axis>
1349 template <
typename Num2>
1352 const unsigned newAxisNumber,
const char*
title)
1353 : title_(title ? title :
""),
1354 accumulatedDataLabel_(h.accumulatedDataLabel_),
1356 overflow_(data_.rank(), 3U),
1357 axes_(Private::
addAxis(h.axes_, newAxis, newAxisNumber)),
1358 weightBuf_(data_.rank()),
1359 indexBuf_(2U*data_.rank()),
1363 if (
dim_ >= CHAR_BIT*
sizeof(
unsigned long))
1365 "In npstat::HistoND constructor: requested histogram "
1366 "dimensionality is not supported (too large)");
1370 template <
typename Numeric,
class Axis>
1373 for (
unsigned i=0;
i<dim_; ++
i)
1374 if (!axes_[
i].isUniform())
1379 template <
typename Numeric,
class Axis>
1386 if (isUniformlyBinned())
1388 Precise sum = data_.template sum<Precise>();
1389 return static_cast<double>(sum)*binVolume();
1393 Precise sum = Precise();
1394 const Numeric*
data = data_.data();
1395 const unsigned long len = data_.length();
1396 for (
unsigned long i=0;
i<len; ++
i)
1397 sum += data[
i]*binVolume(
i);
1398 return static_cast<double>(sum);
1402 template <
typename Numeric,
class Axis>
1409 const Axis*
ax = &axes_[0];
1410 for (
unsigned i=0;
i<dim_; ++
i)
1411 box.push_back(ax[
i].interval());
1416 template <
typename Numeric,
class Axis>
1419 double* coords,
const unsigned lenCoords)
const
1422 "In npstat::HistoND::binCenter: "
1423 "incompatible input point dimensionality");
1427 data_.convertLinearIndex(binNumber, &indexBuf_[0], dim_);
1428 const Axis*
ax = &axes_[0];
1429 for (
unsigned i=0;
i<dim_; ++
i)
1430 coords[
i] = ax[
i].binCenter(indexBuf_[
i]);
1434 template <
typename Numeric,
class Axis>
1435 template <
class Po
int>
1437 std::vector<Point>* centers)
const
1441 const unsigned long len = data_.length();
1442 centers->reserve(len);
1443 unsigned* ibuf = &indexBuf_[0];
1444 const Axis*
ax = &axes_[0];
1447 "In npstat::HistoND::allBinCenters: "
1448 "incompatible point dimensionality (too small)");
1451 for (
unsigned long i=0;
i<len; ++
i)
1453 data_.convertLinearIndex(
i, ibuf, dim_);
1454 for (
unsigned idim=0; idim<dim_; ++idim)
1455 cdat[idim] = ax[idim].binCenter(ibuf[idim]);
1456 centers->push_back(center);
1460 template <
typename Numeric,
class Axis>
1469 data_.convertLinearIndex(binNumber, &indexBuf_[0], dim_);
1470 const Axis*
ax = &axes_[0];
1471 for (
unsigned i=0;
i<dim_; ++
i)
1472 box->push_back(ax[
i].binInterval(indexBuf_[
i]));
1476 template <
typename Numeric,
class Axis>
1479 return dim_ == r.dim_ &&
1480 overflow_ == r.overflow_ &&
1484 template <
typename Numeric,
class Axis>
1487 return dim_ == r.dim_ &&
1488 fillCount_ == r.fillCount_ &&
1489 overCount_ == r.overCount_ &&
1490 title_ == r.title_ &&
1491 accumulatedDataLabel_ == r.accumulatedDataLabel_ &&
1493 overflow_ == r.overflow_ &&
1497 template <
typename Numeric,
class Axis>
1500 return !(*
this ==
r);
1503 template <
typename Numeric,
class Axis>
1510 data_.convertLinearIndex(binNumber, &indexBuf_[0], dim_);
1511 const Axis*
ax = &axes_[0];
1512 for (
unsigned i=0;
i<dim_; ++
i)
1513 v *= ax[
i].binWidth(indexBuf_[
i]);
1518 template <
typename Numeric,
class Axis>
1524 const Axis*
ax = &axes_[0];
1525 for (
unsigned i=0;
i<dim_; ++
i)
1531 template <
typename Numeric,
class Axis>
1532 template <
typename Num2>
1534 const double* coords,
const unsigned coordLength,
const Num2&
w)
1537 "In npstat::HistoND::fill: "
1538 "incompatible input point dimensionality");
1542 unsigned*
idx = &indexBuf_[0];
1543 unsigned* over = idx + dim_;
1544 const Axis*
ax = &axes_[0];
1545 unsigned overflown = 0U;
1546 for (
unsigned i=0;
i<dim_; ++
i)
1548 over[
i] = ax[
i].overflowIndex(coords[
i], idx + i);
1549 overflown |= (over[
i] - 1U);
1553 overflow_.value(over, dim_) +=
w;
1557 data_.value(idx, dim_) +=
w;
1561 ++fillCount_; ++modCount_;
1564 template <
typename Numeric,
class Axis>
1565 template <
typename Num2,
class Functor>
1567 const double* coords,
const unsigned coordLength, Num2&
w, Functor&
f)
1570 "In npstat::HistoND::dispatch: "
1571 "incompatible input point dimensionality");
1575 unsigned*
idx = &indexBuf_[0];
1576 unsigned* over = idx + dim_;
1577 const Axis*
ax = &axes_[0];
1578 unsigned overflown = 0U;
1579 for (
unsigned i=0;
i<dim_; ++
i)
1581 over[
i] = ax[
i].overflowIndex(coords[
i], idx + i);
1582 overflown |= (over[
i] - 1U);
1585 f(overflow_.value(over, dim_),
w);
1587 f(data_.value(idx, dim_),
w);
1594 template <
typename Numeric,
class Axis>
1596 const double* coords,
const unsigned coordLength)
const
1599 "In npstat::HistoND::examine: "
1600 "incompatible input point dimensionality");
1604 unsigned*
idx = &indexBuf_[0];
1605 unsigned* over = idx + dim_;
1606 const Axis*
ax = &axes_[0];
1607 unsigned overflown = 0U;
1608 for (
unsigned i=0;
i<dim_; ++
i)
1610 over[
i] = ax[
i].overflowIndex(coords[
i], idx + i);
1611 overflown |= (over[
i] - 1U);
1614 return overflow_.value(over, dim_);
1616 return data_.value(idx, dim_);
1622 template <
typename Numeric,
class Axis>
1624 const double* coords,
const unsigned coordLength)
const
1627 "In npstat::HistoND::closestBin: "
1628 "incompatible input point dimensionality");
1632 unsigned*
idx = &indexBuf_[0];
1633 const Axis*
ax = &axes_[0];
1634 for (
unsigned i=0;
i<dim_; ++
i)
1635 idx[
i] = ax[
i].closestValidBin(coords[
i]);
1636 return data_.value(idx, dim_);
1642 template <
typename Numeric,
class Axis>
1643 template <
typename Num2>
1646 const double*
weights = &weightBuf_[0];
1647 const unsigned* cell = &indexBuf_[0];
1648 const unsigned long* strides = data_.strides();
1649 const unsigned long maxcycle = 1UL << dim_;
1650 for (
unsigned long icycle=0; icycle<maxcycle; ++icycle)
1653 unsigned long icell = 0UL;
1654 for (
unsigned i=0;
i<dim_; ++
i)
1656 if (icycle & (1UL <<
i))
1658 w *= (1.0 - weights[
i]);
1659 icell += strides[
i]*(cell[
i] + 1U);
1664 icell += strides[
i]*cell[
i];
1667 data_.linearValue(icell) += (value *
w);
1671 template <
typename Numeric,
class Axis>
1672 template <
typename Num2>
1674 const double* coords,
const unsigned coordLength,
const Num2&
w)
1677 "In npstat::HistoND::fillC: "
1678 "incompatible input point dimensionality");
1682 double* wg = &weightBuf_[0];
1683 unsigned*
idx = &indexBuf_[0];
1684 unsigned* over = idx + dim_;
1685 const Axis*
ax = &axes_[0];
1686 unsigned overflown = 0U;
1687 for (
unsigned i=0;
i<dim_; ++
i)
1689 over[
i] = ax[
i].overflowIndexWeighted(coords[
i], idx+i, wg+i);
1690 overflown |= (over[
i] - 1U);
1694 overflow_.value(over, dim_) +=
w;
1698 fillPreservingCentroid(w);
1702 ++fillCount_; ++modCount_;
1705 template <
typename Numeric,
class Axis>
1706 template <
typename Num2>
1711 ++fillCount_; ++modCount_;
1714 template <
typename Numeric,
class Axis>
1715 template <
typename Num2,
class Functor>
1723 template <
typename Numeric,
class Axis>
1724 template <
typename Num2>
1729 ++fillCount_; ++modCount_;
1732 template <
typename Numeric,
class Axis>
1739 template <
typename Numeric,
class Axis>
1746 template <
typename Numeric,
class Axis>
1747 template <
typename Num2>
1752 const unsigned ov0 = axes_[0].overflowIndex(x0, &i0);
1757 overflow_(ov0) +=
w;
1760 ++fillCount_; ++modCount_;
1763 template <
typename Numeric,
class Axis>
1764 template <
typename Num2,
class Functor>
1769 const unsigned ov0 = axes_[0].overflowIndex(x0, &i0);
1773 f(overflow_(ov0), w);
1777 template <
typename Numeric,
class Axis>
1778 template <
typename Num2>
1782 double* wg = &weightBuf_[0];
1783 unsigned*
idx = &indexBuf_[0];
1784 const unsigned ov0 = axes_[0].overflowIndexWeighted(x0, idx, wg);
1786 fillPreservingCentroid(w);
1789 overflow_(ov0) +=
w;
1792 ++fillCount_; ++modCount_;
1795 template <
typename Numeric,
class Axis>
1800 const unsigned ov0 = axes_[0].overflowIndex(x0, &i0);
1804 return overflow_(ov0);
1807 template <
typename Numeric,
class Axis>
1811 const unsigned i0 = axes_[0].closestValidBin(x0);
1815 template <
typename Numeric,
class Axis>
1816 template <
typename Num2>
1822 const Axis*
ax = &axes_[0];
1823 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
1824 const unsigned o1 = ax[1].overflowIndex(x1, &i1);
1825 if (o0 == 1U && o1 == 1U)
1829 overflow_(o0, o1) +=
w;
1832 ++fillCount_; ++modCount_;
1835 template <
typename Numeric,
class Axis>
1836 template <
typename Num2,
class Functor>
1838 Num2&
w, Functor&
f)
1842 const Axis*
ax = &axes_[0];
1843 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
1844 const unsigned o1 = ax[1].overflowIndex(x1, &i1);
1845 if (o0 == 1U && o1 == 1U)
1846 f(data_(i0, i1), w);
1848 f(overflow_(o0, o1), w);
1852 template <
typename Numeric,
class Axis>
1853 template <
typename Num2>
1858 double* wg = &weightBuf_[0];
1859 unsigned*
idx = &indexBuf_[0];
1860 const Axis*
ax = &axes_[0];
1861 const unsigned o0 = ax[0].overflowIndexWeighted(x0, idx+0, wg+0);
1862 const unsigned o1 = ax[1].overflowIndexWeighted(x1, idx+1, wg+1);
1863 if (o0 == 1U && o1 == 1U)
1864 fillPreservingCentroid(w);
1867 overflow_(o0, o1) +=
w;
1870 ++fillCount_; ++modCount_;
1873 template <
typename Numeric,
class Axis>
1875 const double x1)
const
1879 const Axis*
ax = &axes_[0];
1880 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
1881 const unsigned o1 = ax[1].overflowIndex(x1, &i1);
1882 if (o0 == 1U && o1 == 1U)
1883 return data_(i0, i1);
1885 return overflow_(o0, o1);
1888 template <
typename Numeric,
class Axis>
1890 const double x1)
const
1893 const Axis*
ax = &axes_[0];
1894 const unsigned i0 = ax[0].closestValidBin(x0);
1895 const unsigned i1 = ax[1].closestValidBin(x1);
1896 return data_(i0, i1);
1899 template <
typename Numeric,
class Axis>
1900 template <
typename Num2>
1902 const double x2,
const Num2&
w)
1905 unsigned i0, i1, i2;
1906 const Axis*
ax = &axes_[0];
1907 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
1908 const unsigned o1 = ax[1].overflowIndex(x1, &i1);
1909 const unsigned o2 = ax[2].overflowIndex(x2, &i2);
1910 if (o0 == 1U && o1 == 1U && o2 == 1U)
1911 data_(i0, i1, i2) +=
w;
1914 overflow_(o0, o1, o2) +=
w;
1917 ++fillCount_; ++modCount_;
1920 template <
typename Numeric,
class Axis>
1921 template <
typename Num2,
class Functor>
1923 const double x2, Num2&
w, Functor&
f)
1926 unsigned i0, i1, i2;
1927 const Axis*
ax = &axes_[0];
1928 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
1929 const unsigned o1 = ax[1].overflowIndex(x1, &i1);
1930 const unsigned o2 = ax[2].overflowIndex(x2, &i2);
1931 if (o0 == 1U && o1 == 1U && o2 == 1U)
1932 f(data_(i0, i1, i2), w);
1934 f(overflow_(o0, o1, o2), w);
1938 template <
typename Numeric,
class Axis>
1939 template <
typename Num2>
1941 const double x2,
const Num2&
w)
1944 double* wg = &weightBuf_[0];
1945 unsigned*
idx = &indexBuf_[0];
1946 const Axis*
ax = &axes_[0];
1947 const unsigned o0 = ax[0].overflowIndexWeighted(x0, idx+0, wg+0);
1948 const unsigned o1 = ax[1].overflowIndexWeighted(x1, idx+1, wg+1);
1949 const unsigned o2 = ax[2].overflowIndexWeighted(x2, idx+2, wg+2);
1950 if (o0 == 1U && o1 == 1U && o2 == 1U)
1951 fillPreservingCentroid(w);
1954 overflow_(o0, o1, o2) +=
w;
1957 ++fillCount_; ++modCount_;
1960 template <
typename Numeric,
class Axis>
1963 const double x2)
const
1966 unsigned i0, i1, i2;
1967 const Axis*
ax = &axes_[0];
1968 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
1969 const unsigned o1 = ax[1].overflowIndex(x1, &i1);
1970 const unsigned o2 = ax[2].overflowIndex(x2, &i2);
1971 if (o0 == 1U && o1 == 1U && o2 == 1U)
1972 return data_(i0, i1, i2);
1974 return overflow_(o0, o1, o2);
1977 template <
typename Numeric,
class Axis>
1980 const double x2)
const
1983 const Axis*
ax = &axes_[0];
1984 const unsigned i0 = ax[0].closestValidBin(x0);
1985 const unsigned i1 = ax[1].closestValidBin(x1);
1986 const unsigned i2 = ax[2].closestValidBin(x2);
1987 return data_(i0, i1, i2);
1990 template <
typename Numeric,
class Axis>
1991 template <
typename Num2>
1993 const double x2,
const double x3,
1997 unsigned i0, i1, i2, i3;
1998 const Axis*
ax = &axes_[0];
1999 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2000 const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2001 const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2002 const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2003 if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U)
2004 data_(i0, i1, i2, i3) +=
w;
2007 overflow_(o0, o1, o2, o3) +=
w;
2010 ++fillCount_; ++modCount_;
2013 template <
typename Numeric,
class Axis>
2014 template <
typename Num2,
class Functor>
2016 const double x2,
const double x3,
2017 Num2&
w, Functor&
f)
2020 unsigned i0, i1, i2, i3;
2021 const Axis*
ax = &axes_[0];
2022 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2023 const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2024 const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2025 const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2026 if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U)
2027 f(data_(i0, i1, i2, i3), w);
2029 f(overflow_(o0, o1, o2, o3), w);
2033 template <
typename Numeric,
class Axis>
2034 template <
typename Num2>
2036 const double x2,
const double x3,
2040 double* wg = &weightBuf_[0];
2041 unsigned*
idx = &indexBuf_[0];
2042 const Axis*
ax = &axes_[0];
2043 const unsigned o0 = ax[0].overflowIndexWeighted(x0, idx+0, wg+0);
2044 const unsigned o1 = ax[1].overflowIndexWeighted(x1, idx+1, wg+1);
2045 const unsigned o2 = ax[2].overflowIndexWeighted(x2, idx+2, wg+2);
2046 const unsigned o3 = ax[3].overflowIndexWeighted(x3, idx+3, wg+3);
2047 if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U)
2048 fillPreservingCentroid(w);
2051 overflow_(o0, o1, o2, o3) +=
w;
2054 ++fillCount_; ++modCount_;
2057 template <
typename Numeric,
class Axis>
2061 const double x3)
const
2064 unsigned i0, i1, i2, i3;
2065 const Axis*
ax = &axes_[0];
2066 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2067 const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2068 const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2069 const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2070 if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U)
2071 return data_(i0, i1, i2, i3);
2073 return overflow_(o0, o1, o2, o3);
2076 template <
typename Numeric,
class Axis>
2080 const double x3)
const
2083 const Axis*
ax = &axes_[0];
2084 const unsigned i0 = ax[0].closestValidBin(x0);
2085 const unsigned i1 = ax[1].closestValidBin(x1);
2086 const unsigned i2 = ax[2].closestValidBin(x2);
2087 const unsigned i3 = ax[3].closestValidBin(x3);
2088 return data_(i0, i1, i2, i3);
2091 template <
typename Numeric,
class Axis>
2092 template <
typename Num2>
2094 const double x2,
const double x3,
2095 const double x4,
const Num2&
w)
2098 unsigned i0, i1, i2, i3, i4;
2099 const Axis*
ax = &axes_[0];
2100 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2101 const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2102 const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2103 const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2104 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2105 if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U)
2106 data_(i0, i1, i2, i3, i4) +=
w;
2109 overflow_(o0, o1, o2, o3, o4) +=
w;
2112 ++fillCount_; ++modCount_;
2115 template <
typename Numeric,
class Axis>
2116 template <
typename Num2,
class Functor>
2118 const double x2,
const double x3,
2119 const double x4, Num2&
w, Functor&
f)
2122 unsigned i0, i1, i2, i3, i4;
2123 const Axis*
ax = &axes_[0];
2124 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2125 const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2126 const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2127 const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2128 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2129 if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U)
2130 f(data_(i0, i1, i2, i3, i4), w);
2132 f(overflow_(o0, o1, o2, o3, o4), w);
2136 template <
typename Numeric,
class Axis>
2137 template <
typename Num2>
2139 const double x2,
const double x3,
2140 const double x4,
const Num2&
w)
2143 double* wg = &weightBuf_[0];
2144 unsigned*
idx = &indexBuf_[0];
2145 const Axis*
ax = &axes_[0];
2146 const unsigned o0 = ax[0].overflowIndexWeighted(x0, idx+0, wg+0);
2147 const unsigned o1 = ax[1].overflowIndexWeighted(x1, idx+1, wg+1);
2148 const unsigned o2 = ax[2].overflowIndexWeighted(x2, idx+2, wg+2);
2149 const unsigned o3 = ax[3].overflowIndexWeighted(x3, idx+3, wg+3);
2150 const unsigned o4 = ax[4].overflowIndexWeighted(x4, idx+4, wg+4);
2151 if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U)
2152 fillPreservingCentroid(w);
2155 overflow_(o0, o1, o2, o3, o4) +=
w;
2158 ++fillCount_; ++modCount_;
2161 template <
typename Numeric,
class Axis>
2163 const double x0,
const double x1,
2164 const double x2,
const double x3,
2165 const double x4)
const
2168 unsigned i0, i1, i2, i3, i4;
2169 const Axis*
ax = &axes_[0];
2170 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2171 const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2172 const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2173 const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2174 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2175 if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U)
2176 return data_(i0, i1, i2, i3, i4);
2178 return overflow_(o0, o1, o2, o3, o4);
2181 template <
typename Numeric,
class Axis>
2186 const double x4)
const
2189 const Axis*
ax = &axes_[0];
2190 const unsigned i0 = ax[0].closestValidBin(x0);
2191 const unsigned i1 = ax[1].closestValidBin(x1);
2192 const unsigned i2 = ax[2].closestValidBin(x2);
2193 const unsigned i3 = ax[3].closestValidBin(x3);
2194 const unsigned i4 = ax[4].closestValidBin(x4);
2195 return data_(i0, i1, i2, i3, i4);
2198 template <
typename Numeric,
class Axis>
2199 template <
typename Num2>
2201 const double x2,
const double x3,
2202 const double x4,
const double x5,
2206 unsigned i0, i1, i2, i3, i4, i5;
2207 const Axis*
ax = &axes_[0];
2208 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2209 const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2210 const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2211 const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2212 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2213 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2214 if (o0 == 1U && o1 == 1U && o2 == 1U &&
2215 o3 == 1U && o4 == 1U && o5 == 1U)
2216 data_(i0, i1, i2, i3, i4, i5) +=
w;
2219 overflow_(o0, o1, o2, o3, o4, o5) +=
w;
2222 ++fillCount_; ++modCount_;
2225 template <
typename Numeric,
class Axis>
2226 template <
typename Num2,
class Functor>
2228 const double x2,
const double x3,
2229 const double x4,
const double x5,
2230 Num2&
w, Functor&
f)
2233 unsigned i0, i1, i2, i3, i4, i5;
2234 const Axis*
ax = &axes_[0];
2235 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2236 const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2237 const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2238 const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2239 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2240 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2241 if (o0 == 1U && o1 == 1U && o2 == 1U &&
2242 o3 == 1U && o4 == 1U && o5 == 1U)
2243 f(data_(i0, i1, i2, i3, i4, i5), w);
2245 f(overflow_(o0, o1, o2, o3, o4, o5), w);
2249 template <
typename Numeric,
class Axis>
2250 template <
typename Num2>
2252 const double x2,
const double x3,
2253 const double x4,
const double x5,
2257 double* wg = &weightBuf_[0];
2258 unsigned*
idx = &indexBuf_[0];
2259 const Axis*
ax = &axes_[0];
2260 const unsigned o0 = ax[0].overflowIndexWeighted(x0, idx+0, wg+0);
2261 const unsigned o1 = ax[1].overflowIndexWeighted(x1, idx+1, wg+1);
2262 const unsigned o2 = ax[2].overflowIndexWeighted(x2, idx+2, wg+2);
2263 const unsigned o3 = ax[3].overflowIndexWeighted(x3, idx+3, wg+3);
2264 const unsigned o4 = ax[4].overflowIndexWeighted(x4, idx+4, wg+4);
2265 const unsigned o5 = ax[5].overflowIndexWeighted(x5, idx+5, wg+5);
2266 if (o0 == 1U && o1 == 1U && o2 == 1U &&
2267 o3 == 1U && o4 == 1U && o5 == 1U)
2268 fillPreservingCentroid(w);
2271 overflow_(o0, o1, o2, o3, o4, o5) +=
w;
2274 ++fillCount_; ++modCount_;
2277 template <
typename Numeric,
class Axis>
2283 const double x5)
const
2286 unsigned i0, i1, i2, i3, i4, i5;
2287 const Axis*
ax = &axes_[0];
2288 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2289 const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2290 const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2291 const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2292 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2293 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2294 if (o0 == 1U && o1 == 1U && o2 == 1U &&
2295 o3 == 1U && o4 == 1U && o5 == 1U)
2296 return data_(i0, i1, i2, i3, i4, i5);
2298 return overflow_(o0, o1, o2, o3, o4, o5);
2301 template <
typename Numeric,
class Axis>
2307 const double x5)
const
2310 const Axis*
ax = &axes_[0];
2311 const unsigned i0 = ax[0].closestValidBin(x0);
2312 const unsigned i1 = ax[1].closestValidBin(x1);
2313 const unsigned i2 = ax[2].closestValidBin(x2);
2314 const unsigned i3 = ax[3].closestValidBin(x3);
2315 const unsigned i4 = ax[4].closestValidBin(x4);
2316 const unsigned i5 = ax[5].closestValidBin(x5);
2317 return data_(i0, i1, i2, i3, i4, i5);
2320 template <
typename Numeric,
class Axis>
2321 template <
typename Num2>
2323 const double x2,
const double x3,
2324 const double x4,
const double x5,
2325 const double x6,
const Num2&
w)
2328 unsigned i0, i1, i2, i3, i4, i5, i6;
2329 const Axis*
ax = &axes_[0];
2330 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2331 const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2332 const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2333 const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2334 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2335 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2336 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2337 if (o0 == 1U && o1 == 1U && o2 == 1U &&
2338 o3 == 1U && o4 == 1U && o5 == 1U && o6 == 1U)
2339 data_(i0, i1, i2, i3, i4, i5, i6) +=
w;
2342 overflow_(o0, o1, o2, o3, o4, o5, o6) +=
w;
2345 ++fillCount_; ++modCount_;
2348 template <
typename Numeric,
class Axis>
2349 template <
typename Num2,
class Functor>
2351 const double x2,
const double x3,
2352 const double x4,
const double x5,
2353 const double x6, Num2&
w, Functor&
f)
2356 unsigned i0, i1, i2, i3, i4, i5, i6;
2357 const Axis*
ax = &axes_[0];
2358 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2359 const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2360 const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2361 const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2362 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2363 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2364 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2365 if (o0 == 1U && o1 == 1U && o2 == 1U &&
2366 o3 == 1U && o4 == 1U && o5 == 1U && o6 == 1U)
2367 f(data_(i0, i1, i2, i3, i4, i5, i6), w);
2369 f(overflow_(o0, o1, o2, o3, o4, o5, o6), w);
2373 template <
typename Numeric,
class Axis>
2374 template <
typename Num2>
2376 const double x2,
const double x3,
2377 const double x4,
const double x5,
2378 const double x6,
const Num2&
w)
2381 double* wg = &weightBuf_[0];
2382 unsigned*
idx = &indexBuf_[0];
2383 const Axis*
ax = &axes_[0];
2384 const unsigned o0 = ax[0].overflowIndexWeighted(x0, idx+0, wg+0);
2385 const unsigned o1 = ax[1].overflowIndexWeighted(x1, idx+1, wg+1);
2386 const unsigned o2 = ax[2].overflowIndexWeighted(x2, idx+2, wg+2);
2387 const unsigned o3 = ax[3].overflowIndexWeighted(x3, idx+3, wg+3);
2388 const unsigned o4 = ax[4].overflowIndexWeighted(x4, idx+4, wg+4);
2389 const unsigned o5 = ax[5].overflowIndexWeighted(x5, idx+5, wg+5);
2390 const unsigned o6 = ax[6].overflowIndexWeighted(x6, idx+6, wg+6);
2391 if (o0 == 1U && o1 == 1U && o2 == 1U &&
2392 o3 == 1U && o4 == 1U && o5 == 1U && o6 == 1U)
2393 fillPreservingCentroid(w);
2396 overflow_(o0, o1, o2, o3, o4, o5, o6) +=
w;
2399 ++fillCount_; ++modCount_;
2402 template <
typename Numeric,
class Axis>
2404 const double x0,
const double x1,
2405 const double x2,
const double x3,
2406 const double x4,
const double x5,
2407 const double x6)
const
2410 unsigned i0, i1, i2, i3, i4, i5, i6;
2411 const Axis*
ax = &axes_[0];
2412 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2413 const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2414 const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2415 const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2416 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2417 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2418 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2419 if (o0 == 1U && o1 == 1U && o2 == 1U &&
2420 o3 == 1U && o4 == 1U && o5 == 1U && o6 == 1U)
2421 return data_(i0, i1, i2, i3, i4, i5, i6);
2423 return overflow_(o0, o1, o2, o3, o4, o5, o6);
2426 template <
typename Numeric,
class Axis>
2433 const double x6)
const
2436 const Axis*
ax = &axes_[0];
2437 const unsigned i0 = ax[0].closestValidBin(x0);
2438 const unsigned i1 = ax[1].closestValidBin(x1);
2439 const unsigned i2 = ax[2].closestValidBin(x2);
2440 const unsigned i3 = ax[3].closestValidBin(x3);
2441 const unsigned i4 = ax[4].closestValidBin(x4);
2442 const unsigned i5 = ax[5].closestValidBin(x5);
2443 const unsigned i6 = ax[6].closestValidBin(x6);
2444 return data_(i0, i1, i2, i3, i4, i5, i6);
2447 template <
typename Numeric,
class Axis>
2448 template <
typename Num2>
2450 const double x2,
const double x3,
2451 const double x4,
const double x5,
2452 const double x6,
const double x7,
2456 unsigned i0, i1, i2, i3, i4, i5, i6, i7;
2457 const Axis*
ax = &axes_[0];
2458 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2459 const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2460 const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2461 const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2462 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2463 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2464 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2465 const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2466 if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U &&
2467 o4 == 1U && o5 == 1U && o6 == 1U && o7 == 1U)
2468 data_(i0, i1, i2, i3, i4, i5, i6, i7) +=
w;
2471 overflow_(o0, o1, o2, o3, o4, o5, o6, o7) +=
w;
2474 ++fillCount_; ++modCount_;
2477 template <
typename Numeric,
class Axis>
2478 template <
typename Num2,
class Functor>
2480 const double x2,
const double x3,
2481 const double x4,
const double x5,
2482 const double x6,
const double x7,
2483 Num2&
w, Functor&
f)
2486 unsigned i0, i1, i2, i3, i4, i5, i6, i7;
2487 const Axis*
ax = &axes_[0];
2488 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2489 const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2490 const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2491 const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2492 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2493 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2494 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2495 const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2496 if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U &&
2497 o4 == 1U && o5 == 1U && o6 == 1U && o7 == 1U)
2498 f(data_(i0, i1, i2, i3, i4, i5, i6, i7), w);
2500 f(overflow_(o0, o1, o2, o3, o4, o5, o6, o7), w);
2504 template <
typename Numeric,
class Axis>
2505 template <
typename Num2>
2507 const double x2,
const double x3,
2508 const double x4,
const double x5,
2509 const double x6,
const double x7,
2513 double* wg = &weightBuf_[0];
2514 unsigned*
idx = &indexBuf_[0];
2515 const Axis*
ax = &axes_[0];
2516 const unsigned o0 = ax[0].overflowIndexWeighted(x0, idx+0, wg+0);
2517 const unsigned o1 = ax[1].overflowIndexWeighted(x1, idx+1, wg+1);
2518 const unsigned o2 = ax[2].overflowIndexWeighted(x2, idx+2, wg+2);
2519 const unsigned o3 = ax[3].overflowIndexWeighted(x3, idx+3, wg+3);
2520 const unsigned o4 = ax[4].overflowIndexWeighted(x4, idx+4, wg+4);
2521 const unsigned o5 = ax[5].overflowIndexWeighted(x5, idx+5, wg+5);
2522 const unsigned o6 = ax[6].overflowIndexWeighted(x6, idx+6, wg+6);
2523 const unsigned o7 = ax[7].overflowIndexWeighted(x7, idx+7, wg+7);
2524 if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U &&
2525 o4 == 1U && o5 == 1U && o6 == 1U && o7 == 1U)
2526 fillPreservingCentroid(w);
2529 overflow_(o0, o1, o2, o3, o4, o5, o6, o7) +=
w;
2532 ++fillCount_; ++modCount_;
2535 template <
typename Numeric,
class Axis>
2537 const double x0,
const double x1,
2538 const double x2,
const double x3,
2539 const double x4,
const double x5,
2541 const double x7)
const
2544 unsigned i0, i1, i2, i3, i4, i5, i6, i7;
2545 const Axis*
ax = &axes_[0];
2546 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2547 const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2548 const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2549 const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2550 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2551 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2552 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2553 const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2554 if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U &&
2555 o4 == 1U && o5 == 1U && o6 == 1U && o7 == 1U)
2556 return data_(i0, i1, i2, i3, i4, i5, i6, i7);
2558 return overflow_(o0, o1, o2, o3, o4, o5, o6, o7);
2561 template <
typename Numeric,
class Axis>
2569 const double x7)
const
2572 const Axis*
ax = &axes_[0];
2573 const unsigned i0 = ax[0].closestValidBin(x0);
2574 const unsigned i1 = ax[1].closestValidBin(x1);
2575 const unsigned i2 = ax[2].closestValidBin(x2);
2576 const unsigned i3 = ax[3].closestValidBin(x3);
2577 const unsigned i4 = ax[4].closestValidBin(x4);
2578 const unsigned i5 = ax[5].closestValidBin(x5);
2579 const unsigned i6 = ax[6].closestValidBin(x6);
2580 const unsigned i7 = ax[7].closestValidBin(x7);
2581 return data_(i0, i1, i2, i3, i4, i5, i6, i7);
2584 template <
typename Numeric,
class Axis>
2585 template <
typename Num2>
2587 const double x2,
const double x3,
2588 const double x4,
const double x5,
2589 const double x6,
const double x7,
2590 const double x8,
const Num2&
w)
2593 unsigned i0, i1, i2, i3, i4, i5, i6, i7, i8;
2594 const Axis*
ax = &axes_[0];
2595 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2596 const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2597 const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2598 const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2599 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2600 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2601 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2602 const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2603 const unsigned o8 = ax[8].overflowIndex(x8, &i8);
2604 if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U &&
2605 o5 == 1U && o6 == 1U && o7 == 1U && o8 == 1U)
2606 data_(i0, i1, i2, i3, i4, i5, i6, i7, i8) +=
w;
2609 overflow_(o0, o1, o2, o3, o4, o5, o6, o7, o8) +=
w;
2612 ++fillCount_; ++modCount_;
2615 template <
typename Numeric,
class Axis>
2616 template <
typename Num2,
class Functor>
2618 const double x2,
const double x3,
2619 const double x4,
const double x5,
2620 const double x6,
const double x7,
2621 const double x8, Num2&
w, Functor&
f)
2624 unsigned i0, i1, i2, i3, i4, i5, i6, i7, i8;
2625 const Axis*
ax = &axes_[0];
2626 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2627 const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2628 const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2629 const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2630 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2631 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2632 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2633 const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2634 const unsigned o8 = ax[8].overflowIndex(x8, &i8);
2635 if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U &&
2636 o5 == 1U && o6 == 1U && o7 == 1U && o8 == 1U)
2637 f(data_(i0, i1, i2, i3, i4, i5, i6, i7, i8), w);
2639 f(overflow_(o0, o1, o2, o3, o4, o5, o6, o7, o8), w);
2643 template <
typename Numeric,
class Axis>
2644 template <
typename Num2>
2646 const double x2,
const double x3,
2647 const double x4,
const double x5,
2648 const double x6,
const double x7,
2649 const double x8,
const Num2&
w)
2652 double* wg = &weightBuf_[0];
2653 unsigned*
idx = &indexBuf_[0];
2654 const Axis*
ax = &axes_[0];
2655 const unsigned o0 = ax[0].overflowIndexWeighted(x0, idx+0, wg+0);
2656 const unsigned o1 = ax[1].overflowIndexWeighted(x1, idx+1, wg+1);
2657 const unsigned o2 = ax[2].overflowIndexWeighted(x2, idx+2, wg+2);
2658 const unsigned o3 = ax[3].overflowIndexWeighted(x3, idx+3, wg+3);
2659 const unsigned o4 = ax[4].overflowIndexWeighted(x4, idx+4, wg+4);
2660 const unsigned o5 = ax[5].overflowIndexWeighted(x5, idx+5, wg+5);
2661 const unsigned o6 = ax[6].overflowIndexWeighted(x6, idx+6, wg+6);
2662 const unsigned o7 = ax[7].overflowIndexWeighted(x7, idx+7, wg+7);
2663 const unsigned o8 = ax[8].overflowIndexWeighted(x8, idx+8, wg+8);
2664 if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U &&
2665 o5 == 1U && o6 == 1U && o7 == 1U && o8 == 1U)
2666 fillPreservingCentroid(w);
2669 overflow_(o0, o1, o2, o3, o4, o5, o6, o7, o8) +=
w;
2672 ++fillCount_; ++modCount_;
2675 template <
typename Numeric,
class Axis>
2677 const double x0,
const double x1,
2678 const double x2,
const double x3,
2679 const double x4,
const double x5,
2680 const double x6,
const double x7,
2681 const double x8)
const
2684 unsigned i0, i1, i2, i3, i4, i5, i6, i7, i8;
2685 const Axis*
ax = &axes_[0];
2686 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2687 const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2688 const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2689 const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2690 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2691 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2692 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2693 const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2694 const unsigned o8 = ax[8].overflowIndex(x8, &i8);
2695 if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U &&
2696 o5 == 1U && o6 == 1U && o7 == 1U && o8 == 1U)
2697 return data_(i0, i1, i2, i3, i4, i5, i6, i7, i8);
2699 return overflow_(o0, o1, o2, o3, o4, o5, o6, o7, o8);
2702 template <
typename Numeric,
class Axis>
2711 const double x8)
const
2714 const Axis*
ax = &axes_[0];
2715 const unsigned i0 = ax[0].closestValidBin(x0);
2716 const unsigned i1 = ax[1].closestValidBin(x1);
2717 const unsigned i2 = ax[2].closestValidBin(x2);
2718 const unsigned i3 = ax[3].closestValidBin(x3);
2719 const unsigned i4 = ax[4].closestValidBin(x4);
2720 const unsigned i5 = ax[5].closestValidBin(x5);
2721 const unsigned i6 = ax[6].closestValidBin(x6);
2722 const unsigned i7 = ax[7].closestValidBin(x7);
2723 const unsigned i8 = ax[8].closestValidBin(x8);
2724 return data_(i0, i1, i2, i3, i4, i5, i6, i7, i8);
2727 template <
typename Numeric,
class Axis>
2728 template <
typename Num2>
2730 const double x2,
const double x3,
2731 const double x4,
const double x5,
2732 const double x6,
const double x7,
2733 const double x8,
const double x9,
2737 unsigned i0, i1, i2, i3, i4, i5, i6, i7, i8, i9;
2738 const Axis*
ax = &axes_[0];
2739 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2740 const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2741 const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2742 const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2743 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2744 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2745 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2746 const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2747 const unsigned o8 = ax[8].overflowIndex(x8, &i8);
2748 const unsigned o9 = ax[9].overflowIndex(x9, &i9);
2749 if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U &&
2750 o5 == 1U && o6 == 1U && o7 == 1U && o8 == 1U && o9 == 1U)
2751 data_(i0, i1, i2, i3, i4, i5, i6, i7, i8, i9) +=
w;
2754 overflow_(o0, o1, o2, o3, o4, o5, o6, o7, o8, o9) +=
w;
2757 ++fillCount_; ++modCount_;
2760 template <
typename Numeric,
class Axis>
2761 template <
typename Num2,
class Functor>
2763 const double x2,
const double x3,
2764 const double x4,
const double x5,
2765 const double x6,
const double x7,
2766 const double x8,
const double x9,
2767 Num2&
w, Functor&
f)
2770 unsigned i0, i1, i2, i3, i4, i5, i6, i7, i8, i9;
2771 const Axis*
ax = &axes_[0];
2772 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2773 const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2774 const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2775 const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2776 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2777 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2778 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2779 const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2780 const unsigned o8 = ax[8].overflowIndex(x8, &i8);
2781 const unsigned o9 = ax[9].overflowIndex(x9, &i9);
2782 if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U &&
2783 o5 == 1U && o6 == 1U && o7 == 1U && o8 == 1U && o9 == 1U)
2784 f(data_(i0, i1, i2, i3, i4, i5, i6, i7, i8, i9), w);
2786 f(overflow_(o0, o1, o2, o3, o4, o5, o6, o7, o8, o9), w);
2790 template <
typename Numeric,
class Axis>
2791 template <
typename Num2>
2793 const double x2,
const double x3,
2794 const double x4,
const double x5,
2795 const double x6,
const double x7,
2796 const double x8,
const double x9,
2800 double* wg = &weightBuf_[0];
2801 unsigned*
idx = &indexBuf_[0];
2802 const Axis*
ax = &axes_[0];
2803 const unsigned o0 = ax[0].overflowIndexWeighted(x0, idx+0, wg+0);
2804 const unsigned o1 = ax[1].overflowIndexWeighted(x1, idx+1, wg+1);
2805 const unsigned o2 = ax[2].overflowIndexWeighted(x2, idx+2, wg+2);
2806 const unsigned o3 = ax[3].overflowIndexWeighted(x3, idx+3, wg+3);
2807 const unsigned o4 = ax[4].overflowIndexWeighted(x4, idx+4, wg+4);
2808 const unsigned o5 = ax[5].overflowIndexWeighted(x5, idx+5, wg+5);
2809 const unsigned o6 = ax[6].overflowIndexWeighted(x6, idx+6, wg+6);
2810 const unsigned o7 = ax[7].overflowIndexWeighted(x7, idx+7, wg+7);
2811 const unsigned o8 = ax[8].overflowIndexWeighted(x8, idx+8, wg+8);
2812 const unsigned o9 = ax[9].overflowIndexWeighted(x9, idx+9, wg+9);
2813 if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U &&
2814 o5 == 1U && o6 == 1U && o7 == 1U && o8 == 1U && o9 == 1U)
2815 fillPreservingCentroid(w);
2818 overflow_(o0, o1, o2, o3, o4, o5, o6, o7, o8, o9) +=
w;
2821 ++fillCount_; ++modCount_;
2824 template <
typename Numeric,
class Axis>
2826 const double x0,
const double x1,
2827 const double x2,
const double x3,
2828 const double x4,
const double x5,
2829 const double x6,
const double x7,
2831 const double x9)
const
2834 unsigned i0, i1, i2, i3, i4, i5, i6, i7, i8, i9;
2835 const Axis*
ax = &axes_[0];
2836 const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2837 const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2838 const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2839 const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2840 const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2841 const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2842 const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2843 const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2844 const unsigned o8 = ax[8].overflowIndex(x8, &i8);
2845 const unsigned o9 = ax[9].overflowIndex(x9, &i9);
2846 if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U &&
2847 o5 == 1U && o6 == 1U && o7 == 1U && o8 == 1U && o9 == 1U)
2848 return data_(i0, i1, i2, i3, i4, i5, i6, i7, i8, i9);
2850 return overflow_(o0, o1, o2, o3, o4, o5, o6, o7, o8, o9);
2853 template <
typename Numeric,
class Axis>
2863 const double x9)
const
2866 const Axis*
ax = &axes_[0];
2867 const unsigned i0 = ax[0].closestValidBin(x0);
2868 const unsigned i1 = ax[1].closestValidBin(x1);
2869 const unsigned i2 = ax[2].closestValidBin(x2);
2870 const unsigned i3 = ax[3].closestValidBin(x3);
2871 const unsigned i4 = ax[4].closestValidBin(x4);
2872 const unsigned i5 = ax[5].closestValidBin(x5);
2873 const unsigned i6 = ax[6].closestValidBin(x6);
2874 const unsigned i7 = ax[7].closestValidBin(x7);
2875 const unsigned i8 = ax[8].closestValidBin(x8);
2876 const unsigned i9 = ax[9].closestValidBin(x9);
2877 return data_(i0, i1, i2, i3, i4, i5, i6, i7, i8, i9);
2880 template <
typename Numeric,
class Axis>
2881 template <
typename Num2>
2883 const unsigned indexLen,
2886 data_.value(index, indexLen) =
v;
2890 template <
typename Numeric,
class Axis>
2891 template <
typename Num2>
2893 const unsigned indexLen,
2896 data_.valueAt(index, indexLen) =
v;
2900 template <
typename Numeric,
class Axis>
2901 template <
typename Num2>
2908 template <
typename Numeric,
class Axis>
2909 template <
typename Num2>
2916 template <
typename Numeric,
class Axis>
2917 template <
typename Num2>
2919 const unsigned i0,
const Num2&
v)
2925 template <
typename Numeric,
class Axis>
2926 template <
typename Num2>
2928 const unsigned i0,
const Num2&
v)
2934 template <
typename Numeric,
class Axis>
2935 template <
typename Num2>
2944 template <
typename Numeric,
class Axis>
2945 template <
typename Num2>
2950 data_.at(i0, i1) =
v;
2954 template <
typename Numeric,
class Axis>
2955 template <
typename Num2>
2961 data_(i0, i1, i2) =
v;
2965 template <
typename Numeric,
class Axis>
2966 template <
typename Num2>
2973 data_(i0, i1, i2, i3) =
v;
2977 template <
typename Numeric,
class Axis>
2978 template <
typename Num2>
2986 data_(i0, i1, i2, i3, i4) =
v;
2990 template <
typename Numeric,
class Axis>
2991 template <
typename Num2>
3000 data_(i0, i1, i2, i3, i4, i5) =
v;
3004 template <
typename Numeric,
class Axis>
3005 template <
typename Num2>
3015 data_(i0, i1, i2, i3, i4, i5, i6) =
v;
3019 template <
typename Numeric,
class Axis>
3020 template <
typename Num2>
3031 data_(i0, i1, i2, i3, i4, i5, i6, i7) =
v;
3035 template <
typename Numeric,
class Axis>
3036 template <
typename Num2>
3048 data_(i0, i1, i2, i3, i4, i5, i6, i7, i8) =
v;
3052 template <
typename Numeric,
class Axis>
3053 template <
typename Num2>
3066 data_(i0, i1, i2, i3, i4, i5, i6, i7, i8, i9) =
v;
3070 template <
typename Numeric,
class Axis>
3071 template <
typename Num2>
3077 data_.at(i0, i1, i2) =
v;
3081 template <
typename Numeric,
class Axis>
3082 template <
typename Num2>
3089 data_.at(i0, i1, i2, i3) =
v;
3093 template <
typename Numeric,
class Axis>
3094 template <
typename Num2>
3102 data_.at(i0, i1, i2, i3, i4) =
v;
3106 template <
typename Numeric,
class Axis>
3107 template <
typename Num2>
3116 data_.at(i0, i1, i2, i3, i4, i5) =
v;
3120 template <
typename Numeric,
class Axis>
3121 template <
typename Num2>
3131 data_.at(i0, i1, i2, i3, i4, i5, i6) =
v;
3135 template <
typename Numeric,
class Axis>
3136 template <
typename Num2>
3147 data_.at(i0, i1, i2, i3, i4, i5, i6, i7) =
v;
3151 template <
typename Numeric,
class Axis>
3152 template <
typename Num2>
3164 data_.at(i0, i1, i2, i3, i4, i5, i6, i7, i8) =
v;
3168 template <
typename Numeric,
class Axis>
3169 template <
typename Num2>
3182 data_.at(i0, i1, i2, i3, i4, i5, i6, i7, i8, i9) =
v;
3186 template <
typename Numeric,
class Axis>
3187 template <
typename Num2>
3192 overflow_ += r.overflow_;
3193 fillCount_ += r.fillCount_;
3194 overCount_ += r.overCount_;
3199 template <
typename Numeric,
class Axis>
3200 template <
typename Num2>
3205 overflow_ -= r.overflow_;
3212 fillCount_ += r.fillCount_;
3213 overCount_ += r.overCount_;
3219 template <
typename Numeric,
class Axis>
3220 template <
typename Num2>
3230 template <
typename Numeric,
class Axis>
3231 template <
typename Num2>
3241 template <
typename Numeric,
class Axis>
3246 accumulatedDataLabel_(r.accumulatedDataLabel_),
3248 overflow_(r.overflow_.
transpose(ax1, ax2)),
3250 weightBuf_(r.weightBuf_),
3251 indexBuf_(r.indexBuf_),
3252 fillCount_(r.fillCount_),
3253 overCount_(r.overCount_),
3260 template <
typename Numeric,
class Axis>
3263 accumulatedDataLabel_(r.accumulatedDataLabel_),
3265 overflow_(r.overflow_),
3267 weightBuf_(r.weightBuf_),
3268 indexBuf_(r.indexBuf_),
3269 fillCount_(r.fillCount_),
3270 overCount_(r.overCount_),
3276 template <
typename Numeric,
class Axis>
3282 accumulatedDataLabel_ = r.accumulatedDataLabel_;
3283 data_.uninitialize();
3285 overflow_.uninitialize();
3286 overflow_ = r.overflow_;
3288 weightBuf_ = r.weightBuf_;
3289 indexBuf_ = r.indexBuf_;
3290 fillCount_ = r.fillCount_;
3291 overCount_ = r.overCount_;
3298 template <
typename Numeric,
class Axis>
3300 const unsigned axisNum1,
const unsigned axisNum2)
const
3302 if (axisNum1 >= dim_ || axisNum2 >= dim_)
3304 "axis number is out of range");
3305 if (axisNum1 == axisNum2)
3309 return HistoND(*
this, axisNum1, axisNum2);
3312 template <
typename Numeric,
class Axis>
3313 template <
typename Num2>
3316 const unsigned long nDat = data_.length();
3317 Numeric*
data =
const_cast<Numeric*
>(data_.data());
3318 for (
unsigned long i=0;
i<nDat; ++
i)
3324 template <
typename Numeric,
class Axis>
3325 template <
typename Num2>
3328 const unsigned long nOver = overflow_.length();
3329 Numeric*
data =
const_cast<Numeric*
>(overflow_.data());
3330 for (
unsigned long i=0;
i<nOver; ++
i)
3332 overCount_ += nOver;
3333 fillCount_ += nOver;
3337 template <
typename Numeric,
class Axis>
3338 template <
typename Num2>
3340 const Num2*
data,
const unsigned long dataLength)
3343 "In npstat::HistoND::addToBinContents: incompatible data length");
3345 Numeric* dat =
const_cast<Numeric*
>(data_.data());
3346 for (
unsigned long i=0;
i<dataLength; ++
i)
3348 fillCount_ += dataLength;
3352 template <
typename Numeric,
class Axis>
3353 template <
typename Num2>
3355 const Num2*
data,
const unsigned long dataLength)
3358 "In npstat::HistoND::addToOverflows: incompatible data length");
3360 Numeric* dat =
const_cast<Numeric*
>(overflow_.data());
3361 for (
unsigned long i=0;
i<dataLength; ++
i)
3363 overCount_ += dataLength;
3364 fillCount_ += dataLength;
3368 template <
typename Numeric,
class Axis>
3369 template <
typename Num2>
3371 const Num2*
data,
const unsigned long dataLength)
3374 "In npstat::HistoND::scaleBinContents: incompatible data length");
3376 Numeric* dat =
const_cast<Numeric*
>(data_.data());
3377 for (
unsigned long i=0;
i<dataLength; ++
i)
3382 template <
typename Numeric,
class Axis>
3383 template <
typename Num2>
3385 const Num2*
data,
const unsigned long dataLength)
3388 "In npstat::HistoND::scaleOverflows: incompatible data length");
3390 Numeric* dat =
const_cast<Numeric*
>(overflow_.data());
3391 for (
unsigned long i=0;
i<dataLength; ++
i)
3396 template <
typename Numeric,
class Axis>
3397 template <
typename Num2>
3399 const Num2*
data,
const unsigned long dataLength,
3400 const bool clearOverflowsNow)
3402 data_.setData(data, dataLength);
3403 if (clearOverflowsNow)
3408 template <
typename Numeric,
class Axis>
3409 template <
typename Num2>
3411 const Num2*
data,
const unsigned long dataLength)
3413 overflow_.setData(data, dataLength);
3417 template <
typename Numeric,
class Axis>
3420 const long double nOver = overflow_.template sum<long double>();
3421 const long double nData = data_.template sum<long double>();
3422 overCount_ =
static_cast<unsigned long>(nOver);
3423 fillCount_ =
static_cast<unsigned long>(nData + nOver);
3427 template <
typename Numeric,
class Axis>
3428 template <
typename Num2,
typename Num3>
3432 const unsigned *projectedIndices,
3433 const unsigned nProjectedIndices)
const
3436 data_.addToProjection(&projection->data_, projector,
3437 projectedIndices, nProjectedIndices);
3438 projection->fillCount_ += projection->nBins();
3439 projection->modCount_++;
3442 template <
typename Numeric,
class Axis>
3443 template <
typename Num2,
typename Num3>
3447 const unsigned *projectedIndices,
3448 const unsigned nProjectedIndices)
const
3451 data_.addToProjection(&projection->data_, projector,
3452 projectedIndices, nProjectedIndices);
3453 projection->fillCount_ += projection->nBins();
3454 projection->modCount_++;
3457 template <
typename Numeric,
class Axis>
3460 static const std::string myClass(gs::template_class_name<Numeric,Axis>(
3461 "npstat::HistoND"));
3462 return myClass.c_str();
3465 template<
typename Numeric,
class Axis>
3468 gs::write_pod(of, title_);
3469 gs::write_pod(of, accumulatedDataLabel_);
3470 gs::write_pod(of, fillCount_);
3471 gs::write_pod(of, overCount_);
3473 return !of.fail() &&
3474 gs::write_obj_vector(of, axes_) &&
3475 data_.classId().write(of) &&
3477 overflow_.write(of);
3480 template<
typename Numeric,
class Axis>
3484 static const gs::ClassId
current(
3486 current.ensureSameId(
id);
3489 gs::read_pod(in, &title);
3492 gs::read_pod(in, &accumulatedDataLabel);
3494 unsigned long fillCount = 0, overCount = 0;
3495 gs::read_pod(in, &fillCount);
3496 gs::read_pod(in, &overCount);
3497 if (in.fail())
throw gs::IOReadFailure(
3498 "In npstat::HistoND::read: input stream failure");
3500 std::vector<Axis> axes;
3501 gs::read_heap_obj_vector_as_placed(in, &axes);
3502 gs::ClassId ida(in, 1);
3506 CPP11_auto_ptr<HistoND<Numeric,Axis> >
result(
3508 accumulatedDataLabel.c_str()));
3509 result->data_ =
data;
3510 result->overflow_ = over;
3511 result->fillCount_ = fillCount;
3512 result->overCount_ = overCount;
3513 return result.release();
3516 template <
typename Histo>
3520 if (!knownNonNegative)
3523 const double integ = h->integral();
3527 template <
typename Histo>
3530 std::vector<LinearMapper1d>
result;
3531 const unsigned d = histo.dim();
3533 for (
unsigned i=0;
i<d; ++
i)
3536 result.push_back(m.
inverse());
3541 template <
typename Histo>
3543 const Histo&
histo,
const bool doubleRange)
3545 std::vector<CircularMapper1d>
result;
3546 const unsigned d = histo.dim();
3548 for (
unsigned i=0;
i<d; ++
i)
3549 result.push_back(histo.axis(
i).kernelScanMapper(doubleRange));
3555 #endif // NPSTAT_HISTOND_HH_
void setBinAt(const unsigned *index, unsigned indexLen, const Num2 &v)
static unsigned version()
bool operator==(const HistoND &) const
unsigned long getModCount() const
bool write(std::ostream &of) const
HistoND & operator+=(const HistoND< Num2, Axis > &r)
std::vector< CircularMapper1d > convolutionHistoMap(const Histo &histo, bool doubleDataRange)
void addToProjection(HistoND< Num2, Axis > *projection, AbsArrayProjector< Numeric, Num3 > &projector, const unsigned *projectedIndices, unsigned nProjectedIndices) const
void accumulateBinsInBox(const BoxND< double > &box, Acc *acc) const
const std::string & accumulatedDataLabel() const
const Numeric & examine() const
bool isSameData(const HistoND &) const
unsigned long nFillsTotal() const
void binCenter(unsigned long binNumber, double *coords, unsigned lenCoords) const
const Axis & axis(const unsigned i) const
HistoND & operator=(const HistoND &)
void dispatch(const double *coords, unsigned coordLength, Num2 &weight, Functor &f)
std::vector< unsigned > ArrayShape
HistoND & operator*=(const Num2 &r)
Numeric & linearValue(unsigned long index)
unsigned long length() const
void setLinearBin(const unsigned long index, const Num2 &v)
void fill(const double *coords, unsigned coordLength, const Num2 &weight)
const std::string & title() const
Numeric & linearValueAt(unsigned long index)
void recalculateNFillsFromData()
void scaleBinContents(const Num2 *data, unsigned long dataLength)
LinearMapper1d inverse() const
std::string accumulatedDataLabel_
void convertHistoToDensity(Histo *histogram, bool knownNonNegative=false)
ArrayND & constFill(Numeric c)
void setNFillsOver(const unsigned long i)
double binVolume(unsigned long binNumber=0) const
gs::ClassId classId() const
const ArrayND< Numeric > & binContents() const
Exceptions for the npstat namespace.
void h_badargs(const char *method)
void setAccumulatedDataLabel(const char *newlabel)
void setOverflowsToConst(const Num2 &value)
void addToBinContents(const Num2 &weight)
const T & max(const T &a, const T &b)
void accumulateBinsLoop(unsigned level, const BoxND< double > &box, unsigned *idx, Acc *accumulator, double overlapFraction) const
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
void setBin(const unsigned *index, unsigned indexLen, const Num2 &v)
static const char * classname()
void addToOverflows(const Num2 &weight)
void setNFillsTotal(const unsigned long i)
void fillC(const double *coords, unsigned coordLength, const Num2 &weight)
PreciseTypeHelper< T, gs::IOIsNumber< T >::value >::type type
bool isUniformlyBinned() const
ArrayShape makeHistoShape(const std::vector< Axis > &axes)
unsigned long nFillsOver() const
Container::value_type value_type
std::vector< double > weightBuf_
const std::vector< Axis > & axes() const
void allBinCenters(std::vector< Point > *centers) const
static void restore(const gs::ClassId &id, std::istream &in, ArrayND *array)
std::vector< unsigned > indexBuf_
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
unsigned long nBins() const
std::vector< Axis > addAxis(const std::vector< Axis > &axes, const Axis &newAxis, const unsigned newAxisNumber)
const Numeric & closestBin() const
BoxND< double > boundingBox() const
HistoND & operator-=(const HistoND< Num2, Axis > &r)
void setTitle(const char *newtitle)
HistoND & operator/=(const Num2 &r)
void setOverflows(const Num2 *data, unsigned long dataLength)
void binBox(unsigned long binNumber, BoxND< double > *box) const
void fillPreservingCentroid(const Num2 &weight)
char data[epos_bytes_allocation]
unsigned long nFillsInRange() const
std::vector< Axis > axesOfASlice(const std::vector< Axis > &axes, const unsigned *fixedIndices, const unsigned nFixedIndices)
void setBinContents(const Num2 *data, unsigned long dataLength, bool clearOverflows=true)
void setAxisLabel(const unsigned axisNum, const char *newlabel)
void setBinsToConst(const Num2 &value)
static HistoND * read(const gs::ClassId &id, std::istream &in)
bool operator!=(const HistoND &) const
void setLinearBinAt(const unsigned long index, const Num2 &v)
std::vector< Axis > axes_
ArrayShape shapeOfASlice(const std::vector< Axis > &axes, const unsigned *fixedIndices, const unsigned nFixedIndices)
ArrayND< Numeric > overflow_
const ArrayND< Numeric > & overflows() const
std::vector< LinearMapper1d > densityScanHistoMap(const Histo &histo)
HistoND transpose(unsigned axisNum1, unsigned axisNum2) const
tuple size
Write out results.
Histogram axis with equidistant bins.
void scaleOverflows(const Num2 *data, unsigned long dataLength)
Arbitrary-dimensional array template.
ArrayShape shapeWithExtraAxis(const std::vector< Axis > &axes, const Axis &newAxis, const unsigned newAxisNumber)