CMS 3D CMS Logo

HistoND.h
Go to the documentation of this file.
1 #ifndef NPSTAT_HISTOND_HH_
2 #define NPSTAT_HISTOND_HH_
3 
16 
17 namespace npstat {
42  template <typename Numeric, class Axis = HistoAxis>
43  class HistoND {
44  template <typename Num2, class Axis2>
45  friend class HistoND;
46 
47  public:
48  typedef Numeric value_type;
49  typedef Axis axis_type;
50 
51  enum RebinType { SAMPLE = 0, SUM, AVERAGE };
52 
54  explicit HistoND(const std::vector<Axis>& axes,
55  const char* title = nullptr,
56  const char* accumulatedDataLabel = nullptr);
57 
59  explicit HistoND(const Axis& xAxis, const char* title = nullptr, const char* accumulatedDataLabel = nullptr);
60 
62  HistoND(const Axis& xAxis,
63  const Axis& yAxis,
64  const char* title = nullptr,
65  const char* accumulatedDataLabel = nullptr);
66 
68  HistoND(const Axis& xAxis,
69  const Axis& yAxis,
70  const Axis& zAxis,
71  const char* title = nullptr,
72  const char* accumulatedDataLabel = nullptr);
73 
75  HistoND(const Axis& xAxis,
76  const Axis& yAxis,
77  const Axis& zAxis,
78  const Axis& tAxis,
79  const char* title = nullptr,
80  const char* accumulatedDataLabel = nullptr);
81 
83  HistoND(const Axis& xAxis,
84  const Axis& yAxis,
85  const Axis& zAxis,
86  const Axis& tAxis,
87  const Axis& vAxis,
88  const char* title = nullptr,
89  const char* accumulatedDataLabel = nullptr);
90 
96  HistoND(const ArrayShape& shape,
98  const char* title = nullptr,
99  const char* accumulatedDataLabel = nullptr);
100 
107  template <typename Num2, class Functor>
109  const Functor& f,
110  const char* title = nullptr,
111  const char* accumulatedDataLabel = nullptr);
112 
120  template <typename Num2>
121  HistoND(const HistoND<Num2, Axis>& h, const unsigned* indices, unsigned nIndices, const char* title = nullptr);
122 
132  template <typename Num2>
133  HistoND(const HistoND<Num2, Axis>& h, const Axis& newAxis, unsigned newAxisNumber, const char* title = nullptr);
134 
152  template <typename Num2>
154  RebinType rType,
155  const unsigned* newBinCounts,
156  unsigned lenNewBinCounts,
157  const double* shifts = nullptr,
158  const char* title = nullptr);
159 
161  HistoND(const HistoND&);
162 
167  HistoND& operator=(const HistoND&);
168 
170  inline unsigned dim() const { return dim_; }
171 
173  inline const std::string& title() const { return title_; }
174 
176  inline const std::string& accumulatedDataLabel() const { return accumulatedDataLabel_; }
177 
179  inline const ArrayND<Numeric>& binContents() const { return data_; }
180 
182  inline const ArrayND<Numeric>& overflows() const { return overflow_; }
183 
185  inline const std::vector<Axis>& axes() const { return axes_; }
186 
188  inline const Axis& axis(const unsigned i) const { return axes_.at(i); }
189 
191  inline unsigned long nBins() const { return data_.length(); }
192 
194  inline unsigned long nFillsTotal() const { return fillCount_; }
195 
197  inline unsigned long nFillsInRange() const { return fillCount_ - overCount_; }
198 
200  inline unsigned long nFillsOver() const { return overCount_; }
201 
206  bool isUniformlyBinned() const;
207 
209  inline void setTitle(const char* newtitle) {
210  title_ = newtitle ? newtitle : "";
211  ++modCount_;
212  }
213 
215  inline void setAccumulatedDataLabel(const char* newlabel) {
216  accumulatedDataLabel_ = newlabel ? newlabel : "";
217  ++modCount_;
218  }
219 
221  inline void setAxisLabel(const unsigned axisNum, const char* newlabel) {
222  axes_.at(axisNum).setLabel(newlabel);
223  ++modCount_;
224  }
225 
230  double binVolume(unsigned long binNumber = 0) const;
231 
237  void binCenter(unsigned long binNumber, double* coords, unsigned lenCoords) const;
238 
246  template <class Point>
247  void allBinCenters(std::vector<Point>* centers) const;
248 
250  void binBox(unsigned long binNumber, BoxND<double>* box) const;
251 
253  BoxND<double> boundingBox() const;
254 
260  double volume() const;
261 
263  double integral() const;
264 
266  void clear();
267 
269  void clearBinContents();
270 
272  void clearOverflows();
273 
275  bool operator==(const HistoND&) const;
276 
278  bool operator!=(const HistoND&) const;
279 
284  bool isSameData(const HistoND&) const;
285 
292  template <typename Num2>
293  void fill(const double* coords, unsigned coordLength, const Num2& weight);
294 
296 
300  template <typename Num2>
301  void fill(const Num2& weight);
302 
303  template <typename Num2>
304  void fill(double x0, const Num2& weight);
305 
306  template <typename Num2>
307  void fill(double x0, double x1, const Num2& weight);
308 
309  template <typename Num2>
310  void fill(double x0, double x1, double x2, const Num2& weight);
311 
312  template <typename Num2>
313  void fill(double x0, double x1, double x2, double x3, const Num2& weight);
314 
315  template <typename Num2>
316  void fill(double x0, double x1, double x2, double x3, double x4, const Num2& weight);
317 
318  template <typename Num2>
319  void fill(double x0, double x1, double x2, double x3, double x4, double x5, const Num2& weight);
320 
321  template <typename Num2>
322  void fill(double x0, double x1, double x2, double x3, double x4, double x5, double x6, const Num2& weight);
323 
324  template <typename Num2>
325  void fill(
326  double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7, const Num2& weight);
327 
328  template <typename Num2>
329  void fill(double x0,
330  double x1,
331  double x2,
332  double x3,
333  double x4,
334  double x5,
335  double x6,
336  double x7,
337  double x8,
338  const Num2& weight);
339 
340  template <typename Num2>
341  void fill(double x0,
342  double x1,
343  double x2,
344  double x3,
345  double x4,
346  double x5,
347  double x6,
348  double x7,
349  double x8,
350  double x9,
351  const Num2& weight);
353 
367  template <typename Num2, class Functor>
368  void dispatch(const double* coords, unsigned coordLength, Num2& weight, Functor& f);
369 
371 
375  template <typename Num2, class Functor>
376  void dispatch(Num2& weight, Functor& f);
377 
378  template <typename Num2, class Functor>
379  void dispatch(double x0, Num2& weight, Functor& f);
380 
381  template <typename Num2, class Functor>
382  void dispatch(double x0, double x1, Num2& weight, Functor& f);
383 
384  template <typename Num2, class Functor>
385  void dispatch(double x0, double x1, double x2, Num2& weight, Functor& f);
386 
387  template <typename Num2, class Functor>
388  void dispatch(double x0, double x1, double x2, double x3, Num2& weight, Functor& f);
389 
390  template <typename Num2, class Functor>
391  void dispatch(double x0, double x1, double x2, double x3, double x4, Num2& weight, Functor& f);
392 
393  template <typename Num2, class Functor>
394  void dispatch(double x0, double x1, double x2, double x3, double x4, double x5, Num2& weight, Functor& f);
395 
396  template <typename Num2, class Functor>
397  void dispatch(double x0, double x1, double x2, double x3, double x4, double x5, double x6, Num2& weight, Functor& f);
398 
399  template <typename Num2, class Functor>
400  void dispatch(double x0,
401  double x1,
402  double x2,
403  double x3,
404  double x4,
405  double x5,
406  double x6,
407  double x7,
408  Num2& weight,
409  Functor& f);
410 
411  template <typename Num2, class Functor>
412  void dispatch(double x0,
413  double x1,
414  double x2,
415  double x3,
416  double x4,
417  double x5,
418  double x6,
419  double x7,
420  double x8,
421  Num2& weight,
422  Functor& f);
423 
424  template <typename Num2, class Functor>
425  void dispatch(double x0,
426  double x1,
427  double x2,
428  double x3,
429  double x4,
430  double x5,
431  double x6,
432  double x7,
433  double x8,
434  double x9,
435  Num2& weight,
436  Functor& f);
438 
445  const Numeric& examine(const double* coords, unsigned coordLength) const;
446 
448 
452  const Numeric& examine() const;
453 
454  const Numeric& examine(double x0) const;
455 
456  const Numeric& examine(double x0, double x1) const;
457 
458  const Numeric& examine(double x0, double x1, double x2) const;
459 
460  const Numeric& examine(double x0, double x1, double x2, double x3) const;
461 
462  const Numeric& examine(double x0, double x1, double x2, double x3, double x4) const;
463 
464  const Numeric& examine(double x0, double x1, double x2, double x3, double x4, double x5) const;
465 
466  const Numeric& examine(double x0, double x1, double x2, double x3, double x4, double x5, double x6) const;
467 
468  const Numeric& examine(double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7) const;
469 
470  const Numeric& examine(
471  double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7, double x8) const;
472 
473  const Numeric& examine(
474  double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7, double x8, double x9)
475  const;
477 
484  const Numeric& closestBin(const double* coords, unsigned coordLength) const;
485 
487 
491  const Numeric& closestBin() const;
492 
493  const Numeric& closestBin(double x0) const;
494 
495  const Numeric& closestBin(double x0, double x1) const;
496 
497  const Numeric& closestBin(double x0, double x1, double x2) const;
498 
499  const Numeric& closestBin(double x0, double x1, double x2, double x3) const;
500 
501  const Numeric& closestBin(double x0, double x1, double x2, double x3, double x4) const;
502 
503  const Numeric& closestBin(double x0, double x1, double x2, double x3, double x4, double x5) const;
504 
505  const Numeric& closestBin(double x0, double x1, double x2, double x3, double x4, double x5, double x6) const;
506 
507  const Numeric& closestBin(
508  double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7) const;
509 
510  const Numeric& closestBin(
511  double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7, double x8) const;
512 
513  const Numeric& closestBin(
514  double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7, double x8, double x9)
515  const;
517 
540  template <typename Num2>
541  void fillC(const double* coords, unsigned coordLength, const Num2& weight);
542 
544 
548  template <typename Num2>
549  void fillC(const Num2& weight);
550 
551  template <typename Num2>
552  void fillC(double x0, const Num2& weight);
553 
554  template <typename Num2>
555  void fillC(double x0, double x1, const Num2& weight);
556 
557  template <typename Num2>
558  void fillC(double x0, double x1, double x2, const Num2& weight);
559 
560  template <typename Num2>
561  void fillC(double x0, double x1, double x2, double x3, const Num2& weight);
562 
563  template <typename Num2>
564  void fillC(double x0, double x1, double x2, double x3, double x4, const Num2& weight);
565 
566  template <typename Num2>
567  void fillC(double x0, double x1, double x2, double x3, double x4, double x5, const Num2& weight);
568 
569  template <typename Num2>
570  void fillC(double x0, double x1, double x2, double x3, double x4, double x5, double x6, const Num2& weight);
571 
572  template <typename Num2>
573  void fillC(
574  double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7, const Num2& weight);
575 
576  template <typename Num2>
577  void fillC(double x0,
578  double x1,
579  double x2,
580  double x3,
581  double x4,
582  double x5,
583  double x6,
584  double x7,
585  double x8,
586  const Num2& weight);
587 
588  template <typename Num2>
589  void fillC(double x0,
590  double x1,
591  double x2,
592  double x3,
593  double x4,
594  double x5,
595  double x6,
596  double x7,
597  double x8,
598  double x9,
599  const Num2& weight);
601 
606  template <typename Num2>
608 
618  template <typename Num2>
620 
622 
623  template <typename Num2>
624  void setBin(const unsigned* index, unsigned indexLen, const Num2& v);
625 
626  template <typename Num2>
627  void setBin(const Num2& v);
628 
629  template <typename Num2>
630  void setBin(unsigned i0, const Num2& v);
631 
632  template <typename Num2>
633  void setBin(unsigned i0, unsigned i1, const Num2& v);
634 
635  template <typename Num2>
636  void setBin(unsigned i0, unsigned i1, unsigned i2, const Num2& v);
637 
638  template <typename Num2>
639  void setBin(unsigned i0, unsigned i1, unsigned i2, unsigned i3, const Num2& v);
640 
641  template <typename Num2>
642  void setBin(unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, const Num2& v);
643 
644  template <typename Num2>
645  void setBin(unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5, const Num2& v);
646 
647  template <typename Num2>
648  void setBin(
649  unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5, unsigned i6, const Num2& v);
650 
651  template <typename Num2>
652  void setBin(unsigned i0,
653  unsigned i1,
654  unsigned i2,
655  unsigned i3,
656  unsigned i4,
657  unsigned i5,
658  unsigned i6,
659  unsigned i7,
660  const Num2& v);
661 
662  template <typename Num2>
663  void setBin(unsigned i0,
664  unsigned i1,
665  unsigned i2,
666  unsigned i3,
667  unsigned i4,
668  unsigned i5,
669  unsigned i6,
670  unsigned i7,
671  unsigned i8,
672  const Num2& v);
673 
674  template <typename Num2>
675  void setBin(unsigned i0,
676  unsigned i1,
677  unsigned i2,
678  unsigned i3,
679  unsigned i4,
680  unsigned i5,
681  unsigned i6,
682  unsigned i7,
683  unsigned i8,
684  unsigned i9,
685  const Num2& v);
686 
687  template <typename Num2>
688  inline void setLinearBin(const unsigned long index, const Num2& v) {
690  ++modCount_;
691  }
693 
695 
696  template <typename Num2>
697  void setBinAt(const unsigned* index, unsigned indexLen, const Num2& v);
698 
699  template <typename Num2>
700  void setBinAt(const Num2& v);
701 
702  template <typename Num2>
703  void setBinAt(unsigned i0, const Num2& v);
704 
705  template <typename Num2>
706  void setBinAt(unsigned i0, unsigned i1, const Num2& v);
707 
708  template <typename Num2>
709  void setBinAt(unsigned i0, unsigned i1, unsigned i2, const Num2& v);
710 
711  template <typename Num2>
712  void setBinAt(unsigned i0, unsigned i1, unsigned i2, unsigned i3, const Num2& v);
713 
714  template <typename Num2>
715  void setBinAt(unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, const Num2& v);
716 
717  template <typename Num2>
718  void setBinAt(unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5, const Num2& v);
719 
720  template <typename Num2>
721  void setBinAt(
722  unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5, unsigned i6, const Num2& v);
723 
724  template <typename Num2>
725  void setBinAt(unsigned i0,
726  unsigned i1,
727  unsigned i2,
728  unsigned i3,
729  unsigned i4,
730  unsigned i5,
731  unsigned i6,
732  unsigned i7,
733  const Num2& v);
734 
735  template <typename Num2>
736  void setBinAt(unsigned i0,
737  unsigned i1,
738  unsigned i2,
739  unsigned i3,
740  unsigned i4,
741  unsigned i5,
742  unsigned i6,
743  unsigned i7,
744  unsigned i8,
745  const Num2& v);
746 
747  template <typename Num2>
748  void setBinAt(unsigned i0,
749  unsigned i1,
750  unsigned i2,
751  unsigned i3,
752  unsigned i4,
753  unsigned i5,
754  unsigned i6,
755  unsigned i7,
756  unsigned i8,
757  unsigned i9,
758  const Num2& v);
759 
760  template <typename Num2>
761  inline void setLinearBinAt(const unsigned long index, const Num2& v) {
763  ++modCount_;
764  }
766 
768  template <typename Num2>
769  void setBinContents(const Num2* data, unsigned long dataLength, bool clearOverflows = true);
770 
772  template <typename Num2>
773  void setOverflows(const Num2* data, unsigned long dataLength);
774 
779  template <typename Num2>
780  inline void setBinsToConst(const Num2& value) {
782  ++modCount_;
783  }
784 
789  template <typename Num2>
790  inline void setOverflowsToConst(const Num2& value) {
792  ++modCount_;
793  }
794 
802 
804 
808  inline void setNFillsTotal(const unsigned long i) {
809  fillCount_ = i;
810  ++modCount_;
811  }
812  inline void setNFillsOver(const unsigned long i) {
813  overCount_ = i;
814  ++modCount_;
815  }
817 
819  template <typename Num2>
820  HistoND& operator*=(const Num2& r);
821 
823  template <typename Num2>
824  HistoND& operator/=(const Num2& r);
825 
827 
828  template <typename Num2>
829  void scaleBinContents(const Num2* data, unsigned long dataLength);
830 
831  template <typename Num2>
832  void scaleOverflows(const Num2* data, unsigned long dataLength);
834 
836 
840  template <typename Num2>
841  void addToBinContents(const Num2& weight);
842 
843  template <typename Num2>
844  void addToOverflows(const Num2& weight);
846 
848 
853  template <typename Num2>
854  void addToBinContents(const Num2* data, unsigned long dataLength);
855 
856  template <typename Num2>
857  void addToOverflows(const Num2* data, unsigned long dataLength);
859 
868  template <typename Acc>
869  void accumulateBinsInBox(const BoxND<double>& box, Acc* acc, bool calculateAverage = false) const;
870 
872 
882  template <typename Num2, typename Num3>
883  void addToProjection(HistoND<Num2, Axis>* projection,
885  const unsigned* projectedIndices,
886  unsigned nProjectedIndices) const;
887 
888  template <typename Num2, typename Num3>
889  void addToProjection(HistoND<Num2, Axis>* projection,
890  AbsVisitor<Numeric, Num3>& projector,
891  const unsigned* projectedIndices,
892  unsigned nProjectedIndices) const;
894 
896  HistoND transpose(unsigned axisNum1, unsigned axisNum2) const;
897 
910  inline unsigned long getModCount() const { return modCount_; }
911 
917  inline void incrModCount() { ++modCount_; }
918 
920 
921  inline gs::ClassId classId() const { return gs::ClassId(*this); }
922  bool write(std::ostream& of) const;
924 
925  static const char* classname();
926  static inline unsigned version() { return 1; }
927  static HistoND* read(const gs::ClassId& id, std::istream& in);
928 
929  private:
930  HistoND() = delete;
931 
932  // Special constructor which speeds up the "transpose" operation.
933  // Does not do full error checking (some of it is done in transpose).
934  HistoND(const HistoND& r, unsigned ax1, unsigned ax2);
935 
936  template <typename Num2>
937  void fillPreservingCentroid(const Num2& weight);
938 
939  template <typename Acc>
940  void accumulateBinsLoop(unsigned level,
941  const BoxND<double>& box,
942  unsigned* idx,
943  Acc* accumulator,
944  double overlapFraction,
945  long double* wsum) const;
950  std::vector<Axis> axes_;
951  mutable std::vector<double> weightBuf_;
952  mutable std::vector<unsigned> indexBuf_;
953  unsigned long fillCount_;
954  unsigned long overCount_;
955  unsigned long modCount_;
956  unsigned dim_;
957  };
958 
973  template <typename Histo>
974  void convertHistoToDensity(Histo* histogram, bool knownNonNegative = false);
975 
981  template <typename Histo>
982  std::vector<LinearMapper1d> densityScanHistoMap(const Histo& histo);
983 
994  template <typename Histo>
995  std::vector<CircularMapper1d> convolutionHistoMap(const Histo& histo, bool doubleDataRange);
996 } // namespace npstat
997 
998 #include <cassert>
1000 #include <sstream>
1001 #include <climits>
1002 #include <algorithm>
1003 
1004 #include "Alignment/Geners/interface/CPP11_auto_ptr.hh"
1005 #include "Alignment/Geners/interface/binaryIO.hh"
1006 
1007 namespace npstat {
1008  namespace Private {
1009  template <class Axis>
1010  ArrayShape makeHistoShape(const std::vector<Axis>& axes) {
1011  const unsigned n = axes.size();
1013  result.reserve(n);
1014  for (unsigned i = 0; i < n; ++i)
1015  result.push_back(axes[i].nBins());
1016  return result;
1017  }
1018 
1019  template <class Axis>
1022  result.reserve(1U);
1023  result.push_back(xAxis.nBins());
1024  return result;
1025  }
1026 
1027  template <class Axis>
1028  ArrayShape makeHistoShape(const Axis& xAxis, const Axis& yAxis) {
1030  result.reserve(2U);
1031  result.push_back(xAxis.nBins());
1032  result.push_back(yAxis.nBins());
1033  return result;
1034  }
1035 
1036  template <class Axis>
1037  ArrayShape makeHistoShape(const Axis& xAxis, const Axis& yAxis, const Axis& zAxis) {
1039  result.reserve(3U);
1040  result.push_back(xAxis.nBins());
1041  result.push_back(yAxis.nBins());
1042  result.push_back(zAxis.nBins());
1043  return result;
1044  }
1045 
1046  template <class Axis>
1047  ArrayShape makeHistoShape(const Axis& xAxis, const Axis& yAxis, const Axis& zAxis, const Axis& tAxis) {
1049  result.reserve(4U);
1050  result.push_back(xAxis.nBins());
1051  result.push_back(yAxis.nBins());
1052  result.push_back(zAxis.nBins());
1053  result.push_back(tAxis.nBins());
1054  return result;
1055  }
1056 
1057  template <class Axis>
1059  const Axis& xAxis, const Axis& yAxis, const Axis& zAxis, const Axis& tAxis, const Axis& vAxis) {
1061  result.reserve(5U);
1062  result.push_back(xAxis.nBins());
1063  result.push_back(yAxis.nBins());
1064  result.push_back(zAxis.nBins());
1065  result.push_back(tAxis.nBins());
1066  result.push_back(vAxis.nBins());
1067  return result;
1068  }
1069 
1070  template <class Axis>
1071  std::vector<Axis> rebinAxes(const std::vector<Axis>& axes, const unsigned* newBins, const unsigned lenNewBins) {
1072  const unsigned dim = axes.size();
1073  if (lenNewBins != dim)
1075  "In npstat::Private::rebinAxes: invalid length "
1076  "of the new bins array");
1077  assert(newBins);
1078  std::vector<Axis> newAxes;
1079  newAxes.reserve(dim);
1080  for (unsigned i = 0; i < dim; ++i)
1081  newAxes.push_back(axes[i].rebin(newBins[i]));
1082  return newAxes;
1083  }
1084 
1085  template <class Axis>
1086  std::vector<Axis> axesOfASlice(const std::vector<Axis>& axes,
1087  const unsigned* fixedIndices,
1088  const unsigned nFixedIndices) {
1089  const unsigned dim = axes.size();
1090  std::vector<Axis> newAxes;
1091  if (nFixedIndices == 0U)
1093  "In npstat::Private::axesOfASlice: "
1094  "at least one fixed index must be specified");
1095  if (nFixedIndices > dim)
1096  throw npstat::NpstatInvalidArgument("In npstat::Private::axesOfASlice: too many fixed indices");
1097  assert(fixedIndices);
1098  for (unsigned i = 0; i < nFixedIndices; ++i)
1099  if (fixedIndices[i] >= dim)
1100  throw npstat::NpstatInvalidArgument("In npstat::Private::axesOfASlice: fixed index out of range");
1101  newAxes.reserve(dim - nFixedIndices);
1102  for (unsigned i = 0; i < dim; ++i) {
1103  bool fixed = false;
1104  for (unsigned j = 0; j < nFixedIndices; ++j)
1105  if (fixedIndices[j] == i) {
1106  fixed = true;
1107  break;
1108  }
1109  if (!fixed)
1110  newAxes.push_back(axes[i]);
1111  }
1112  if (newAxes.size() != dim - nFixedIndices)
1113  throw npstat::NpstatInvalidArgument("In npstat::Private::axesOfASlice: duplicate fixed index");
1114  return newAxes;
1115  }
1116 
1117  template <class Axis>
1118  ArrayShape shapeOfASlice(const std::vector<Axis>& axes,
1119  const unsigned* fixedIndices,
1120  const unsigned nFixedIndices) {
1121  const unsigned dim = axes.size();
1122  if (nFixedIndices == 0U)
1124  "In npstat::Private::shapeOfASlice: "
1125  "at least one fixed index must be specified");
1126  if (nFixedIndices > dim)
1127  throw npstat::NpstatInvalidArgument("In npstat::Private::shapeOfASlice: too many fixed indices");
1128  assert(fixedIndices);
1129 
1130  // Check that the fixed indices are within range
1131  for (unsigned j = 0; j < nFixedIndices; ++j)
1132  if (fixedIndices[j] >= dim)
1133  throw npstat::NpstatInvalidArgument("In npstat::Private::shapeOfASlice: fixed index out of range");
1134 
1135  // Build the shape for the slice
1136  ArrayShape sh;
1137  if (nFixedIndices < dim)
1138  sh.reserve(dim - nFixedIndices);
1139  for (unsigned i = 0; i < dim; ++i) {
1140  bool fixed = false;
1141  for (unsigned j = 0; j < nFixedIndices; ++j)
1142  if (fixedIndices[j] == i) {
1143  fixed = true;
1144  break;
1145  }
1146  if (!fixed)
1147  sh.push_back(axes[i].nBins());
1148  }
1149  if (sh.size() != dim - nFixedIndices)
1150  throw npstat::NpstatInvalidArgument("In npstat::Private::shapeOfASlice: duplicate fixed index");
1151  return sh;
1152  }
1153 
1154  template <class Axis>
1155  std::vector<Axis> addAxis(const std::vector<Axis>& axes, const Axis& newAxis, const unsigned newAxisNumber) {
1156  const unsigned dim = axes.size();
1157  std::vector<Axis> newAxes;
1158  newAxes.reserve(dim + 1U);
1159  unsigned iadd = 0;
1160  for (unsigned i = 0; i < dim; ++i) {
1161  if (newAxisNumber == i)
1162  newAxes.push_back(newAxis);
1163  else
1164  newAxes.push_back(axes[iadd++]);
1165  }
1166  if (iadd == dim)
1167  newAxes.push_back(newAxis);
1168  else
1169  newAxes.push_back(axes[iadd]);
1170  return newAxes;
1171  }
1172 
1173  template <class Axis>
1174  ArrayShape shapeWithExtraAxis(const std::vector<Axis>& axes, const Axis& newAxis, const unsigned newAxisNumber) {
1175  const unsigned dim = axes.size();
1177  result.reserve(dim + 1U);
1178  unsigned iadd = 0;
1179  for (unsigned i = 0; i < dim; ++i) {
1180  if (newAxisNumber == i)
1181  result.push_back(newAxis.nBins());
1182  else
1183  result.push_back(axes[iadd++].nBins());
1184  }
1185  if (iadd == dim)
1186  result.push_back(newAxis.nBins());
1187  else
1188  result.push_back(axes[iadd].nBins());
1189  return result;
1190  }
1191 
1192  inline void h_badargs(const char* method) {
1193  std::ostringstream os;
1194  os << "In npstat::HistoND::" << method << ": number of arguments"
1195  << " is incompatible with histogram dimensionality";
1196  throw npstat::NpstatInvalidArgument(os.str());
1197  }
1198  } // namespace Private
1199 
1200  template <typename Numeric, class Axis>
1201  template <typename Acc>
1203  const BoxND<double>& box,
1204  unsigned* idx,
1205  Acc* accumulator,
1206  const double overlapFraction,
1207  long double* wsum) const {
1208  const Interval<double>& boxSide(box[level]);
1209  const Axis& axis(axes_[level]);
1210  const unsigned nbins = axis.nBins();
1211  const bool lastLevel = level == dim_ - 1U;
1212  for (unsigned i = 0; i < nbins; ++i) {
1213  const double over = overlapFraction * axis.binInterval(i).overlapFraction(boxSide);
1214  if (over > 0.0) {
1215  idx[level] = i;
1216  if (lastLevel) {
1217  *accumulator += over * data_.value(idx, dim_);
1218  *wsum += over;
1219  } else
1220  accumulateBinsLoop(level + 1U, box, idx, accumulator, over, wsum);
1221  }
1222  }
1223  }
1224 
1225  template <typename Numeric, class Axis>
1226  template <typename Acc>
1228  Acc* accumulator,
1229  const bool calculateAverage) const {
1230  if (box.size() != dim_)
1232  "In npstat::HistoND::accumulateBinsInBox: "
1233  "incompatible box dimensionality");
1235  if (dim_) {
1236  long double wsum = 0.0L;
1237  for (unsigned i = 0; i < dim_; ++i)
1238  indexBuf_[i] = 0U;
1239  accumulateBinsLoop(0U, box, &indexBuf_[0], accumulator, 1.0, &wsum);
1240  if (calculateAverage && wsum > 0.0L)
1241  *accumulator *= static_cast<double>(1.0L / wsum);
1242  } else
1243  *accumulator += 1.0 * data_();
1244  }
1245 
1246  template <typename Numeric, class Axis>
1248  data_.clear();
1249  fillCount_ = 0UL;
1250  ++modCount_;
1251  }
1252 
1253  template <typename Numeric, class Axis>
1255  overflow_.clear();
1256  overCount_ = 0UL;
1257  ++modCount_;
1258  }
1259 
1260  template <typename Numeric, class Axis>
1262  clearBinContents();
1263  clearOverflows();
1264  ++modCount_;
1265  }
1266 
1267  template <typename Numeric, class Axis>
1268  HistoND<Numeric, Axis>::HistoND(const std::vector<Axis>& axesIn, const char* title, const char* label)
1269  : title_(title ? title : ""),
1270  accumulatedDataLabel_(label ? label : ""),
1271  data_(Private::makeHistoShape(axesIn)),
1272  overflow_(ArrayShape(axesIn.size(), 3U)),
1273  axes_(axesIn),
1274  weightBuf_(axesIn.size()),
1275  indexBuf_(2U * axesIn.size()),
1276  modCount_(0UL),
1277  dim_(axesIn.size()) {
1278  if (dim_ >= CHAR_BIT * sizeof(unsigned long))
1280  "In npstat::HistoND constructor: requested histogram "
1281  "dimensionality is not supported (too large)");
1282  clear();
1283  }
1284 
1285  template <typename Numeric, class Axis>
1286  HistoND<Numeric, Axis>::HistoND(const Axis& xAxis, const char* title, const char* label)
1287  : title_(title ? title : ""),
1288  accumulatedDataLabel_(label ? label : ""),
1289  data_(Private::makeHistoShape(xAxis)),
1290  overflow_(ArrayShape(1U, 3U)),
1291  weightBuf_(1U),
1292  indexBuf_(2U * 1U),
1293  modCount_(0UL),
1294  dim_(1U) {
1295  axes_.reserve(dim_);
1296  axes_.push_back(xAxis);
1297  clear();
1298  }
1299 
1300  template <typename Numeric, class Axis>
1301  HistoND<Numeric, Axis>::HistoND(const Axis& xAxis, const Axis& yAxis, const char* title, const char* label)
1302  : title_(title ? title : ""),
1303  accumulatedDataLabel_(label ? label : ""),
1304  data_(Private::makeHistoShape(xAxis, yAxis)),
1305  overflow_(ArrayShape(2U, 3U)),
1306  weightBuf_(2U),
1307  indexBuf_(2U * 2U),
1308  modCount_(0UL),
1309  dim_(2U) {
1310  axes_.reserve(dim_);
1311  axes_.push_back(xAxis);
1312  axes_.push_back(yAxis);
1313  clear();
1314  }
1315 
1316  template <typename Numeric, class Axis>
1318  const Axis& xAxis, const Axis& yAxis, const Axis& zAxis, const char* title, const char* label)
1319  : title_(title ? title : ""),
1320  accumulatedDataLabel_(label ? label : ""),
1321  data_(Private::makeHistoShape(xAxis, yAxis, zAxis)),
1322  overflow_(ArrayShape(3U, 3U)),
1323  weightBuf_(3U),
1324  indexBuf_(2U * 3U),
1325  modCount_(0UL),
1326  dim_(3U) {
1327  axes_.reserve(dim_);
1328  axes_.push_back(xAxis);
1329  axes_.push_back(yAxis);
1330  axes_.push_back(zAxis);
1331  clear();
1332  }
1333 
1334  template <typename Numeric, class Axis>
1336  const Axis& xAxis, const Axis& yAxis, const Axis& zAxis, const Axis& tAxis, const char* title, const char* label)
1337  : title_(title ? title : ""),
1338  accumulatedDataLabel_(label ? label : ""),
1339  data_(Private::makeHistoShape(xAxis, yAxis, zAxis, tAxis)),
1340  overflow_(ArrayShape(4U, 3U)),
1341  weightBuf_(4U),
1342  indexBuf_(2U * 4U),
1343  modCount_(0UL),
1344  dim_(4U) {
1345  axes_.reserve(dim_);
1346  axes_.push_back(xAxis);
1347  axes_.push_back(yAxis);
1348  axes_.push_back(zAxis);
1349  axes_.push_back(tAxis);
1350  clear();
1351  }
1352 
1353  template <typename Numeric, class Axis>
1355  const Axis& yAxis,
1356  const Axis& zAxis,
1357  const Axis& tAxis,
1358  const Axis& vAxis,
1359  const char* title,
1360  const char* label)
1361  : title_(title ? title : ""),
1362  accumulatedDataLabel_(label ? label : ""),
1363  data_(Private::makeHistoShape(xAxis, yAxis, zAxis, tAxis, vAxis)),
1364  overflow_(ArrayShape(5U, 3U)),
1365  weightBuf_(5U),
1366  indexBuf_(2U * 5U),
1367  modCount_(0UL),
1368  dim_(5U) {
1369  axes_.reserve(dim_);
1370  axes_.push_back(xAxis);
1371  axes_.push_back(yAxis);
1372  axes_.push_back(zAxis);
1373  axes_.push_back(tAxis);
1374  axes_.push_back(vAxis);
1375  clear();
1376  }
1377 
1378  template <typename Numeric, class Axis>
1380  const BoxND<double>& boundingBox,
1381  const char* title,
1382  const char* label)
1383  : title_(title ? title : ""),
1384  accumulatedDataLabel_(label ? label : ""),
1385  data_(shape),
1386  overflow_(ArrayShape(shape.size(), 3U)),
1387  weightBuf_(shape.size()),
1388  indexBuf_(2U * shape.size()),
1389  modCount_(0UL),
1390  dim_(shape.size()) {
1391  if (boundingBox.size() != dim_)
1393  "In npstat::HistoND constructor: "
1394  "incompatible bounding box dimensionality");
1395  if (dim_ >= CHAR_BIT * sizeof(unsigned long))
1397  "In npstat::HistoND constructor: requested histogram "
1398  "dimensionality is not supported (too large)");
1399  axes_.reserve(dim_);
1400  for (unsigned i = 0; i < dim_; ++i)
1401  axes_.push_back(Axis(shape[i], boundingBox[i].min(), boundingBox[i].max()));
1402  clear();
1403  }
1404 
1405  template <typename Numeric, class Axis>
1406  template <typename Num2, class Functor>
1407  HistoND<Numeric, Axis>::HistoND(const HistoND<Num2, Axis>& r, const Functor& f, const char* title, const char* label)
1408  : title_(title ? title : ""),
1409  accumulatedDataLabel_(label ? label : ""),
1410  data_(r.data_, f),
1411  overflow_(r.overflow_, f),
1412  axes_(r.axes_),
1413  weightBuf_(r.dim_),
1414  indexBuf_(2U * r.dim_),
1415  fillCount_(r.fillCount_),
1416  overCount_(r.overCount_),
1417  modCount_(0UL),
1418  dim_(r.dim_) {}
1419 
1420  template <typename Numeric, class Axis>
1421  template <typename Num2>
1423  const unsigned* indices,
1424  const unsigned nIndices,
1425  const char* title)
1426  : title_(title ? title : ""),
1427  accumulatedDataLabel_(h.accumulatedDataLabel_),
1428  data_(Private::shapeOfASlice(h.axes_, indices, nIndices)),
1429  overflow_(ArrayShape(data_.rank(), 3U)),
1430  axes_(Private::axesOfASlice(h.axes_, indices, nIndices)),
1431  weightBuf_(data_.rank()),
1432  indexBuf_(2U * data_.rank()),
1433  modCount_(0UL),
1434  dim_(data_.rank()) {
1435  clear();
1436  }
1437 
1438  template <typename Numeric, class Axis>
1439  template <typename Num2>
1441  const Axis& newAxis,
1442  const unsigned newAxisNumber,
1443  const char* title)
1444  : title_(title ? title : ""),
1445  accumulatedDataLabel_(h.accumulatedDataLabel_),
1446  data_(Private::shapeWithExtraAxis(h.axes_, newAxis, newAxisNumber)),
1447  overflow_(data_.rank(), 3U),
1448  axes_(Private::addAxis(h.axes_, newAxis, newAxisNumber)),
1449  weightBuf_(data_.rank()),
1450  indexBuf_(2U * data_.rank()),
1451  modCount_(0UL),
1452  dim_(data_.rank()) {
1453  if (dim_ >= CHAR_BIT * sizeof(unsigned long))
1455  "In npstat::HistoND constructor: requested histogram "
1456  "dimensionality is not supported (too large)");
1457  clear();
1458  }
1459 
1460  template <typename Numeric, class Axis>
1461  template <typename Num2>
1463  const RebinType rType,
1464  const unsigned* newBinCounts,
1465  const unsigned lenNewBinCounts,
1466  const double* shifts,
1467  const char* title)
1468  : title_(title ? title : h.title_.c_str()),
1469  accumulatedDataLabel_(h.accumulatedDataLabel_),
1470  data_(newBinCounts, lenNewBinCounts),
1471  overflow_(h.overflow_),
1472  axes_(Private::rebinAxes(h.axes_, newBinCounts, lenNewBinCounts)),
1473  weightBuf_(h.dim_),
1474  indexBuf_(2U * h.dim_),
1475  fillCount_(h.fillCount_),
1476  overCount_(h.overCount_),
1477  modCount_(0UL),
1478  dim_(h.dim_) {
1479  const unsigned long newBins = data_.length();
1480  const Axis* ax = &axes_[0];
1481  unsigned* ubuf = &indexBuf_[0];
1482 
1483  // Fill out the bins of the new histogram
1484  if (rType == SAMPLE) {
1485  double* buf = &weightBuf_[0];
1486  for (unsigned long ibin = 0; ibin < newBins; ++ibin) {
1487  data_.convertLinearIndex(ibin, ubuf, dim_);
1488  if (shifts)
1489  for (unsigned i = 0; i < dim_; ++i)
1490  buf[i] = ax[i].binCenter(ubuf[i]) + shifts[i];
1491  else
1492  for (unsigned i = 0; i < dim_; ++i)
1493  buf[i] = ax[i].binCenter(ubuf[i]);
1494  data_.linearValue(ibin) = h.examine(buf, dim_);
1495  }
1496  } else {
1497  const Numeric zero = Numeric();
1498  BoxND<double> binLimits(dim_);
1499  for (unsigned long ibin = 0; ibin < newBins; ++ibin) {
1500  data_.convertLinearIndex(ibin, ubuf, dim_);
1501  for (unsigned i = 0; i < dim_; ++i)
1502  binLimits[i] = ax[i].binInterval(ubuf[i]);
1503  Numeric& thisBin(data_.linearValue(ibin));
1504  thisBin = zero;
1505  h.accumulateBinsInBox(binLimits, &thisBin, rType == AVERAGE);
1506  }
1507  }
1508  }
1509 
1510  template <typename Numeric, class Axis>
1512  for (unsigned i = 0; i < dim_; ++i)
1513  if (!axes_[i].isUniform())
1514  return false;
1515  return true;
1516  }
1517 
1518  template <typename Numeric, class Axis>
1520  typedef typename PreciseType<Numeric>::type Precise;
1521 
1522  if (dim_ == 0U)
1523  return 0.0;
1524  if (isUniformlyBinned()) {
1525  Precise sum = data_.template sum<Precise>();
1526  return static_cast<double>(sum) * binVolume();
1527  } else {
1528  Precise sum = Precise();
1529  const Numeric* data = data_.data();
1530  const unsigned long len = data_.length();
1531  for (unsigned long i = 0; i < len; ++i)
1532  sum += data[i] * binVolume(i);
1533  return static_cast<double>(sum);
1534  }
1535  }
1536 
1537  template <typename Numeric, class Axis>
1539  BoxND<double> box;
1540  if (dim_) {
1541  box.reserve(dim_);
1542  const Axis* ax = &axes_[0];
1543  for (unsigned i = 0; i < dim_; ++i)
1544  box.push_back(ax[i].interval());
1545  }
1546  return box;
1547  }
1548 
1549  template <typename Numeric, class Axis>
1551  double* coords,
1552  const unsigned lenCoords) const {
1553  if (dim_ != lenCoords)
1555  "In npstat::HistoND::binCenter: "
1556  "incompatible input point dimensionality");
1557  if (dim_) {
1558  assert(coords);
1559  data_.convertLinearIndex(binNumber, &indexBuf_[0], dim_);
1560  const Axis* ax = &axes_[0];
1561  for (unsigned i = 0; i < dim_; ++i)
1562  coords[i] = ax[i].binCenter(indexBuf_[i]);
1563  }
1564  }
1565 
1566  template <typename Numeric, class Axis>
1567  template <class Point>
1568  void HistoND<Numeric, Axis>::allBinCenters(std::vector<Point>* centers) const {
1569  assert(centers);
1570  centers->clear();
1571  const unsigned long len = data_.length();
1572  centers->reserve(len);
1573  unsigned* ibuf = &indexBuf_[0];
1574  const Axis* ax = &axes_[0];
1575  Point center;
1576  if (center.size() < dim_)
1578  "In npstat::HistoND::allBinCenters: "
1579  "incompatible point dimensionality (too small)");
1580  typename Point::value_type* cdat = &center[0];
1581 
1582  for (unsigned long i = 0; i < len; ++i) {
1583  data_.convertLinearIndex(i, ibuf, dim_);
1584  for (unsigned idim = 0; idim < dim_; ++idim)
1585  cdat[idim] = ax[idim].binCenter(ibuf[idim]);
1586  centers->push_back(center);
1587  }
1588  }
1589 
1590  template <typename Numeric, class Axis>
1591  void HistoND<Numeric, Axis>::binBox(const unsigned long binNumber, BoxND<double>* box) const {
1592  assert(box);
1593  box->clear();
1594  if (dim_) {
1595  box->reserve(dim_);
1596  data_.convertLinearIndex(binNumber, &indexBuf_[0], dim_);
1597  const Axis* ax = &axes_[0];
1598  for (unsigned i = 0; i < dim_; ++i)
1599  box->push_back(ax[i].binInterval(indexBuf_[i]));
1600  }
1601  }
1602 
1603  template <typename Numeric, class Axis>
1604  inline bool HistoND<Numeric, Axis>::isSameData(const HistoND& r) const {
1605  return dim_ == r.dim_ && overflow_ == r.overflow_ && data_ == r.data_;
1606  }
1607 
1608  template <typename Numeric, class Axis>
1609  inline bool HistoND<Numeric, Axis>::operator==(const HistoND& r) const {
1610  return dim_ == r.dim_ && fillCount_ == r.fillCount_ && overCount_ == r.overCount_ && title_ == r.title_ &&
1611  accumulatedDataLabel_ == r.accumulatedDataLabel_ && axes_ == r.axes_ && overflow_ == r.overflow_ &&
1612  data_ == r.data_;
1613  }
1614 
1615  template <typename Numeric, class Axis>
1616  inline bool HistoND<Numeric, Axis>::operator!=(const HistoND& r) const {
1617  return !(*this == r);
1618  }
1619 
1620  template <typename Numeric, class Axis>
1621  double HistoND<Numeric, Axis>::binVolume(const unsigned long binNumber) const {
1622  double v = 1.0;
1623  if (dim_) {
1624  data_.convertLinearIndex(binNumber, &indexBuf_[0], dim_);
1625  const Axis* ax = &axes_[0];
1626  for (unsigned i = 0; i < dim_; ++i)
1627  v *= ax[i].binWidth(indexBuf_[i]);
1628  }
1629  return v;
1630  }
1631 
1632  template <typename Numeric, class Axis>
1634  double v = 1.0;
1635  if (dim_) {
1636  const Axis* ax = &axes_[0];
1637  for (unsigned i = 0; i < dim_; ++i)
1638  v *= (ax[i].max() - ax[i].min());
1639  }
1640  return v;
1641  }
1642 
1643  template <typename Numeric, class Axis>
1644  template <typename Num2>
1645  void HistoND<Numeric, Axis>::fill(const double* coords, const unsigned coordLength, const Num2& w) {
1646  if (coordLength != dim_)
1648  "In npstat::HistoND::fill: "
1649  "incompatible input point dimensionality");
1650  if (coordLength) {
1651  assert(coords);
1652  unsigned* idx = &indexBuf_[0];
1653  unsigned* over = idx + dim_;
1654  const Axis* ax = &axes_[0];
1655  unsigned overflown = 0U;
1656  for (unsigned i = 0; i < dim_; ++i) {
1657  over[i] = ax[i].overflowIndex(coords[i], idx + i);
1658  overflown |= (over[i] - 1U);
1659  }
1660  if (overflown) {
1661  overflow_.value(over, dim_) += w;
1662  ++overCount_;
1663  } else
1664  data_.value(idx, dim_) += w;
1665  } else
1666  data_() += w;
1667  ++fillCount_;
1668  ++modCount_;
1669  }
1670 
1671  template <typename Numeric, class Axis>
1672  template <typename Num2, class Functor>
1673  void HistoND<Numeric, Axis>::dispatch(const double* coords, const unsigned coordLength, Num2& w, Functor& f) {
1674  if (coordLength != dim_)
1676  "In npstat::HistoND::dispatch: "
1677  "incompatible input point dimensionality");
1678  if (coordLength) {
1679  assert(coords);
1680  unsigned* idx = &indexBuf_[0];
1681  unsigned* over = idx + dim_;
1682  const Axis* ax = &axes_[0];
1683  unsigned overflown = 0U;
1684  for (unsigned i = 0; i < dim_; ++i) {
1685  over[i] = ax[i].overflowIndex(coords[i], idx + i);
1686  overflown |= (over[i] - 1U);
1687  }
1688  if (overflown)
1689  f(overflow_.value(over, dim_), w);
1690  else
1691  f(data_.value(idx, dim_), w);
1692  } else
1693  f(data_(), w);
1694  ++modCount_;
1695  }
1696 
1697  template <typename Numeric, class Axis>
1698  const Numeric& HistoND<Numeric, Axis>::examine(const double* coords, const unsigned coordLength) const {
1699  if (coordLength != dim_)
1701  "In npstat::HistoND::examine: "
1702  "incompatible input point dimensionality");
1703  if (coordLength) {
1704  assert(coords);
1705  unsigned* idx = &indexBuf_[0];
1706  unsigned* over = idx + dim_;
1707  const Axis* ax = &axes_[0];
1708  unsigned overflown = 0U;
1709  for (unsigned i = 0; i < dim_; ++i) {
1710  over[i] = ax[i].overflowIndex(coords[i], idx + i);
1711  overflown |= (over[i] - 1U);
1712  }
1713  if (overflown)
1714  return overflow_.value(over, dim_);
1715  else
1716  return data_.value(idx, dim_);
1717  } else
1718  return data_();
1719  }
1720 
1721  template <typename Numeric, class Axis>
1722  const Numeric& HistoND<Numeric, Axis>::closestBin(const double* coords, const unsigned coordLength) const {
1723  if (coordLength != dim_)
1725  "In npstat::HistoND::closestBin: "
1726  "incompatible input point dimensionality");
1727  if (coordLength) {
1728  assert(coords);
1729  unsigned* idx = &indexBuf_[0];
1730  const Axis* ax = &axes_[0];
1731  for (unsigned i = 0; i < dim_; ++i)
1732  idx[i] = ax[i].closestValidBin(coords[i]);
1733  return data_.value(idx, dim_);
1734  } else
1735  return data_();
1736  }
1737 
1738  template <typename Numeric, class Axis>
1739  template <typename Num2>
1741  const double* weights = &weightBuf_[0];
1742  const unsigned* cell = &indexBuf_[0];
1743  const unsigned long* strides = data_.strides();
1744  const unsigned long maxcycle = 1UL << dim_;
1745  for (unsigned long icycle = 0; icycle < maxcycle; ++icycle) {
1746  double w = 1.0;
1747  unsigned long icell = 0UL;
1748  for (unsigned i = 0; i < dim_; ++i) {
1749  if (icycle & (1UL << i)) {
1750  w *= (1.0 - weights[i]);
1751  icell += strides[i] * (cell[i] + 1U);
1752  } else {
1753  w *= weights[i];
1754  icell += strides[i] * cell[i];
1755  }
1756  }
1757  data_.linearValue(icell) += (value * w);
1758  }
1759  }
1760 
1761  template <typename Numeric, class Axis>
1762  template <typename Num2>
1763  void HistoND<Numeric, Axis>::fillC(const double* coords, const unsigned coordLength, const Num2& w) {
1764  if (coordLength != dim_)
1766  "In npstat::HistoND::fillC: "
1767  "incompatible input point dimensionality");
1768  if (coordLength) {
1769  assert(coords);
1770  double* wg = &weightBuf_[0];
1771  unsigned* idx = &indexBuf_[0];
1772  unsigned* over = idx + dim_;
1773  const Axis* ax = &axes_[0];
1774  unsigned overflown = 0U;
1775  for (unsigned i = 0; i < dim_; ++i) {
1776  over[i] = ax[i].overflowIndexWeighted(coords[i], idx + i, wg + i);
1777  overflown |= (over[i] - 1U);
1778  }
1779  if (overflown) {
1780  overflow_.value(over, dim_) += w;
1781  ++overCount_;
1782  } else
1783  fillPreservingCentroid(w);
1784  } else
1785  data_() += w;
1786  ++fillCount_;
1787  ++modCount_;
1788  }
1789 
1790  template <typename Numeric, class Axis>
1791  template <typename Num2>
1792  inline void HistoND<Numeric, Axis>::fill(const Num2& w) {
1793  if (dim_)
1794  Private::h_badargs("fill");
1795  data_() += w;
1796  ++fillCount_;
1797  ++modCount_;
1798  }
1799 
1800  template <typename Numeric, class Axis>
1801  template <typename Num2, class Functor>
1802  inline void HistoND<Numeric, Axis>::dispatch(Num2& w, Functor& f) {
1803  if (dim_)
1804  Private::h_badargs("dispatch");
1805  f(data_(), w);
1806  ++modCount_;
1807  }
1808 
1809  template <typename Numeric, class Axis>
1810  template <typename Num2>
1811  inline void HistoND<Numeric, Axis>::fillC(const Num2& w) {
1812  if (dim_)
1813  Private::h_badargs("fillC");
1814  data_() += w;
1815  ++fillCount_;
1816  ++modCount_;
1817  }
1818 
1819  template <typename Numeric, class Axis>
1820  inline const Numeric& HistoND<Numeric, Axis>::examine() const {
1821  if (dim_)
1822  Private::h_badargs("examine");
1823  return data_();
1824  }
1825 
1826  template <typename Numeric, class Axis>
1827  inline const Numeric& HistoND<Numeric, Axis>::closestBin() const {
1828  if (dim_)
1829  Private::h_badargs("closestBin");
1830  return data_();
1831  }
1832 
1833  template <typename Numeric, class Axis>
1834  template <typename Num2>
1835  void HistoND<Numeric, Axis>::fill(const double x0, const Num2& w) {
1836  if (dim_ != 1U)
1837  Private::h_badargs("fill");
1838  unsigned i0 = 0;
1839  const unsigned ov0 = axes_[0].overflowIndex(x0, &i0);
1840  if (ov0 == 1U)
1841  data_(i0) += w;
1842  else {
1843  overflow_(ov0) += w;
1844  ++overCount_;
1845  }
1846  ++fillCount_;
1847  ++modCount_;
1848  }
1849 
1850  template <typename Numeric, class Axis>
1851  template <typename Num2, class Functor>
1852  void HistoND<Numeric, Axis>::dispatch(const double x0, Num2& w, Functor& f) {
1853  if (dim_ != 1U)
1854  Private::h_badargs("dispatch");
1855  unsigned i0 = 0;
1856  const unsigned ov0 = axes_[0].overflowIndex(x0, &i0);
1857  if (ov0 == 1U)
1858  f(data_(i0), w);
1859  else
1860  f(overflow_(ov0), w);
1861  ++modCount_;
1862  }
1863 
1864  template <typename Numeric, class Axis>
1865  template <typename Num2>
1866  void HistoND<Numeric, Axis>::fillC(const double x0, const Num2& w) {
1867  if (dim_ != 1U)
1868  Private::h_badargs("fillC");
1869  double* wg = &weightBuf_[0];
1870  unsigned* idx = &indexBuf_[0];
1871  const unsigned ov0 = axes_[0].overflowIndexWeighted(x0, idx, wg);
1872  if (ov0 == 1U)
1873  fillPreservingCentroid(w);
1874  else {
1875  overflow_(ov0) += w;
1876  ++overCount_;
1877  }
1878  ++fillCount_;
1879  ++modCount_;
1880  }
1881 
1882  template <typename Numeric, class Axis>
1883  inline const Numeric& HistoND<Numeric, Axis>::examine(const double x0) const {
1884  if (dim_ != 1U)
1885  Private::h_badargs("examine");
1886  unsigned i0 = 0;
1887  const unsigned ov0 = axes_[0].overflowIndex(x0, &i0);
1888  if (ov0 == 1U)
1889  return data_(i0);
1890  else
1891  return overflow_(ov0);
1892  }
1893 
1894  template <typename Numeric, class Axis>
1895  inline const Numeric& HistoND<Numeric, Axis>::closestBin(const double x0) const {
1896  if (dim_ != 1U)
1897  Private::h_badargs("closestBin");
1898  const unsigned i0 = axes_[0].closestValidBin(x0);
1899  return data_(i0);
1900  }
1901 
1902  template <typename Numeric, class Axis>
1903  template <typename Num2>
1904  void HistoND<Numeric, Axis>::fill(const double x0, const double x1, const Num2& w) {
1905  if (dim_ != 2U)
1906  Private::h_badargs("fill");
1907  unsigned i0 = 0, i1 = 0;
1908  const Axis* ax = &axes_[0];
1909  const unsigned o0 = ax[0].overflowIndex(x0, &i0);
1910  const unsigned o1 = ax[1].overflowIndex(x1, &i1);
1911  if (o0 == 1U && o1 == 1U)
1912  data_(i0, i1) += w;
1913  else {
1914  overflow_(o0, o1) += w;
1915  ++overCount_;
1916  }
1917  ++fillCount_;
1918  ++modCount_;
1919  }
1920 
1921  template <typename Numeric, class Axis>
1922  template <typename Num2, class Functor>
1923  void HistoND<Numeric, Axis>::dispatch(const double x0, const double x1, Num2& w, Functor& f) {
1924  if (dim_ != 2U)
1925  Private::h_badargs("dispatch");
1926  unsigned i0 = 0, i1 = 0;
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  if (o0 == 1U && o1 == 1U)
1931  f(data_(i0, i1), w);
1932  else
1933  f(overflow_(o0, o1), w);
1934  ++modCount_;
1935  }
1936 
1937  template <typename Numeric, class Axis>
1938  template <typename Num2>
1939  void HistoND<Numeric, Axis>::fillC(const double x0, const double x1, const Num2& w) {
1940  if (dim_ != 2U)
1941  Private::h_badargs("fillC");
1942  double* wg = &weightBuf_[0];
1943  unsigned* idx = &indexBuf_[0];
1944  const Axis* ax = &axes_[0];
1945  const unsigned o0 = ax[0].overflowIndexWeighted(x0, idx + 0, wg + 0);
1946  const unsigned o1 = ax[1].overflowIndexWeighted(x1, idx + 1, wg + 1);
1947  if (o0 == 1U && o1 == 1U)
1948  fillPreservingCentroid(w);
1949  else {
1950  overflow_(o0, o1) += w;
1951  ++overCount_;
1952  }
1953  ++fillCount_;
1954  ++modCount_;
1955  }
1956 
1957  template <typename Numeric, class Axis>
1958  const Numeric& HistoND<Numeric, Axis>::examine(const double x0, const double x1) const {
1959  if (dim_ != 2U)
1960  Private::h_badargs("examine");
1961  unsigned i0 = 0, i1 = 0;
1962  const Axis* ax = &axes_[0];
1963  const unsigned o0 = ax[0].overflowIndex(x0, &i0);
1964  const unsigned o1 = ax[1].overflowIndex(x1, &i1);
1965  if (o0 == 1U && o1 == 1U)
1966  return data_(i0, i1);
1967  else
1968  return overflow_(o0, o1);
1969  }
1970 
1971  template <typename Numeric, class Axis>
1972  const Numeric& HistoND<Numeric, Axis>::closestBin(const double x0, const double x1) const {
1973  if (dim_ != 2U)
1974  Private::h_badargs("closestBin");
1975  const Axis* ax = &axes_[0];
1976  const unsigned i0 = ax[0].closestValidBin(x0);
1977  const unsigned i1 = ax[1].closestValidBin(x1);
1978  return data_(i0, i1);
1979  }
1980 
1981  template <typename Numeric, class Axis>
1982  template <typename Num2>
1983  void HistoND<Numeric, Axis>::fill(const double x0, const double x1, const double x2, const Num2& w) {
1984  if (dim_ != 3U)
1985  Private::h_badargs("fill");
1986  unsigned i0 = 0, i1 = 0, i2 = 0;
1987  const Axis* ax = &axes_[0];
1988  const unsigned o0 = ax[0].overflowIndex(x0, &i0);
1989  const unsigned o1 = ax[1].overflowIndex(x1, &i1);
1990  const unsigned o2 = ax[2].overflowIndex(x2, &i2);
1991  if (o0 == 1U && o1 == 1U && o2 == 1U)
1992  data_(i0, i1, i2) += w;
1993  else {
1994  overflow_(o0, o1, o2) += w;
1995  ++overCount_;
1996  }
1997  ++fillCount_;
1998  ++modCount_;
1999  }
2000 
2001  template <typename Numeric, class Axis>
2002  template <typename Num2, class Functor>
2003  void HistoND<Numeric, Axis>::dispatch(const double x0, const double x1, const double x2, Num2& w, Functor& f) {
2004  if (dim_ != 3U)
2005  Private::h_badargs("dispatch");
2006  unsigned i0 = 0, i1 = 0, i2 = 0;
2007  const Axis* ax = &axes_[0];
2008  const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2009  const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2010  const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2011  if (o0 == 1U && o1 == 1U && o2 == 1U)
2012  f(data_(i0, i1, i2), w);
2013  else
2014  f(overflow_(o0, o1, o2), w);
2015  ++modCount_;
2016  }
2017 
2018  template <typename Numeric, class Axis>
2019  template <typename Num2>
2020  void HistoND<Numeric, Axis>::fillC(const double x0, const double x1, const double x2, const Num2& w) {
2021  if (dim_ != 3U)
2022  Private::h_badargs("fillC");
2023  double* wg = &weightBuf_[0];
2024  unsigned* idx = &indexBuf_[0];
2025  const Axis* ax = &axes_[0];
2026  const unsigned o0 = ax[0].overflowIndexWeighted(x0, idx + 0, wg + 0);
2027  const unsigned o1 = ax[1].overflowIndexWeighted(x1, idx + 1, wg + 1);
2028  const unsigned o2 = ax[2].overflowIndexWeighted(x2, idx + 2, wg + 2);
2029  if (o0 == 1U && o1 == 1U && o2 == 1U)
2030  fillPreservingCentroid(w);
2031  else {
2032  overflow_(o0, o1, o2) += w;
2033  ++overCount_;
2034  }
2035  ++fillCount_;
2036  ++modCount_;
2037  }
2038 
2039  template <typename Numeric, class Axis>
2040  const Numeric& HistoND<Numeric, Axis>::examine(const double x0, const double x1, const double x2) const {
2041  if (dim_ != 3U)
2042  Private::h_badargs("examine");
2043  unsigned i0 = 0, i1 = 0, i2 = 0;
2044  const Axis* ax = &axes_[0];
2045  const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2046  const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2047  const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2048  if (o0 == 1U && o1 == 1U && o2 == 1U)
2049  return data_(i0, i1, i2);
2050  else
2051  return overflow_(o0, o1, o2);
2052  }
2053 
2054  template <typename Numeric, class Axis>
2055  const Numeric& HistoND<Numeric, Axis>::closestBin(const double x0, const double x1, const double x2) const {
2056  if (dim_ != 3U)
2057  Private::h_badargs("closestBin");
2058  const Axis* ax = &axes_[0];
2059  const unsigned i0 = ax[0].closestValidBin(x0);
2060  const unsigned i1 = ax[1].closestValidBin(x1);
2061  const unsigned i2 = ax[2].closestValidBin(x2);
2062  return data_(i0, i1, i2);
2063  }
2064 
2065  template <typename Numeric, class Axis>
2066  template <typename Num2>
2067  void HistoND<Numeric, Axis>::fill(const double x0, const double x1, const double x2, const double x3, const Num2& w) {
2068  if (dim_ != 4U)
2069  Private::h_badargs("fill");
2070  unsigned i0 = 0, i1 = 0, i2 = 0, i3 = 0;
2071  const Axis* ax = &axes_[0];
2072  const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2073  const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2074  const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2075  const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2076  if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U)
2077  data_(i0, i1, i2, i3) += w;
2078  else {
2079  overflow_(o0, o1, o2, o3) += w;
2080  ++overCount_;
2081  }
2082  ++fillCount_;
2083  ++modCount_;
2084  }
2085 
2086  template <typename Numeric, class Axis>
2087  template <typename Num2, class Functor>
2089  const double x0, const double x1, const double x2, const double x3, Num2& w, Functor& f) {
2090  if (dim_ != 4U)
2091  Private::h_badargs("dispatch");
2092  unsigned i0 = 0, i1 = 0, i2 = 0, i3 = 0;
2093  const Axis* ax = &axes_[0];
2094  const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2095  const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2096  const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2097  const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2098  if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U)
2099  f(data_(i0, i1, i2, i3), w);
2100  else
2101  f(overflow_(o0, o1, o2, o3), w);
2102  ++modCount_;
2103  }
2104 
2105  template <typename Numeric, class Axis>
2106  template <typename Num2>
2107  void HistoND<Numeric, Axis>::fillC(const double x0, const double x1, const double x2, const double x3, const Num2& w) {
2108  if (dim_ != 4U)
2109  Private::h_badargs("fillC");
2110  double* wg = &weightBuf_[0];
2111  unsigned* idx = &indexBuf_[0];
2112  const Axis* ax = &axes_[0];
2113  const unsigned o0 = ax[0].overflowIndexWeighted(x0, idx + 0, wg + 0);
2114  const unsigned o1 = ax[1].overflowIndexWeighted(x1, idx + 1, wg + 1);
2115  const unsigned o2 = ax[2].overflowIndexWeighted(x2, idx + 2, wg + 2);
2116  const unsigned o3 = ax[3].overflowIndexWeighted(x3, idx + 3, wg + 3);
2117  if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U)
2118  fillPreservingCentroid(w);
2119  else {
2120  overflow_(o0, o1, o2, o3) += w;
2121  ++overCount_;
2122  }
2123  ++fillCount_;
2124  ++modCount_;
2125  }
2126 
2127  template <typename Numeric, class Axis>
2128  const Numeric& HistoND<Numeric, Axis>::examine(const double x0,
2129  const double x1,
2130  const double x2,
2131  const double x3) const {
2132  if (dim_ != 4U)
2133  Private::h_badargs("examine");
2134  unsigned i0 = 0, i1 = 0, i2 = 0, i3 = 0;
2135  const Axis* ax = &axes_[0];
2136  const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2137  const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2138  const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2139  const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2140  if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U)
2141  return data_(i0, i1, i2, i3);
2142  else
2143  return overflow_(o0, o1, o2, o3);
2144  }
2145 
2146  template <typename Numeric, class Axis>
2147  const Numeric& HistoND<Numeric, Axis>::closestBin(const double x0,
2148  const double x1,
2149  const double x2,
2150  const double x3) const {
2151  if (dim_ != 4U)
2152  Private::h_badargs("closestBin");
2153  const Axis* ax = &axes_[0];
2154  const unsigned i0 = ax[0].closestValidBin(x0);
2155  const unsigned i1 = ax[1].closestValidBin(x1);
2156  const unsigned i2 = ax[2].closestValidBin(x2);
2157  const unsigned i3 = ax[3].closestValidBin(x3);
2158  return data_(i0, i1, i2, i3);
2159  }
2160 
2161  template <typename Numeric, class Axis>
2162  template <typename Num2>
2164  const double x0, const double x1, const double x2, const double x3, const double x4, const Num2& w) {
2165  if (dim_ != 5U)
2166  Private::h_badargs("fill");
2167  unsigned i0 = 0, i1 = 0, i2 = 0, i3 = 0, i4 = 0;
2168  const Axis* ax = &axes_[0];
2169  const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2170  const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2171  const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2172  const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2173  const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2174  if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U)
2175  data_(i0, i1, i2, i3, i4) += w;
2176  else {
2177  overflow_(o0, o1, o2, o3, o4) += w;
2178  ++overCount_;
2179  }
2180  ++fillCount_;
2181  ++modCount_;
2182  }
2183 
2184  template <typename Numeric, class Axis>
2185  template <typename Num2, class Functor>
2187  const double x0, const double x1, const double x2, const double x3, const double x4, Num2& w, Functor& f) {
2188  if (dim_ != 5U)
2189  Private::h_badargs("dispatch");
2190  unsigned i0 = 0, i1 = 0, i2 = 0, i3 = 0, i4 = 0;
2191  const Axis* ax = &axes_[0];
2192  const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2193  const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2194  const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2195  const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2196  const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2197  if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U)
2198  f(data_(i0, i1, i2, i3, i4), w);
2199  else
2200  f(overflow_(o0, o1, o2, o3, o4), w);
2201  ++modCount_;
2202  }
2203 
2204  template <typename Numeric, class Axis>
2205  template <typename Num2>
2207  const double x0, const double x1, const double x2, const double x3, const double x4, const Num2& w) {
2208  if (dim_ != 5U)
2209  Private::h_badargs("fillC");
2210  double* wg = &weightBuf_[0];
2211  unsigned* idx = &indexBuf_[0];
2212  const Axis* ax = &axes_[0];
2213  const unsigned o0 = ax[0].overflowIndexWeighted(x0, idx + 0, wg + 0);
2214  const unsigned o1 = ax[1].overflowIndexWeighted(x1, idx + 1, wg + 1);
2215  const unsigned o2 = ax[2].overflowIndexWeighted(x2, idx + 2, wg + 2);
2216  const unsigned o3 = ax[3].overflowIndexWeighted(x3, idx + 3, wg + 3);
2217  const unsigned o4 = ax[4].overflowIndexWeighted(x4, idx + 4, wg + 4);
2218  if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U)
2219  fillPreservingCentroid(w);
2220  else {
2221  overflow_(o0, o1, o2, o3, o4) += w;
2222  ++overCount_;
2223  }
2224  ++fillCount_;
2225  ++modCount_;
2226  }
2227 
2228  template <typename Numeric, class Axis>
2230  const double x0, const double x1, const double x2, const double x3, const double x4) const {
2231  if (dim_ != 5U)
2232  Private::h_badargs("examine");
2233  unsigned i0 = 0, i1 = 0, i2 = 0, i3 = 0, i4 = 0;
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  if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U)
2241  return data_(i0, i1, i2, i3, i4);
2242  else
2243  return overflow_(o0, o1, o2, o3, o4);
2244  }
2245 
2246  template <typename Numeric, class Axis>
2248  const double x0, const double x1, const double x2, const double x3, const double x4) const {
2249  if (dim_ != 5U)
2250  Private::h_badargs("closestBin");
2251  const Axis* ax = &axes_[0];
2252  const unsigned i0 = ax[0].closestValidBin(x0);
2253  const unsigned i1 = ax[1].closestValidBin(x1);
2254  const unsigned i2 = ax[2].closestValidBin(x2);
2255  const unsigned i3 = ax[3].closestValidBin(x3);
2256  const unsigned i4 = ax[4].closestValidBin(x4);
2257  return data_(i0, i1, i2, i3, i4);
2258  }
2259 
2260  template <typename Numeric, class Axis>
2261  template <typename Num2>
2262  void HistoND<Numeric, Axis>::fill(const double x0,
2263  const double x1,
2264  const double x2,
2265  const double x3,
2266  const double x4,
2267  const double x5,
2268  const Num2& w) {
2269  if (dim_ != 6U)
2270  Private::h_badargs("fill");
2271  unsigned i0 = 0, i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0;
2272  const Axis* ax = &axes_[0];
2273  const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2274  const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2275  const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2276  const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2277  const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2278  const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2279  if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U && o5 == 1U)
2280  data_(i0, i1, i2, i3, i4, i5) += w;
2281  else {
2282  overflow_(o0, o1, o2, o3, o4, o5) += w;
2283  ++overCount_;
2284  }
2285  ++fillCount_;
2286  ++modCount_;
2287  }
2288 
2289  template <typename Numeric, class Axis>
2290  template <typename Num2, class Functor>
2291  void HistoND<Numeric, Axis>::dispatch(const double x0,
2292  const double x1,
2293  const double x2,
2294  const double x3,
2295  const double x4,
2296  const double x5,
2297  Num2& w,
2298  Functor& f) {
2299  if (dim_ != 6U)
2300  Private::h_badargs("dispatch");
2301  unsigned i0 = 0, i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0;
2302  const Axis* ax = &axes_[0];
2303  const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2304  const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2305  const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2306  const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2307  const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2308  const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2309  if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U && o5 == 1U)
2310  f(data_(i0, i1, i2, i3, i4, i5), w);
2311  else
2312  f(overflow_(o0, o1, o2, o3, o4, o5), w);
2313  ++modCount_;
2314  }
2315 
2316  template <typename Numeric, class Axis>
2317  template <typename Num2>
2318  void HistoND<Numeric, Axis>::fillC(const double x0,
2319  const double x1,
2320  const double x2,
2321  const double x3,
2322  const double x4,
2323  const double x5,
2324  const Num2& w) {
2325  if (dim_ != 6U)
2326  Private::h_badargs("fillC");
2327  double* wg = &weightBuf_[0];
2328  unsigned* idx = &indexBuf_[0];
2329  const Axis* ax = &axes_[0];
2330  const unsigned o0 = ax[0].overflowIndexWeighted(x0, idx + 0, wg + 0);
2331  const unsigned o1 = ax[1].overflowIndexWeighted(x1, idx + 1, wg + 1);
2332  const unsigned o2 = ax[2].overflowIndexWeighted(x2, idx + 2, wg + 2);
2333  const unsigned o3 = ax[3].overflowIndexWeighted(x3, idx + 3, wg + 3);
2334  const unsigned o4 = ax[4].overflowIndexWeighted(x4, idx + 4, wg + 4);
2335  const unsigned o5 = ax[5].overflowIndexWeighted(x5, idx + 5, wg + 5);
2336  if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U && o5 == 1U)
2337  fillPreservingCentroid(w);
2338  else {
2339  overflow_(o0, o1, o2, o3, o4, o5) += w;
2340  ++overCount_;
2341  }
2342  ++fillCount_;
2343  ++modCount_;
2344  }
2345 
2346  template <typename Numeric, class Axis>
2348  const double x0, const double x1, const double x2, const double x3, const double x4, const double x5) const {
2349  if (dim_ != 6U)
2350  Private::h_badargs("examine");
2351  unsigned i0 = 0, i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0;
2352  const Axis* ax = &axes_[0];
2353  const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2354  const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2355  const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2356  const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2357  const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2358  const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2359  if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U && o5 == 1U)
2360  return data_(i0, i1, i2, i3, i4, i5);
2361  else
2362  return overflow_(o0, o1, o2, o3, o4, o5);
2363  }
2364 
2365  template <typename Numeric, class Axis>
2367  const double x0, const double x1, const double x2, const double x3, const double x4, const double x5) const {
2368  if (dim_ != 6U)
2369  Private::h_badargs("closestBin");
2370  const Axis* ax = &axes_[0];
2371  const unsigned i0 = ax[0].closestValidBin(x0);
2372  const unsigned i1 = ax[1].closestValidBin(x1);
2373  const unsigned i2 = ax[2].closestValidBin(x2);
2374  const unsigned i3 = ax[3].closestValidBin(x3);
2375  const unsigned i4 = ax[4].closestValidBin(x4);
2376  const unsigned i5 = ax[5].closestValidBin(x5);
2377  return data_(i0, i1, i2, i3, i4, i5);
2378  }
2379 
2380  template <typename Numeric, class Axis>
2381  template <typename Num2>
2382  void HistoND<Numeric, Axis>::fill(const double x0,
2383  const double x1,
2384  const double x2,
2385  const double x3,
2386  const double x4,
2387  const double x5,
2388  const double x6,
2389  const Num2& w) {
2390  if (dim_ != 7U)
2391  Private::h_badargs("fill");
2392  unsigned i0 = 0, i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0;
2393  const Axis* ax = &axes_[0];
2394  const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2395  const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2396  const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2397  const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2398  const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2399  const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2400  const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2401  if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U && o5 == 1U && o6 == 1U)
2402  data_(i0, i1, i2, i3, i4, i5, i6) += w;
2403  else {
2404  overflow_(o0, o1, o2, o3, o4, o5, o6) += w;
2405  ++overCount_;
2406  }
2407  ++fillCount_;
2408  ++modCount_;
2409  }
2410 
2411  template <typename Numeric, class Axis>
2412  template <typename Num2, class Functor>
2413  void HistoND<Numeric, Axis>::dispatch(const double x0,
2414  const double x1,
2415  const double x2,
2416  const double x3,
2417  const double x4,
2418  const double x5,
2419  const double x6,
2420  Num2& w,
2421  Functor& f) {
2422  if (dim_ != 7U)
2423  Private::h_badargs("dispatch");
2424  unsigned i0 = 0, i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0;
2425  const Axis* ax = &axes_[0];
2426  const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2427  const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2428  const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2429  const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2430  const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2431  const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2432  const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2433  if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U && o5 == 1U && o6 == 1U)
2434  f(data_(i0, i1, i2, i3, i4, i5, i6), w);
2435  else
2436  f(overflow_(o0, o1, o2, o3, o4, o5, o6), w);
2437  ++modCount_;
2438  }
2439 
2440  template <typename Numeric, class Axis>
2441  template <typename Num2>
2442  void HistoND<Numeric, Axis>::fillC(const double x0,
2443  const double x1,
2444  const double x2,
2445  const double x3,
2446  const double x4,
2447  const double x5,
2448  const double x6,
2449  const Num2& w) {
2450  if (dim_ != 7U)
2451  Private::h_badargs("fillC");
2452  double* wg = &weightBuf_[0];
2453  unsigned* idx = &indexBuf_[0];
2454  const Axis* ax = &axes_[0];
2455  const unsigned o0 = ax[0].overflowIndexWeighted(x0, idx + 0, wg + 0);
2456  const unsigned o1 = ax[1].overflowIndexWeighted(x1, idx + 1, wg + 1);
2457  const unsigned o2 = ax[2].overflowIndexWeighted(x2, idx + 2, wg + 2);
2458  const unsigned o3 = ax[3].overflowIndexWeighted(x3, idx + 3, wg + 3);
2459  const unsigned o4 = ax[4].overflowIndexWeighted(x4, idx + 4, wg + 4);
2460  const unsigned o5 = ax[5].overflowIndexWeighted(x5, idx + 5, wg + 5);
2461  const unsigned o6 = ax[6].overflowIndexWeighted(x6, idx + 6, wg + 6);
2462  if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U && o5 == 1U && o6 == 1U)
2463  fillPreservingCentroid(w);
2464  else {
2465  overflow_(o0, o1, o2, o3, o4, o5, o6) += w;
2466  ++overCount_;
2467  }
2468  ++fillCount_;
2469  ++modCount_;
2470  }
2471 
2472  template <typename Numeric, class Axis>
2473  const Numeric& HistoND<Numeric, Axis>::examine(const double x0,
2474  const double x1,
2475  const double x2,
2476  const double x3,
2477  const double x4,
2478  const double x5,
2479  const double x6) const {
2480  if (dim_ != 7U)
2481  Private::h_badargs("examine");
2482  unsigned i0 = 0, i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0;
2483  const Axis* ax = &axes_[0];
2484  const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2485  const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2486  const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2487  const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2488  const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2489  const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2490  const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2491  if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U && o5 == 1U && o6 == 1U)
2492  return data_(i0, i1, i2, i3, i4, i5, i6);
2493  else
2494  return overflow_(o0, o1, o2, o3, o4, o5, o6);
2495  }
2496 
2497  template <typename Numeric, class Axis>
2498  const Numeric& HistoND<Numeric, Axis>::closestBin(const double x0,
2499  const double x1,
2500  const double x2,
2501  const double x3,
2502  const double x4,
2503  const double x5,
2504  const double x6) const {
2505  if (dim_ != 7U)
2506  Private::h_badargs("closestBin");
2507  const Axis* ax = &axes_[0];
2508  const unsigned i0 = ax[0].closestValidBin(x0);
2509  const unsigned i1 = ax[1].closestValidBin(x1);
2510  const unsigned i2 = ax[2].closestValidBin(x2);
2511  const unsigned i3 = ax[3].closestValidBin(x3);
2512  const unsigned i4 = ax[4].closestValidBin(x4);
2513  const unsigned i5 = ax[5].closestValidBin(x5);
2514  const unsigned i6 = ax[6].closestValidBin(x6);
2515  return data_(i0, i1, i2, i3, i4, i5, i6);
2516  }
2517 
2518  template <typename Numeric, class Axis>
2519  template <typename Num2>
2520  void HistoND<Numeric, Axis>::fill(const double x0,
2521  const double x1,
2522  const double x2,
2523  const double x3,
2524  const double x4,
2525  const double x5,
2526  const double x6,
2527  const double x7,
2528  const Num2& w) {
2529  if (dim_ != 8U)
2530  Private::h_badargs("fill");
2531  unsigned i0 = 0, i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0;
2532  const Axis* ax = &axes_[0];
2533  const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2534  const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2535  const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2536  const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2537  const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2538  const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2539  const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2540  const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2541  if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U && o5 == 1U && o6 == 1U && o7 == 1U)
2542  data_(i0, i1, i2, i3, i4, i5, i6, i7) += w;
2543  else {
2544  overflow_(o0, o1, o2, o3, o4, o5, o6, o7) += w;
2545  ++overCount_;
2546  }
2547  ++fillCount_;
2548  ++modCount_;
2549  }
2550 
2551  template <typename Numeric, class Axis>
2552  template <typename Num2, class Functor>
2553  void HistoND<Numeric, Axis>::dispatch(const double x0,
2554  const double x1,
2555  const double x2,
2556  const double x3,
2557  const double x4,
2558  const double x5,
2559  const double x6,
2560  const double x7,
2561  Num2& w,
2562  Functor& f) {
2563  if (dim_ != 8U)
2564  Private::h_badargs("dispatch");
2565  unsigned i0 = 0, i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0;
2566  const Axis* ax = &axes_[0];
2567  const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2568  const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2569  const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2570  const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2571  const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2572  const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2573  const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2574  const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2575  if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U && o5 == 1U && o6 == 1U && o7 == 1U)
2576  f(data_(i0, i1, i2, i3, i4, i5, i6, i7), w);
2577  else
2578  f(overflow_(o0, o1, o2, o3, o4, o5, o6, o7), w);
2579  ++modCount_;
2580  }
2581 
2582  template <typename Numeric, class Axis>
2583  template <typename Num2>
2584  void HistoND<Numeric, Axis>::fillC(const double x0,
2585  const double x1,
2586  const double x2,
2587  const double x3,
2588  const double x4,
2589  const double x5,
2590  const double x6,
2591  const double x7,
2592  const Num2& w) {
2593  if (dim_ != 8U)
2594  Private::h_badargs("fillC");
2595  double* wg = &weightBuf_[0];
2596  unsigned* idx = &indexBuf_[0];
2597  const Axis* ax = &axes_[0];
2598  const unsigned o0 = ax[0].overflowIndexWeighted(x0, idx + 0, wg + 0);
2599  const unsigned o1 = ax[1].overflowIndexWeighted(x1, idx + 1, wg + 1);
2600  const unsigned o2 = ax[2].overflowIndexWeighted(x2, idx + 2, wg + 2);
2601  const unsigned o3 = ax[3].overflowIndexWeighted(x3, idx + 3, wg + 3);
2602  const unsigned o4 = ax[4].overflowIndexWeighted(x4, idx + 4, wg + 4);
2603  const unsigned o5 = ax[5].overflowIndexWeighted(x5, idx + 5, wg + 5);
2604  const unsigned o6 = ax[6].overflowIndexWeighted(x6, idx + 6, wg + 6);
2605  const unsigned o7 = ax[7].overflowIndexWeighted(x7, idx + 7, wg + 7);
2606  if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U && o5 == 1U && o6 == 1U && o7 == 1U)
2607  fillPreservingCentroid(w);
2608  else {
2609  overflow_(o0, o1, o2, o3, o4, o5, o6, o7) += w;
2610  ++overCount_;
2611  }
2612  ++fillCount_;
2613  ++modCount_;
2614  }
2615 
2616  template <typename Numeric, class Axis>
2617  const Numeric& HistoND<Numeric, Axis>::examine(const double x0,
2618  const double x1,
2619  const double x2,
2620  const double x3,
2621  const double x4,
2622  const double x5,
2623  const double x6,
2624  const double x7) const {
2625  if (dim_ != 8U)
2626  Private::h_badargs("examine");
2627  unsigned i0 = 0, i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0;
2628  const Axis* ax = &axes_[0];
2629  const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2630  const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2631  const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2632  const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2633  const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2634  const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2635  const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2636  const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2637  if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U && o5 == 1U && o6 == 1U && o7 == 1U)
2638  return data_(i0, i1, i2, i3, i4, i5, i6, i7);
2639  else
2640  return overflow_(o0, o1, o2, o3, o4, o5, o6, o7);
2641  }
2642 
2643  template <typename Numeric, class Axis>
2644  const Numeric& HistoND<Numeric, Axis>::closestBin(const double x0,
2645  const double x1,
2646  const double x2,
2647  const double x3,
2648  const double x4,
2649  const double x5,
2650  const double x6,
2651  const double x7) const {
2652  if (dim_ != 8U)
2653  Private::h_badargs("closestBin");
2654  const Axis* ax = &axes_[0];
2655  const unsigned i0 = ax[0].closestValidBin(x0);
2656  const unsigned i1 = ax[1].closestValidBin(x1);
2657  const unsigned i2 = ax[2].closestValidBin(x2);
2658  const unsigned i3 = ax[3].closestValidBin(x3);
2659  const unsigned i4 = ax[4].closestValidBin(x4);
2660  const unsigned i5 = ax[5].closestValidBin(x5);
2661  const unsigned i6 = ax[6].closestValidBin(x6);
2662  const unsigned i7 = ax[7].closestValidBin(x7);
2663  return data_(i0, i1, i2, i3, i4, i5, i6, i7);
2664  }
2665 
2666  template <typename Numeric, class Axis>
2667  template <typename Num2>
2668  void HistoND<Numeric, Axis>::fill(const double x0,
2669  const double x1,
2670  const double x2,
2671  const double x3,
2672  const double x4,
2673  const double x5,
2674  const double x6,
2675  const double x7,
2676  const double x8,
2677  const Num2& w) {
2678  if (dim_ != 9U)
2679  Private::h_badargs("fill");
2680  unsigned i0 = 0, i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0;
2681  const Axis* ax = &axes_[0];
2682  const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2683  const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2684  const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2685  const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2686  const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2687  const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2688  const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2689  const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2690  const unsigned o8 = ax[8].overflowIndex(x8, &i8);
2691  if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U && o5 == 1U && o6 == 1U && o7 == 1U && o8 == 1U)
2692  data_(i0, i1, i2, i3, i4, i5, i6, i7, i8) += w;
2693  else {
2694  overflow_(o0, o1, o2, o3, o4, o5, o6, o7, o8) += w;
2695  ++overCount_;
2696  }
2697  ++fillCount_;
2698  ++modCount_;
2699  }
2700 
2701  template <typename Numeric, class Axis>
2702  template <typename Num2, class Functor>
2703  void HistoND<Numeric, Axis>::dispatch(const double x0,
2704  const double x1,
2705  const double x2,
2706  const double x3,
2707  const double x4,
2708  const double x5,
2709  const double x6,
2710  const double x7,
2711  const double x8,
2712  Num2& w,
2713  Functor& f) {
2714  if (dim_ != 9U)
2715  Private::h_badargs("dispatch");
2716  unsigned i0 = 0, i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0;
2717  const Axis* ax = &axes_[0];
2718  const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2719  const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2720  const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2721  const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2722  const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2723  const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2724  const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2725  const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2726  const unsigned o8 = ax[8].overflowIndex(x8, &i8);
2727  if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U && o5 == 1U && o6 == 1U && o7 == 1U && o8 == 1U)
2728  f(data_(i0, i1, i2, i3, i4, i5, i6, i7, i8), w);
2729  else
2730  f(overflow_(o0, o1, o2, o3, o4, o5, o6, o7, o8), w);
2731  ++modCount_;
2732  }
2733 
2734  template <typename Numeric, class Axis>
2735  template <typename Num2>
2736  void HistoND<Numeric, Axis>::fillC(const double x0,
2737  const double x1,
2738  const double x2,
2739  const double x3,
2740  const double x4,
2741  const double x5,
2742  const double x6,
2743  const double x7,
2744  const double x8,
2745  const Num2& w) {
2746  if (dim_ != 9U)
2747  Private::h_badargs("fillC");
2748  double* wg = &weightBuf_[0];
2749  unsigned* idx = &indexBuf_[0];
2750  const Axis* ax = &axes_[0];
2751  const unsigned o0 = ax[0].overflowIndexWeighted(x0, idx + 0, wg + 0);
2752  const unsigned o1 = ax[1].overflowIndexWeighted(x1, idx + 1, wg + 1);
2753  const unsigned o2 = ax[2].overflowIndexWeighted(x2, idx + 2, wg + 2);
2754  const unsigned o3 = ax[3].overflowIndexWeighted(x3, idx + 3, wg + 3);
2755  const unsigned o4 = ax[4].overflowIndexWeighted(x4, idx + 4, wg + 4);
2756  const unsigned o5 = ax[5].overflowIndexWeighted(x5, idx + 5, wg + 5);
2757  const unsigned o6 = ax[6].overflowIndexWeighted(x6, idx + 6, wg + 6);
2758  const unsigned o7 = ax[7].overflowIndexWeighted(x7, idx + 7, wg + 7);
2759  const unsigned o8 = ax[8].overflowIndexWeighted(x8, idx + 8, wg + 8);
2760  if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U && o5 == 1U && o6 == 1U && o7 == 1U && o8 == 1U)
2761  fillPreservingCentroid(w);
2762  else {
2763  overflow_(o0, o1, o2, o3, o4, o5, o6, o7, o8) += w;
2764  ++overCount_;
2765  }
2766  ++fillCount_;
2767  ++modCount_;
2768  }
2769 
2770  template <typename Numeric, class Axis>
2771  const Numeric& HistoND<Numeric, Axis>::examine(const double x0,
2772  const double x1,
2773  const double x2,
2774  const double x3,
2775  const double x4,
2776  const double x5,
2777  const double x6,
2778  const double x7,
2779  const double x8) const {
2780  if (dim_ != 9U)
2781  Private::h_badargs("examine");
2782  unsigned i0 = 0, i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0;
2783  const Axis* ax = &axes_[0];
2784  const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2785  const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2786  const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2787  const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2788  const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2789  const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2790  const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2791  const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2792  const unsigned o8 = ax[8].overflowIndex(x8, &i8);
2793  if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U && o5 == 1U && o6 == 1U && o7 == 1U && o8 == 1U)
2794  return data_(i0, i1, i2, i3, i4, i5, i6, i7, i8);
2795  else
2796  return overflow_(o0, o1, o2, o3, o4, o5, o6, o7, o8);
2797  }
2798 
2799  template <typename Numeric, class Axis>
2800  const Numeric& HistoND<Numeric, Axis>::closestBin(const double x0,
2801  const double x1,
2802  const double x2,
2803  const double x3,
2804  const double x4,
2805  const double x5,
2806  const double x6,
2807  const double x7,
2808  const double x8) const {
2809  if (dim_ != 9U)
2810  Private::h_badargs("closestBin");
2811  const Axis* ax = &axes_[0];
2812  const unsigned i0 = ax[0].closestValidBin(x0);
2813  const unsigned i1 = ax[1].closestValidBin(x1);
2814  const unsigned i2 = ax[2].closestValidBin(x2);
2815  const unsigned i3 = ax[3].closestValidBin(x3);
2816  const unsigned i4 = ax[4].closestValidBin(x4);
2817  const unsigned i5 = ax[5].closestValidBin(x5);
2818  const unsigned i6 = ax[6].closestValidBin(x6);
2819  const unsigned i7 = ax[7].closestValidBin(x7);
2820  const unsigned i8 = ax[8].closestValidBin(x8);
2821  return data_(i0, i1, i2, i3, i4, i5, i6, i7, i8);
2822  }
2823 
2824  template <typename Numeric, class Axis>
2825  template <typename Num2>
2826  void HistoND<Numeric, Axis>::fill(const double x0,
2827  const double x1,
2828  const double x2,
2829  const double x3,
2830  const double x4,
2831  const double x5,
2832  const double x6,
2833  const double x7,
2834  const double x8,
2835  const double x9,
2836  const Num2& w) {
2837  if (dim_ != 10U)
2838  Private::h_badargs("fill");
2839  unsigned i0 = 0, i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0;
2840  const Axis* ax = &axes_[0];
2841  const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2842  const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2843  const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2844  const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2845  const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2846  const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2847  const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2848  const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2849  const unsigned o8 = ax[8].overflowIndex(x8, &i8);
2850  const unsigned o9 = ax[9].overflowIndex(x9, &i9);
2851  if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U && o5 == 1U && o6 == 1U && o7 == 1U && o8 == 1U &&
2852  o9 == 1U)
2853  data_(i0, i1, i2, i3, i4, i5, i6, i7, i8, i9) += w;
2854  else {
2855  overflow_(o0, o1, o2, o3, o4, o5, o6, o7, o8, o9) += w;
2856  ++overCount_;
2857  }
2858  ++fillCount_;
2859  ++modCount_;
2860  }
2861 
2862  template <typename Numeric, class Axis>
2863  template <typename Num2, class Functor>
2864  void HistoND<Numeric, Axis>::dispatch(const double x0,
2865  const double x1,
2866  const double x2,
2867  const double x3,
2868  const double x4,
2869  const double x5,
2870  const double x6,
2871  const double x7,
2872  const double x8,
2873  const double x9,
2874  Num2& w,
2875  Functor& f) {
2876  if (dim_ != 10U)
2877  Private::h_badargs("dispatch");
2878  unsigned i0 = 0, i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0;
2879  const Axis* ax = &axes_[0];
2880  const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2881  const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2882  const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2883  const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2884  const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2885  const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2886  const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2887  const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2888  const unsigned o8 = ax[8].overflowIndex(x8, &i8);
2889  const unsigned o9 = ax[9].overflowIndex(x9, &i9);
2890  if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U && o5 == 1U && o6 == 1U && o7 == 1U && o8 == 1U &&
2891  o9 == 1U)
2892  f(data_(i0, i1, i2, i3, i4, i5, i6, i7, i8, i9), w);
2893  else
2894  f(overflow_(o0, o1, o2, o3, o4, o5, o6, o7, o8, o9), w);
2895  ++modCount_;
2896  }
2897 
2898  template <typename Numeric, class Axis>
2899  template <typename Num2>
2900  void HistoND<Numeric, Axis>::fillC(const double x0,
2901  const double x1,
2902  const double x2,
2903  const double x3,
2904  const double x4,
2905  const double x5,
2906  const double x6,
2907  const double x7,
2908  const double x8,
2909  const double x9,
2910  const Num2& w) {
2911  if (dim_ != 10U)
2912  Private::h_badargs("fillC");
2913  double* wg = &weightBuf_[0];
2914  unsigned* idx = &indexBuf_[0];
2915  const Axis* ax = &axes_[0];
2916  const unsigned o0 = ax[0].overflowIndexWeighted(x0, idx + 0, wg + 0);
2917  const unsigned o1 = ax[1].overflowIndexWeighted(x1, idx + 1, wg + 1);
2918  const unsigned o2 = ax[2].overflowIndexWeighted(x2, idx + 2, wg + 2);
2919  const unsigned o3 = ax[3].overflowIndexWeighted(x3, idx + 3, wg + 3);
2920  const unsigned o4 = ax[4].overflowIndexWeighted(x4, idx + 4, wg + 4);
2921  const unsigned o5 = ax[5].overflowIndexWeighted(x5, idx + 5, wg + 5);
2922  const unsigned o6 = ax[6].overflowIndexWeighted(x6, idx + 6, wg + 6);
2923  const unsigned o7 = ax[7].overflowIndexWeighted(x7, idx + 7, wg + 7);
2924  const unsigned o8 = ax[8].overflowIndexWeighted(x8, idx + 8, wg + 8);
2925  const unsigned o9 = ax[9].overflowIndexWeighted(x9, idx + 9, wg + 9);
2926  if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U && o5 == 1U && o6 == 1U && o7 == 1U && o8 == 1U &&
2927  o9 == 1U)
2928  fillPreservingCentroid(w);
2929  else {
2930  overflow_(o0, o1, o2, o3, o4, o5, o6, o7, o8, o9) += w;
2931  ++overCount_;
2932  }
2933  ++fillCount_;
2934  ++modCount_;
2935  }
2936 
2937  template <typename Numeric, class Axis>
2938  const Numeric& HistoND<Numeric, Axis>::examine(const double x0,
2939  const double x1,
2940  const double x2,
2941  const double x3,
2942  const double x4,
2943  const double x5,
2944  const double x6,
2945  const double x7,
2946  const double x8,
2947  const double x9) const {
2948  if (dim_ != 10U)
2949  Private::h_badargs("examine");
2950  unsigned i0 = 0, i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0;
2951  const Axis* ax = &axes_[0];
2952  const unsigned o0 = ax[0].overflowIndex(x0, &i0);
2953  const unsigned o1 = ax[1].overflowIndex(x1, &i1);
2954  const unsigned o2 = ax[2].overflowIndex(x2, &i2);
2955  const unsigned o3 = ax[3].overflowIndex(x3, &i3);
2956  const unsigned o4 = ax[4].overflowIndex(x4, &i4);
2957  const unsigned o5 = ax[5].overflowIndex(x5, &i5);
2958  const unsigned o6 = ax[6].overflowIndex(x6, &i6);
2959  const unsigned o7 = ax[7].overflowIndex(x7, &i7);
2960  const unsigned o8 = ax[8].overflowIndex(x8, &i8);
2961  const unsigned o9 = ax[9].overflowIndex(x9, &i9);
2962  if (o0 == 1U && o1 == 1U && o2 == 1U && o3 == 1U && o4 == 1U && o5 == 1U && o6 == 1U && o7 == 1U && o8 == 1U &&
2963  o9 == 1U)
2964  return data_(i0, i1, i2, i3, i4, i5, i6, i7, i8, i9);
2965  else
2966  return overflow_(o0, o1, o2, o3, o4, o5, o6, o7, o8, o9);
2967  }
2968 
2969  template <typename Numeric, class Axis>
2970  const Numeric& HistoND<Numeric, Axis>::closestBin(const double x0,
2971  const double x1,
2972  const double x2,
2973  const double x3,
2974  const double x4,
2975  const double x5,
2976  const double x6,
2977  const double x7,
2978  const double x8,
2979  const double x9) const {
2980  if (dim_ != 10U)
2981  Private::h_badargs("closestBin");
2982  const Axis* ax = &axes_[0];
2983  const unsigned i0 = ax[0].closestValidBin(x0);
2984  const unsigned i1 = ax[1].closestValidBin(x1);
2985  const unsigned i2 = ax[2].closestValidBin(x2);
2986  const unsigned i3 = ax[3].closestValidBin(x3);
2987  const unsigned i4 = ax[4].closestValidBin(x4);
2988  const unsigned i5 = ax[5].closestValidBin(x5);
2989  const unsigned i6 = ax[6].closestValidBin(x6);
2990  const unsigned i7 = ax[7].closestValidBin(x7);
2991  const unsigned i8 = ax[8].closestValidBin(x8);
2992  const unsigned i9 = ax[9].closestValidBin(x9);
2993  return data_(i0, i1, i2, i3, i4, i5, i6, i7, i8, i9);
2994  }
2995 
2996  template <typename Numeric, class Axis>
2997  template <typename Num2>
2998  inline void HistoND<Numeric, Axis>::setBin(const unsigned* index, const unsigned indexLen, const Num2& v) {
2999  data_.value(index, indexLen) = v;
3000  ++modCount_;
3001  }
3002 
3003  template <typename Numeric, class Axis>
3004  template <typename Num2>
3005  inline void HistoND<Numeric, Axis>::setBinAt(const unsigned* index, const unsigned indexLen, const Num2& v) {
3006  data_.valueAt(index, indexLen) = v;
3007  ++modCount_;
3008  }
3009 
3010  template <typename Numeric, class Axis>
3011  template <typename Num2>
3012  inline void HistoND<Numeric, Axis>::setBin(const Num2& v) {
3013  data_() = v;
3014  ++modCount_;
3015  }
3016 
3017  template <typename Numeric, class Axis>
3018  template <typename Num2>
3019  inline void HistoND<Numeric, Axis>::setBinAt(const Num2& v) {
3020  data_.at() = v;
3021  ++modCount_;
3022  }
3023 
3024  template <typename Numeric, class Axis>
3025  template <typename Num2>
3026  inline void HistoND<Numeric, Axis>::setBin(const unsigned i0, const Num2& v) {
3027  data_(i0) = v;
3028  ++modCount_;
3029  }
3030 
3031  template <typename Numeric, class Axis>
3032  template <typename Num2>
3033  inline void HistoND<Numeric, Axis>::setBinAt(const unsigned i0, const Num2& v) {
3034  data_.at(i0) = v;
3035  ++modCount_;
3036  }
3037 
3038  template <typename Numeric, class Axis>
3039  template <typename Num2>
3040  inline void HistoND<Numeric, Axis>::setBin(const unsigned i0, const unsigned i1, const Num2& v) {
3041  data_(i0, i1) = v;
3042  ++modCount_;
3043  }
3044 
3045  template <typename Numeric, class Axis>
3046  template <typename Num2>
3047  inline void HistoND<Numeric, Axis>::setBinAt(const unsigned i0, const unsigned i1, const Num2& v) {
3048  data_.at(i0, i1) = v;
3049  ++modCount_;
3050  }
3051 
3052  template <typename Numeric, class Axis>
3053  template <typename Num2>
3054  inline void HistoND<Numeric, Axis>::setBin(const unsigned i0, const unsigned i1, const unsigned i2, const Num2& v) {
3055  data_(i0, i1, i2) = v;
3056  ++modCount_;
3057  }
3058 
3059  template <typename Numeric, class Axis>
3060  template <typename Num2>
3062  const unsigned i0, const unsigned i1, const unsigned i2, const unsigned i3, const Num2& v) {
3063  data_(i0, i1, i2, i3) = v;
3064  ++modCount_;
3065  }
3066 
3067  template <typename Numeric, class Axis>
3068  template <typename Num2>
3070  const unsigned i0, const unsigned i1, const unsigned i2, const unsigned i3, const unsigned i4, const Num2& v) {
3071  data_(i0, i1, i2, i3, i4) = v;
3072  ++modCount_;
3073  }
3074 
3075  template <typename Numeric, class Axis>
3076  template <typename Num2>
3077  inline void HistoND<Numeric, Axis>::setBin(const unsigned i0,
3078  const unsigned i1,
3079  const unsigned i2,
3080  const unsigned i3,
3081  const unsigned i4,
3082  const unsigned i5,
3083  const Num2& v) {
3084  data_(i0, i1, i2, i3, i4, i5) = v;
3085  ++modCount_;
3086  }
3087 
3088  template <typename Numeric, class Axis>
3089  template <typename Num2>
3090  inline void HistoND<Numeric, Axis>::setBin(const unsigned i0,
3091  const unsigned i1,
3092  const unsigned i2,
3093  const unsigned i3,
3094  const unsigned i4,
3095  const unsigned i5,
3096  const unsigned i6,
3097  const Num2& v) {
3098  data_(i0, i1, i2, i3, i4, i5, i6) = v;
3099  ++modCount_;
3100  }
3101 
3102  template <typename Numeric, class Axis>
3103  template <typename Num2>
3104  inline void HistoND<Numeric, Axis>::setBin(const unsigned i0,
3105  const unsigned i1,
3106  const unsigned i2,
3107  const unsigned i3,
3108  const unsigned i4,
3109  const unsigned i5,
3110  const unsigned i6,
3111  const unsigned i7,
3112  const Num2& v) {
3113  data_(i0, i1, i2, i3, i4, i5, i6, i7) = v;
3114  ++modCount_;
3115  }
3116 
3117  template <typename Numeric, class Axis>
3118  template <typename Num2>
3119  inline void HistoND<Numeric, Axis>::setBin(const unsigned i0,
3120  const unsigned i1,
3121  const unsigned i2,
3122  const unsigned i3,
3123  const unsigned i4,
3124  const unsigned i5,
3125  const unsigned i6,
3126  const unsigned i7,
3127  const unsigned i8,
3128  const Num2& v) {
3129  data_(i0, i1, i2, i3, i4, i5, i6, i7, i8) = v;
3130  ++modCount_;
3131  }
3132 
3133  template <typename Numeric, class Axis>
3134  template <typename Num2>
3135  inline void HistoND<Numeric, Axis>::setBin(const unsigned i0,
3136  const unsigned i1,
3137  const unsigned i2,
3138  const unsigned i3,
3139  const unsigned i4,
3140  const unsigned i5,
3141  const unsigned i6,
3142  const unsigned i7,
3143  const unsigned i8,
3144  const unsigned i9,
3145  const Num2& v) {
3146  data_(i0, i1, i2, i3, i4, i5, i6, i7, i8, i9) = v;
3147  ++modCount_;
3148  }
3149 
3150  template <typename Numeric, class Axis>
3151  template <typename Num2>
3152  inline void HistoND<Numeric, Axis>::setBinAt(const unsigned i0, const unsigned i1, const unsigned i2, const Num2& v) {
3153  data_.at(i0, i1, i2) = v;
3154  ++modCount_;
3155  }
3156 
3157  template <typename Numeric, class Axis>
3158  template <typename Num2>
3160  const unsigned i0, const unsigned i1, const unsigned i2, const unsigned i3, const Num2& v) {
3161  data_.at(i0, i1, i2, i3) = v;
3162  ++modCount_;
3163  }
3164 
3165  template <typename Numeric, class Axis>
3166  template <typename Num2>
3168  const unsigned i0, const unsigned i1, const unsigned i2, const unsigned i3, const unsigned i4, const Num2& v) {
3169  data_.at(i0, i1, i2, i3, i4) = v;
3170  ++modCount_;
3171  }
3172 
3173  template <typename Numeric, class Axis>
3174  template <typename Num2>
3175  inline void HistoND<Numeric, Axis>::setBinAt(const unsigned i0,
3176  const unsigned i1,
3177  const unsigned i2,
3178  const unsigned i3,
3179  const unsigned i4,
3180  const unsigned i5,
3181  const Num2& v) {
3182  data_.at(i0, i1, i2, i3, i4, i5) = v;
3183  ++modCount_;
3184  }
3185 
3186  template <typename Numeric, class Axis>
3187  template <typename Num2>
3188  inline void HistoND<Numeric, Axis>::setBinAt(const unsigned i0,
3189  const unsigned i1,
3190  const unsigned i2,
3191  const unsigned i3,
3192  const unsigned i4,
3193  const unsigned i5,
3194  const unsigned i6,
3195  const Num2& v) {
3196  data_.at(i0, i1, i2, i3, i4, i5, i6) = v;
3197  ++modCount_;
3198  }
3199 
3200  template <typename Numeric, class Axis>
3201  template <typename Num2>
3202  inline void HistoND<Numeric, Axis>::setBinAt(const unsigned i0,
3203  const unsigned i1,
3204  const unsigned i2,
3205  const unsigned i3,
3206  const unsigned i4,
3207  const unsigned i5,
3208  const unsigned i6,
3209  const unsigned i7,
3210  const Num2& v) {
3211  data_.at(i0, i1, i2, i3, i4, i5, i6, i7) = v;
3212  ++modCount_;
3213  }
3214 
3215  template <typename Numeric, class Axis>
3216  template <typename Num2>
3217  inline void HistoND<Numeric, Axis>::setBinAt(const unsigned i0,
3218  const unsigned i1,
3219  const unsigned i2,
3220  const unsigned i3,
3221  const unsigned i4,
3222  const unsigned i5,
3223  const unsigned i6,
3224  const unsigned i7,
3225  const unsigned i8,
3226  const Num2& v) {
3227  data_.at(i0, i1, i2, i3, i4, i5, i6, i7, i8) = v;
3228  ++modCount_;
3229  }
3230 
3231  template <typename Numeric, class Axis>
3232  template <typename Num2>
3233  inline void HistoND<Numeric, Axis>::setBinAt(const unsigned i0,
3234  const unsigned i1,
3235  const unsigned i2,
3236  const unsigned i3,
3237  const unsigned i4,
3238  const unsigned i5,
3239  const unsigned i6,
3240  const unsigned i7,
3241  const unsigned i8,
3242  const unsigned i9,
3243  const Num2& v) {
3244  data_.at(i0, i1, i2, i3, i4, i5, i6, i7, i8, i9) = v;
3245  ++modCount_;
3246  }
3247 
3248  template <typename Numeric, class Axis>
3249  template <typename Num2>
3251  data_ += r.data_;
3252  overflow_ += r.overflow_;
3253  fillCount_ += r.fillCount_;
3254  overCount_ += r.overCount_;
3255  ++modCount_;
3256  return *this;
3257  }
3258 
3259  template <typename Numeric, class Axis>
3260  template <typename Num2>
3262  data_ -= r.data_;
3263  overflow_ -= r.overflow_;
3264 
3265  // Subtraction does not make much sense for fill counts.
3266  // We will assume that what we want should be equivalent
3267  // to the in-place multiplication of the other histogram
3268  // by -1 and then adding.
3269  //
3270  fillCount_ += r.fillCount_;
3271  overCount_ += r.overCount_;
3272 
3273  ++modCount_;
3274  return *this;
3275  }
3276 
3277  template <typename Numeric, class Axis>
3278  template <typename Num2>
3280  data_ *= r;
3281  overflow_ *= r;
3282  ++modCount_;
3283  return *this;
3284  }
3285 
3286  template <typename Numeric, class Axis>
3287  template <typename Num2>
3289  data_ /= r;
3290  overflow_ /= r;
3291  ++modCount_;
3292  return *this;
3293  }
3294 
3295  template <typename Numeric, class Axis>
3296  HistoND<Numeric, Axis>::HistoND(const HistoND& r, const unsigned ax1, const unsigned ax2)
3297  : title_(r.title_),
3298  accumulatedDataLabel_(r.accumulatedDataLabel_),
3299  data_(r.data_.transpose(ax1, ax2)),
3300  overflow_(r.overflow_.transpose(ax1, ax2)),
3301  axes_(r.axes_),
3302  weightBuf_(r.weightBuf_),
3303  indexBuf_(r.indexBuf_),
3304  fillCount_(r.fillCount_),
3305  overCount_(r.overCount_),
3306  modCount_(0UL),
3307  dim_(r.dim_) {
3308  std::swap(axes_[ax1], axes_[ax2]);
3309  }
3310 
3311  template <typename Numeric, class Axis>
3313  : title_(r.title_),
3314  accumulatedDataLabel_(r.accumulatedDataLabel_),
3315  data_(r.data_),
3316  overflow_(r.overflow_),
3317  axes_(r.axes_),
3318  weightBuf_(r.weightBuf_),
3319  indexBuf_(r.indexBuf_),
3320  fillCount_(r.fillCount_),
3321  overCount_(r.overCount_),
3322  modCount_(0UL),
3323  dim_(r.dim_) {}
3324 
3325  template <typename Numeric, class Axis>
3327  if (&r != this) {
3328  title_ = r.title_;
3329  accumulatedDataLabel_ = r.accumulatedDataLabel_;
3330  data_.uninitialize();
3331  data_ = r.data_;
3332  overflow_.uninitialize();
3333  overflow_ = r.overflow_;
3334  axes_ = r.axes_;
3335  weightBuf_ = r.weightBuf_;
3336  indexBuf_ = r.indexBuf_;
3337  fillCount_ = r.fillCount_;
3338  overCount_ = r.overCount_;
3339  dim_ = r.dim_;
3340  ++modCount_;
3341  }
3342  return *this;
3343  }
3344 
3345  template <typename Numeric, class Axis>
3346  HistoND<Numeric, Axis> HistoND<Numeric, Axis>::transpose(const unsigned axisNum1, const unsigned axisNum2) const {
3347  if (axisNum1 >= dim_ || axisNum2 >= dim_)
3349  "In npstat::HistoND::transpose: "
3350  "axis number is out of range");
3351  if (axisNum1 == axisNum2)
3352  // Just make a copy
3353  return *this;
3354  else
3355  return HistoND(*this, axisNum1, axisNum2);
3356  }
3357 
3358  template <typename Numeric, class Axis>
3359  template <typename Num2>
3361  const unsigned long nDat = data_.length();
3362  Numeric* data = const_cast<Numeric*>(data_.data());
3363  for (unsigned long i = 0; i < nDat; ++i)
3364  data[i] += weight;
3365  fillCount_ += nDat;
3366  ++modCount_;
3367  }
3368 
3369  template <typename Numeric, class Axis>
3370  template <typename Num2>
3372  const unsigned long nOver = overflow_.length();
3373  Numeric* data = const_cast<Numeric*>(overflow_.data());
3374  for (unsigned long i = 0; i < nOver; ++i)
3375  data[i] += weight;
3376  overCount_ += nOver;
3377  fillCount_ += nOver;
3378  ++modCount_;
3379  }
3380 
3381  template <typename Numeric, class Axis>
3382  template <typename Num2>
3383  void HistoND<Numeric, Axis>::addToBinContents(const Num2* data, const unsigned long dataLength) {
3384  if (dataLength != data_.length())
3385  throw npstat::NpstatInvalidArgument("In npstat::HistoND::addToBinContents: incompatible data length");
3386  assert(data);
3387  Numeric* dat = const_cast<Numeric*>(data_.data());
3388  for (unsigned long i = 0; i < dataLength; ++i)
3389  dat[i] += data[i];
3390  fillCount_ += dataLength;
3391  ++modCount_;
3392  }
3393 
3394  template <typename Numeric, class Axis>
3395  template <typename Num2>
3396  void HistoND<Numeric, Axis>::addToOverflows(const Num2* data, const unsigned long dataLength) {
3397  if (dataLength != overflow_.length())
3398  throw npstat::NpstatInvalidArgument("In npstat::HistoND::addToOverflows: incompatible data length");
3399  assert(data);
3400  Numeric* dat = const_cast<Numeric*>(overflow_.data());
3401  for (unsigned long i = 0; i < dataLength; ++i)
3402  dat[i] += data[i];
3403  overCount_ += dataLength;
3404  fillCount_ += dataLength;
3405  ++modCount_;
3406  }
3407 
3408  template <typename Numeric, class Axis>
3409  template <typename Num2>
3410  void HistoND<Numeric, Axis>::scaleBinContents(const Num2* data, const unsigned long dataLength) {
3411  if (dataLength != data_.length())
3412  throw npstat::NpstatInvalidArgument("In npstat::HistoND::scaleBinContents: incompatible data length");
3413  assert(data);
3414  Numeric* dat = const_cast<Numeric*>(data_.data());
3415  for (unsigned long i = 0; i < dataLength; ++i)
3416  dat[i] *= data[i];
3417  ++modCount_;
3418  }
3419 
3420  template <typename Numeric, class Axis>
3421  template <typename Num2>
3422  void HistoND<Numeric, Axis>::scaleOverflows(const Num2* data, const unsigned long dataLength) {
3423  if (dataLength != overflow_.length())
3424  throw npstat::NpstatInvalidArgument("In npstat::HistoND::scaleOverflows: incompatible data length");
3425  assert(data);
3426  Numeric* dat = const_cast<Numeric*>(overflow_.data());
3427  for (unsigned long i = 0; i < dataLength; ++i)
3428  dat[i] *= data[i];
3429  ++modCount_;
3430  }
3431 
3432  template <typename Numeric, class Axis>
3433  template <typename Num2>
3435  const unsigned long dataLength,
3436  const bool clearOverflowsNow) {
3437  data_.setData(data, dataLength);
3438  if (clearOverflowsNow)
3439  clearOverflows();
3440  ++modCount_;
3441  }
3442 
3443  template <typename Numeric, class Axis>
3444  template <typename Num2>
3445  inline void HistoND<Numeric, Axis>::setOverflows(const Num2* data, const unsigned long dataLength) {
3446  overflow_.setData(data, dataLength);
3447  ++modCount_;
3448  }
3449 
3450  template <typename Numeric, class Axis>
3452  const long double nOver = overflow_.template sum<long double>();
3453  const long double nData = data_.template sum<long double>();
3454  overCount_ = static_cast<unsigned long>(nOver);
3455  fillCount_ = static_cast<unsigned long>(nData + nOver);
3456  ++modCount_;
3457  }
3458 
3459  template <typename Numeric, class Axis>
3460  template <typename Num2, typename Num3>
3463  const unsigned* projectedIndices,
3464  const unsigned nProjectedIndices) const {
3465  assert(projection);
3466  data_.addToProjection(&projection->data_, projector, projectedIndices, nProjectedIndices);
3467  projection->fillCount_ += projection->nBins();
3468  projection->modCount_++;
3469  }
3470 
3471  template <typename Numeric, class Axis>
3472  template <typename Num2, typename Num3>
3474  AbsVisitor<Numeric, Num3>& projector,
3475  const unsigned* projectedIndices,
3476  const unsigned nProjectedIndices) const {
3477  assert(projection);
3478  data_.addToProjection(&projection->data_, projector, projectedIndices, nProjectedIndices);
3479  projection->fillCount_ += projection->nBins();
3480  projection->modCount_++;
3481  }
3482 
3483  template <typename Numeric, class Axis>
3485  static const std::string myClass(gs::template_class_name<Numeric, Axis>("npstat::HistoND"));
3486  return myClass.c_str();
3487  }
3488 
3489  template <typename Numeric, class Axis>
3490  bool HistoND<Numeric, Axis>::write(std::ostream& of) const {
3491  gs::write_pod(of, title_);
3492  gs::write_pod(of, accumulatedDataLabel_);
3493  gs::write_pod(of, fillCount_);
3494  gs::write_pod(of, overCount_);
3495 
3496  return !of.fail() && gs::write_obj_vector(of, axes_) && data_.classId().write(of) && data_.write(of) &&
3497  overflow_.write(of);
3498  }
3499 
3500  template <typename Numeric, class Axis>
3501  HistoND<Numeric, Axis>* HistoND<Numeric, Axis>::read(const gs::ClassId& id, std::istream& in) {
3502  static const gs::ClassId current(gs::ClassId::makeId<HistoND<Numeric, Axis> >());
3503  current.ensureSameId(id);
3504 
3506  gs::read_pod(in, &title);
3507 
3508  std::string accumulatedDataLabel;
3509  gs::read_pod(in, &accumulatedDataLabel);
3510 
3511  unsigned long fillCount = 0, overCount = 0;
3512  gs::read_pod(in, &fillCount);
3513  gs::read_pod(in, &overCount);
3514  if (in.fail())
3515  throw gs::IOReadFailure("In npstat::HistoND::read: input stream failure");
3516 
3517  std::vector<Axis> axes;
3518  gs::read_heap_obj_vector_as_placed(in, &axes);
3519  gs::ClassId ida(in, 1);
3520  ArrayND<Numeric> data, over;
3522  ArrayND<Numeric>::restore(ida, in, &over);
3523  CPP11_auto_ptr<HistoND<Numeric, Axis> > result(
3524  new HistoND<Numeric, Axis>(axes, title.c_str(), accumulatedDataLabel.c_str()));
3525  result->data_ = data;
3526  result->overflow_ = over;
3527  result->fillCount_ = fillCount;
3528  result->overCount_ = overCount;
3529  return result.release();
3530  }
3531 
3532  template <typename Histo>
3533  void convertHistoToDensity(Histo* h, const bool knownNonNegative) {
3534  assert(h);
3535  if (!knownNonNegative)
3536  (const_cast<ArrayND<typename Histo::value_type>&>(h->binContents())).makeNonNegative();
3537  const double integ = h->integral();
3538  *h /= integ;
3539  }
3540 
3541  template <typename Histo>
3542  std::vector<LinearMapper1d> densityScanHistoMap(const Histo& histo) {
3543  std::vector<LinearMapper1d> result;
3544  const unsigned d = histo.dim();
3545  result.reserve(d);
3546  for (unsigned i = 0; i < d; ++i) {
3547  const LinearMapper1d& m = histo.axis(i).binNumberMapper(false);
3548  result.push_back(m.inverse());
3549  }
3550  return result;
3551  }
3552 
3553  template <typename Histo>
3554  std::vector<CircularMapper1d> convolutionHistoMap(const Histo& histo, const bool doubleRange) {
3555  std::vector<CircularMapper1d> result;
3556  const unsigned d = histo.dim();
3557  result.reserve(d);
3558  for (unsigned i = 0; i < d; ++i)
3559  result.push_back(histo.axis(i).kernelScanMapper(doubleRange));
3560  return result;
3561  }
3562 } // namespace npstat
3563 
3564 #endif // NPSTAT_HISTOND_HH_
personalPlayback.level
level
Definition: personalPlayback.py:22
npstat::HistoND::fillPreservingCentroid
void fillPreservingCentroid(const Num2 &weight)
Definition: HistoND.h:1740
bTagCombinedSVVariables_cff.indices
indices
Definition: bTagCombinedSVVariables_cff.py:67
geometryDiff.transpose
def transpose(a)
Definition: geometryDiff.py:39
npstat::HistoND::HistoND
HistoND()=delete
dttmaxenums::L
Definition: DTTMax.h:29
testProducerWithPsetDescEmpty_cfi.i2
i2
Definition: testProducerWithPsetDescEmpty_cfi.py:46
alignBH_cfg.fixed
fixed
Definition: alignBH_cfg.py:54
runGCPTkAlMap.title
string title
Definition: runGCPTkAlMap.py:94
testProducerWithPsetDescEmpty_cfi.i3
i3
Definition: testProducerWithPsetDescEmpty_cfi.py:47
mps_fire.i
i
Definition: mps_fire.py:428
npstat::HistoND::binBox
void binBox(unsigned long binNumber, BoxND< double > *box) const
Definition: HistoND.h:1591
HistoAxis.h
Histogram axis with equidistant bins.
npstat::HistoND::dim
unsigned dim() const
Definition: HistoND.h:170
npstat::HistoND::nFillsInRange
unsigned long nFillsInRange() const
Definition: HistoND.h:197
npstat::AbsVisitor
Definition: AbsVisitor.h:19
npstat::HistoND::setBinContents
void setBinContents(const Num2 *data, unsigned long dataLength, bool clearOverflows=true)
Definition: HistoND.h:3434
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
npstat::HistoND::data_
ArrayND< Numeric > data_
Definition: HistoND.h:948
npstat::ArrayND::restore
static void restore(const gs::ClassId &id, std::istream &in, ArrayND *array)
Definition: ArrayND.h:5386
npstat::HistoND::setBinsToConst
void setBinsToConst(const Num2 &value)
Definition: HistoND.h:780
npstat::HistoND::operator!=
bool operator!=(const HistoND &) const
Definition: HistoND.h:1616
npstat::HistoND::recalculateNFillsFromData
void recalculateNFillsFromData()
Definition: HistoND.h:3451
npstat::HistoND::nFillsTotal
unsigned long nFillsTotal() const
Definition: HistoND.h:194
npstat::HistoND::scaleBinContents
void scaleBinContents(const Num2 *data, unsigned long dataLength)
Definition: HistoND.h:3410
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
npstat::convolutionHistoMap
std::vector< CircularMapper1d > convolutionHistoMap(const Histo &histo, bool doubleDataRange)
Definition: HistoND.h:3554
min
T min(T a, T b)
Definition: MathUtil.h:58
testProducerWithPsetDescEmpty_cfi.x2
x2
Definition: testProducerWithPsetDescEmpty_cfi.py:28
npstat::HistoND::incrModCount
void incrModCount()
Definition: HistoND.h:917
AlcaSiPixelAliHarvester0T_cff.method
method
Definition: AlcaSiPixelAliHarvester0T_cff.py:41
npstat::HistoND::weightBuf_
std::vector< double > weightBuf_
Definition: HistoND.h:951
npstat::HistoND::overflows
const ArrayND< Numeric > & overflows() const
Definition: HistoND.h:182
testProducerWithPsetDescEmpty_cfi.i1
i1
Definition: testProducerWithPsetDescEmpty_cfi.py:45
npstat::HistoND::clearBinContents
void clearBinContents()
Definition: HistoND.h:1247
npstat::HistoND::setBinAt
void setBinAt(const unsigned *index, unsigned indexLen, const Num2 &v)
Definition: HistoND.h:3005
npstat::LinearMapper1d
Definition: LinearMapper1d.h:18
npstat::HistoND::overCount_
unsigned long overCount_
Definition: HistoND.h:954
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:279
cms::cuda::assert
assert(be >=bs)
npstat::HistoND::overflow_
ArrayND< Numeric > overflow_
Definition: HistoND.h:949
npstat::HistoND::boundingBox
BoxND< double > boundingBox() const
Definition: HistoND.h:1538
npstat::HistoND::AVERAGE
Definition: HistoND.h:51
npstat::HistoND::integral
double integral() const
Definition: HistoND.h:1519
SiPixelPI::zero
Definition: SiPixelPayloadInspectorHelper.h:39
npstat::HistoND::accumulateBinsLoop
void accumulateBinsLoop(unsigned level, const BoxND< double > &box, unsigned *idx, Acc *accumulator, double overlapFraction, long double *wsum) const
Definition: HistoND.h:1202
findQualityFiles.v
v
Definition: findQualityFiles.py:179
npstat::HistoND::setAccumulatedDataLabel
void setAccumulatedDataLabel(const char *newlabel)
Definition: HistoND.h:215
npstat::HistoND::read
static HistoND * read(const gs::ClassId &id, std::istream &in)
Definition: HistoND.h:3501
npstat::HistoND::allBinCenters
void allBinCenters(std::vector< Point > *centers) const
Definition: HistoND.h:1568
npstat::HistoND::examine
const Numeric & examine() const
Definition: HistoND.h:1820
npstat::Private::shapeWithExtraAxis
ArrayShape shapeWithExtraAxis(const std::vector< Axis > &axes, const Axis &newAxis, const unsigned newAxisNumber)
Definition: HistoND.h:1174
npstat::HistoND::nFillsOver
unsigned long nFillsOver() const
Definition: HistoND.h:200
npstat::densityScanHistoMap
std::vector< LinearMapper1d > densityScanHistoMap(const Histo &histo)
Definition: HistoND.h:3542
npstat::PreciseType::type
PreciseTypeHelper< T, gs::IOIsNumber< T >::value >::type type
Definition: PreciseType.h:36
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
npstat::ArrayShape
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21
npstat::ArrayND::constFill
ArrayND & constFill(Numeric c)
Definition: ArrayND.h:4342
npstat::HistoND::scaleOverflows
void scaleOverflows(const Num2 *data, unsigned long dataLength)
Definition: HistoND.h:3422
npstat::HistoND::operator-=
HistoND & operator-=(const HistoND< Num2, Axis > &r)
npstat::HistoND::accumulatedDataLabel
const std::string & accumulatedDataLabel() const
Definition: HistoND.h:176
npstat::HistoND::SAMPLE
Definition: HistoND.h:51
npstat
Definition: AbsArrayProjector.h:14
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
npstat::HistoND::operator*=
HistoND & operator*=(const Num2 &r)
npstat::HistoND::setOverflows
void setOverflows(const Num2 *data, unsigned long dataLength)
Definition: HistoND.h:3445
npstat::HistoND::operator+=
HistoND & operator+=(const HistoND< Num2, Axis > &r)
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
npstat::HistoND::operator==
bool operator==(const HistoND &) const
Definition: HistoND.h:1609
w
const double w
Definition: UKUtility.cc:23
HLT_FULL_cff.weights
weights
Definition: HLT_FULL_cff.py:99244
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
npstat::ArrayND::length
unsigned long length() const
Definition: ArrayND.h:233
npstat::HistoND::accumulateBinsInBox
void accumulateBinsInBox(const BoxND< double > &box, Acc *acc, bool calculateAverage=false) const
Definition: HistoND.h:1227
npstat::HistoND::operator=
HistoND & operator=(const HistoND &)
Definition: HistoND.h:3326
HLT_FULL_cff.zAxis
zAxis
Definition: HLT_FULL_cff.py:46209
npstat::Interval
Definition: Interval.h:25
LaserClient_cfi.nbins
nbins
Definition: LaserClient_cfi.py:51
npstat::HistoND::value_type
Numeric value_type
Definition: HistoND.h:48
ArrayND.h
Arbitrary-dimensional array template.
seedmultiplicitymonitor_newtracking_cfi.nBins
nBins
Definition: seedmultiplicitymonitor_newtracking_cfi.py:8
h
npstat::HistoND::setLinearBinAt
void setLinearBinAt(const unsigned long index, const Num2 &v)
Definition: HistoND.h:761
CastorDigiReco.o1
o1
Definition: CastorDigiReco.py:84
npstat::NpstatInvalidArgument
Definition: NpstatException.h:38
npstat::HistoND::version
static unsigned version()
Definition: HistoND.h:926
npstat::HistoND::setLinearBin
void setLinearBin(const unsigned long index, const Num2 &v)
Definition: HistoND.h:688
npstat::HistoND::axes
const std::vector< Axis > & axes() const
Definition: HistoND.h:185
npstat::HistoND::title
const std::string & title() const
Definition: HistoND.h:173
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
npstat::HistoND::nBins
unsigned long nBins() const
Definition: HistoND.h:191
npstat::convertHistoToDensity
void convertHistoToDensity(Histo *histogram, bool knownNonNegative=false)
Definition: HistoND.h:3533
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
npstat::HistoND::classname
static const char * classname()
Definition: HistoND.h:3484
Point
Structure Point Contains parameters of Gaussian fits to DMRs.
Definition: DMRtrends.cc:57
npstat::HistoND::isUniformlyBinned
bool isUniformlyBinned() const
Definition: HistoND.h:1511
npstat::HistoND::axis_type
Axis axis_type
Definition: HistoND.h:49
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
npstat::BoxND
Definition: BoxND.h:24
npstat::HistoND::addToBinContents
void addToBinContents(const Num2 &weight)
Definition: HistoND.h:3360
HLT_FULL_cff.yAxis
yAxis
Definition: HLT_FULL_cff.py:46210
plotT0FromHistos.binNumber
def binNumber(station, sl)
Definition: plotT0FromHistos.py:6
recoMuon::in
Definition: RecoMuonEnumerators.h:6
npstat::HistoND::fillCount_
unsigned long fillCount_
Definition: HistoND.h:953
npstat::Private::h_badargs
void h_badargs(const char *method)
Definition: HistoND.h:1192
npstat::HistoND::clearOverflows
void clearOverflows()
Definition: HistoND.h:1254
npstat::HistoND::fill
void fill(const double *coords, unsigned coordLength, const Num2 &weight)
Definition: HistoND.h:1645
npstat::HistoND::isSameData
bool isSameData(const HistoND &) const
Definition: HistoND.h:1604
npstat::HistoND::SUM
Definition: HistoND.h:51
npstat::HistoND::setNFillsOver
void setNFillsOver(const unsigned long i)
Definition: HistoND.h:812
value
Definition: value.py:1
npstat::HistoND::dim_
unsigned dim_
Definition: HistoND.h:956
npstat::HistoND::operator/=
HistoND & operator/=(const Num2 &r)
npstat::ArrayND< Numeric >
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition: JetExtendedAssociation.h:30
npstat::HistoND
Definition: HistoAxis.h:23
npstat::HistoND::clear
void clear()
Definition: HistoND.h:1261
npstat::ArrayND::convertLinearIndex
void convertLinearIndex(unsigned long l, unsigned *index, unsigned indexLen) const
Definition: ArrayND.h:3048
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
npstat::Private::axesOfASlice
std::vector< Axis > axesOfASlice(const std::vector< Axis > &axes, const unsigned *fixedIndices, const unsigned nFixedIndices)
Definition: HistoND.h:1086
alignCSCRings.r
r
Definition: alignCSCRings.py:93
npstat::HistoND::getModCount
unsigned long getModCount() const
Definition: HistoND.h:910
npstat::Private::makeHistoShape
ArrayShape makeHistoShape(const Axis &xAxis, const Axis &yAxis, const Axis &zAxis, const Axis &tAxis, const Axis &vAxis)
Definition: HistoND.h:1058
npstat::ArrayND::linearValueAt
Numeric & linearValueAt(unsigned long index)
Definition: ArrayND.h:3133
npstat::Private::makeHistoShape
ArrayShape makeHistoShape(const std::vector< Axis > &axes)
Definition: HistoND.h:1010
mixOne_premix_on_sim_cfi.accumulator
accumulator
Definition: mixOne_premix_on_sim_cfi.py:167
npstat::NpstatOutOfRange
Definition: NpstatException.h:30
npstat::HistoND::binCenter
void binCenter(unsigned long binNumber, double *coords, unsigned lenCoords) const
Definition: HistoND.h:1550
npstat::Private::addAxis
std::vector< Axis > addAxis(const std::vector< Axis > &axes, const Axis &newAxis, const unsigned newAxisNumber)
Definition: HistoND.h:1155
npstat::HistoND::fillC
void fillC(const double *coords, unsigned coordLength, const Num2 &weight)
Definition: HistoND.h:1763
npstat::HistoND::setBin
void setBin(const unsigned *index, unsigned indexLen, const Num2 &v)
Definition: HistoND.h:2998
npstat::HistoND::binVolume
double binVolume(unsigned long binNumber=0) const
Definition: HistoND.h:1621
npstat::HistoND::modCount_
unsigned long modCount_
Definition: HistoND.h:955
npstat::AbsArrayProjector
Definition: AbsArrayProjector.h:20
npstat::HistoND::addToProjection
void addToProjection(HistoND< Num2, Axis > *projection, AbsArrayProjector< Numeric, Num3 > &projector, const unsigned *projectedIndices, unsigned nProjectedIndices) const
Definition: HistoND.h:3461
npstat::HistoND::setOverflowsToConst
void setOverflowsToConst(const Num2 &value)
Definition: HistoND.h:790
npstat::HistoND::closestBin
const Numeric & closestBin() const
Definition: HistoND.h:1827
npstat::HistoND::setTitle
void setTitle(const char *newtitle)
Definition: HistoND.h:209
npstat::HistoND::setNFillsTotal
void setNFillsTotal(const unsigned long i)
Definition: HistoND.h:808
HLT_FULL_cff.xAxis
xAxis
Definition: HLT_FULL_cff.py:46208
npstat::HistoND::accumulatedDataLabel_
std::string accumulatedDataLabel_
Definition: HistoND.h:947
npstat::HistoND::transpose
HistoND transpose(unsigned axisNum1, unsigned axisNum2) const
Definition: HistoND.h:3346
npstat::HistoND::binContents
const ArrayND< Numeric > & binContents() const
Definition: HistoND.h:179
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
npstat::HistoND::dispatch
void dispatch(const double *coords, unsigned coordLength, Num2 &weight, Functor &f)
Definition: HistoND.h:1673
npstat::HistoND::RebinType
RebinType
Definition: HistoND.h:51
npstat::HistoND::volume
double volume() const
Definition: HistoND.h:1633
ztail.d
d
Definition: ztail.py:151
npstat::HistoND::classId
gs::ClassId classId() const
Definition: HistoND.h:921
mps_fire.result
result
Definition: mps_fire.py:311
npstat::Private::shapeOfASlice
ArrayShape shapeOfASlice(const std::vector< Axis > &axes, const unsigned *fixedIndices, const unsigned nFixedIndices)
Definition: HistoND.h:1118
npstat::ArrayND::linearValue
Numeric & linearValue(unsigned long index)
Definition: ArrayND.h:3123
npstat::HistoND::addToOverflows
void addToOverflows(const Num2 &weight)
Definition: HistoND.h:3371
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
NpstatException.h
Exceptions for the npstat namespace.
npstat::HistoND::axes_
std::vector< Axis > axes_
Definition: HistoND.h:950
label
const char * label
Definition: PFTauDecayModeTools.cc:11
npstat::HistoND::axis
const Axis & axis(const unsigned i) const
Definition: HistoND.h:188
weight
Definition: weight.py:1
npstat::HistoND::indexBuf_
std::vector< unsigned > indexBuf_
Definition: HistoND.h:952
npstat::HistoND::write
bool write(std::ostream &of) const
Definition: HistoND.h:3490
npstat::Private::rebinAxes
std::vector< Axis > rebinAxes(const std::vector< Axis > &axes, const unsigned *newBins, const unsigned lenNewBins)
Definition: HistoND.h:1071
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
npstat::HistoND::setAxisLabel
void setAxisLabel(const unsigned axisNum, const char *newlabel)
Definition: HistoND.h:221
npstat::HistoND::title_
std::string title_
Definition: HistoND.h:946