YODA Namespace Reference Anonymous namespace to limit visibility. More...
Detailed DescriptionAnonymous namespace to limit visibility.
Typedef Documentation◆ all_CAxes
template<typename... EdgeT>
Definition at line 18 of file BinningUtils.h. ◆ AO
Convenience alias. Definition at line 360 of file AnalysisObject.h. ◆ BinnedEstimate1D
template<typename A1 >
Define dimension-specific short-hands (Cython sugar) Definition at line 1222 of file BinnedEstimate.h. ◆ BinnedEstimate2D
template<typename A1 , typename A2 >
Definition at line 1225 of file BinnedEstimate.h. ◆ BinnedEstimate3D
template<typename A1 , typename A2 , typename A3 >
Definition at line 1228 of file BinnedEstimate.h. ◆ BinnedHisto
template<typename... AxisTypes>
Definition at line 97 of file BinnedDbn.h. ◆ BinnedHisto1D
template<typename A1 >
◆ BinnedHisto2D
template<typename A1 , typename A2 >
◆ BinnedHisto3D
template<typename A1 , typename A2 , typename A3 >
◆ BinnedProfile
template<typename... AxisTypes>
Definition at line 100 of file BinnedDbn.h. ◆ BinnedProfile1D
template<typename A1 >
◆ BinnedProfile2D
template<typename A1 , typename A2 >
◆ BinnedProfile3D
template<typename A1 , typename A2 , typename A3 >
◆ Dbn0D
◆ Dbn1D
◆ Dbn2D
◆ Dbn3D
◆ enable_if_all_CAxisT
template<typename... EdgeT>
Checks if all edge types are continuous. Definition at line 22 of file BinningUtils.h. ◆ enable_if_CAxisT
template<typename EdgeT >
Checks if edge type is continuous and returns edge type. Definition at line 26 of file BinningUtils.h. ◆ enable_if_DAxisT
template<typename EdgeT >
Checks if edge type is discrete and returns edge type. Definition at line 30 of file BinningUtils.h. ◆ Estimate1D
Definition at line 1246 of file BinnedEstimate.h. ◆ Estimate2D
Definition at line 1247 of file BinnedEstimate.h. ◆ Estimate3D
Definition at line 1248 of file BinnedEstimate.h. ◆ EstimateND
template<size_t N>
Definition at line 1242 of file BinnedEstimate.h. ◆ Histo1D
◆ Histo2D
◆ Histo3D
◆ HistoND
template<size_t N>
◆ Point1D
◆ Point2D
◆ Point3D
◆ Point4D
◆ Profile1D
◆ Profile2D
◆ Profile3D
◆ ProfileND
template<size_t N>
◆ S1D◆ S2D◆ S3D◆ S4D◆ Scatter1D
◆ Scatter2D
◆ Scatter3D
◆ Scatter4D
◆ Trf
template<size_t N>
Definition at line 128 of file Transformation.h. Enumeration Type Documentation◆ RangeBoundary
Represents whether an interval is open (non-inclusive) or closed (inclusive). For example, the interval
Definition at line 156 of file MathUtils.h. ◆ Sign
Function Documentation◆ add() [1/2]
template<size_t DbnN, typename... AxisT>
Calculate the addition of a BinnedDbn with a BinnedEstimate. Definition at line 1285 of file BinnedDbn.h. 1285 {
1287 }
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(). Referenced by asymm(), efficiency(), efficiency(), operator+(), operator+(), operator+(), and operator+(). ◆ add() [2/2]
Add two numbers with FP fuzziness. Definition at line 253 of file MathUtils.h. 253 {
255 }
BinnedEstimate< AxisT... > subtract(const BinnedDbn< DbnN, AxisT... > &dbn, const BinnedEstimate< AxisT... > &est) Calculate the subtraction of a BinnedEstimate from a BinnedDbn. Definition BinnedDbn.h:1317 References subtract(). ◆ add_quad()
template<typename... Num>
Named number-type addition in quadrature operation. Definition at line 223 of file MathUtils.h. 223 {
225 }
References sqr(). Referenced by divide(). ◆ approx()
Returns a number floored at the nth decimal place. Definition at line 140 of file MathUtils.h. 140 {
141 double roundTo = pow(10.0,n);
142 a *= roundTo;
143 a = floor(a);
144 return a/roundTo;
145 }
◆ asymm() [1/2]
template<size_t DbnN, typename... AxisT>
Calculate the asymmetry (a-b)/(a+b) of two BinnedDbn objects. Definition at line 1216 of file BinnedDbn.h. 1216 {
1217 return (a-b) / (a+b);
1218 }
◆ asymm() [2/2]
template<typename... AxisT>
Calculate the asymmetry (a-b)/(a+b) of two BinnedDbn objects. Definition at line 1189 of file BinnedEstimate.h. 1191 {
1193 }
BinnedEstimate< AxisT... > add(const BinnedDbn< DbnN, AxisT... > &dbn, const BinnedEstimate< AxisT... > &est) Calculate the addition of a BinnedDbn with a BinnedEstimate. Definition BinnedDbn.h:1285 References add(), and subtract(). ◆ combine() [1/4]
template<int N>
Definition at line 804 of file Scatter.h. 804 {
805 ScatterND<N> rtn;
806 rtn.combineWith(scatters);
807 return rtn;
808 }
A generic data type which is just a collection of n-dim data points with errors. Definition Scatter.h:154 ScatterND< N > & combineWith(const ScatterND< N > &other) Definition Scatter.h:568 References YODA::ScatterND< N >::combineWith(). ◆ combine() [2/4]Definition at line 792 of file Scatter.h. References YODA::ScatterND< N >::combineWith(). ◆ combine() [3/4]Definition at line 798 of file Scatter.h. References YODA::ScatterND< N >::combineWith(). ◆ combine() [4/4]Definition at line 811 of file Scatter.h. References YODA::ScatterND< N >::combineWith(). ◆ containsNan()
template<typename... Args>
Checks if a coordinate tuple has a nan. Definition at line 30 of file Binning.h. 30 {
31 std::array<size_t, sizeof...(Args)> hasNan{};
32 auto checkCoords = [&hasNan, &coords](auto I) {
33 using isContinuous = typename std::is_floating_point<typename std::tuple_element_t<I, std::tuple<Args...>>>;
34
35 hasNan[I] = size_t(std::isnan(nullifyIfDiscCoord(std::move(std::get<I>(coords)),
36 std::integral_constant<bool,
37 isContinuous::value>{})));
38 };
39
41
42 return std::any_of(hasNan.begin(), hasNan.end(), [ ](const bool i) { return i; } );
43 }
constexpr void staticFor(Func &&f) Used to apply functor on tuple. Calls lambda with integral constant, which can be used to query tuple... Definition MetaUtils.h:35 References nullifyIfDiscCoord(), and MetaUtils::staticFor(). Referenced by YODA::FillableStorage< FillDim, BinContentT, AxisT >::fill(). ◆ correlation()
Calculate the correlation strength between two samples. Definition at line 533 of file MathUtils.h. 533 {
539 return corr_strength;
540 }
double covariance(const std::vector< int > &sample1, const std::vector< int > &sample2) Calculate the covariance (variance) between two samples. Definition MathUtils.h:518 double correlation(const std::vector< int > &sample1, const std::vector< int > &sample2) Calculate the correlation strength between two samples. Definition MathUtils.h:533 References correlation(), and covariance(). Referenced by correlation(). ◆ covariance()
Calculate the covariance (variance) between two samples. Definition at line 518 of file MathUtils.h. 518 {
521 const size_t N = sample1.size();
522 double cov = 0.0;
523 for (size_t i = 0; i < N; i++) {
524 const double cov_i = (sample1[i] - mean1)*(sample2[i] - mean2);
525 cov += cov_i;
526 }
527 if (N > 1) return cov/(N-1);
528 else return 0.0;
529 }
double mean(const std::vector< int > &sample) Calculate the mean of a sample. Definition MathUtils.h:397 References mean(). Referenced by correlation(). ◆ divide() [1/6]
template<size_t DbnN, typename... AxisT>
Calculate the division of a BinnedDbn and a BinnedEstimate. Definition at line 1349 of file BinnedDbn.h. References YODA::DbnStorage< DbnN, AxisT >::mkEstimate(). ◆ divide() [2/6]
template<size_t DbnN, typename... AxisT>
Divide two BinnedDbn objects. Definition at line 1112 of file BinnedDbn.h. 1112 {
1113
1114 if (numer != denom) {
1116 }
1117
1118 BinnedEstimate<AxisT...> rtn = numer.mkEstimate();
1120 if (rtn.hasAnnotation("ScaledBy")) rtn.rmAnnotation("ScaledBy");
1121
1122 for (const auto& b_num : numer.bins(true, true)) {
1123 const size_t idx = b_num.index();
1125 double v, e;
1126 if (isZero(b_den.effNumEntries())) {
1127 v = std::numeric_limits<double>::quiet_NaN();
1128 e = std::numeric_limits<double>::quiet_NaN();
1129 }
1130 else {
1131 if constexpr(DbnN > sizeof...(AxisT)) {
1132 v = b_num.mean(DbnN) / b_den.mean(DbnN);
1136 }
1137 else {
1138 v = b_num.sumW() / b_den.sumW();
1142 }
1143 }
1144 rtn.bin(idx).set(v, {-e, e}); // @todo put "stats" as source?
1145 }
1147
1148 return rtn;
1149 }
std::vector< size_t > maskedBins() const noexcept Definition BinnedStorage.h:379 std::enable_if_t< std::is_floating_point_v< NUM >, bool > isZero(NUM val, double tolerance=1e-5) Compare a number to zero. Definition MathUtils.h:63 References YODA::BinnedStorage< BinContentT, AxisT >::bin(), YODA::BinnedStorage< BinContentT, AxisT >::bins(), isZero(), YODA::BinnedStorage< BinContentT, AxisT >::maskedBins(), YODA::DbnStorage< DbnN, AxisT >::mkEstimate(), YODA::AnalysisObject::path(), and sqr(). Referenced by divide(), divide(), efficiency(), efficiency(), efficiency(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), and operator/(). ◆ divide() [3/6]
template<typename... AxisT>
Divide two BinnedEstimates. Definition at line 1109 of file BinnedEstimate.h. 1110 {
1111 if (numer != denom) {
1113 }
1114
1115 BinnedEstimate<AxisT...> rtn(numer.binning());
1117 if (rtn.hasAnnotation("ScaledBy")) rtn.rmAnnotation("ScaledBy");
1118
1119 for (const auto& b_num : numer.bins(true, true)) {
1120 const size_t idx = b_num.index();
1121 rtn.bin(idx) = divide(b_num, denom.bin(idx), pat_uncorr);
1122 }
1124
1125 return rtn;
1126 }
const BinningT & binning() const noexcept Returns dimension underlying binning object reference. Definition BinnedStorage.h:321 References YODA::BinnedStorage< BinContentT, AxisT >::bin(), YODA::BinnedStorage< BinContentT, AxisT >::binning(), YODA::BinnedStorage< BinContentT, AxisT >::bins(), divide(), YODA::BinnedStorage< BinContentT, AxisT >::maskedBins(), and YODA::AnalysisObject::path(). ◆ divide() [4/6]
Divide two counters, with an uncorrelated error treatment.
Definition at line 19 of file Counter.cc. 19 {
20 Estimate0D rtn;
26 rtn.set(val, {-err, err});
27 }
28 return rtn;
29 }
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 set(const double val, const std::pair< double, double > &err, const std::string source="") Set both central value and uncertainty component. Definition Estimate.h:181 std::enable_if_t< std::conjunction_v< std::is_arithmetic< Num >... >, double > add_quad(Num ... vals) Named number-type addition in quadrature operation. Definition MathUtils.h:223 References add_quad(), YODA::AnalysisObject::hasAnnotation(), YODA::AnalysisObject::path(), YODA::Counter::relErr(), YODA::AnalysisObject::rmAnnotation(), YODA::Estimate::set(), YODA::AnalysisObject::setPath(), and YODA::Counter::val(). ◆ divide() [5/6]
Divide two Estimate objects. Definition at line 686 of file Estimate.h. 687 {
688
689 Estimate rtn;
692
693 // get error sources
694 std::vector<std::string> sources = numer.sources();
695 std::vector<std::string> tmp = denom.sources();
696 sources.insert(std::end(sources),
697 std::make_move_iterator(std::begin(tmp)),
698 std::make_move_iterator(std::end(tmp)));
699 std::sort(sources.begin(), sources.end());
700 sources.erase( std::unique(sources.begin(), sources.end()), sources.end() );
701
702 std::smatch match;
703 const std::regex re(pat_uncorr, std::regex_constants::icase);
704 for (const std::string& src : sources) {
705 if (std::regex_search(src, match, re)) {
706 // treat as uncorrelated between AOs:
707 // add relative errors in quadrature
708 double n_dn = 0.0, n_up = 0.0;
710 n_dn = numer.relErrDown(src);
711 n_up = numer.relErrUp(src);
712 }
713 double d_dn = 0.0, d_up = 0.0;
715 d_dn = denom.relErrDown(src);
716 d_up = denom.relErrUp(src);
717 }
718 const double new_dn = fabs(newVal) * std::sqrt(n_dn*n_dn + d_dn*d_dn);
719 const double new_up = fabs(newVal) * std::sqrt(n_up*n_up + d_up*d_up);
720 rtn.setErr({-new_dn,new_up}, src);
721 }
722 else {
723 // treat as correlated between AOs:
724 // work out correlated ratio: R+dR = (N+dN)/(D+dD)
727 n_dn += numer.errDown(src);
728 n_up += numer.errUp(src);
729 }
732 d_dn += denom.errDown(src);
733 d_up += denom.errUp(src);
734 }
735 double new_dn = std::numeric_limits<double>::quiet_NaN();
736 double new_up = std::numeric_limits<double>::quiet_NaN();
737 if (d_dn) new_dn = n_dn / d_dn - newVal;
738 if (d_up) new_up = n_up / d_up - newVal;
739 rtn.setErr({new_dn, new_up}, src);
740 }
741 }
742
743 return rtn;
744 }
void setErr(const std::pair< double, double > &err, const std::string &source="") Set a signed uncertainty component. Definition Estimate.h:165 std::vector< std::string > sources() const noexcept The list of error source names. Definition Estimate.h:487 double errDown(const std::string &source="") const The signed error due to the systematic downward variation. Definition Estimate.h:283 double relErrUp(const std::string &source="") const The relative positive error with respect to the central value. Definition Estimate.h:322 double errUp(const std::string &source="") const The signed error due to the systematic upward variation. Definition Estimate.h:288 double relErrDown(const std::string &source="") const The relative negative error with respect to the central value. Definition Estimate.h:317 bool hasSource(const std::string &key) const noexcept Returns true/false if the error map contains key. Definition Estimate.h:494 References YODA::Estimate::errDown(), YODA::Estimate::errUp(), YODA::Estimate::hasSource(), YODA::Estimate::relErrDown(), YODA::Estimate::relErrUp(), YODA::Estimate::setErr(), YODA::Estimate::setVal(), YODA::Estimate::sources(), and YODA::Estimate::val(). ◆ divide() [6/6]
Divide two Estimate0D objects. Definition at line 326 of file Estimate0D.h. 327 {
332 return rtn;
333 }
BinnedEstimate< AxisT... > divide(const BinnedDbn< DbnN, AxisT... > &numer, const BinnedDbn< DbnN, AxisT... > &denom) Divide two BinnedDbn objects. Definition BinnedDbn.h:1112 References divide(), YODA::AnalysisObject::hasAnnotation(), YODA::AnalysisObject::path(), YODA::AnalysisObject::rmAnnotation(), and YODA::AnalysisObject::setPath(). ◆ efficiency() [1/5]
template<size_t DbnN, typename... AxisT>
Calculate a binned efficiency ratio of two BinnedDbn objects.
Definition at line 1182 of file BinnedDbn.h. 1182 {
1183
1184 if (accepted != total) {
1186 }
1187
1188 BinnedEstimate<AxisT...> rtn = divide(accepted, total);
1189
1190 for (const auto& b_acc : accepted.bins(true, true)) {
1192 auto& b_rtn = rtn.bin(b_acc.index());
1193
1194 // Check that the numerator is consistent with being a subset of the denominator
1196 if (b_acc.numEntries() > b_tot.numEntries())
1197 throw UserError("Attempt to calculate an efficiency when the numerator is not a subset of the denominator: "
1198 + Utils::toStr(b_acc.numEntries()) + " entries / " + Utils::toStr(b_tot.numEntries()) + " entries");
1199
1200 // If no entries on the denominator, set eff = err = 0 and move to the next bin
1201 double eff = std::numeric_limits<double>::quiet_NaN();
1202 double err = std::numeric_limits<double>::quiet_NaN();
1203 if (!isZero(b_tot.effNumEntries())) {
1204 eff = b_rtn.val();
1205 err = sqrt(fabs( add((1.0-2.0*eff)*b_acc.sumW2(), sqr(eff)*b_tot.sumW2()) / sqr(b_tot.sumW()) ));
1206 }
1207 b_rtn.setErr({-err, err}); // @todo put "stats" as source?
1208 }
1209 return rtn;
1210 }
References add(), YODA::BinnedStorage< BinContentT, AxisT >::bin(), YODA::BinnedStorage< BinContentT, AxisT >::bins(), divide(), isZero(), and sqr(). Referenced by efficiency(), and efficiency(). ◆ efficiency() [2/5]
template<typename... AxisT>
Calculate a binned efficiency ratio of two BinnedEstimate objects.
Definition at line 1163 of file BinnedEstimate.h. 1164 {
1165
1166 if (accepted != total) {
1168 }
1169
1170 BinnedEstimate<AxisT...> rtn(accepted.binning());
1171
1172 for (const auto& b_acc : accepted.bins(true, true)) {
1173 Estimate est;
1174 const size_t idx = b_acc.index();
1175 try {
1176 est = efficiency(b_acc, total.bin(idx), pat_uncorr);
1177 } catch (const UserError& e) {
1178 //
1179 }
1180 rtn.bin(idx).set(est);
1181 }
1182 return rtn;
1183 }
References YODA::BinnedStorage< BinContentT, AxisT >::bin(), YODA::BinnedStorage< BinContentT, AxisT >::binning(), YODA::BinnedStorage< BinContentT, AxisT >::bins(), and efficiency(). ◆ efficiency() [3/5]
Calculate an efficiency ratio of two counters.
Note that an efficiency is not the same thing as a standard division of two histograms: the errors must be treated as correlated
Definition at line 34 of file Counter.cc. 34 {
36
37 // Check that the numerator is consistent with being a subset of the denominator (NOT effNumEntries here!)
39 throw UserError("Attempt to calculate an efficiency when the numerator is not a subset of the denominator");
40
41 // If no entries on the denominator, set eff = err = 0 and move to the next bin
44 double eff = std::numeric_limits<double>::quiet_NaN();
45 double err = std::numeric_limits<double>::quiet_NaN();
49 }
50
51 tmp.set(eff, {-err, err});
52 return tmp;
53 }
Error for problems introduced outside YODA, to put it nicely. Definition Exceptions.h:86 References divide(), YODA::Counter::numEntries(), YODA::Estimate::set(), sqr(), YODA::Counter::sumW(), and YODA::Counter::sumW2(). ◆ efficiency() [4/5]
Divide two Estimate objects using binomial statistics. Check that the numerator is consistent with being a subset of the denominator
Definition at line 767 of file Estimate.h. 768 {
769
775 if (acc_val > tot_val)
776 throw UserError("Attempt to calculate an efficiency when the numerator is not a subset of the denominator: "
777 + Utils::toStr(acc_val) + " / " + Utils::toStr(tot_val));
778
780
781 // get error sources
782 std::vector<std::string> sources = accepted.sources();
783 std::vector<std::string> tmp = total.sources();
784 sources.insert(std::end(sources),
785 std::make_move_iterator(std::begin(tmp)),
786 std::make_move_iterator(std::end(tmp)));
787 std::sort(sources.begin(), sources.end());
788 sources.erase( std::unique(sources.begin(), sources.end()), sources.end() );
789
790 // set binomial error for uncorrelated error sources
791 std::smatch match;
793 const std::regex re(pat_uncorr, std::regex_constants::icase);
794 for (const std::string& src : sources) {
795 double err = std::numeric_limits<double>::quiet_NaN();
796 if (!tot_val) {
797 rtn.setErr({-err,err}, src);
798 continue;
799 }
800 else if (std::regex_search(src, match, re)) {
804 rtn.setErr({-err,err}, src);
805 continue;
806 }
807 }
808
809 return rtn;
810 }
double totalErrAvg(const std::string &pat_match="") const The average of the total downward/upward uncertainty shifts, which are taken to be the signed quadrat... Definition Estimate.h:429 double relTotalErrAvg(const std::string &pat_match="") const noexcept The relative average of the quad-sum-based total downward/upward uncertainty components. Definition Estimate.h:476 References add(), divide(), YODA::Estimate::relTotalErrAvg(), YODA::Estimate::setErr(), YODA::Estimate::sources(), sqr(), YODA::Estimate::totalErrAvg(), and YODA::Estimate::val(). ◆ efficiency() [5/5]
Divide two Estimate0D objects using binomial statistics. Definition at line 356 of file Estimate0D.h. 357 {
362 return rtn;
363 }
BinnedEstimate< AxisT... > efficiency(const BinnedDbn< DbnN, AxisT... > &accepted, const BinnedDbn< DbnN, AxisT... > &total) Calculate a binned efficiency ratio of two BinnedDbn objects. Definition BinnedDbn.h:1182 References efficiency(), YODA::AnalysisObject::hasAnnotation(), YODA::AnalysisObject::path(), YODA::AnalysisObject::rmAnnotation(), and YODA::AnalysisObject::setPath(). ◆ effNumEntries() [1/2]
Calculate the effective number of entries of a sample. Definition at line 381 of file MathUtils.h. References isZero(), and sqr(). Referenced by effNumEntries(), YODA::DbnBase< N >::relErrW(), YODA::DbnBase< N >::relStdErr(), RMS(), stdErr(), stdErr(), and variance(). ◆ effNumEntries() [2/2]
Calculate the effective number of entries of a sample. Definition at line 387 of file MathUtils.h. 387 {
388 double sumW = 0.0, sumW2 = 0.0;
389 for (size_t i = 0; i < weights.size(); ++i) {
390 sumW += weights[i];
391 sumW2 += sqr(weights[i]);
392 }
393 return effNumEntries(sumW, sumW2);
394 }
References effNumEntries(), and sqr(). ◆ fuzzyEquals() [1/2]
template<typename N1 , typename N2 >
Compare two numbers for equality with a degree of fuzziness. This version for floating point types (if any argument is FP) has a degree of fuzziness expressed by the fractional tolerance parameter, for floating point safety. Definition at line 96 of file MathUtils.h. 96 {
97 const double absavg = (std::abs(a) + std::abs(b))/2.0;
98 const double absdiff = std::abs(a - b);
100 return rtn;
101 }
References isZero(). Referenced by YODA::Axis< T, isCAxis< T > >::Axis(), fuzzyGtrEquals(), fuzzyLessEquals(), YODA::Axis< T, isCAxis< T > >::hasSameEdges(), operator==(), and subtract(). ◆ fuzzyEquals() [2/2]
template<typename N1 , typename N2 >
Compare two numbers for equality with a degree of fuzziness. Simpler SFINAE template specialisation for integers, since there is no FP precision issue. Definition at line 110 of file MathUtils.h. 110 { //< NB. unused tolerance parameter for ints, still needs a default value!
111 return a == b;
112 }
◆ fuzzyGtrEquals()
template<typename N1 , typename N2 >
Compare two numbers for >= with a degree of fuzziness. The tolerance parameter on the equality test is as for Definition at line 125 of file MathUtils.h. 125 {
127 }
std::enable_if_t< std::is_arithmetic_v< N1 > &&std::is_arithmetic_v< N2 > &&(std::is_floating_point_v< N1 >||std::is_floating_point_v< N2 >), bool > fuzzyEquals(N1 a, N2 b, double tolerance=1e-5) Compare two numbers for equality with a degree of fuzziness. Definition MathUtils.h:96 References fuzzyEquals(). Referenced by YODA::Axis< T, isCAxis< T > >::Axis(). ◆ fuzzyLessEquals()
template<typename N1 , typename N2 >
Compare two floating point numbers for <= with a degree of fuzziness. The tolerance parameter on the equality test is as for Definition at line 135 of file MathUtils.h. References fuzzyEquals(). Referenced by variance(). ◆ getDataPath()
Get the path to the installed share/YODA/ data directory. Definition at line 26 of file Paths.cc. 26 {
27 BrInitError error;
28 br_init_lib(&error);
30 const string sharedir(temp);
31 free(temp);
32 return sharedir + "/YODA";
33 }
References br_find_data_dir, and br_init_lib. Referenced by getYodaDataPath(). ◆ getLibPath()
Get the path to the directory containing libYODA. Definition at line 17 of file Paths.cc. 17 {
18 BrInitError error;
19 br_init_lib(&error);
21 const string libdir(temp);
22 free(temp);
23 return libdir;
24 }
References br_find_lib_dir, and br_init_lib. ◆ getYodaDataPath()
YODA data paths. Definition at line 35 of file Paths.cc. 35 {
36 vector<string> dirs;
37 // Use the YODA data path variable if set...
38 const char* env = getenv("YODA_DATA_PATH");
39 if (env) dirs = Utils::pathsplit(env);
40 // ... then, unless the path ends in :: ...
41 if (!env || strlen(env) < 2 || string(env).substr(strlen(env)-2) != "::") {
42 // ... fall back to the YODA data install path
43 dirs.push_back(getDataPath());
44 }
45 return dirs;
46 }
std::string getDataPath() Get the path to the installed share/YODA/ data directory. Definition Paths.cc:26 References getDataPath(). ◆ index_between()
template<typename NUM >
Return the bin index of the given value, val, given a vector of bin edges. NB. The binedges vector must be sorted Definition at line 361 of file MathUtils.h. 361 {
363 int index = -1;
364 for (size_t i = 1; i < binedges.size(); ++i) {
365 if (val < binedges[i]) {
366 index = i-1;
367 break;
368 }
369 }
370 assert(inRange(index, -1, binedges.size()-1));
371 return index;
372 }
bool inRange(NUM value, NUM low, NUM high, RangeBoundary lowbound=CLOSED, RangeBoundary highbound=OPEN) Determine if value is in the range low to high, for floating point numbers. Definition MathUtils.h:164 References inRange(). ◆ inRange() [1/4]
Determine if value is in the range low to high, for integer types. Interval boundary types are defined by lowbound and highbound.
Definition at line 189 of file MathUtils.h. 190 {
191 if (lowbound == OPEN && highbound == OPEN) {
192 return (value > low && value < high);
193 } else if (lowbound == OPEN && highbound == CLOSED) {
194 return (value > low && value <= high);
195 } else if (lowbound == CLOSED && highbound == OPEN) {
196 return (value >= low && value < high);
197 } else { // if (lowbound == CLOSED && highbound == CLOSED) {
198 return (value >= low && value <= high);
199 }
200 }
◆ inRange() [2/4]
Alternative version of Definition at line 203 of file MathUtils.h. References inRange(). ◆ inRange() [3/4]
template<typename NUM >
Determine if value is in the range low to high, for floating point numbers. Interval boundary types are defined by lowbound and highbound.
Definition at line 164 of file MathUtils.h. 165 {
166 if (lowbound == OPEN && highbound == OPEN) {
167 return (value > low && value < high);
168 } else if (lowbound == OPEN && highbound == CLOSED) {
169 return (value > low && value <= high);
170 } else if (lowbound == CLOSED && highbound == OPEN) {
171 return (value >= low && value < high);
172 } else { // if (lowbound == CLOSED && highbound == CLOSED) {
173 return (value >= low && value <= high);
174 }
175 }
Referenced by index_between(), inRange(), and inRange(). ◆ inRange() [4/4]
template<typename NUM >
Alternative version of inRange for doubles, which accepts a pair for the range arguments. Definition at line 179 of file MathUtils.h. References inRange(). ◆ isNaN()
template<typename NUM >
◆ isZero() [1/2]
template<typename NUM >
Compare a number to zero. This version for floating point types has a degree of fuzziness expressed by the absolute tolerance parameter, for floating point safety. Definition at line 63 of file MathUtils.h. 63 {
64 return fabs(val) < tolerance;
65 }
Referenced by divide(), efficiency(), effNumEntries(), fuzzyEquals(), and sign(). ◆ isZero() [2/2]
template<typename NUM >
Compare a number to zero. SFINAE template specialisation for integers, since there is no FP precision issue. Definition at line 73 of file MathUtils.h. 73 {
74 return val==0;
75 }
◆ linspace()
Make a list of nbins + 1 values uniformly spaced between xmin and xmax inclusive.
Definition at line 267 of file MathUtils.h. 267 {
270 std::vector<double> rtn;
271 const double interval = (xmax-xmin)/static_cast<double>(nbins);
272 for (size_t i = 0; i < nbins; ++i) {
273 rtn.push_back(xmin + i*interval);
274 }
275 assert(rtn.size() == nbins);
276 if (include_end) rtn.push_back(xmax); // exact xmax, not result of n * interval
277 return rtn;
278 }
Referenced by logspace(), and pdfspace(). ◆ logspace()
Make a list of nbins + 1 values uniformly spaced in log(x) between xmin and xmax inclusive.
Definition at line 286 of file MathUtils.h. 286 {
290 const double logxmin = std::log(xmin);
291 const double logxmax = std::log(xmax);
293 assert(logvals.size() == nbins+1);
294 std::vector<double> rtn; rtn.reserve(logvals.size());
295 rtn.push_back(xmin);
296 for (size_t i = 1; i < logvals.size()-1; ++i) {
297 rtn.push_back(std::exp(logvals[i]));
298 }
299 assert(rtn.size() == nbins);
300 if (include_end) rtn.push_back(xmax);
301 return rtn;
302 }
std::vector< double > linspace(size_t nbins, double xmin, double xmax, bool include_end=true) Make a list of nbins + 1 values uniformly spaced between xmin and xmax inclusive. Definition MathUtils.h:267 References linspace(). ◆ mean() [1/3]
Calculate the weighted mean of a sample. Definition at line 406 of file MathUtils.h. 406 {
407 return sumW? sumWX / sumW : std::numeric_limits<double>::quiet_NaN();
408 }
◆ mean() [2/3]
Calculate the weighted mean of a sample. Definition at line 411 of file MathUtils.h. 412 {
414 double sumWX = 0., sumW = 0.;
415 for (size_t i = 0; i < sample.size(); ++i) {
416 sumW += weights[i];
417 sumWX += weights[i]*sample[i];
418 }
419 return mean(sumWX, sumW);
420 }
References mean(). ◆ mean() [3/3]
Calculate the mean of a sample. Definition at line 397 of file MathUtils.h. 397 {
399 for (size_t i=0; i<sample.size(); ++i) {
400 mean += sample[i];
401 }
402 return mean/sample.size();
403 }
References mean(). Referenced by covariance(), YODA::DbnBase< N >::mean(), mean(), mean(), YODA::DbnBase< N >::relStdErr(), YODA::XDbnMixin< Derived >::xMean(), YODA::XStatsMixin< Derived >::xMean(), YODA::YDbnMixin< Derived >::yMean(), YODA::YStatsMixin< Derived >::yMean(), zipProfiles(), YODA::ZDbnMixin< Derived >::zMean(), and YODA::ZStatsMixin< Derived >::zMean(). ◆ mkAxisConfig()
template<typename A , typename... As>
Helper function to construct the axis config. Definition at line 58 of file BinningUtils.h. 58 {
60 }
◆ mkIntegral()
template<size_t DbnN, typename... AxisT>
Convert a BinnedDbn to a BinnedEstimate representing the integral of the histogram.
The includeunderflow param chooses whether the underflow bin is included in the integral numbers as an offset. Definition at line 1231 of file BinnedDbn.h. 1231 {
1232
1234
1235 double sumW = 0.0, sumW2 = 0.0;
1236 for (const auto& b : histo.bins(includeOverflows)) {
1237 sumW += b.sumW();
1238 sumW2 += b.sumW2();
1239 const double e = sqrt(sumW2);
1240 rtn.bin(b.index()).set(sumW, {-e, e});
1241 }
1242
1243 return rtn;
1244 }
References YODA::BinnedStorage< BinContentT, AxisT >::bins(), and YODA::DbnStorage< DbnN, AxisT >::mkEstimate(). Referenced by mkIntegralEff(). ◆ mkIntegralEff()
template<size_t DbnN, typename... AxisT>
Convert a BinnedDbn to a BinnedEstimate where each bin is a fraction of the total.
The includeunderflow param behaves as for toIntegral, and applies to both the initial integration and the integral used for the scaling. The includeoverflow param applies only to obtaining the scaling factor.
Definition at line 1260 of file BinnedDbn.h. 1260 {
1261
1264
1265 // If the integral is empty, the (integrated) efficiency values may as well all be zero, so return here
1269 if (!integral) return rtn;
1270
1272 for (const auto& b : rtn.bins(includeOverflows)) {
1273 const double eff = b.val() / integral;
1274 const double err = sqrt(std::abs( ((1-2*eff)*sqr(b.relTotalErrAvg()) + sqr(eff)*sqr(integral_err)) / sqr(integral) ));
1275 b.set(eff, {-err,err});
1276 }
1277
1278 return rtn;
1279 }
double integralError(const bool includeOverflows=true) const noexcept Get the total volume error of the histogram. Definition BinnedDbn.h:468 double integral(const bool includeOverflows=true) const noexcept Get the total volume of the histogram. Definition BinnedDbn.h:463 BinnedEstimate< AxisT... > mkIntegral(const BinnedDbn< DbnN, AxisT... > &histo, const bool includeOverflows=true) Convert a BinnedDbn to a BinnedEstimate representing the integral of the histogram. Definition BinnedDbn.h:1231 References YODA::DbnStorage< DbnN, AxisT >::integral(), YODA::DbnStorage< DbnN, AxisT >::integralError(), mkIntegral(), and sqr(). ◆ mkReader()
Factory function to make a reader object by format name or a filename. <
<
Definition at line 15 of file Reader.cc. 15 {
16 // Determine the format from the string (a file or file extension)
17 const size_t lastdot = name.find_last_of(".");
18 string fmt = Utils::toLower(lastdot == string::npos ? name : name.substr(lastdot+1));
19 if (fmt == "gz") {
20 #ifndef HAVE_LIBZ
22 #endif
23 const size_t lastbutonedot = (lastdot == string::npos) ? string::npos : name.find_last_of(".", lastdot-1);
24 fmt = Utils::toLower(lastbutonedot == string::npos ? name : name.substr(lastbutonedot+1));
25 }
26 // Create the appropriate Reader
27 if (Utils::startswith(fmt, "yoda")) return ReaderYODA::create();
28 if (Utils::startswith(fmt, "dat" )) return ReaderFLAT::create();
29 if (Utils::startswith(fmt, "flat")) return ReaderFLAT::create();
30 throw UserError("Format cannot be identified from string '" + name + "'");
31 }
References YODA::ReaderFLAT::create(), and YODA::ReaderYODA::create(). ◆ mkTypeString() [1/2]
template<ssize_t DbnN, typename A , typename... As>
Helper function to construct the BinnedDbn and BinnedEstimate type names. Definition at line 65 of file BinningUtils.h. 65 {
66
67 constexpr size_t N = sizeof...(As)+1;
68
70 if constexpr (DbnN < 0) {
71 return "Estimate"+std::to_string(N)+"D";
72 }
73 if constexpr (DbnN == N+1) {
74 return "Profile"+std::to_string(N)+"D";
75 }
76 if constexpr (DbnN == N) {
77 return "Histo"+std::to_string(N)+"D";
78 }
79 }
80
81 std::string type = "Binned";
82 if (DbnN < 0) type += "Estimate";
83 else if (DbnN == N) type += "Histo";
84 else if (DbnN == N+1) type += "Profile";
85 else type += "Dbn" + std::to_string(DbnN);
86
87 std::string axes = (TypeID<A>::name() + ... + (std::string{","} + TypeID<As>::name()));
88
89 return (type + "<" + axes + ">");
90 }
typename std::conjunction< std::is_floating_point< EdgeT >... > all_CAxes Definition BinningUtils.h:18 References YODA::TypeID< T >::name(). Referenced by mkTypeString(). ◆ mkTypeString() [2/2]
template<typename A , typename... As>
Same as above, but for non-Dbn bin contents. Definition at line 94 of file BinningUtils.h. std::string mkTypeString() Helper function to construct the BinnedDbn and BinnedEstimate type names. Definition BinningUtils.h:65 References mkTypeString(). ◆ mkWriter()
Factory function to make a writer object by format name or a filename. <
<
Definition at line 25 of file Writer.cc. 25 {
26 // Determine the format from the string (a file or file extension)
27 const size_t lastdot = name.find_last_of(".");
28 string fmt = Utils::toLower(lastdot == string::npos ? name : name.substr(lastdot+1));
29 const bool compress = (fmt == "gz");
30 //cout << "***" << compress << endl;
31 if (compress) {
32 #ifndef HAVE_LIBZ
34 #endif
35 const size_t lastbutonedot = (lastdot == string::npos) ? string::npos : name.find_last_of(".", lastdot-1);
36 fmt = Utils::toLower(lastbutonedot == string::npos ? name : name.substr(lastbutonedot+1));
37 }
38 // Create the appropriate Writer
39 Writer* w = nullptr;
40 if (Utils::startswith(fmt, "yoda")) w = &WriterYODA::create();
41 if (Utils::startswith(fmt, "dat" )) w = &WriterFLAT::create();
42 if (Utils::startswith(fmt, "flat")) w = &WriterFLAT::create();
43 if (!w) throw UserError("Format cannot be identified from string '" + name + "'");
44 w->useCompression(compress);
45 return *w;
46 }
References YODA::WriterFLAT::create(), YODA::WriterYODA::create(), and YODA::Writer::useCompression(). Referenced by write(), write(), write(), write(), write(), and write(). ◆ naiveChi2()
Calculate the error-weighted chi2 statistic between two samples.
Definition at line 549 of file MathUtils.h. 550 {},
551 const std::vector<double>& s2errors = std::vector<double>{}) {
552 if (sample1.size() != sample2.size()) {
553 throw RangeError("Inputs should have equal length!");
554 }
555 if (s1errors.size() && sample1.size() != s1errors.size()) {
556 throw RangeError("Inputs should have equal length!");
557 }
558 if (s2errors.size() && sample2.size() != s2errors.size()) {
559 throw RangeError("Inputs should have equal length!");
560 }
561 const size_t N = sample1.size();
562 double chi2 = 0.0;
563 for (size_t i = 0; i < N; ++i) {
565 if (s1errors.size()) {
567 }
568 chi2 += temp;
569 }
570 return chi2;
571 }
◆ naiveChi2reduced()
Calculate the error-weighted reduced chi2 statistic between two samples.
Definition at line 579 of file MathUtils.h. 580 {},
581 const std::vector<double>& s2errors = std::vector<double>{}) {
582 if (sample1.empty()) throw RangeError("Inputs should not have 0 length!");
584 }
double naiveChi2(const std::vector< double > &sample1, const std::vector< double > &sample2, const std::vector< double > &s1errors=std::vector< double >{}, const std::vector< double > &s2errors=std::vector< double >{}) Calculate the error-weighted chi2 statistic between two samples. Definition MathUtils.h:549 ◆ notNaN()
template<typename NUM >
Check if a number is non-NaN. Definition at line 85 of file MathUtils.h. 85{ return !std::isnan(val); }
◆ nullifyIfDiscCoord() [1/2]
template<typename CoordT >
Nullifies coordinate if it is discrete. Definition at line 19 of file Binning.h. 19 {
20 return null;
21 }
Referenced by containsNan(). ◆ nullifyIfDiscCoord() [2/2]
template<typename CoordT >
◆ operator!=()◆ operator*() [1/3]◆ operator*() [2/3]◆ operator*() [3/3]◆ operator+() [1/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1309 of file BinnedDbn.h. References add(). ◆ operator+() [2/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1297 of file BinnedDbn.h. References add(). ◆ operator+() [3/17]
template<size_t DbnN, typename... AxisT>
Add two BinnedDbn objects. Definition at line 1080 of file BinnedDbn.h. 1080 {
1081 first += std::move(second);
1082 return first;
1083 }
◆ operator+() [4/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1087 of file BinnedDbn.h. 1087 {
1088 first += second;
1089 return first;
1090 }
◆ operator+() [5/17]
template<typename... AxisT>
Add two BinnedEstimates. Definition at line 1084 of file BinnedEstimate.h. 1084 {
1085 first += std::move(second);
1086 return first;
1087 }
◆ operator+() [6/17]
template<typename... AxisT>
Add two BinnedEstimates. Definition at line 1075 of file BinnedEstimate.h. 1075 {
1076 first += second;
1077 return first;
1078 }
◆ operator+() [7/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1303 of file BinnedDbn.h. References add(). ◆ operator+() [8/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1291 of file BinnedDbn.h. References add(). ◆ operator+() [9/17]◆ operator+() [10/17]◆ operator+() [11/17]◆ operator+() [12/17]◆ operator+() [13/17]◆ operator+() [14/17]Add two Estimate objects. Definition at line 662 of file Estimate.h. 662 {
663 lhs += rhs;
664 return lhs;
665 }
◆ operator+() [15/17]Add two Estimate objects. Definition at line 668 of file Estimate.h. 668 {
669 lhs += std::move(rhs);
670 return lhs;
671 }
◆ operator+() [16/17]
Add two Estimate0D objects. Definition at line 302 of file Estimate0D.h. 302 {
303 lhs += rhs;
304 return lhs;
305 }
◆ operator+() [17/17]
Add two Estimate0D objects. Definition at line 308 of file Estimate0D.h. 308 {
309 lhs += std::move(rhs);
310 return lhs;
311 }
◆ operator-() [1/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1341 of file BinnedDbn.h. References subtract(). ◆ operator-() [2/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1329 of file BinnedDbn.h. References subtract(). ◆ operator-() [3/17]
template<size_t DbnN, typename... AxisT>
Subtract one BinnedDbn object from another. Definition at line 1096 of file BinnedDbn.h. 1096 {
1097 first -= std::move(second);
1098 return first;
1099 }
◆ operator-() [4/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1103 of file BinnedDbn.h. 1103 {
1104 first -= second;
1105 return first;
1106 }
◆ operator-() [5/17]
template<typename... AxisT>
Subtract two BinnedEstimates. Definition at line 1101 of file BinnedEstimate.h. 1101 {
1102 first -= std::move(second);
1103 return first;
1104 }
◆ operator-() [6/17]
template<typename... AxisT>
Subtract two BinnedEstimates. Definition at line 1093 of file BinnedEstimate.h. 1093 {
1094 first -= second;
1095 return first;
1096 }
◆ operator-() [7/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1335 of file BinnedDbn.h. References subtract(). ◆ operator-() [8/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1323 of file BinnedDbn.h. References subtract(). ◆ operator-() [9/17]◆ operator-() [10/17]◆ operator-() [11/17]◆ operator-() [12/17]◆ operator-() [13/17]◆ operator-() [14/17]Subtract two Estimate objects. Definition at line 674 of file Estimate.h. 674 {
675 lhs -= rhs;
676 return lhs;
677 }
◆ operator-() [15/17]Subtract two Estimate objects. Definition at line 680 of file Estimate.h. 680 {
681 lhs -= std::move(rhs);
682 return lhs;
683 }
◆ operator-() [16/17]
Subtract two Estimate0D objects. Definition at line 314 of file Estimate0D.h. 314 {
315 lhs -= rhs;
316 return lhs;
317 }
◆ operator-() [17/17]
Subtract two Estimate0D objects. Definition at line 320 of file Estimate0D.h. 320 {
321 lhs -= std::move(rhs);
322 return lhs;
323 }
◆ operator/() [1/27]
template<size_t DbnN, typename... AxisT>
Definition at line 1373 of file BinnedDbn.h. References divide(). ◆ operator/() [2/27]
template<size_t DbnN, typename... AxisT>
Definition at line 1361 of file BinnedDbn.h. References divide(). ◆ operator/() [3/27]
template<size_t DbnN, typename... AxisT>
Definition at line 1171 of file BinnedDbn.h. References divide(). ◆ operator/() [4/27]
template<size_t DbnN, typename... AxisT>
Definition at line 1165 of file BinnedDbn.h. References divide(). ◆ operator/() [5/27]
template<typename... AxisT>
◆ operator/() [6/27]
template<typename... AxisT>
◆ operator/() [7/27]
template<size_t DbnN, typename... AxisT>
Definition at line 1367 of file BinnedDbn.h. References divide(). ◆ operator/() [8/27]
template<size_t DbnN, typename... AxisT>
Definition at line 1355 of file BinnedDbn.h. References divide(). ◆ operator/() [9/27]
template<size_t DbnN, typename... AxisT>
Definition at line 1159 of file BinnedDbn.h. References divide(). ◆ operator/() [10/27]
template<size_t DbnN, typename... AxisT>
Definition at line 1153 of file BinnedDbn.h. References divide(). ◆ operator/() [11/27]
template<typename... AxisT>
◆ operator/() [12/27]
template<typename... AxisT>
◆ operator/() [13/27]
◆ operator/() [14/27]
◆ operator/() [15/27]◆ operator/() [16/27]◆ operator/() [17/27]
◆ operator/() [18/27]
◆ operator/() [19/27]◆ operator/() [20/27]◆ operator/() [21/27]
◆ operator/() [22/27]
◆ operator/() [23/27]Divide a double by a Weights
Definition at line 303 of file Weights.h. 303 {
305 tmp /= w;
306 return tmp;
307 }
References YODA::Weights::keys(). ◆ operator/() [24/27]◆ operator/() [25/27]◆ operator/() [26/27]
◆ operator/() [27/27]
◆ operator<()
template<size_t N>
Less-than operator used to sort points. Definition at line 512 of file Point.h. 512 {
513 #define LT_IF_NOT_EQ(a,b) { if (!fuzzyEquals(a, b)) return a < b; }
514 for (size_t i = 0; i < N; ++i) {
518 }
519 #undef LT_IF_NOT_EQ
520 return false;
521 }
#define LT_IF_NOT_EQ(a, b) References YODA::PointBase< N >::errs(), LT_IF_NOT_EQ, and YODA::PointBase< N >::vals(). ◆ operator<<()
Standard text representaion. Definition at line 313 of file Weights.h. 313 {
314 out << "{ ";
317 out << i->first << ": " << i->second;
318 }
319 out << "}";
320 return out;
321 }
std::map< std::string, double >::const_iterator const_iterator Definition Weights.h:72 References YODA::Weights::begin(), and YODA::Weights::end(). ◆ operator<=()◆ operator==()
template<size_t N>
Equality test. Definition at line 493 of file Point.h. 493 {
494 // Compare valitions
495 for (size_t i = 0; i < N; ++i) {
499 }
500 return true;
501 }
References YODA::PointBase< N >::errs(), fuzzyEquals(), and YODA::PointBase< N >::vals(). ◆ operator>()◆ operator>=()◆ pdfspace()
Make a list of nbins + 1 values spaced with density ~ f(x) between xmin and end inclusive.
The density function fn will be evaluated at nsample uniformly distributed points between xmin and xmax, its integral approximated via the Trapezium Rule and used to normalize the distribution, and nbins + 1 edges then selected to (approximately) divide into bins each containing fraction 1/nbins of the integral.
Definition at line 328 of file MathUtils.h. 328 {
329 const double dx = (xmax-xmin)/(double)nsample;
331 std::vector<double> ys(0, nsample);
332 auto posfn = [&](double x){return std::max(fn(x), 0.0);};
333 std::transform(xs.begin(), xs.end(), ys.begin(), posfn);
334 std::vector<double> areas; areas.reserve(nsample);
335 double areasum = 0;
336 for (size_t i = 0; i < ys.size()-1; ++i) {
337 const double area = (ys[i] + ys[i+1])*dx/2.0;
338 areas[i] = area;
339 areasum += area;
340 }
341 const double df = areasum/(double)nbins;
342 std::vector<double> xedges{xmin}; xedges.reserve(nbins+1);
343 double fsum = 0;
344 for (size_t i = 0; i < nsample-1; ++i) {
345 fsum += areas[i];
346 if (fsum > df) {
347 fsum = 0;
348 xedges.push_back(xs[i+1]);
349 }
350 }
351 xedges.push_back(xmax);
352 assert(xedges.size() == nbins+1);
353 return xedges;
354 }
References linspace(). ◆ read() [1/4]
Read in a collection of objects from file filename. This version returns a vector by value, involving copying, and is hence less CPU efficient than the alternative version where a vector is filled by reference. The appropriate format reader will be determined from the filename. Definition at line 98 of file IO.h. 100 {
101 std::vector<AnalysisObject*> rtn;
102 read(filename, rtn, match, unmatch);
103 return rtn;
104 }
void read(const std::string &filename, std::vector< AnalysisObject * > &aos, const std::string &match="", const std::string &unmatch="") Read in a collection of objects objs from file filename. Definition IO.h:85 References read(). ◆ read() [2/4]
Read in a collection of objects objs from file filename. This version fills (actually, appends to) a supplied vector, avoiding copying, and is hence CPU efficient. The appropriate format reader will be determined from the filename.
Definition at line 85 of file IO.h. 87 {
89 r.read(filename, aos, match, unmatch);
90 }
std::enable_if_t< YODA::Pushable< CONT, AnalysisObject * >::value > read(std::istream &stream, CONT &aos, const std::string &match="", const std::string &unmatch="") Read in a collection of objects objs from output stream stream. Definition Reader.h:50 Reader & mkReader(const std::string &format_name) Factory function to make a reader object by format name or a filename. Definition Reader.cc:15 References mkReader(), and YODA::Reader::read(). ◆ read() [3/4]
Read in a collection of objects from stream is, expecting format fmt. This version returns a vector by value, involving copying, and is hence less CPU efficient than the alternative version where a vector is filled by reference. Definition at line 129 of file IO.h. 131 {
132 std::vector<AnalysisObject*> rtn;
133 read(is, rtn, fmt, match, unmatch);
134 return rtn;
135 }
References read(). ◆ read() [4/4]
Read in a collection of objects objs from stream is, expecting format fmt. This version fills (actually, appends to) a supplied vector, avoiding copying, and is hence CPU efficient.
Definition at line 118 of file IO.h. References mkReader(), and YODA::Reader::read(). ◆ RMS() [1/2]
Calculate the weighted RMS of a sample. Definition at line 495 of file MathUtils.h. 495 {
496 // Weighted RMS defined as
497 // rms = sqrt(sum{w x^2} / sum{w})
499 if (effN == 0) return std::numeric_limits<double>::quiet_NaN();
500 const double meanSq = sumWX2 / sumW;
501 return std::sqrt(meanSq);
502 }
double effNumEntries(const double sumW, const double sumW2) Calculate the effective number of entries of a sample. Definition MathUtils.h:381 References effNumEntries(). Referenced by YODA::DbnBase< N >::RMS(), RMS(), YODA::XDbnMixin< Derived >::xRMS(), YODA::YDbnMixin< Derived >::yRMS(), and YODA::ZDbnMixin< Derived >::zRMS(). ◆ RMS() [2/2]
Calculate the weighted RMS of a sample. Definition at line 505 of file MathUtils.h. ◆ sign() [1/3]
◆ sign() [2/3]
◆ sign() [3/3]
◆ sqr()
template<typename NUM >
Named number-type squaring operation. Definition at line 216 of file MathUtils.h. 216 {
217 return a*a;
218 }
Referenced by add_quad(), YODA::EstimateStorage< AxisT >::covarianceMatrix(), divide(), efficiency(), efficiency(), efficiency(), effNumEntries(), effNumEntries(), YODA::DbnBase< N >::fill(), YODA::FillableStorage< FillDim, BinContentT, AxisT >::fill(), mkIntegralEff(), RMS(), YODA::DbnBase< N >::scale(), YODA::DbnBase< N >::scaleW(), variance(), and variance(). ◆ stdDev() [1/2]
Calculate the weighted standard deviation of a sample. Definition at line 464 of file MathUtils.h. 465 {
467 }
double variance(const double sumWX, const double sumW, const double sumWX2, const double sumW2) Calculate the weighted variance of a sample. Definition MathUtils.h:427 References variance(). Referenced by YODA::XDbnMixin< Derived >::xStdDev(), YODA::XStatsMixin< Derived >::xStdDev(), YODA::YDbnMixin< Derived >::yStdDev(), YODA::YStatsMixin< Derived >::yStdDev(), YODA::ZDbnMixin< Derived >::zStdDev(), and YODA::ZStatsMixin< Derived >::zStdDev(). ◆ stdDev() [2/2]
Calculate the weighted variance of a sample. Definition at line 470 of file MathUtils.h. References variance(). ◆ stdErr() [1/2]
Calculate the weighted standard error of a sample. Definition at line 476 of file MathUtils.h. 477 {
479 if (effN == 0) return std::numeric_limits<double>::quiet_NaN();
481 return std::sqrt(var / effN);
482 }
References effNumEntries(), and variance(). Referenced by YODA::DbnBase< N >::relStdErr(), YODA::DbnBase< N >::stdErr(), YODA::XDbnMixin< Derived >::xStdErr(), YODA::XStatsMixin< Derived >::xStdErr(), YODA::YDbnMixin< Derived >::yStdErr(), YODA::YStatsMixin< Derived >::yStdErr(), zipProfiles(), YODA::ZDbnMixin< Derived >::zStdErr(), and YODA::ZStatsMixin< Derived >::zStdErr(). ◆ stdErr() [2/2]
Calculate the weighted variance of a sample. Definition at line 485 of file MathUtils.h. 486 {
489 if (effN == 0) return std::numeric_limits<double>::quiet_NaN();
491 return std::sqrt(var / effN);
492 }
References effNumEntries(), and variance(). ◆ subtract() [1/2]
template<size_t DbnN, typename... AxisT>
Calculate the subtraction of a BinnedEstimate from a BinnedDbn. Definition at line 1317 of file BinnedDbn.h. References YODA::DbnStorage< DbnN, AxisT >::mkEstimate(). Referenced by add(), asymm(), operator-(), operator-(), operator-(), operator-(), and variance(). ◆ subtract() [2/2]
Subtract two numbers with FP fuzziness. Definition at line 247 of file MathUtils.h. References fuzzyEquals(). ◆ transform() [1/6]
template<typename... AxisT, typename FN >
Definition at line 1210 of file BinnedEstimate.h. 1210 {
1212 }
Definition Transformation.h:31 void transform(BinnedEstimate< AxisT... > &est, const Trf< 1 > &fn) Definition BinnedEstimate.h:1203 References transform(). ◆ transform() [2/6]
template<typename... AxisT>
Definition at line 1203 of file BinnedEstimate.h. 1203 {
1204 for (auto& b : est.bins(true, true)) {
1205 b.transform(fn);
1206 }
1207 }
References YODA::BinnedStorage< BinContentT, AxisT >::bins(). Referenced by transform(), transform(), transform(), transformX(), transformY(), and transformZ(). ◆ transform() [3/6]
template<typename FN >
Definition at line 291 of file Estimate0D.h. References transform(). ◆ transform() [4/6]
Definition at line 286 of file Estimate0D.h. 286 {
287 est.transform(fn);
288 }
void transform(const Trf< 1 > &trf) Generalised transformations with functors. Definition Estimate.h:214 References YODA::Estimate::transform(). ◆ transform() [5/6]
template<size_t N, typename FN >
Definition at line 878 of file Scatter.h. References transform(). ◆ transform() [6/6]
template<size_t N>
Definition at line 871 of file Scatter.h. 871 {
872 for (auto& p : s.points()) {
873 p.transform(i, fn);
874 }
875 }
References YODA::ScatterND< N >::points(). ◆ transformX()
template<size_t N, typename FN >
Definition at line 883 of file Scatter.h. References transform(). ◆ transformY()
template<size_t N, typename FN >
Definition at line 888 of file Scatter.h. References transform(). ◆ transformZ()
template<size_t N, typename FN >
Definition at line 893 of file Scatter.h. References transform(). ◆ variance() [1/2]
Calculate the weighted variance of a sample. Weighted variance defined as sig2 = ( sum(wx**2) * sum(w) - sum(wx)**2 ) / ( sum(w)**2 - sum(w**2) ) see http://en.wikipedia.org/wiki/Weighted_mean
We take the modulus of the weighted variance since the ratio can be negative with weighted means
Definition at line 427 of file MathUtils.h. 428 {
434 // if (fabs(num) < 1e-10 && fabs(den) < 1e-10) {
435 // return std::numeric_limits<double>::quiet_NaN();
436 // }
441 return den? fabs(num/den): std::numeric_limits<double>::quiet_NaN();
442 }
References sqr(), and subtract(). Referenced by stdDev(), stdDev(), stdErr(), stdErr(), YODA::DbnBase< N >::variance(), variance(), YODA::XDbnMixin< Derived >::xVariance(), YODA::XStatsMixin< Derived >::xVariance(), YODA::YDbnMixin< Derived >::yVariance(), YODA::YStatsMixin< Derived >::yVariance(), YODA::ZDbnMixin< Derived >::zVariance(), and YODA::ZStatsMixin< Derived >::zVariance(). ◆ variance() [2/2]
Calculate the weighted variance of a sample. Definition at line 445 of file MathUtils.h. 446 {
449 //throw LowStatsError("Requested variance of a distribution with only one effective entry");
450 return std::numeric_limits<double>::quiet_NaN();
451 }
452 double sumWX = 0., sumW = 0.;
453 double sumWX2 = 0., sumW2 = 0.;
454 for (size_t i = 0; i < sample.size(); ++i) {
455 sumW += weights[i];
456 sumWX += weights[i]*sample[i];
457 sumW2 += sqr(weights[i]);
458 sumWX2 += weights[i]*sqr(sample[i]);
459 }
461 }
std::enable_if_t< std::is_arithmetic_v< N1 > &&std::is_arithmetic_v< N2 >, bool > fuzzyLessEquals(N1 a, N2 b, double tolerance=1e-5) Compare two floating point numbers for <= with a degree of fuzziness. Definition MathUtils.h:135 References effNumEntries(), fuzzyLessEquals(), sqr(), and variance(). ◆ version()
Namespaced version string function. Definition at line 25 of file YodaConfig.h. References YODA_VERSION. ◆ write() [1/6]
Write out object ao to file filename. Definition at line 19 of file IO.h. 19 {
22 w.write(filename, ao);
23 }
void write(const std::string &filename, const AnalysisObject &ao) Write out object ao to file filename. Definition Writer.cc:49 void setPrecision(int precision) Set precision of numerical quantities in this writer's output. Definition Writer.h:143 Writer & mkWriter(const std::string &format_name) Factory function to make a writer object by format name or a filename. Definition Writer.cc:25 References mkWriter(), YODA::Writer::setPrecision(), and YODA::Writer::write(). ◆ write() [2/6]
template<typename AOITER >
Write out the objects specified by start iterator begin and end iterator end to file filename. Definition at line 36 of file IO.h. References mkWriter(), YODA::Writer::setPrecision(), and YODA::Writer::write(). ◆ write() [3/6]
template<typename RANGE >
Write out a collection of objects objs to file filename. Definition at line 27 of file IO.h. References mkWriter(), YODA::Writer::setPrecision(), and YODA::Writer::write(). ◆ write() [4/6]
Write out object ao to stream os with format fmt. Definition at line 49 of file IO.h. References mkWriter(), YODA::Writer::setPrecision(), and YODA::Writer::write(). ◆ write() [5/6]
template<typename AOITER >
Write out the objects specified by start iterator begin and end iterator end to file filename. Definition at line 66 of file IO.h. References mkWriter(), YODA::Writer::setPrecision(), and YODA::Writer::write(). ◆ write() [6/6]
template<typename RANGE >
Write out a collection of objects objs to file filename. Definition at line 57 of file IO.h. References mkWriter(), YODA::Writer::setPrecision(), and YODA::Writer::write(). ◆ zipProfiles()
template<size_t DbnN, typename... AxisT, typename... Args, typename = std::enable_if_t<(DbnN == sizeof...(AxisT)+1 && (std::is_same_v<BinnedDbn<DbnN, AxisT...>, Args> && ...))>>
Zip profile objects of the same type into a combined scatter object. The resulting object has as many points as profile bins and whose central values are given by the means along the unbinned profile axes with means of first profile corresponding to x-coordinate, means of second profile corresponding to y-coordinate etc.
Definition at line 1389 of file BinnedDbn.h. 1390 {
1391
1392 // Check profiles have the same binning
1393 if ( !((p1 == others) && ...) )
1395
1396 // Construct resulting Scatter whose coordinates
1397 // are given by the unbinned means
1398 constexpr size_t N = sizeof...(Args)+1;
1399 ScatterND<N> rtn;
1401 for (const auto& b1 : p1.bins()) {
1402 typename ScatterND<N>::NdVal vals = { b1.mean(DbnN), others.bin(b1.binIndex()).mean(DbnN) ... };
1403 typename ScatterND<N>::NdVal errs = { b1.stdErr(DbnN), others.bin(b1.binIndex()).stdErr(DbnN) ... };
1404 rtn.addPoint(vals, errs);
1405 }
1406 return rtn;
1407 }
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::ScatterND< N >::addPoint(), YODA::BinnedStorage< BinContentT, AxisT >::bins(), mean(), YODA::AnalysisObject::setAnnotation(), and stdErr(). Variable Documentation◆ BISECT_LINEAR_THRESHOLDlc
Definition at line 29 of file BinnedAxis.h. ◆ fuzzyEqComp
Initial value:
=
Comparator wrapper to use with STL algorithms, e.g. std::equal etc. Definition at line 115 of file MathUtils.h. ◆ HALFPI
A pre-defined value of Definition at line 48 of file MathUtils.h. ◆ isCIterable
template<typename... T>
◆ isIterable
template<typename... T>
◆ MAXDOUBLE
Pre-defined numeric type limits
Definition at line 38 of file MathUtils.h. ◆ MAXINT
Definition at line 39 of file MathUtils.h. ◆ PI
A pre-defined value of Definition at line 42 of file MathUtils.h. ◆ SEARCH_SIZElc
Definition at line 28 of file BinnedAxis.h. Referenced by YODA::Axis< T, isCAxis< T > >::index(). ◆ TWOPI
A pre-defined value of Definition at line 45 of file MathUtils.h. ◆ YODA_FORMAT_VERSION
YODA text-format version
Definition at line 33 of file WriterYODA.cc. Generated on Sun Feb 9 2025 18:56:41 for YODA - Yet more Objects for Data Analysis by |