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 115 of file BinnedDbn.h. Member Typedef Documentation◆ BaseT
template<size_t DbnN, typename... AxisT>
Definition at line 119 of file BinnedDbn.h. ◆ BinningT
template<size_t DbnN, typename... AxisT>
Definition at line 120 of file BinnedDbn.h. ◆ BinT
template<size_t DbnN, typename... AxisT>
Definition at line 121 of file BinnedDbn.h. ◆ BinType
template<size_t DbnN, typename... AxisT>
Definition at line 122 of file BinnedDbn.h. ◆ FillType
template<size_t DbnN, typename... AxisT>
Definition at line 123 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 133 of file BinnedDbn.h. FillableStorage< DbnN, Dbn< DbnN >, AxisT... > BaseT Definition BinnedDbn.h:119 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 140 of file BinnedDbn.h. 142 : 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 150 of file BinnedDbn.h. 152 : 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 160 of file BinnedDbn.h. 162 : 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 170 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 184 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 200 of file BinnedDbn.h. ◆ DbnStorage() [12/12]
template<size_t DbnN, typename... AxisT>
Move constructor.
Definition at line 206 of file BinnedDbn.h. Member Function Documentation◆ clone()
template<size_t DbnN, typename... AxisT>
Make a copy on the stack. Definition at line 210 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 557 of file BinnedDbn.h. 557 {
558 if (A1 >= DbnN || A2 >= DbnN) throw RangeError("Invalid axis int, must be in range 0..dim-1");
559 if (A1 >= A2) throw RangeError("Indices need to be different for cross term");
560 double sumw = 0;
562 sumw += b.crossTerm(A1, A2);
563 return sumw;
564 }
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:557 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 611 of file BinnedDbn.h. 611 {
614 return std::numeric_limits<double>::quiet_NaN();
615 }
double dVol(const bool includeOverflows=true) const noexcept Definition BinnedDbn.h:603 double integral(const bool includeOverflows=true) const noexcept Get the total volume of the histogram. Definition BinnedDbn.h:463 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 618 of file BinnedDbn.h. 618 {
621 return std::numeric_limits<double>::quiet_NaN();
622 }
double integralError(const bool includeOverflows=true) const noexcept Get the total volume error of the histogram. Definition BinnedDbn.h:468 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 625 of file BinnedDbn.h. 625 {
626 double rho = 0.0;
629 return rho;
630 }
double sumW(const bool includeOverflows=true) const noexcept Calculates sum of weights in histo. Definition BinnedDbn.h:522 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 729 of file BinnedDbn.h. 729 {
730
731 constexpr size_t dbnSize = Dbn<DbnN>::DataSize::value;
733 if (data.size() != nBins * dbnSize)
734 throw UserError("Length of serialized data should be "
735 + std::to_string(nBins * dbnSize)+"!");
736
737 const auto itr = data.cbegin();
738 for (size_t i = 0; i < nBins; ++i) {
739 auto first = itr + i*dbnSize;
740 auto last = first + dbnSize;
741 BaseT::bin(i)._deserializeContent(std::vector<double>{first, last});
742 }
743
744 }
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 417 of file BinnedDbn.h. 417{ 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 603 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 424 of file BinnedDbn.h. 424 {
425 return BaseT::_binning.template edges<I>(includeOverflows);
426 }
◆ effNumEntries()
template<size_t DbnN, typename... AxisT>
Get the effective number of fills. Implements YODA::Fillable. Definition at line 514 of file BinnedDbn.h. 514 {
515 double n = 0;
517 n += b.effNumEntries();
518 return n;
519 }
double effNumEntries(const bool includeOverflows=true) const noexcept Get the effective number of fills. Definition BinnedDbn.h:514 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 229 of file BinnedDbn.h. 229 {
230 return BaseT::fill(std::move(coords), std::make_index_sequence<sizeof...(AxisT)>{}, weight, fraction);
231 }
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 414 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 463 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 468 of file BinnedDbn.h. 468 {
470 }
double sumW2(const bool includeOverflows=true) const noexcept Calculates sum of squared weights in histo. Definition BinnedDbn.h:530 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 479 of file BinnedDbn.h. 479 {
480 assert(binIndex2 >= binIndex1);
483 double sumw = 0;
484 for (size_t idx = binIndex1; idx <= binIndex2; ++idx) {
486 sumw += BaseT::bin(idx).sumW();
487 }
488 return sumw;
489 }
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 493 of file BinnedDbn.h. 493 {
494 assert(binIndex2 >= binIndex1);
497 double sumw2 = 0;
498 for (size_t idx = binIndex1; idx <= binIndex2; ++idx) {
500 sumw2 += BaseT::bin(idx).sumW2();
501 }
502 return sumw2;
503 }
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 473 of file BinnedDbn.h. 473 {
475 }
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:479 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 712 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 452 of file BinnedDbn.h. 452 {
453 return BaseT::_binning.template max<I>();
454 }
◆ maxDensity()
template<size_t DbnN, typename... AxisT>
Returns the largest density in any of the bins. Definition at line 633 of file BinnedDbn.h. 633 {
634 std::vector<double> vals;
637 return *max_element(vals.begin(), vals.end());
638 }
References YODA::BinnedStorage< BinContentT, AxisT >::bins(). ◆ mean()
template<size_t DbnN, typename... AxisT>
Calculates the mean value at axis. Definition at line 567 of file BinnedDbn.h. 567 {
568 Dbn<DbnN> dbn;
570 dbn += b;
571 return dbn.mean(axisN+1);
572 }
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 444 of file BinnedDbn.h. 444 {
445 return BaseT::_binning.template min<I>();
446 }
◆ mkEstimate()
template<size_t DbnN, typename... AxisT>
Produce a BinnedEstimate from a DbnStorage. The binning remains unchanged. Definition at line 754 of file BinnedDbn.h. 756 {
757
758 // @todo Should we check BaseT::nanCount() and report?
759 BinnedEstimate<AxisT...> rtn(BaseT::_binning);
762 }
764
770 rtn.setAnnotation("NanFraction", frac);
771 if (wtot) rtn.setAnnotation("WeightedNanFraction", nanw/wtot);
772 }
773
775 if (!b.isVisible()) continue;
776 if constexpr(DbnN > sizeof...(AxisT)) {
777 rtn.bin(b.index()).setVal(b.mean(DbnN));
778 if (b.numEntries()) { // only set uncertainty for filled Dbns
779 rtn.bin(b.index()).setErr(b.stdErr(DbnN), source);
780 }
781 }
782 else {
784 rtn.bin(b.index()).setVal(b.sumW() / scale);
785 if (b.numEntries()) { // only set uncertainty for filled Dbns
786 rtn.bin(b.index()).setErr(b.errW() / scale, source);
787 }
788 }
789 }
790
791 return rtn;
792 }
std::vector< std::string > annotations() const Definition AnalysisObject.h:107 const std::string & annotation(const std::string &name) const Get an annotation by name (as a string) Definition AnalysisObject.h:122 double numEntries(const bool includeOverflows=true) const noexcept Get the number of fills (fractional fills are possible). Definition BinnedDbn.h:506 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:242 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 >::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 799 of file BinnedDbn.h. 800 {
801
804 }
BinnedEstimate< AxisT... > mkEstimate(const std::string &path="", const std::string &source="", const bool divbyvol=true) const Produce a BinnedEstimate from a DbnStorage. Definition BinnedDbn.h:754 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 838 of file BinnedDbn.h. 838 {
839
840 BinnedHisto<AxisT...> rtn(BaseT::_binning);
844 }
846
848 rtn.bin(b.index()) += b.template reduce<N-1>();
849 }
850
851 return rtn;
852 }
double nanSumW2() const Definition FillableStorage.h:203 BinnedDbn< sizeof...(AxisTypes), AxisTypes... > BinnedHisto Definition BinnedDbn.h:97 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 999 of file BinnedDbn.h. 999 {
1000
1001 if constexpr (DbnN != sizeof...(AxisT)) {
1002 // Case 1: BP(N+1) -> BH(N+1) -> BHN
1004 }
1005 else {
1006 // Case 2: BH(N+1) -> BHN
1007
1008 // Need to provide a prescription for how to add the two bin contents
1009 auto how2add = [](auto& pivot, const BinType& toCopy) { pivot = toCopy.template reduce<axisN>(); };
1010 auto rtn = BaseT::template mkBinnedSlices<axisN,BinnedHisto>(how2add, includeOverflows);
1012 if (a == "Type") continue;
1013 for (size_t i = 0; i < rtn.size(); ++i) {
1014 rtn[i].setAnnotation(a, annotation(a));
1015 }
1016 }
1017 for (size_t i = 0; i < rtn.size(); ++i) {
1019 }
1020 return rtn;
1021 }
1022 }
BinnedHisto< AxisT... > mkHisto(const std::string &path="") const Produce a BinnedHisto from BinnedProfile. Definition BinnedDbn.h:838 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 1026 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 920 of file BinnedDbn.h. 920 {
921
922 if constexpr (DbnN != sizeof...(AxisT)) {
923 // Case 1: BP(N+1) -> BH(N+1) -> BHN
925 }
926 else {
927 // Case 2: BH(N+1) -> BHN
928
929 auto rtn = BaseT::template _mkBinnedT<BinnedHisto>(BaseT::_binning.template _getAxesExcept<axisN>());
933 }
935
936 auto collapseStorageBins =
937 [&oldBinning = BaseT::_binning, &oldBins = BaseT::_bins, &rtn](auto I, auto dbnRed) {
938
939 auto collapse = [&oldBins, &rtn](const auto& binsIndicesToMerge, auto axis) {
940 assert(rtn.numBins(true) == binsIndicesToMerge.size());
941
942 // for any given pivot, add the content
943 // from the old slice to the new slice
944 for (size_t i = 0; i < rtn.numBins(true); ++i) {
945 auto& pivotBin = rtn.bin(i);
946 auto& binToAppend = oldBins[binsIndicesToMerge[i]];
947 pivotBin += binToAppend.template reduce<axis>();
948 }
949 };
950
951 // get bin slice for any given bin along the axis that is to be
952 // collapsed, then copy the values into the new binning
953 ssize_t nBinRowsToBeMerged = oldBinning.numBinsAt(I);
954 while (nBinRowsToBeMerged--) {
957 collapse(oldBinning.sliceIndices(I, nBinRowsToBeMerged), dbnRed);
958 }
959 };
960 // collapse Dbn along axisN
961 auto dbnRed = std::integral_constant<size_t, axisN>();
962 (void)collapseStorageBins(std::integral_constant<std::size_t, axisN>(), dbnRed);
963
964 return rtn;
965 }
966 }
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 866 of file BinnedDbn.h. 866 {
867
868 auto rtn = BaseT::template _mkBinnedT<BinnedProfile>(BaseT::_binning.template _getAxesExcept<axisN>());
872 }
874
875 auto collapseStorageBins =
876 [&oldBinning = BaseT::_binning, &oldBins = BaseT::_bins, &rtn](auto I, auto dbnRed) {
877
878 auto collapse = [&oldBins, &rtn](const auto& binsIndicesToMerge, auto axis) {
879 assert(rtn.numBins(true) == binsIndicesToMerge.size());
880
881 // for any given pivot, add the content
882 // from the old slice to the new slice
883 for (size_t i = 0; i < rtn.numBins(true); ++i) {
884 auto& pivotBin = rtn.bin(i);
885 auto& binToAppend = oldBins[binsIndicesToMerge[i]];
886 pivotBin += binToAppend.template reduce<axis>();
887 }
888 };
889
890 // get bin slice for any given bin along the axis that is to be
891 // collapsed, then copy the values into the new binning
892 ssize_t nBinRowsToBeMerged = oldBinning.numBinsAt(I);
893 while (nBinRowsToBeMerged--) {
896 collapse(oldBinning.sliceIndices(I, nBinRowsToBeMerged), dbnRed);
897 }
898 };
902 auto dbnRed = std::integral_constant<size_t, (sizeof...(AxisT) == DbnN)? DbnN : axisN>();
903 (void)collapseStorageBins(std::integral_constant<std::size_t, axisN>(), dbnRed);
904
905 return rtn;
906 }
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 976 of file BinnedDbn.h. 976 {
977
978 // Need to provide a prescription for how to add the two bin contents
979 auto how2add = [](auto& pivot, const BinType& toCopy) { pivot = toCopy.template reduce<axisN>(); };
980 auto rtn = BaseT::template mkBinnedSlices<axisN, BinnedProfile>(how2add, includeOverflows);
982 if (a == "Type") continue;
983 for (size_t i = 0; i < rtn.size(); ++i) {
984 rtn[i].setAnnotation(a, annotation(a));
985 }
986 }
987 for (size_t i = 0; i < rtn.size(); ++i) {
989 }
990 return rtn;
991 }
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 808 of file BinnedDbn.h. 811 {
813 ScatterND<sizeof...(AxisT)+1> rtn = est.mkScatter(path, "", includeOverflows, includeMaskedBins);
814 if (usefocus) {
815 size_t idx = 0;
817 auto shiftIfContinuous = [&rtn, &b, &idx](auto I) {
818 using isContinuous = typename BinningT::template is_CAxis<I>;
819 if constexpr (isContinuous::value) {
820 const double oldMax = rtn.point(idx).max(I);
821 const double oldMin = rtn.point(idx).min(I);
822 const double newVal = b.mean(I+1);
823 rtn.point(idx).set(I, newVal, newVal - oldMin, oldMax - newVal);
824 }
825 };
826 MetaUtils::staticFor<BinningT::Dimension::value>(shiftIfContinuous);
827 ++idx;
828 }
829 }
830 return rtn;
831 }
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 215 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 255 of file BinnedDbn.h. 255 {
257 if (oldintegral == 0) throw WeightError("Attempted to normalize a histogram with null area");
258 scaleW(normto / oldintegral);
259 }
void scaleW(const double scalefactor) noexcept Rescale as if all fill weights had been different by factor scalefactor. Definition BinnedDbn.h:234 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 506 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 349 of file BinnedDbn.h. 349 {
350 if (*this != dbn)
351 throw BinningError("Arithmetic operation requires compatible binning!");
354 BaseT::bin(i) += dbn.bin(i);
355 }
357 return *this;
358 }
void rmAnnotation(const std::string &name) Delete an annotation by name. Definition AnalysisObject.h:198 bool hasAnnotation(const std::string &name) const Check if an annotation is defined. Definition AnalysisObject.h:116 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 360 of file BinnedDbn.h. 360 {
361 if (*this != dbn)
362 throw BinningError("Arithmetic operation requires compatible binning!");
365 BaseT::bin(i) += std::move(dbn.bin(i));
366 }
368 return *this;
369 }
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 376 of file BinnedDbn.h. 376 {
377 if (*this != dbn)
378 throw BinningError("Arithmetic operation requires compatible binning!");
381 BaseT::bin(i) -= dbn.bin(i);
382 }
384 return *this;
385 }
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 387 of file BinnedDbn.h. 387 {
388 if (*this != dbn)
389 throw BinningError("Arithmetic operation requires compatible binning!");
392 BaseT::bin(i) -= std::move(dbn.bin(i));
393 }
395 return *this;
396 }
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 325 of file BinnedDbn.h. 325 {
326 if (this != &dbn) {
327 AnalysisObject::operator = (dbn);
328 BaseT::operator = (dbn);
329 }
330 return *this;
331 }
virtual AnalysisObject & operator=(const AnalysisObject &ao) noexcept Default copy assignment operator. Definition AnalysisObject.h:61 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 334 of file BinnedDbn.h. 334 {
335 if (this != &dbn) {
336 AnalysisObject::operator = (dbn);
337 BaseT::operator = (std::move(dbn));
338 }
339 return *this;
340 }
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 320 of file BinnedDbn.h. 320 {
321 rebinTo<axisN>(newedges);
322 }
◆ rebin() [2/2]
template<size_t DbnN, typename... AxisT>
template<size_t axisN>
Overloaded alias for rebinBy. Definition at line 287 of file BinnedDbn.h. 287 {
288 rebinBy<axisN>(n, begin, end);
289 }
◆ 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 271 of file BinnedDbn.h. 271 {
272 if (n < 1) throw UserError("Rebinning requested in groups of 0!");
273 if (!begin) throw UserError("Visible bins start with index 1!");
275 for (size_t m = begin; m < end; ++m) {
278 if (myend > m) {
279 BaseT::template mergeBins<axisN>({m, myend});
280 end -= myend-m; //< reduce upper index by the number of removed bins
281 }
282 }
283 }
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 293 of file BinnedDbn.h. 293 {
294 if (newedges.size() < 2)
295 throw UserError("Requested rebinning to an edge list which defines no bins");
296 using thisAxisT = typename BinningT::template getAxisT<axisN>;
297 using thisEdgeT = typename thisAxisT::EdgeT;
298 // get list of shared edges
299 thisAxisT& oldAxis = BaseT::_binning.template axis<axisN>();
300 const thisAxisT newAxis(newedges);
301 const std::vector<thisEdgeT> eshared = oldAxis.sharedEdges(newAxis);
302 if (eshared.size() != newAxis.edges().size())
303 throw BinningError("Requested rebinning to incompatible edges");
304 // loop over new lower bin edges (= first bin index of merge range)
305 for (size_t begin = 0; begin < eshared.size() - 1; ++begin) {
306 // find index of upper edge along old axis
307 // (subtracting 1 gives index of last bin to be merged)
308 size_t end = oldAxis.index(eshared[begin+1]) - 1;
309 // if the current edge is the last visible edge before the overflow
310 // merge the remaining bins into the overflow
311 if (begin == newAxis.numBins(true)-1) end = oldAxis.numBins(true)-1;
312 // merge this range
313 if (end > begin) BaseT::template mergeBins<axisN>({begin, end});
314 if (eshared.size() == oldAxis.edges().size()) break; // we're done
315 }
316 }
◆ 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 406 of file BinnedDbn.h. 406{ 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 596 of file BinnedDbn.h. 596 {
597 Dbn<DbnN> dbn;
599 dbn += b;
600 return dbn.RMS(axisN+1);
601 }
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 242 of file BinnedDbn.h. 242 {
245 bin.scale(i, scalefactor);
246 }
247 }
void setAnnotation(const std::string &name, const T &value) Add or set an annotation by name (templated for remaining types) Definition AnalysisObject.h:166 References YODA::BinnedStorage< BinContentT, AxisT >::bin(), and YODA::AnalysisObject::setAnnotation(). Referenced by 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 234 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 716 of file BinnedDbn.h. 716 {
717 std::vector<double> rtn;
719 rtn.reserve(nBins * Dbn<DbnN>::DataSize::value);
720 for (size_t i = 0; i < nBins; ++i) {
721 std::vector<double> bdata = BaseT::bin(i)._serializeContent();
722 rtn.insert(std::end(rtn),
723 std::make_move_iterator(std::begin(bdata)),
724 std::make_move_iterator(std::end(bdata)));
725 }
726 return rtn;
727 }
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 583 of file BinnedDbn.h. 583 {
585 }
double variance(size_t axisN, const bool includeOverflows=true) const noexcept Calculates the variance at axis. Definition BinnedDbn.h:575 References YODA::DbnStorage< DbnN, AxisT >::variance(). ◆ stdErr()
template<size_t DbnN, typename... AxisT>
Calculates the standard error at axis. Definition at line 588 of file BinnedDbn.h. 588 {
589 Dbn<DbnN> dbn;
591 dbn += b;
592 return dbn.stdErr(axisN+1);
593 }
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 522 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 530 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 538 of file BinnedDbn.h. 538 {
540 double sumwa = 0;
543 return sumwa;
544 }
size_t dim() const noexcept Total dimension of the object (number of axes + filled value) Definition BinnedDbn.h:417 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 547 of file BinnedDbn.h. 547 {
549 double sumwa2 = 0;
552 return sumwa2;
553 }
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 575 of file BinnedDbn.h. 575 {
576 Dbn<DbnN> dbn;
578 dbn += b;
579 return dbn.variance(axisN+1);
580 }
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 436 of file BinnedDbn.h. 436 {
437 return BaseT::_binning.template widths<I>(includeOverflows);
438 }
The documentation for this class was generated from the following file:
Generated on Mon Oct 28 2024 13:47:24 for YODA - Yet more Objects for Data Analysis by 1.9.8 |