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 1225 of file BinnedEstimate.h. ◆ BinnedEstimate2D
template<typename A1 , typename A2 >
Definition at line 1228 of file BinnedEstimate.h. ◆ BinnedEstimate3D
template<typename A1 , typename A2 , typename A3 >
Definition at line 1231 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 1249 of file BinnedEstimate.h. ◆ Estimate2D
Definition at line 1250 of file BinnedEstimate.h. ◆ Estimate3D
Definition at line 1251 of file BinnedEstimate.h. ◆ EstimateND
template<size_t N>
Definition at line 1245 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 is closed (an inclusive boundary) at 0, and open (a non-inclusive boundary) at .
Definition at line 156 of file MathUtils.h. ◆ Sign
Function Documentation◆ add()
template<size_t DbnN, typename... AxisT>
Calculate the addition of a BinnedDbn with a BinnedEstimate. Definition at line 1270 of file BinnedDbn.h. 1270 {
1272 }
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(), operator+(), operator+(), operator+(), and operator+(). ◆ add_quad() [1/2]
template<typename Num >
Named number-type addition in quadrature operation. Definition at line 222 of file MathUtils.h. 222 {
223 return sqrt(a*a + b*b);
224 }
Referenced by divide(). ◆ add_quad() [2/2]
template<typename Num >
Named number-type addition in quadrature operation. Definition at line 228 of file MathUtils.h. 228 {
229 return sqrt(a*a + b*b + c*c);
230 }
◆ 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 1201 of file BinnedDbn.h. 1201 {
1202 return (a-b) / (a+b);
1203 }
◆ asymm() [2/2]
template<typename... AxisT>
Calculate the asymmetry (a-b)/(a+b) of two BinnedDbn objects. Definition at line 1192 of file BinnedEstimate.h. 1194 {
1196 }
BinnedEstimate< AxisT... > add(const BinnedDbn< DbnN, AxisT... > &dbn, const BinnedEstimate< AxisT... > &est) Calculate the addition of a BinnedDbn with a BinnedEstimate. Definition BinnedDbn.h:1270 BinnedEstimate< AxisT... > subtract(const BinnedDbn< DbnN, AxisT... > &dbn, const BinnedEstimate< AxisT... > &est) Calculate the subtraction of a BinnedEstimate from a BinnedDbn. Definition BinnedDbn.h:1302 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:34 References nullifyIfDiscCoord(), and MetaUtils::staticFor(). Referenced by YODA::FillableStorage< FillDim, BinContentT, AxisT >::fill(). ◆ correlation()
Calculate the correlation strength between two samples. Definition at line 527 of file MathUtils.h. 527 {
533 return corr_strength;
534 }
double covariance(const std::vector< int > &sample1, const std::vector< int > &sample2) Calculate the covariance (variance) between two samples. Definition MathUtils.h:512 double correlation(const std::vector< int > &sample1, const std::vector< int > &sample2) Calculate the correlation strength between two samples. Definition MathUtils.h:527 References correlation(), and covariance(). Referenced by correlation(). ◆ covariance()
Calculate the covariance (variance) between two samples. Definition at line 512 of file MathUtils.h. 512 {
515 const size_t N = sample1.size();
516 double cov = 0.0;
517 for (size_t i = 0; i < N; i++) {
518 const double cov_i = (sample1[i] - mean1)*(sample2[i] - mean2);
519 cov += cov_i;
520 }
521 if (N > 1) return cov/(N-1);
522 else return 0.0;
523 }
double mean(const std::vector< int > &sample) Calculate the mean of a sample. Definition MathUtils.h:391 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 1334 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 1092 of file BinnedDbn.h. 1092 {
1093
1094 if (numer != denom) {
1096 }
1097
1098 BinnedEstimate<AxisT...> rtn = numer.mkEstimate();
1100 if (rtn.hasAnnotation("ScaledBy")) rtn.rmAnnotation("ScaledBy");
1101
1102 for (const auto& b_num : numer.bins(true, true)) {
1103 const size_t idx = b_num.index();
1105 double v, e;
1106 if (!b_den.effNumEntries()) {
1107 v = std::numeric_limits<double>::quiet_NaN();
1108 e = std::numeric_limits<double>::quiet_NaN();
1109 }
1110 else {
1111 if constexpr(DbnN > sizeof...(AxisT)) {
1112 v = b_num.mean(DbnN) / b_den.mean(DbnN);
1113 const double e_num = b_num.effNumEntries()? b_num.relStdErr(DbnN) : 0;
1114 const double e_den = b_den.effNumEntries()? b_den.relStdErr(DbnN) : 0;
1116 }
1117 else {
1118 v = b_num.sumW() / b_den.sumW();
1119 const double e_num = b_num.sumW()? b_num.relErrW() : 0;
1120 const double e_den = b_den.sumW()? b_den.relErrW() : 0;
1122 }
1123 }
1124 rtn.bin(idx).set(v, {-e, e}); // @todo put "stats" as source?
1125 }
1127
1128 return rtn;
1129 }
std::vector< size_t > maskedBins() const noexcept Definition BinnedStorage.h:379 References YODA::BinnedStorage< BinContentT, AxisT >::bin(), YODA::BinnedStorage< BinContentT, AxisT >::bins(), 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 1112 of file BinnedEstimate.h. 1113 {
1114 if (numer != denom) {
1116 }
1117
1118 BinnedEstimate<AxisT...> rtn(numer.binning());
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();
1124 rtn.bin(idx) = divide(b_num, denom.bin(idx), pat_uncorr);
1125 }
1127
1128 return rtn;
1129 }
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 Num add_quad(Num a, Num b) Named number-type addition in quadrature operation. Definition MathUtils.h:222 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:1092 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 1162 of file BinnedDbn.h. 1162 {
1163
1164 if (accepted != total) {
1166 }
1167
1168 BinnedEstimate<AxisT...> rtn = divide(accepted, total);
1169
1170 for (const auto& b_acc : accepted.bins(true, true)) {
1172 auto& b_rtn = rtn.bin(b_acc.index());
1173
1174 // Check that the numerator is consistent with being a subset of the denominator
1176 if (b_acc.numEntries() > b_tot.numEntries())
1177 throw UserError("Attempt to calculate an efficiency when the numerator is not a subset of the denominator: "
1178 + Utils::toStr(b_acc.numEntries()) + " entries / " + Utils::toStr(b_tot.numEntries()) + " entries");
1179
1180 // If no entries on the denominator, set eff = err = 0 and move to the next bin
1181 double eff = std::numeric_limits<double>::quiet_NaN();
1182 double err = std::numeric_limits<double>::quiet_NaN();
1183 try {
1184 if (b_tot.sumW()) {
1185 eff = b_rtn.val();
1186 err = sqrt(abs( ((1-2*eff)*b_acc.sumW2() + sqr(eff)*b_tot.sumW2()) / sqr(b_tot.sumW()) ));
1187 }
1188 } catch (const LowStatsError& e) {
1189 //
1190 }
1191
1192 b_rtn.setErr({-err, err}); // @todo put "stats" as source?
1193 }
1194 return rtn;
1195 }
References YODA::BinnedStorage< BinContentT, AxisT >::bin(), YODA::BinnedStorage< BinContentT, AxisT >::bins(), divide(), 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 1166 of file BinnedEstimate.h. 1167 {
1168
1169 if (accepted != total) {
1171 }
1172
1173 BinnedEstimate<AxisT...> rtn(accepted.binning());
1174
1175 for (const auto& b_acc : accepted.bins(true, true)) {
1176 Estimate est;
1177 const size_t idx = b_acc.index();
1178 try {
1179 est = efficiency(b_acc, total.bin(idx), pat_uncorr);
1180 } catch (const UserError& e) {
1181 //
1182 }
1183 rtn.bin(idx).set(est);
1184 }
1185 return rtn;
1186 }
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:100 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 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:1162 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 375 of file MathUtils.h. 375 {
378 }
std::enable_if_t< std::is_floating_point_v< NUM >, bool > isZero(NUM val, double tolerance=1e-8) Compare a number to zero. Definition MathUtils.h:63 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 381 of file MathUtils.h. 381 {
382 double sumW = 0.0, sumW2 = 0.0;
383 for (size_t i = 0; i < weights.size(); ++i) {
384 sumW += weights[i];
385 sumW2 += sqr(weights[i]);
386 }
387 return effNumEntries(sumW, sumW2);
388 }
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(), and operator==(). ◆ 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 355 of file MathUtils.h. 355 {
357 int index = -1;
358 for (size_t i = 1; i < binedges.size(); ++i) {
359 if (val < binedges[i]) {
360 index = i-1;
361 break;
362 }
363 }
364 assert(inRange(index, -1, binedges.size()-1));
365 return index;
366 }
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 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 261 of file MathUtils.h. 261 {
264 std::vector<double> rtn;
265 const double interval = (xmax-xmin)/static_cast<double>(nbins);
266 for (size_t i = 0; i < nbins; ++i) {
267 rtn.push_back(xmin + i*interval);
268 }
269 assert(rtn.size() == nbins);
270 if (include_end) rtn.push_back(xmax); // exact xmax, not result of n * interval
271 return rtn;
272 }
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 280 of file MathUtils.h. 280 {
284 const double logxmin = std::log(xmin);
285 const double logxmax = std::log(xmax);
287 assert(logvals.size() == nbins+1);
288 std::vector<double> rtn; rtn.reserve(logvals.size());
289 rtn.push_back(xmin);
290 for (size_t i = 1; i < logvals.size()-1; ++i) {
291 rtn.push_back(std::exp(logvals[i]));
292 }
293 assert(rtn.size() == nbins);
294 if (include_end) rtn.push_back(xmax);
295 return rtn;
296 }
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:261 References linspace(). ◆ mean() [1/3]
Calculate the weighted mean of a sample. Definition at line 400 of file MathUtils.h. 400 {
401 return sumW? sumWX / sumW : std::numeric_limits<double>::quiet_NaN();
402 }
◆ mean() [2/3]
Calculate the weighted mean of a sample. Definition at line 405 of file MathUtils.h. 406 {
408 double sumWX = 0., sumW = 0.;
409 for (size_t i = 0; i < sample.size(); ++i) {
410 sumW += weights[i];
411 sumWX += weights[i]*sample[i];
412 }
413 return mean(sumWX, sumW);
414 }
References mean(). ◆ mean() [3/3]
Calculate the mean of a sample. Definition at line 391 of file MathUtils.h. 391 {
393 for (size_t i=0; i<sample.size(); ++i) {
394 mean += sample[i];
395 }
396 return mean/sample.size();
397 }
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 Histo1D to a Scatter2D 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 1216 of file BinnedDbn.h. 1216 {
1217
1219
1220 double sumW = 0.0, sumW2 = 0.0;
1221 for (const auto& b : histo.bins(includeOverflows)) {
1222 sumW += b.sumW();
1223 sumW2 += b.sumW2();
1224 const double e = sqrt(sumW2);
1225 rtn.bin(b.index()).set(sumW, {-e, e});
1226 }
1227
1228 return rtn;
1229 }
References YODA::BinnedStorage< BinContentT, AxisT >::bins(), and YODA::DbnStorage< DbnN, AxisT >::mkEstimate(). Referenced by mkIntegralEff(). ◆ mkIntegralEff()
template<size_t DbnN, typename... AxisT>
Convert a Histo1D to a Scatter2D 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 1245 of file BinnedDbn.h. 1245 {
1246
1249
1250 // If the integral is empty, the (integrated) efficiency values may as well all be zero, so return here
1254 if (!integral) return rtn;
1255
1257 for (const auto& b : rtn.bins(includeOverflows)) {
1258 const double eff = b.val() / integral;
1259 const double err = sqrt(std::abs( ((1-2*eff)*sqr(b.relTotalErrAvg()) + sqr(eff)*sqr(integral_err)) / sqr(integral) ));
1260 b.set(eff, {-err,err});
1261 }
1262
1263 return rtn;
1264 }
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 Histo1D to a Scatter2D representing the integral of the histogram. Definition BinnedDbn.h:1216 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(). ◆ mkScatter()Make a Scatter1D representation of a Histo1D. Definition at line 8 of file Scatter.cc. 8 {
9 Scatter1D rtn;
10 for (const std::string& a : c.annotations())
11 rtn.setAnnotation(a, c.annotation(a));
14 rtn.addPoint(pt);
15 return rtn;
16 }
virtual std::string type() const Get name of the analysis object type. Definition AnalysisObject.h:268 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::AnalysisObject::annotation(), YODA::AnalysisObject::annotations(), YODA::Counter::err(), YODA::AnalysisObject::setAnnotation(), YODA::AnalysisObject::type(), and YODA::Counter::val(). ◆ 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 543 of file MathUtils.h. 544 {},
545 const std::vector<double>& s2errors = std::vector<double>{}) {
546 if (sample1.size() != sample2.size()) {
547 throw RangeError("Inputs should have equal length!");
548 }
549 if (s1errors.size() && sample1.size() != s1errors.size()) {
550 throw RangeError("Inputs should have equal length!");
551 }
552 if (s2errors.size() && sample2.size() != s2errors.size()) {
553 throw RangeError("Inputs should have equal length!");
554 }
555 const size_t N = sample1.size();
556 double chi2 = 0.0;
557 for (size_t i = 0; i < N; ++i) {
559 if (s1errors.size()) {
561 }
562 chi2 += temp;
563 }
564 return chi2;
565 }
◆ naiveChi2reduced()
Calculate the error-weighted reduced chi2 statistic between two samples.
Definition at line 573 of file MathUtils.h. 574 {},
575 const std::vector<double>& s2errors = std::vector<double>{}) {
576 if (sample1.empty()) throw RangeError("Inputs should not have 0 length!");
578 }
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:543 ◆ 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 1294 of file BinnedDbn.h. References add(). ◆ operator+() [2/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1282 of file BinnedDbn.h. References add(). ◆ operator+() [3/17]
template<size_t DbnN, typename... AxisT>
Add two BinnedDbn objects. Definition at line 1060 of file BinnedDbn.h. 1060 {
1061 first += std::move(second);
1062 return first;
1063 }
◆ operator+() [4/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1067 of file BinnedDbn.h. 1067 {
1068 first += second;
1069 return first;
1070 }
◆ operator+() [5/17]
template<typename... AxisT>
Add two BinnedEstimates. Definition at line 1087 of file BinnedEstimate.h. 1087 {
1088 first += std::move(second);
1089 return first;
1090 }
◆ operator+() [6/17]
template<typename... AxisT>
Add two BinnedEstimates. Definition at line 1078 of file BinnedEstimate.h. 1078 {
1079 first += second;
1080 return first;
1081 }
◆ operator+() [7/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1288 of file BinnedDbn.h. References add(). ◆ operator+() [8/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1276 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 1326 of file BinnedDbn.h. References subtract(). ◆ operator-() [2/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1314 of file BinnedDbn.h. References subtract(). ◆ operator-() [3/17]
template<size_t DbnN, typename... AxisT>
Subtract one BinnedDbn object from another. Definition at line 1076 of file BinnedDbn.h. 1076 {
1077 first -= std::move(second);
1078 return first;
1079 }
◆ operator-() [4/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1083 of file BinnedDbn.h. 1083 {
1084 first -= second;
1085 return first;
1086 }
◆ operator-() [5/17]
template<typename... AxisT>
Subtract two BinnedEstimates. Definition at line 1104 of file BinnedEstimate.h. 1104 {
1105 first -= std::move(second);
1106 return first;
1107 }
◆ operator-() [6/17]
template<typename... AxisT>
Subtract two BinnedEstimates. Definition at line 1096 of file BinnedEstimate.h. 1096 {
1097 first -= second;
1098 return first;
1099 }
◆ operator-() [7/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1320 of file BinnedDbn.h. References subtract(). ◆ operator-() [8/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1308 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 1358 of file BinnedDbn.h. References divide(). ◆ operator/() [2/27]
template<size_t DbnN, typename... AxisT>
Definition at line 1346 of file BinnedDbn.h. References divide(). ◆ operator/() [3/27]
template<size_t DbnN, typename... AxisT>
Definition at line 1151 of file BinnedDbn.h. References divide(). ◆ operator/() [4/27]
template<size_t DbnN, typename... AxisT>
Definition at line 1145 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 1352 of file BinnedDbn.h. References divide(). ◆ operator/() [8/27]
template<size_t DbnN, typename... AxisT>
Definition at line 1340 of file BinnedDbn.h. References divide(). ◆ operator/() [9/27]
template<size_t DbnN, typename... AxisT>
Definition at line 1139 of file BinnedDbn.h. References divide(). ◆ operator/() [10/27]
template<size_t DbnN, typename... AxisT>
Definition at line 1133 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 322 of file MathUtils.h. 322 {
323 const double dx = (xmax-xmin)/(double)nsample;
325 std::vector<double> ys(0, nsample);
326 auto posfn = [&](double x){return std::max(fn(x), 0.0);};
327 std::transform(xs.begin(), xs.end(), ys.begin(), posfn);
328 std::vector<double> areas; areas.reserve(nsample);
329 double areasum = 0;
330 for (size_t i = 0; i < ys.size()-1; ++i) {
331 const double area = (ys[i] + ys[i+1])*dx/2.0;
332 areas[i] = area;
333 areasum += area;
334 }
335 const double df = areasum/(double)nbins;
336 std::vector<double> xedges{xmin}; xedges.reserve(nbins+1);
337 double fsum = 0;
338 for (size_t i = 0; i < nsample-1; ++i) {
339 fsum += areas[i];
340 if (fsum > df) {
341 fsum = 0;
342 xedges.push_back(xs[i+1]);
343 }
344 }
345 xedges.push_back(xmax);
346 assert(xedges.size() == nbins+1);
347 return xedges;
348 }
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 489 of file MathUtils.h. 489 {
490 // Weighted RMS defined as
491 // rms = sqrt(sum{w x^2} / sum{w})
493 if (effN == 0) return std::numeric_limits<double>::quiet_NaN();
494 const double meanSq = sumWX2 / sumW;
495 return std::sqrt(meanSq);
496 }
double effNumEntries(const double sumW, const double sumW2) Calculate the effective number of entries of a sample. Definition MathUtils.h:375 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 499 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 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 458 of file MathUtils.h. 459 {
461 }
double variance(const double sumWX, const double sumW, const double sumWX2, const double sumW2) Calculate the weighted variance of a sample. Definition MathUtils.h:421 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 464 of file MathUtils.h. References variance(). ◆ stdErr() [1/2]
Calculate the weighted standard error of a sample. Definition at line 470 of file MathUtils.h. 471 {
473 if (effN == 0) return std::numeric_limits<double>::quiet_NaN();
475 return std::sqrt(var / effN);
476 }
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 479 of file MathUtils.h. 480 {
483 if (effN == 0) return std::numeric_limits<double>::quiet_NaN();
485 return std::sqrt(var / effN);
486 }
References effNumEntries(), and variance(). ◆ subtract()
template<size_t DbnN, typename... AxisT>
Calculate the subtraction of a BinnedEstimate from a BinnedDbn. Definition at line 1302 of file BinnedDbn.h. References YODA::DbnStorage< DbnN, AxisT >::mkEstimate(). Referenced by asymm(), operator-(), operator-(), operator-(), and operator-(). ◆ transform() [1/6]
template<typename... AxisT, typename FN >
Definition at line 1213 of file BinnedEstimate.h. 1213 {
1215 }
Definition Transformation.h:31 void transform(BinnedEstimate< AxisT... > &est, const Trf< 1 > &fn) Definition BinnedEstimate.h:1206 References transform(). ◆ transform() [2/6]
template<typename... AxisT>
Definition at line 1206 of file BinnedEstimate.h. 1206 {
1207 for (auto& b : est.bins(true, true)) {
1208 b.transform(fn);
1209 }
1210 }
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 421 of file MathUtils.h. 422 {
428 // if (fabs(num) < 1e-10 && fabs(den) < 1e-10) {
429 // return std::numeric_limits<double>::quiet_NaN();
430 // }
435 return den? fabs(num/den): std::numeric_limits<double>::quiet_NaN();
436 }
References sqr(). 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 439 of file MathUtils.h. 440 {
443 //throw LowStatsError("Requested variance of a distribution with only one effective entry");
444 return std::numeric_limits<double>::quiet_NaN();
445 }
446 double sumWX = 0., sumW = 0.;
447 double sumWX2 = 0., sumW2 = 0.;
448 for (size_t i = 0; i < sample.size(); ++i) {
449 sumW += weights[i];
450 sumWX += weights[i]*sample[i];
451 sumW2 += sqr(weights[i]);
452 sumWX2 += weights[i]*sqr(sample[i]);
453 }
455 }
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 1374 of file BinnedDbn.h. 1375 {
1376
1377 // Check profiles have the same binning
1378 if ( !((p1 == others) && ...) )
1380
1381 // Construct resulting Scatter whose coordinates
1382 // are given by the unbinned means
1383 constexpr size_t N = sizeof...(Args)+1;
1384 ScatterND<N> rtn;
1386 for (const auto& b1 : p1.bins()) {
1387 typename ScatterND<N>::NdVal vals = { b1.mean(DbnN), others.bin(b1.binIndex()).mean(DbnN) ... };
1388 typename ScatterND<N>::NdVal errs = { b1.stdErr(DbnN), others.bin(b1.binIndex()).stdErr(DbnN) ... };
1389 rtn.addPoint(vals, errs);
1390 }
1391 return rtn;
1392 }
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 Mon Oct 28 2024 13:47:24 for YODA - Yet more Objects for Data Analysis by 1.9.8 |