YODA::DbnStorage< DbnN, AxisT > Class Template Reference All histograms can be instantiated through this alias. More...
Inheritance diagram for YODA::DbnStorage< DbnN, AxisT >:
![]()
Detailed Descriptiontemplate<size_t DbnN, typename... AxisT> class YODA::DbnStorage< DbnN, AxisT > All histograms can be instantiated through this alias. Histogram convenience class based on FillableStorage. Since objects with continuous axes are by far the most commonly used type in practice, we define convenient short-hand aliases HistoND/ProfileND for with only continuous axes, along with the familar types Histo1D, Profile2D, etc.
Definition at line 120 of file BinnedDbn.h. Member Typedef Documentation◆ BaseT
template<size_t DbnN, typename... AxisT>
Definition at line 124 of file BinnedDbn.h. ◆ BinningT
template<size_t DbnN, typename... AxisT>
Definition at line 125 of file BinnedDbn.h. ◆ BinT
template<size_t DbnN, typename... AxisT>
Definition at line 126 of file BinnedDbn.h. ◆ BinType
template<size_t DbnN, typename... AxisT>
Definition at line 127 of file BinnedDbn.h. ◆ FillType
template<size_t DbnN, typename... AxisT>
Definition at line 128 of file BinnedDbn.h. Constructor & Destructor Documentation◆ DbnStorage() [1/12]
template<size_t DbnN, typename... AxisT>
Nullary constructor for unique pointers etc.
Definition at line 138 of file BinnedDbn.h. FillableStorage< DbnN, Dbn< DbnN >, AxisT... > BaseT Definition BinnedDbn.h:124 Referenced by YODA::DbnStorage< DbnN, AxisT >::clone(), and YODA::DbnStorage< DbnN, AxisT >::newclone(). ◆ DbnStorage() [2/12]
template<size_t DbnN, typename... AxisT>
Constructor giving explicit bin edges as rvalue reference. Discrete axes have as many edges as bins. Continuous axes have number of edges = number of bins + 1, the last one being the upper bound of the last bin. Definition at line 145 of file BinnedDbn.h. 147 : BaseT(Axis<AxisT>(std::move(binsEdges))...),
◆ DbnStorage() [3/12]
template<size_t DbnN, typename... AxisT>
Constructor giving explicit bin edges as lvalue const reference. Discrete axes have as many edges as bins. Continuous axes have bins.size()+1 edges, the last one being the upper bound of the last bin. Definition at line 155 of file BinnedDbn.h. 157 : BaseT(Axis<AxisT>(binsEdges)...),
◆ DbnStorage() [4/12]
template<size_t DbnN, typename... AxisT>
Constructor giving explicit bin edges as initializer list. Discrete axes have as many edges as bins. Continuous axes have number of edges = number of bins + 1, the last one being the upper bound of the last bin. Definition at line 165 of file BinnedDbn.h. 167 : BaseT(Axis<AxisT>(std::move(binsEdges))...),
◆ DbnStorage() [5/12]
template<size_t DbnN, typename... AxisT>
template<typename EdgeT = double, typename = enable_if_all_CAxisT<EdgeT, AxisT...>>
Constructor giving range and number of bins.
Definition at line 175 of file BinnedDbn.h. ◆ DbnStorage() [6/12]
template<size_t DbnN, typename... AxisT>
◆ DbnStorage() [7/12]
template<size_t DbnN, typename... AxisT>
◆ DbnStorage() [8/12]
template<size_t DbnN, typename... AxisT>
Constructor given a BinningT (needed for type reductions) Definition at line 189 of file BinnedDbn.h. const BinningT & binning() const noexcept Returns dimension underlying binning object reference. Definition BinnedStorage.h:321 ◆ DbnStorage() [9/12]
template<size_t DbnN, typename... AxisT>
◆ DbnStorage() [10/12]
template<size_t DbnN, typename... AxisT>
template<typename EdgeT = double, typename = enable_if_all_CAxisT<EdgeT, AxisT...>>
◆ DbnStorage() [11/12]
template<size_t DbnN, typename... AxisT>
Copy constructor.
Definition at line 205 of file BinnedDbn.h. ◆ DbnStorage() [12/12]
template<size_t DbnN, typename... AxisT>
Move constructor.
Definition at line 211 of file BinnedDbn.h. Member Function Documentation◆ clone()
template<size_t DbnN, typename... AxisT>
Make a copy on the stack. Definition at line 215 of file BinnedDbn.h. References YODA::DbnStorage< DbnN, AxisT >::DbnStorage(). ◆ crossTerm()
template<size_t DbnN, typename... AxisT>
template<size_t dim = DbnN, typename = std::enable_if_t<(dim >= 2)>>
Calculates cross-term along axes A1 and A2 in histo. Definition at line 562 of file BinnedDbn.h. 562 {
563 if (A1 >= DbnN || A2 >= DbnN) throw RangeError("Invalid axis int, must be in range 0..dim-1");
564 if (A1 >= A2) throw RangeError("Indices need to be different for cross term");
565 double sumw = 0;
567 sumw += b.crossTerm(A1, A2);
568 return sumw;
569 }
BinsVecWrapper< BinsVecT > bins(const bool includeOverflows=false, const bool includeMaskedBins=false) noexcept Returns bins vector wrapper, which skips masked elements when iterated over. Definition BinnedStorage.h:298 double crossTerm(const size_t A1, const size_t A2, const bool includeOverflows=true) const Calculates cross-term along axes A1 and A2 in histo. Definition BinnedDbn.h:562 References YODA::BinnedStorage< BinContentT, AxisT >::bins(). Referenced by YODA::WriterYODA1::writeHisto2D(), and YODA::WriterYODA1::writeProfile2D(). ◆ density()
template<size_t DbnN, typename... AxisT>
Get the total density of the histogram. Definition at line 616 of file BinnedDbn.h. 616 {
619 return std::numeric_limits<double>::quiet_NaN();
620 }
double dVol(const bool includeOverflows=true) const noexcept Definition BinnedDbn.h:608 double integral(const bool includeOverflows=true) const noexcept Get the total volume of the histogram. Definition BinnedDbn.h:468 References YODA::DbnStorage< DbnN, AxisT >::dVol(), and YODA::DbnStorage< DbnN, AxisT >::integral(). ◆ densityError()
template<size_t DbnN, typename... AxisT>
Get the total density error of the histogram. Definition at line 623 of file BinnedDbn.h. 623 {
626 return std::numeric_limits<double>::quiet_NaN();
627 }
double integralError(const bool includeOverflows=true) const noexcept Get the total volume error of the histogram. Definition BinnedDbn.h:473 References YODA::DbnStorage< DbnN, AxisT >::dVol(), and YODA::DbnStorage< DbnN, AxisT >::integralError(). ◆ densitySum()
template<size_t DbnN, typename... AxisT>
Returns the sum of the bin densities. Definition at line 630 of file BinnedDbn.h. 630 {
631 double rho = 0.0;
634 return rho;
635 }
double sumW(const bool includeOverflows=true) const noexcept Calculates sum of weights in histo. Definition BinnedDbn.h:527 References YODA::BinnedStorage< BinContentT, AxisT >::bins(). ◆ deserializeContent()
template<size_t DbnN, typename... AxisT>
Content deserialisation for MPI reduce operations. Implements YODA::AnalysisObject. Definition at line 772 of file BinnedDbn.h. 772 {
773
774 constexpr size_t dbnSize = Dbn<DbnN>::DataSize::value;
776 if (data.size() != nBins * dbnSize)
777 throw UserError("Length of serialized data should be "
778 + std::to_string(nBins * dbnSize)+"!");
779
780 const auto itr = data.cbegin();
781 for (size_t i = 0; i < nBins; ++i) {
782 auto first = itr + i*dbnSize;
783 auto last = first + dbnSize;
784 BaseT::bin(i)._deserializeContent(std::vector<double>{first, last});
785 }
786
787 }
size_t numBins(const bool includeOverflows=false, const bool includeMaskedBins=false) const noexcept Number of bins in the BinnedStorage. Definition BinnedStorage.h:331 References YODA::BinnedStorage< BinContentT, AxisT >::bin(), and YODA::BinnedStorage< BinContentT, AxisT >::numBins(). ◆ dim()
template<size_t DbnN, typename... AxisT>
Total dimension of the object (number of axes + filled value) Implements YODA::AnalysisObject. Definition at line 422 of file BinnedDbn.h. 422{ return sizeof...(AxisT) + 1; }
Referenced by YODA::DbnStorage< DbnN, AxisT >::sumWA(), and YODA::DbnStorage< DbnN, AxisT >::sumWA2(). ◆ dVol()
template<size_t DbnN, typename... AxisT>
Definition at line 608 of file BinnedDbn.h. References YODA::BinnedStorage< BinContentT, AxisT >::bins(). Referenced by YODA::DbnStorage< DbnN, AxisT >::density(), and YODA::DbnStorage< DbnN, AxisT >::densityError(). ◆ edges()
template<size_t DbnN, typename... AxisT>
template<size_t I, typename E = typename BinningT::template getEdgeT<I>>
Returns the edges of axis N by value. Definition at line 429 of file BinnedDbn.h. 429 {
430 return BaseT::_binning.template edges<I>(includeOverflows);
431 }
◆ effNumEntries()
template<size_t DbnN, typename... AxisT>
Get the effective number of fills. Implements YODA::Fillable. Definition at line 519 of file BinnedDbn.h. 519 {
520 double n = 0;
522 n += b.effNumEntries();
523 return n;
524 }
double effNumEntries(const bool includeOverflows=true) const noexcept Get the effective number of fills. Definition BinnedDbn.h:519 References YODA::BinnedStorage< BinContentT, AxisT >::bins(). Referenced by YODA::DbnStorage< DbnN, AxisT >::mkEstimate(). ◆ fill()
template<size_t DbnN, typename... AxisT>
Triggers fill adapter on the bin corresponding to coords.
Definition at line 234 of file BinnedDbn.h. 234 {
235 return BaseT::fill(std::move(coords), std::make_index_sequence<sizeof...(AxisT)>{}, weight, fraction);
236 }
int fill(FillCoordsT &&coords, std::index_sequence< Is... >, const double weight=1.0, const double fraction=1.0) noexcept Triggers fill adapter on the bin corresponding to coords. Definition FillableStorage.h:169 References YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >::fill(). ◆ fillDim()
template<size_t DbnN, typename... AxisT>
Fill-dimension of this data object. Implements YODA::Fillable. Definition at line 419 of file BinnedDbn.h. References YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >::fillDim(). ◆ integral()
template<size_t DbnN, typename... AxisT>
Get the total volume of the histogram. Definition at line 468 of file BinnedDbn.h. References YODA::DbnStorage< DbnN, AxisT >::sumW(). Referenced by YODA::DbnStorage< DbnN, AxisT >::density(), YODA::mkIntegralEff(), YODA::DbnStorage< DbnN, AxisT >::normalize(), YODA::WriterYODA1::writeHisto1D(), and YODA::WriterYODA1::writeHisto2D(). ◆ integralError()
template<size_t DbnN, typename... AxisT>
Get the total volume error of the histogram. Definition at line 473 of file BinnedDbn.h. 473 {
475 }
double sumW2(const bool includeOverflows=true) const noexcept Calculates sum of squared weights in histo. Definition BinnedDbn.h:535 References YODA::DbnStorage< DbnN, AxisT >::sumW2(). Referenced by YODA::DbnStorage< DbnN, AxisT >::densityError(), and YODA::mkIntegralEff(). ◆ integralRange()
template<size_t DbnN, typename... AxisT>
Calculates the integrated volume of the histogram between global bins binindex1 and binIndex2. Definition at line 484 of file BinnedDbn.h. 484 {
485 assert(binIndex2 >= binIndex1);
488 double sumw = 0;
489 for (size_t idx = binIndex1; idx <= binIndex2; ++idx) {
491 sumw += BaseT::bin(idx).sumW();
492 }
493 return sumw;
494 }
bool isMasked(const size_t binIndex) const noexcept Definition BinnedStorage.h:375 References YODA::BinnedStorage< BinContentT, AxisT >::bin(), YODA::BinnedStorage< BinContentT, AxisT >::isMasked(), and YODA::BinnedStorage< BinContentT, AxisT >::numBins(). Referenced by YODA::DbnStorage< DbnN, AxisT >::integralTo(). ◆ integralRangeError()
template<size_t DbnN, typename... AxisT>
Calculates the integrated volume error of the histogram between global bins binindex1 and binIndex2. Definition at line 498 of file BinnedDbn.h. 498 {
499 assert(binIndex2 >= binIndex1);
502 double sumw2 = 0;
503 for (size_t idx = binIndex1; idx <= binIndex2; ++idx) {
505 sumw2 += BaseT::bin(idx).sumW2();
506 }
507 return sumw2;
508 }
References YODA::BinnedStorage< BinContentT, AxisT >::bin(), YODA::BinnedStorage< BinContentT, AxisT >::isMasked(), and YODA::BinnedStorage< BinContentT, AxisT >::numBins(). ◆ integralTo()
template<size_t DbnN, typename... AxisT>
Get the total volume of the histogram. Definition at line 478 of file BinnedDbn.h. 478 {
480 }
double integralRange(const size_t binIndex1, size_t binIndex2) const Calculates the integrated volume of the histogram between global bins binindex1 and binIndex2. Definition BinnedDbn.h:484 References YODA::DbnStorage< DbnN, AxisT >::integralRange(). ◆ lengthContent()
template<size_t DbnN, typename... AxisT>
Length of serialized content vector for MPI reduce operations. Implements YODA::AnalysisObject. Definition at line 755 of file BinnedDbn.h. References YODA::BinnedStorage< BinContentT, AxisT >::numBins(). ◆ max()
template<size_t DbnN, typename... AxisT>
template<size_t I, typename E = typename BinningT::template getEdgeT<I>>
Get the highest non-overflow edge of the axis.
Definition at line 457 of file BinnedDbn.h. 457 {
458 return BaseT::_binning.template max<I>();
459 }
◆ maxDensity()
template<size_t DbnN, typename... AxisT>
Returns the largest density in any of the bins. Definition at line 638 of file BinnedDbn.h. 638 {
639 std::vector<double> vals;
642 return *max_element(vals.begin(), vals.end());
643 }
References YODA::BinnedStorage< BinContentT, AxisT >::bins(). ◆ mean()
template<size_t DbnN, typename... AxisT>
Calculates the mean value at axis. Definition at line 572 of file BinnedDbn.h. 572 {
573 Dbn<DbnN> dbn;
575 dbn += b;
576 return dbn.mean(axisN+1);
577 }
References YODA::BinnedStorage< BinContentT, AxisT >::bins(), and YODA::DbnBase< N >::mean(). ◆ min()
template<size_t DbnN, typename... AxisT>
template<size_t I, typename E = typename BinningT::template getEdgeT<I>>
Get the lowest non-overflow edge of the axis.
Definition at line 449 of file BinnedDbn.h. 449 {
450 return BaseT::_binning.template min<I>();
451 }
◆ mkBinnedEffNumEntries()
template<size_t DbnN, typename... AxisT>
Convert the BinnedDbn to a BinnedEstimate representing the effective number of entries in each bin.
Definition at line 1085 of file BinnedDbn.h. 1089 {
1090
1092
1095 if (divbyvol) {
1097 }
1100 rtn.bin(b.index()).set(effN, {-err, err}, source);
1101 }
1102
1103 return rtn;
1104 }
BinnedEstimate< AxisT... > mkEstimate(const std::string &path="", const std::string &source="", const bool divbyvol=true, const double overflowsWidth=-1.0) const Produce a BinnedEstimate from a DbnStorage. Definition BinnedDbn.h:800 void scale(const size_t i, const double scalefactor) noexcept Rescale as if all fill weights had been different by factor scalefactor along dimension i. Definition BinnedDbn.h:247 References YODA::BinnedStorage< BinContentT, AxisT >::bins(), YODA::DbnStorage< DbnN, AxisT >::mkEstimate(), YODA::AnalysisObject::path(), and YODA::DbnStorage< DbnN, AxisT >::scale(). ◆ mkEstimate()
template<size_t DbnN, typename... AxisT>
Produce a BinnedEstimate from a DbnStorage. The binning remains unchanged.
Definition at line 800 of file BinnedDbn.h. 803 {
804
805 // @todo Should we check BaseT::nanCount() and report?
806 BinnedEstimate<AxisT...> rtn(BaseT::_binning);
809 }
811
817 rtn.setAnnotation("NanFraction", frac);
818 if (wtot) rtn.setAnnotation("WeightedNanFraction", nanw/wtot);
819 }
820
822 if (overflowsWidth <= 0. && !b.isVisible()) continue;
823 if constexpr(DbnN > sizeof...(AxisT)) {
824 rtn.bin(b.index()).setVal(b.mean(DbnN));
825 if (b.numEntries()) { // only set uncertainty for filled Dbns
826 rtn.bin(b.index()).setErr(b.stdErr(DbnN), source);
827 }
828 }
829 else {
831 rtn.bin(b.index()).setVal(b.sumW() / scale);
832 if (b.numEntries()) { // only set uncertainty for filled Dbns
833 rtn.bin(b.index()).setErr(b.errW() / scale, source);
834 }
835 }
836 }
837
838 return rtn;
839 }
std::vector< std::string > annotations() const Definition AnalysisObject.h:123 const std::string & annotation(const std::string &name) const Get an annotation by name (as a string) Definition AnalysisObject.h:138 double numEntries(const bool includeOverflows=true) const noexcept Get the number of fills (fractional fills are possible). Definition BinnedDbn.h:511 size_t nanCount() const Definition FillableStorage.h:199 double nanSumW() const Definition FillableStorage.h:201 References YODA::AnalysisObject::annotation(), YODA::AnalysisObject::annotations(), YODA::BinnedStorage< BinContentT, AxisT >::bins(), YODA::DbnStorage< DbnN, AxisT >::effNumEntries(), YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >::nanCount(), YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >::nanSumW(), YODA::DbnStorage< DbnN, AxisT >::numEntries(), YODA::AnalysisObject::path(), and YODA::DbnStorage< DbnN, AxisT >::scale(). Referenced by YODA::add(), YODA::divide(), YODA::divide(), YODA::DbnStorage< DbnN, AxisT >::mkBinnedEffNumEntries(), YODA::DbnStorage< DbnN, AxisT >::mkEstimates(), YODA::DbnStorage< DbnN, AxisT >::mkInert(), YODA::mkIntegral(), YODA::DbnStorage< DbnN, AxisT >::mkScatter(), and YODA::subtract(). ◆ mkEstimates()
template<size_t DbnN, typename... AxisT>
template<size_t axisN, typename = std::enable_if_t< (axisN < sizeof...(AxisT)) >>
Produce a BinnedEstimate for each bin along axis axisN and return as a vector. The binning dimension is reduced by one unit.
Definition at line 849 of file BinnedDbn.h. 851 {
852
855 }
References YODA::DbnStorage< DbnN, AxisT >::mkEstimate(), and YODA::AnalysisObject::path(). ◆ mkHisto()
template<size_t DbnN, typename... AxisT>
template<size_t N = DbnN, typename = std::enable_if_t< (N == sizeof...(AxisT)+1) >>
Produce a BinnedHisto from BinnedProfile. The binning remains unchanged, but the fill dimension is reduced by one unit. Definition at line 893 of file BinnedDbn.h. 893 {
894
895 BinnedHisto<AxisT...> rtn(BaseT::_binning);
899 }
901
903 rtn.bin(b.index()) += b.template reduce<N-1>();
904 }
905
906 return rtn;
907 }
double nanSumW2() const Definition FillableStorage.h:203 BinnedDbn< sizeof...(AxisTypes), AxisTypes... > BinnedHisto Definition BinnedDbn.h:102 References YODA::AnalysisObject::annotation(), YODA::AnalysisObject::annotations(), YODA::BinnedStorage< BinContentT, AxisT >::bins(), YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >::nanCount(), YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >::nanSumW(), YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >::nanSumW2(), and YODA::AnalysisObject::path(). Referenced by YODA::DbnStorage< DbnN, AxisT >::mkHistos(), and YODA::DbnStorage< DbnN, AxisT >::mkMarginalHisto(). ◆ mkHistos()
template<size_t DbnN, typename... AxisT>
template<size_t axisN, typename = std::enable_if_t< (axisN < sizeof...(AxisT) && sizeof...(AxisT)>=2) >>
Split into vector of BinnedHisto along axis axisN. The binning dimension of the returned ojects are reduced by one unit.
Definition at line 1054 of file BinnedDbn.h. 1054 {
1055
1056 if constexpr (DbnN != sizeof...(AxisT)) {
1057 // Case 1: BP(N+1) -> BH(N+1) -> BHN
1059 }
1060 else {
1061 // Case 2: BH(N+1) -> BHN
1062
1063 // Need to provide a prescription for how to add the two bin contents
1064 auto how2add = [](auto& pivot, const BinType& toCopy) { pivot = toCopy.template reduce<axisN>(); };
1065 auto rtn = BaseT::template mkBinnedSlices<axisN,BinnedHisto>(how2add, includeOverflows);
1067 if (a == "Type") continue;
1068 for (size_t i = 0; i < rtn.size(); ++i) {
1069 rtn[i].setAnnotation(a, annotation(a));
1070 }
1071 }
1072 for (size_t i = 0; i < rtn.size(); ++i) {
1074 }
1075 return rtn;
1076 }
1077 }
BinnedHisto< AxisT... > mkHisto(const std::string &path="") const Produce a BinnedHisto from BinnedProfile. Definition BinnedDbn.h:893 References YODA::AnalysisObject::annotation(), YODA::AnalysisObject::annotations(), YODA::DbnStorage< DbnN, AxisT >::mkHisto(), and YODA::AnalysisObject::path(). ◆ mkInert()
template<size_t DbnN, typename... AxisT>
Return an inert version of the analysis object (e.g. scatter, estimate) Reimplemented from YODA::AnalysisObject. Definition at line 1108 of file BinnedDbn.h. References YODA::DbnStorage< DbnN, AxisT >::mkEstimate(), YODA::AnalysisObject::newclone(), and YODA::AnalysisObject::path(). ◆ mkMarginalHisto()
template<size_t DbnN, typename... AxisT>
template<size_t axisN, typename = std::enable_if_t< (axisN < sizeof...(AxisT)) >>
Produce a BinnedHisto from a DbnStorage. Case 1: BinnedProfile(N+1)D -> BinnedHistoND The binning dimension is reduced by one unit, and the fill dimension is reduced by two units. Case 2: BinnedHisto(N+1)D -> BinnedHisto Both fill and binning dimension are reduced by one unit.
Definition at line 975 of file BinnedDbn.h. 975 {
976
977 if constexpr (DbnN != sizeof...(AxisT)) {
978 // Case 1: BP(N+1) -> BH(N+1) -> BHN
980 }
981 else {
982 // Case 2: BH(N+1) -> BHN
983
984 auto rtn = BaseT::template _mkBinnedT<BinnedHisto>(BaseT::_binning.template _getAxesExcept<axisN>());
988 }
990
991 auto collapseStorageBins =
992 [&oldBinning = BaseT::_binning, &oldBins = BaseT::_bins, &rtn](auto I, auto dbnRed) {
993
994 auto collapse = [&oldBins, &rtn](const auto& binsIndicesToMerge, auto axis) {
995 assert(rtn.numBins(true) == binsIndicesToMerge.size());
996
997 // for any given pivot, add the content
998 // from the old slice to the new slice
999 for (size_t i = 0; i < rtn.numBins(true); ++i) {
1000 auto& pivotBin = rtn.bin(i);
1001 auto& binToAppend = oldBins[binsIndicesToMerge[i]];
1002 pivotBin += binToAppend.template reduce<axis>();
1003 }
1004 };
1005
1006 // get bin slice for any given bin along the axis that is to be
1007 // collapsed, then copy the values into the new binning
1008 ssize_t nBinRowsToBeMerged = oldBinning.numBinsAt(I);
1009 while (nBinRowsToBeMerged--) {
1012 collapse(oldBinning.sliceIndices(I, nBinRowsToBeMerged), dbnRed);
1013 }
1014 };
1015 // collapse Dbn along axisN
1016 auto dbnRed = std::integral_constant<size_t, axisN>();
1017 (void)collapseStorageBins(std::integral_constant<std::size_t, axisN>(), dbnRed);
1018
1019 return rtn;
1020 }
1021 }
References YODA::AnalysisObject::annotation(), YODA::AnalysisObject::annotations(), YODA::DbnStorage< DbnN, AxisT >::mkHisto(), YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >::nanCount(), YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >::nanSumW(), YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >::nanSumW2(), and YODA::AnalysisObject::path(). ◆ mkMarginalProfile()
template<size_t DbnN, typename... AxisT>
template<size_t axisN, typename = std::enable_if_t< (axisN < sizeof...(AxisT)) >>
Produce a BinnedProfile from a DbnStorage. Case 1: BinnedHisto(N+1)D -> BinnedProfileND The fill dimension remains the same, but the binning is reduced by one dimension. Case 2: BinnedProfile(N+1)D -> BinnedProfileND Both fill and binning dimmensions are reduced by one unit.
If the calling object is a histogram, we can just copy the Dbn<N>, otherwise we need to collapse an axis first in order to produce a Dbn<N-1>.
Definition at line 921 of file BinnedDbn.h. 921 {
922
923 auto rtn = BaseT::template _mkBinnedT<BinnedProfile>(BaseT::_binning.template _getAxesExcept<axisN>());
927 }
929
930 auto collapseStorageBins =
931 [&oldBinning = BaseT::_binning, &oldBins = BaseT::_bins, &rtn](auto I, auto dbnRed) {
932
933 auto collapse = [&oldBins, &rtn](const auto& binsIndicesToMerge, auto axis) {
934 assert(rtn.numBins(true) == binsIndicesToMerge.size());
935
936 // for any given pivot, add the content
937 // from the old slice to the new slice
938 for (size_t i = 0; i < rtn.numBins(true); ++i) {
939 auto& pivotBin = rtn.bin(i);
940 auto& binToAppend = oldBins[binsIndicesToMerge[i]];
941 pivotBin += binToAppend.template reduce<axis>();
942 }
943 };
944
945 // get bin slice for any given bin along the axis that is to be
946 // collapsed, then copy the values into the new binning
947 ssize_t nBinRowsToBeMerged = oldBinning.numBinsAt(I);
948 while (nBinRowsToBeMerged--) {
951 collapse(oldBinning.sliceIndices(I, nBinRowsToBeMerged), dbnRed);
952 }
953 };
957 auto dbnRed = std::integral_constant<size_t, (sizeof...(AxisT) == DbnN)? DbnN : axisN>();
958 (void)collapseStorageBins(std::integral_constant<std::size_t, axisN>(), dbnRed);
959
960 return rtn;
961 }
References YODA::AnalysisObject::annotation(), YODA::AnalysisObject::annotations(), YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >::nanCount(), YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >::nanSumW(), YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >::nanSumW2(), and YODA::AnalysisObject::path(). ◆ mkProfiles()
template<size_t DbnN, typename... AxisT>
template<size_t axisN, typename = std::enable_if_t< (axisN < sizeof...(AxisT) && sizeof...(AxisT)>=2 && DbnN > sizeof...(AxisT)) >>
Split into vector of BinnedProfile along axis axisN. The binning dimension of the returned objects are reduced by one unit.
Definition at line 1031 of file BinnedDbn.h. 1031 {
1032
1033 // Need to provide a prescription for how to add the two bin contents
1034 auto how2add = [](auto& pivot, const BinType& toCopy) { pivot = toCopy.template reduce<axisN>(); };
1035 auto rtn = BaseT::template mkBinnedSlices<axisN, BinnedProfile>(how2add, includeOverflows);
1037 if (a == "Type") continue;
1038 for (size_t i = 0; i < rtn.size(); ++i) {
1039 rtn[i].setAnnotation(a, annotation(a));
1040 }
1041 }
1042 for (size_t i = 0; i < rtn.size(); ++i) {
1044 }
1045 return rtn;
1046 }
References YODA::AnalysisObject::annotation(), YODA::AnalysisObject::annotations(), and YODA::AnalysisObject::path(). ◆ mkScatter()
template<size_t DbnN, typename... AxisT>
Produce a ScatterND from a DbnStorage.
Definition at line 862 of file BinnedDbn.h. 866 {
868 ScatterND<sizeof...(AxisT)+1> rtn = est.mkScatter(path, "", includeOverflows, includeMaskedBins);
869 if (usefocus) {
870 size_t idx = 0;
872 auto shiftIfContinuous = [&rtn, &b, &idx](auto I) {
873 using isContinuous = typename BinningT::template is_CAxis<I>;
874 if constexpr (isContinuous::value) {
875 const double oldMax = rtn.point(idx).max(I);
876 const double oldMin = rtn.point(idx).min(I);
877 const double newVal = b.mean(I+1);
878 rtn.point(idx).set(I, newVal, newVal - oldMin, oldMax - newVal);
879 }
880 };
881 MetaUtils::staticFor<BinningT::Dimension::value>(shiftIfContinuous);
882 ++idx;
883 }
884 }
885 return rtn;
886 }
References YODA::BinnedStorage< BinContentT, AxisT >::bins(), YODA::DbnStorage< DbnN, AxisT >::mkEstimate(), YODA::AnalysisObject::path(), and YODA::ScatterND< N >::point(). ◆ newclone()
template<size_t DbnN, typename... AxisT>
Make a copy on the heap. Implements YODA::AnalysisObject. Definition at line 220 of file BinnedDbn.h. References YODA::DbnStorage< DbnN, AxisT >::DbnStorage(). ◆ normalize()
template<size_t DbnN, typename... AxisT>
Normalize the (visible) histo "volume" to the normto value. If includeoverflows is true, the original normalisation is computed with the overflow bins included, so that the resulting visible normalisation can be less than normto. This is probably what you want. Definition at line 260 of file BinnedDbn.h. 260 {
262 if (oldintegral == 0) throw WeightError("Attempted to normalize a histogram with null area");
263 scaleW(normto / oldintegral);
264 }
void scaleW(const double scalefactor) noexcept Rescale as if all fill weights had been different by factor scalefactor. Definition BinnedDbn.h:239 References YODA::DbnStorage< DbnN, AxisT >::integral(), and YODA::DbnStorage< DbnN, AxisT >::scaleW(). ◆ numEntries()
template<size_t DbnN, typename... AxisT>
Get the number of fills (fractional fills are possible). Implements YODA::Fillable. Definition at line 511 of file BinnedDbn.h. References YODA::BinnedStorage< BinContentT, AxisT >::bins(). Referenced by YODA::DbnStorage< DbnN, AxisT >::mkEstimate(), YODA::WriterYODA1::writeHisto1D(), YODA::WriterYODA1::writeHisto2D(), YODA::WriterYODA1::writeProfile1D(), and YODA::WriterYODA1::writeProfile2D(). ◆ operator+=() [1/2]
template<size_t DbnN, typename... AxisT>
Add two DbnStorages.
Definition at line 354 of file BinnedDbn.h. 354 {
355 if (*this != dbn)
356 throw BinningError("Arithmetic operation requires compatible binning!");
359 BaseT::bin(i) += dbn.bin(i);
360 }
362 return *this;
363 }
void rmAnnotation(const std::string &name) Delete an annotation by name. Definition AnalysisObject.h:214 bool hasAnnotation(const std::string &name) const Check if an annotation is defined. Definition AnalysisObject.h:132 void maskBins(const std::vector< size_t > &indicesToMask, const bool status=true) noexcept Mask a range of bins. Definition BinnedStorage.h:356 References YODA::BinnedStorage< BinContentT, AxisT >::bin(), YODA::AnalysisObject::hasAnnotation(), YODA::BinnedStorage< BinContentT, AxisT >::maskBins(), YODA::BinnedStorage< BinContentT, AxisT >::maskedBins(), YODA::BinnedStorage< BinContentT, AxisT >::numBins(), and YODA::AnalysisObject::rmAnnotation(). ◆ operator+=() [2/2]
template<size_t DbnN, typename... AxisT>
Definition at line 365 of file BinnedDbn.h. 365 {
366 if (*this != dbn)
367 throw BinningError("Arithmetic operation requires compatible binning!");
370 BaseT::bin(i) += std::move(dbn.bin(i));
371 }
373 return *this;
374 }
References YODA::BinnedStorage< BinContentT, AxisT >::bin(), YODA::AnalysisObject::hasAnnotation(), YODA::BinnedStorage< BinContentT, AxisT >::maskBins(), YODA::BinnedStorage< BinContentT, AxisT >::numBins(), and YODA::AnalysisObject::rmAnnotation(). ◆ operator-=() [1/2]
template<size_t DbnN, typename... AxisT>
Subtract one DbnStorages from another one.
Definition at line 381 of file BinnedDbn.h. 381 {
382 if (*this != dbn)
383 throw BinningError("Arithmetic operation requires compatible binning!");
386 BaseT::bin(i) -= dbn.bin(i);
387 }
389 return *this;
390 }
References YODA::BinnedStorage< BinContentT, AxisT >::bin(), YODA::AnalysisObject::hasAnnotation(), YODA::BinnedStorage< BinContentT, AxisT >::maskBins(), YODA::BinnedStorage< BinContentT, AxisT >::maskedBins(), YODA::BinnedStorage< BinContentT, AxisT >::numBins(), and YODA::AnalysisObject::rmAnnotation(). ◆ operator-=() [2/2]
template<size_t DbnN, typename... AxisT>
Definition at line 392 of file BinnedDbn.h. 392 {
393 if (*this != dbn)
394 throw BinningError("Arithmetic operation requires compatible binning!");
397 BaseT::bin(i) -= std::move(dbn.bin(i));
398 }
400 return *this;
401 }
References YODA::BinnedStorage< BinContentT, AxisT >::bin(), YODA::AnalysisObject::hasAnnotation(), YODA::BinnedStorage< BinContentT, AxisT >::maskBins(), YODA::BinnedStorage< BinContentT, AxisT >::numBins(), and YODA::AnalysisObject::rmAnnotation(). ◆ operator=() [1/2]
template<size_t DbnN, typename... AxisT>
Copy assignment. Definition at line 330 of file BinnedDbn.h. 330 {
331 if (this != &dbn) {
332 AnalysisObject::operator = (dbn);
333 BaseT::operator = (dbn);
334 }
335 return *this;
336 }
virtual AnalysisObject & operator=(const AnalysisObject &ao) noexcept Default copy assignment operator. Definition AnalysisObject.h:66 FillableStorage & operator=(const FillableStorage &other) noexcept Copy assignment. Definition FillableStorage.h:226 References YODA::AnalysisObject::operator=(), and YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >::operator=(). ◆ operator=() [2/2]
template<size_t DbnN, typename... AxisT>
Move assignment. Definition at line 339 of file BinnedDbn.h. 339 {
340 if (this != &dbn) {
341 AnalysisObject::operator = (dbn);
342 BaseT::operator = (std::move(dbn));
343 }
344 return *this;
345 }
References YODA::AnalysisObject::operator=(), and YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >::operator=(). ◆ rebin() [1/2]
template<size_t DbnN, typename... AxisT>
template<size_t axisN>
Overloaded alias for rebinTo. Definition at line 325 of file BinnedDbn.h. 325 {
326 rebinTo<axisN>(newedges);
327 }
◆ rebin() [2/2]
template<size_t DbnN, typename... AxisT>
template<size_t axisN>
Overloaded alias for rebinBy. Definition at line 292 of file BinnedDbn.h. 292 {
293 rebinBy<axisN>(n, begin, end);
294 }
◆ rebinBy()
template<size_t DbnN, typename... AxisT>
template<size_t axisN>
Merge every group of n bins, from start to end inclusive. If the number of bins is not a multiple of n, the last m < n bins on the RHS will also be merged, as the closest possible approach to factor
Definition at line 276 of file BinnedDbn.h. 276 {
277 if (n < 1) throw UserError("Rebinning requested in groups of 0!");
278 if (!begin) throw UserError("Visible bins start with index 1!");
280 for (size_t m = begin; m < end; ++m) {
283 if (myend > m) {
284 BaseT::template mergeBins<axisN>({m, myend});
285 end -= myend-m; //< reduce upper index by the number of removed bins
286 }
287 }
288 }
size_t numBinsAt(const size_t axisN, const bool includeOverflows=false) const noexcept Number of bins in the BinnedStorage. Definition BinnedStorage.h:339 References YODA::BinnedStorage< BinContentT, AxisT >::numBinsAt(). ◆ rebinTo()
template<size_t DbnN, typename... AxisT>
template<size_t axisN>
Rebin to the given list of bin edges. Definition at line 298 of file BinnedDbn.h. 298 {
299 if (newedges.size() < 2)
300 throw UserError("Requested rebinning to an edge list which defines no bins");
301 using thisAxisT = typename BinningT::template getAxisT<axisN>;
302 using thisEdgeT = typename thisAxisT::EdgeT;
303 // get list of shared edges
304 thisAxisT& oldAxis = BaseT::_binning.template axis<axisN>();
305 const thisAxisT newAxis(newedges);
306 const std::vector<thisEdgeT> eshared = oldAxis.sharedEdges(newAxis);
307 if (eshared.size() != newAxis.edges().size())
308 throw BinningError("Requested rebinning to incompatible edges");
309 // loop over new lower bin edges (= first bin index of merge range)
310 for (size_t begin = 0; begin < eshared.size() - 1; ++begin) {
311 // find index of upper edge along old axis
312 // (subtracting 1 gives index of last bin to be merged)
313 size_t end = oldAxis.index(eshared[begin+1]) - 1;
314 // if the current edge is the last visible edge before the overflow
315 // merge the remaining bins into the overflow
316 if (begin == newAxis.numBins(true)-1) end = oldAxis.numBins(true)-1;
317 // merge this range
318 if (end > begin) BaseT::template mergeBins<axisN>({begin, end});
319 if (eshared.size() == oldAxis.edges().size()) break; // we're done
320 }
321 }
◆ reset()
template<size_t DbnN, typename... AxisT>
Reset the histogram. Keep the binning but set all bin contents and related quantities to zero Implements YODA::AnalysisObject. Definition at line 411 of file BinnedDbn.h. 411{ BaseT::reset(); }
References YODA::FillableStorage< DbnN, Dbn< DbnN >, AxisT... >::reset(). ◆ rms()
template<size_t DbnN, typename... AxisT>
Calculates the RMS at axis. Definition at line 601 of file BinnedDbn.h. 601 {
602 Dbn<DbnN> dbn;
604 dbn += b;
605 return dbn.RMS(axisN+1);
606 }
References YODA::BinnedStorage< BinContentT, AxisT >::bins(), and YODA::DbnBase< N >::RMS(). ◆ scale()
template<size_t DbnN, typename... AxisT>
Rescale as if all fill weights had been different by factor scalefactor along dimension i. Definition at line 247 of file BinnedDbn.h. 247 {
250 bin.scale(i, scalefactor);
251 }
252 }
void setAnnotation(const std::string &name, const T &value) Add or set an annotation by name (templated for remaining types) Definition AnalysisObject.h:182 References YODA::BinnedStorage< BinContentT, AxisT >::bin(), and YODA::AnalysisObject::setAnnotation(). Referenced by YODA::DbnStorage< DbnN, AxisT >::mkBinnedEffNumEntries(), and YODA::DbnStorage< DbnN, AxisT >::mkEstimate(). ◆ scaleW()
template<size_t DbnN, typename... AxisT>
Rescale as if all fill weights had been different by factor scalefactor. Implements YODA::Fillable. Definition at line 239 of file BinnedDbn.h. References YODA::BinnedStorage< BinContentT, AxisT >::bin(), and YODA::AnalysisObject::setAnnotation(). Referenced by YODA::DbnStorage< DbnN, AxisT >::normalize(). ◆ serializeContent()
template<size_t DbnN, typename... AxisT>
Content serialisation for MPI reduce operations. Implements YODA::AnalysisObject. Definition at line 759 of file BinnedDbn.h. 759 {
760 std::vector<double> rtn;
762 rtn.reserve(nBins * Dbn<DbnN>::DataSize::value);
763 for (size_t i = 0; i < nBins; ++i) {
764 std::vector<double> bdata = BaseT::bin(i)._serializeContent();
765 rtn.insert(std::end(rtn),
766 std::make_move_iterator(std::begin(bdata)),
767 std::make_move_iterator(std::end(bdata)));
768 }
769 return rtn;
770 }
References YODA::BinnedStorage< BinContentT, AxisT >::bin(), and YODA::BinnedStorage< BinContentT, AxisT >::numBins(). ◆ stdDev()
template<size_t DbnN, typename... AxisT>
Calculates the standard deviation at axis. Definition at line 588 of file BinnedDbn.h. 588 {
590 }
double variance(size_t axisN, const bool includeOverflows=true) const noexcept Calculates the variance at axis. Definition BinnedDbn.h:580 References YODA::DbnStorage< DbnN, AxisT >::variance(). ◆ stdErr()
template<size_t DbnN, typename... AxisT>
Calculates the standard error at axis. Definition at line 593 of file BinnedDbn.h. 593 {
594 Dbn<DbnN> dbn;
596 dbn += b;
597 return dbn.stdErr(axisN+1);
598 }
References YODA::BinnedStorage< BinContentT, AxisT >::bins(), and YODA::DbnBase< N >::stdErr(). ◆ sumW()
template<size_t DbnN, typename... AxisT>
Calculates sum of weights in histo. Implements YODA::Fillable. Definition at line 527 of file BinnedDbn.h. References YODA::BinnedStorage< BinContentT, AxisT >::bins(). Referenced by YODA::DbnStorage< DbnN, AxisT >::integral(), YODA::WriterYODA1::writeHisto1D(), YODA::WriterYODA1::writeHisto2D(), YODA::WriterYODA1::writeProfile1D(), and YODA::WriterYODA1::writeProfile2D(). ◆ sumW2()
template<size_t DbnN, typename... AxisT>
Calculates sum of squared weights in histo. Implements YODA::Fillable. Definition at line 535 of file BinnedDbn.h. References YODA::BinnedStorage< BinContentT, AxisT >::bins(). Referenced by YODA::DbnStorage< DbnN, AxisT >::integralError(), YODA::WriterYODA1::writeHisto1D(), YODA::WriterYODA1::writeHisto2D(), YODA::WriterYODA1::writeProfile1D(), and YODA::WriterYODA1::writeProfile2D(). ◆ sumWA()
template<size_t DbnN, typename... AxisT>
Calculates first moment along axis dim in histo. Definition at line 543 of file BinnedDbn.h. 543 {
545 double sumwa = 0;
548 return sumwa;
549 }
size_t dim() const noexcept Total dimension of the object (number of axes + filled value) Definition BinnedDbn.h:422 References YODA::BinnedStorage< BinContentT, AxisT >::bins(), and YODA::DbnStorage< DbnN, AxisT >::dim(). Referenced by YODA::WriterYODA1::writeHisto1D(), YODA::WriterYODA1::writeHisto2D(), YODA::WriterYODA1::writeProfile1D(), and YODA::WriterYODA1::writeProfile2D(). ◆ sumWA2()
template<size_t DbnN, typename... AxisT>
Calculates second moment along axis dim in histo. Definition at line 552 of file BinnedDbn.h. 552 {
554 double sumwa2 = 0;
557 return sumwa2;
558 }
References YODA::BinnedStorage< BinContentT, AxisT >::bins(), and YODA::DbnStorage< DbnN, AxisT >::dim(). Referenced by YODA::WriterYODA1::writeHisto1D(), YODA::WriterYODA1::writeHisto2D(), YODA::WriterYODA1::writeProfile1D(), and YODA::WriterYODA1::writeProfile2D(). ◆ variance()
template<size_t DbnN, typename... AxisT>
Calculates the variance at axis. Definition at line 580 of file BinnedDbn.h. 580 {
581 Dbn<DbnN> dbn;
583 dbn += b;
584 return dbn.variance(axisN+1);
585 }
References YODA::BinnedStorage< BinContentT, AxisT >::bins(), and YODA::DbnBase< N >::variance(). Referenced by YODA::DbnStorage< DbnN, AxisT >::stdDev(). ◆ widths()
template<size_t DbnN, typename... AxisT>
template<size_t I, typename E = typename BinningT::template getEdgeT<I>>
Templated version to get bin widths of axis N by reference. Overflows are included depending on includeOverflows Needed by axis-specific version from AxisMixin
Definition at line 441 of file BinnedDbn.h. 441 {
442 return BaseT::_binning.template widths<I>(includeOverflows);
443 }
The documentation for this class was generated from the following file:
Generated on Fri Mar 7 2025 09:06:40 for YODA - Yet more Objects for Data Analysis by |