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 363 of file AnalysisObject.h. ◆ BinnedEstimate1D
template<typename A1 >
Define dimension-specific short-hands (Cython sugar) Definition at line 1221 of file BinnedEstimate.h. ◆ BinnedEstimate2D
template<typename A1 , typename A2 >
Definition at line 1224 of file BinnedEstimate.h. ◆ BinnedEstimate3D
template<typename A1 , typename A2 , typename A3 >
Definition at line 1227 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 1245 of file BinnedEstimate.h. ◆ Estimate2D
Definition at line 1246 of file BinnedEstimate.h. ◆ Estimate3D
Definition at line 1247 of file BinnedEstimate.h. ◆ EstimateND
template<size_t N>
Definition at line 1241 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 1268 of file BinnedDbn.h. 1268 {
1270 }
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 1199 of file BinnedDbn.h. 1199 {
1200 return (a-b) / (a+b);
1201 }
◆ asymm() [2/2]
template<typename... AxisT>
Calculate the asymmetry (a-b)/(a+b) of two BinnedDbn objects. Definition at line 1188 of file BinnedEstimate.h. 1190 {
1192 }
BinnedEstimate< AxisT... > add(const BinnedDbn< DbnN, AxisT... > &dbn, const BinnedEstimate< AxisT... > &est) Calculate the addition of a BinnedDbn with a BinnedEstimate. Definition BinnedDbn.h:1268 BinnedEstimate< AxisT... > subtract(const BinnedDbn< DbnN, AxisT... > &dbn, const BinnedEstimate< AxisT... > &est) Calculate the subtraction of a BinnedEstimate from a BinnedDbn. Definition BinnedDbn.h:1300 References add(), and subtract(). ◆ combine() [1/4]
template<int N>
Definition at line 783 of file Scatter.h. 783 {
784 ScatterND<N> rtn;
785 rtn.combineWith(scatters);
786 return rtn;
787 }
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:558 References YODA::ScatterND< N >::combineWith(). ◆ combine() [2/4]Definition at line 771 of file Scatter.h. References YODA::ScatterND< N >::combineWith(). ◆ combine() [3/4]Definition at line 777 of file Scatter.h. References YODA::ScatterND< N >::combineWith(). ◆ combine() [4/4]Definition at line 790 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 1332 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 1090 of file BinnedDbn.h. 1090 {
1091
1092 if (numer != denom) {
1094 }
1095
1096 BinnedEstimate<AxisT...> rtn = numer.mkEstimate();
1098 if (rtn.hasAnnotation("ScaledBy")) rtn.rmAnnotation("ScaledBy");
1099
1100 for (const auto& b_num : numer.bins(true, true)) {
1101 const size_t idx = b_num.index();
1103 double v, e;
1104 if (!b_den.effNumEntries()) {
1105 v = std::numeric_limits<double>::quiet_NaN();
1106 e = std::numeric_limits<double>::quiet_NaN();
1107 }
1108 else {
1109 if constexpr(DbnN > sizeof...(AxisT)) {
1110 v = b_num.mean(DbnN) / b_den.mean(DbnN);
1111 const double e_num = b_num.effNumEntries()? b_num.relStdErr(DbnN) : 0;
1112 const double e_den = b_den.effNumEntries()? b_den.relStdErr(DbnN) : 0;
1114 }
1115 else {
1116 v = b_num.sumW() / b_den.sumW();
1117 const double e_num = b_num.sumW()? b_num.relErrW() : 0;
1118 const double e_den = b_den.sumW()? b_den.relErrW() : 0;
1120 }
1121 }
1122 rtn.bin(idx).set(v, {-e, e}); // @todo put "stats" as source?
1123 }
1125
1126 return rtn;
1127 }
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 1108 of file BinnedEstimate.h. 1109 {
1110 if (numer != denom) {
1112 }
1113
1114 BinnedEstimate<AxisT...> rtn(numer.binning());
1116 if (rtn.hasAnnotation("ScaledBy")) rtn.rmAnnotation("ScaledBy");
1117
1118 for (const auto& b_num : numer.bins(true, true)) {
1119 const size_t idx = b_num.index();
1120 rtn.bin(idx) = divide(b_num, denom.bin(idx), pat_uncorr);
1121 }
1123
1124 return rtn;
1125 }
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:201 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 600 of file Estimate.h. 601 {
602
603 Estimate rtn;
606
607 // get error sources
608 std::vector<std::string> sources = numer.sources();
609 std::vector<std::string> tmp = denom.sources();
610 sources.insert(std::end(sources),
611 std::make_move_iterator(std::begin(tmp)),
612 std::make_move_iterator(std::end(tmp)));
613 sources.erase( std::unique(sources.begin(), sources.end()), sources.end() );
614
615 std::smatch match;
616 const std::regex re(pat_uncorr);
617 for (const std::string& src : sources) {
618 if (std::regex_search(src, match, re)) {
619 // treat as uncorrelated between AOs:
620 // add relative errors in quadrature
621 double n_dn = 0.0, n_up = 0.0;
623 n_dn = numer.relErrDown(src);
624 n_up = numer.relErrUp(src);
625 }
626 double d_dn = 0.0, d_up = 0.0;
628 d_dn = denom.relErrDown(src);
629 d_up = denom.relErrUp(src);
630 }
631 const double new_dn = fabs(newVal) * std::sqrt(n_dn*n_dn + d_dn*d_dn);
632 const double new_up = fabs(newVal) * std::sqrt(n_up*n_up + d_up*d_up);
633 rtn.setErr({-new_dn,new_up}, src);
634 }
635 else {
636 // treat as correlated between AOs:
637 // work out correlated ratio: R+dR = (N+dN)/(D+dD)
640 n_dn += numer.errDown(src);
641 n_up += numer.errUp(src);
642 }
645 d_dn += denom.errDown(src);
646 d_up += denom.errUp(src);
647 }
648 double new_dn = std::numeric_limits<double>::quiet_NaN();
649 double new_up = std::numeric_limits<double>::quiet_NaN();
650 if (d_dn) new_dn = n_dn / d_dn - newVal;
651 if (d_up) new_up = n_up / d_up - newVal;
652 rtn.setErr({new_dn, new_up}, src);
653 }
654 }
655
656 return rtn;
657 }
void setErr(const std::pair< double, double > &err, const std::string &source="") Set a signed uncertainty component. Definition Estimate.h:165 double errDown(const std::string &source="") const The signed error due to the systematic downward variation. Definition Estimate.h:272 double relErrUp(const std::string &source="") const The relative positive on the central value. Definition Estimate.h:305 double errUp(const std::string &source="") const The signed error due to the systematic upward variation. Definition Estimate.h:277 double relErrDown(const std::string &source="") const The relative negative on the central value. Definition Estimate.h:300 bool hasSource(const std::string &key) const noexcept Definition Estimate.h:414 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 325 of file Estimate0D.h. 326 {
331 return rtn;
332 }
BinnedEstimate< AxisT... > divide(const BinnedDbn< DbnN, AxisT... > &numer, const BinnedDbn< DbnN, AxisT... > &denom) Divide two BinnedDbn objects. Definition BinnedDbn.h:1090 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 1160 of file BinnedDbn.h. 1160 {
1161
1162 if (accepted != total) {
1164 }
1165
1166 BinnedEstimate<AxisT...> rtn = divide(accepted, total);
1167
1168 for (const auto& b_acc : accepted.bins(true, true)) {
1170 auto& b_rtn = rtn.bin(b_acc.index());
1171
1172 // Check that the numerator is consistent with being a subset of the denominator
1174 if (b_acc.numEntries() > b_tot.numEntries())
1175 throw UserError("Attempt to calculate an efficiency when the numerator is not a subset of the denominator: "
1176 + Utils::toStr(b_acc.numEntries()) + " entries / " + Utils::toStr(b_tot.numEntries()) + " entries");
1177
1178 // If no entries on the denominator, set eff = err = 0 and move to the next bin
1179 double eff = std::numeric_limits<double>::quiet_NaN();
1180 double err = std::numeric_limits<double>::quiet_NaN();
1181 try {
1182 if (b_tot.sumW()) {
1183 eff = b_rtn.val();
1184 err = sqrt(abs( ((1-2*eff)*b_acc.sumW2() + sqr(eff)*b_tot.sumW2()) / sqr(b_tot.sumW()) ));
1185 }
1186 } catch (const LowStatsError& e) {
1187 //
1188 }
1189
1190 b_rtn.setErr({-err, err}); // @todo put "stats" as source?
1191 }
1192 return rtn;
1193 }
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 1162 of file BinnedEstimate.h. 1163 {
1164
1165 if (accepted != total) {
1167 }
1168
1169 BinnedEstimate<AxisT...> rtn(accepted.binning());
1170
1171 for (const auto& b_acc : accepted.bins(true, true)) {
1172 Estimate est;
1173 const size_t idx = b_acc.index();
1174 try {
1175 est = efficiency(b_acc, total.bin(idx), pat_uncorr);
1176 } catch (const UserError& e) {
1177 //
1178 }
1179 rtn.bin(idx).set(est);
1180 }
1181 return rtn;
1182 }
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 680 of file Estimate.h. 681 {
682
688 if (acc_val > tot_val)
689 throw UserError("Attempt to calculate an efficiency when the numerator is not a subset of the denominator: "
690 + Utils::toStr(acc_val) + " / " + Utils::toStr(tot_val));
691
693
694 // get error sources
695 std::vector<std::string> sources = accepted.sources();
696 std::vector<std::string> tmp = total.sources();
697 sources.insert(std::end(sources),
698 std::make_move_iterator(std::begin(tmp)),
699 std::make_move_iterator(std::end(tmp)));
700 sources.erase( std::unique(sources.begin(), sources.end()), sources.end() );
701
702 // set binomial error for uncorrelated error sources
703 std::smatch match;
705 const std::regex re(pat_uncorr);
706 for (const std::string& src : sources) {
707 double err = std::numeric_limits<double>::quiet_NaN();
708 if (!tot_val) {
709 rtn.setErr({-err,err}, src);
710 continue;
711 }
712 else if (std::regex_search(src, match, re)) {
716 rtn.setErr({-err,err}, src);
717 continue;
718 }
719 }
720
721 return rtn;
722 }
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 355 of file Estimate0D.h. 356 {
361 return rtn;
362 }
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:1160 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(), 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 1214 of file BinnedDbn.h. 1214 {
1215
1217
1218 double sumW = 0.0, sumW2 = 0.0;
1219 for (const auto& b : histo.bins(includeOverflows)) {
1220 sumW += b.sumW();
1221 sumW2 += b.sumW2();
1222 const double e = sqrt(sumW2);
1223 rtn.bin(b.index()).set(sumW, {-e, e});
1224 }
1225
1226 return rtn;
1227 }
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 1243 of file BinnedDbn.h. 1243 {
1244
1247
1248 // If the integral is empty, the (integrated) efficiency values may as well all be zero, so return here
1252 if (!integral) return rtn;
1253
1255 for (const auto& b : rtn.bins(includeOverflows)) {
1256 const double eff = b.val() / integral;
1257 const double err = sqrt(std::abs( ((1-2*eff)*sqr(b.relTotalErrAvg()) + sqr(eff)*sqr(integral_err)) / sqr(integral) ));
1258 b.set(eff, {-err,err});
1259 }
1260
1261 return rtn;
1262 }
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:1214 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:271 void setAnnotation(const std::string &name, const T &value) Add or set an annotation by name (templated for remaining types) Definition AnalysisObject.h:169 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(). ◆ 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 1292 of file BinnedDbn.h. References add(). ◆ operator+() [2/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1280 of file BinnedDbn.h. References add(). ◆ operator+() [3/17]
template<size_t DbnN, typename... AxisT>
Add two BinnedDbn objects. Definition at line 1058 of file BinnedDbn.h. 1058 {
1059 first += std::move(second);
1060 return first;
1061 }
◆ operator+() [4/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1065 of file BinnedDbn.h. 1065 {
1066 first += second;
1067 return first;
1068 }
◆ operator+() [5/17]
template<typename... AxisT>
Add two BinnedEstimates. Definition at line 1083 of file BinnedEstimate.h. 1083 {
1084 first += std::move(second);
1085 return first;
1086 }
◆ operator+() [6/17]
template<typename... AxisT>
Add two BinnedEstimates. Definition at line 1074 of file BinnedEstimate.h. 1074 {
1075 first += second;
1076 return first;
1077 }
◆ operator+() [7/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1286 of file BinnedDbn.h. References add(). ◆ operator+() [8/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1274 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 576 of file Estimate.h. 576 {
577 lhs += rhs;
578 return lhs;
579 }
◆ operator+() [15/17]Add two Estimate objects. Definition at line 582 of file Estimate.h. 582 {
583 lhs += std::move(rhs);
584 return lhs;
585 }
◆ operator+() [16/17]
Add two Estimate0D objects. Definition at line 301 of file Estimate0D.h. 301 {
302 lhs += rhs;
303 return lhs;
304 }
◆ operator+() [17/17]
Add two Estimate0D objects. Definition at line 307 of file Estimate0D.h. 307 {
308 lhs += std::move(rhs);
309 return lhs;
310 }
◆ operator-() [1/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1324 of file BinnedDbn.h. References subtract(). ◆ operator-() [2/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1312 of file BinnedDbn.h. References subtract(). ◆ operator-() [3/17]
template<size_t DbnN, typename... AxisT>
Subtract one BinnedDbn object from another. Definition at line 1074 of file BinnedDbn.h. 1074 {
1075 first -= std::move(second);
1076 return first;
1077 }
◆ operator-() [4/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1081 of file BinnedDbn.h. 1081 {
1082 first -= second;
1083 return first;
1084 }
◆ operator-() [5/17]
template<typename... AxisT>
Subtract two BinnedEstimates. Definition at line 1100 of file BinnedEstimate.h. 1100 {
1101 first -= std::move(second);
1102 return first;
1103 }
◆ operator-() [6/17]
template<typename... AxisT>
Subtract two BinnedEstimates. Definition at line 1092 of file BinnedEstimate.h. 1092 {
1093 first -= second;
1094 return first;
1095 }
◆ operator-() [7/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1318 of file BinnedDbn.h. References subtract(). ◆ operator-() [8/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1306 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 588 of file Estimate.h. 588 {
589 lhs -= rhs;
590 return lhs;
591 }
◆ operator-() [15/17]Subtract two Estimate objects. Definition at line 594 of file Estimate.h. 594 {
595 lhs -= std::move(rhs);
596 return lhs;
597 }
◆ operator-() [16/17]
Subtract two Estimate0D objects. Definition at line 313 of file Estimate0D.h. 313 {
314 lhs -= rhs;
315 return lhs;
316 }
◆ operator-() [17/17]
Subtract two Estimate0D objects. Definition at line 319 of file Estimate0D.h. 319 {
320 lhs -= std::move(rhs);
321 return lhs;
322 }
◆ operator/() [1/27]
template<size_t DbnN, typename... AxisT>
Definition at line 1356 of file BinnedDbn.h. References divide(). ◆ operator/() [2/27]
template<size_t DbnN, typename... AxisT>
Definition at line 1344 of file BinnedDbn.h. References divide(). ◆ operator/() [3/27]
template<size_t DbnN, typename... AxisT>
Definition at line 1149 of file BinnedDbn.h. References divide(). ◆ operator/() [4/27]
template<size_t DbnN, typename... AxisT>
Definition at line 1143 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 1350 of file BinnedDbn.h. References divide(). ◆ operator/() [8/27]
template<size_t DbnN, typename... AxisT>
Definition at line 1338 of file BinnedDbn.h. References divide(). ◆ operator/() [9/27]
template<size_t DbnN, typename... AxisT>
Definition at line 1137 of file BinnedDbn.h. References divide(). ◆ operator/() [10/27]
template<size_t DbnN, typename... AxisT>
Definition at line 1131 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 501 of file Point.h. 501 {
502 #define LT_IF_NOT_EQ(a,b) { if (!fuzzyEquals(a, b)) return a < b; }
503 for (size_t i = 0; i < N; ++i) {
507 }
508 #undef LT_IF_NOT_EQ
509 return false;
510 }
#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 482 of file Point.h. 482 {
483 // Compare valitions
484 for (size_t i = 0; i < N; ++i) {
488 }
489 return true;
490 }
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(), 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 1300 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 1209 of file BinnedEstimate.h. 1209 {
1211 }
Definition Transformation.h:31 void transform(BinnedEstimate< AxisT... > &est, const Trf< 1 > &fn) Definition BinnedEstimate.h:1202 References transform(). ◆ transform() [2/6]
template<typename... AxisT>
Definition at line 1202 of file BinnedEstimate.h. 1202 {
1203 for (auto& b : est.bins(true, true)) {
1204 b.transform(fn);
1205 }
1206 }
References YODA::BinnedStorage< BinContentT, AxisT >::bins(). Referenced by transform(), transform(), transform(), transformX(), transformY(), and transformZ(). ◆ transform() [3/6]
template<typename FN >
Definition at line 290 of file Estimate0D.h. References transform(). ◆ transform() [4/6]
Definition at line 285 of file Estimate0D.h. 285 {
286 est.transform(fn);
287 }
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 857 of file Scatter.h. References transform(). ◆ transform() [6/6]
template<size_t N>
Definition at line 850 of file Scatter.h. 850 {
851 for (auto& p : s.points()) {
852 p.transform(i, fn);
853 }
854 }
References YODA::ScatterND< N >::points(). ◆ transformX()
template<size_t N, typename FN >
Definition at line 862 of file Scatter.h. References transform(). ◆ transformY()
template<size_t N, typename FN >
Definition at line 867 of file Scatter.h. References transform(). ◆ transformZ()
template<size_t N, typename FN >
Definition at line 872 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(). 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 Thu Feb 29 2024 12:47:15 for YODA - Yet more Objects for Data Analysis by 1.9.8 |