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 376 of file AnalysisObject.h. ◆ BinnedEstimate1D
template<typename A1 >
Define dimension-specific short-hands (Cython sugar) Definition at line 1293 of file BinnedEstimate.h. ◆ BinnedEstimate2D
template<typename A1 , typename A2 >
Definition at line 1296 of file BinnedEstimate.h. ◆ BinnedEstimate3D
template<typename A1 , typename A2 , typename A3 >
Definition at line 1299 of file BinnedEstimate.h. ◆ BinnedHisto
template<typename... AxisTypes>
Definition at line 102 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 105 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
◆ EdgeHandlerBasePtr
◆ EdgeHandlerPtr
template<typename T >
◆ 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 1317 of file BinnedEstimate.h. ◆ Estimate2D
Definition at line 1318 of file BinnedEstimate.h. ◆ Estimate3D
Definition at line 1319 of file BinnedEstimate.h. ◆ EstimateND
template<size_t N>
Definition at line 1313 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 126 of file Transformation.h. Enumeration Type Documentation◆ RangeBoundary
Represents whether an interval is open (non-inclusive) or closed (inclusive). For example, the interval
Definition at line 156 of file MathUtils.h. ◆ Sign
Function Documentation◆ add() [1/2]
template<size_t DbnN, typename... AxisT>
Calculate the addition of a BinnedDbn with a BinnedEstimate. Definition at line 1347 of file BinnedDbn.h. 1347 {
1349 }
BinnedEstimate< AxisT... > mkEstimate(const std::string &path="", const std::string &source="", const bool divbyvol=true, const double overflowsWidth=-1.0) const Produce a BinnedEstimate from a DbnStorage. Definition BinnedDbn.h:800 References YODA::DbnStorage< DbnN, AxisT >::mkEstimate(). Referenced by asymm(), efficiency(), efficiency(), operator+(), operator+(), operator+(), and operator+(). ◆ add() [2/2]
Add two numbers with FP fuzziness. Definition at line 253 of file MathUtils.h. 253 {
255 }
BinnedEstimate< AxisT... > subtract(const BinnedDbn< DbnN, AxisT... > &dbn, const BinnedEstimate< AxisT... > &est) Calculate the subtraction of a BinnedEstimate from a BinnedDbn. Definition BinnedDbn.h:1379 References subtract(). ◆ add_quad()
template<typename... Num>
Named number-type addition in quadrature operation. Definition at line 223 of file MathUtils.h. 223 {
225 }
References sqr(). Referenced by divide(). ◆ approx()
Returns a number floored at the nth decimal place. Definition at line 140 of file MathUtils.h. 140 {
141 double roundTo = pow(10.0,n);
142 a *= roundTo;
143 a = floor(a);
144 return a/roundTo;
145 }
◆ asymm() [1/2]
template<size_t DbnN, typename... AxisT>
Calculate the asymmetry (a-b)/(a+b) of two BinnedDbn objects. Definition at line 1278 of file BinnedDbn.h. 1278 {
1279 return (a-b) / (a+b);
1280 }
◆ asymm() [2/2]
template<typename... AxisT>
Calculate the asymmetry (a-b)/(a+b) of two BinnedDbn objects. Definition at line 1260 of file BinnedEstimate.h. 1262 {
1264 }
BinnedEstimate< AxisT... > add(const BinnedDbn< DbnN, AxisT... > &dbn, const BinnedEstimate< AxisT... > &est) Calculate the addition of a BinnedDbn with a BinnedEstimate. Definition BinnedDbn.h:1347 References add(), and subtract(). ◆ combine() [1/4]
template<int N>
Definition at line 803 of file Scatter.h. 803 {
804 ScatterND<N> rtn;
805 rtn.combineWith(scatters);
806 return rtn;
807 }
A generic data type which is just a collection of n-dim data points with errors. Definition Scatter.h:153 ScatterND< N > & combineWith(const ScatterND< N > &other) Definition Scatter.h:567 References YODA::ScatterND< N >::combineWith(). ◆ combine() [2/4]Definition at line 791 of file Scatter.h. References YODA::ScatterND< N >::combineWith(). ◆ combine() [3/4]Definition at line 797 of file Scatter.h. References YODA::ScatterND< N >::combineWith(). ◆ combine() [4/4]Definition at line 810 of file Scatter.h. References YODA::ScatterND< N >::combineWith(). ◆ containsNan()
template<typename... Args>
Checks if a coordinate tuple has a nan. Definition at line 30 of file Binning.h. 30 {
31 std::array<size_t, sizeof...(Args)> hasNan{};
32 auto checkCoords = [&hasNan, &coords](auto I) {
33 using isContinuous = typename std::is_floating_point<typename std::tuple_element_t<I, std::tuple<Args...>>>;
34
35 hasNan[I] = size_t(std::isnan(nullifyIfDiscCoord(std::move(std::get<I>(coords)),
36 std::integral_constant<bool,
37 isContinuous::value>{})));
38 };
39
41
42 return std::any_of(hasNan.begin(), hasNan.end(), [ ](const bool i) { return i; } );
43 }
constexpr void staticFor(Func &&f) Used to apply functor on tuple. Calls lambda with integral constant, which can be used to query tuple... Definition MetaUtils.h:35 References nullifyIfDiscCoord(), and MetaUtils::staticFor(). Referenced by YODA::FillableStorage< FillDim, BinContentT, AxisT >::fill(). ◆ correlation()
Calculate the correlation strength between two samples. Definition at line 533 of file MathUtils.h. 533 {
539 return corr_strength;
540 }
double covariance(const std::vector< int > &sample1, const std::vector< int > &sample2) Calculate the covariance (variance) between two samples. Definition MathUtils.h:518 double correlation(const std::vector< int > &sample1, const std::vector< int > &sample2) Calculate the correlation strength between two samples. Definition MathUtils.h:533 References correlation(), and covariance(). Referenced by correlation(). ◆ covariance()
Calculate the covariance (variance) between two samples. Definition at line 518 of file MathUtils.h. 518 {
521 const size_t N = sample1.size();
522 double cov = 0.0;
523 for (size_t i = 0; i < N; i++) {
524 const double cov_i = (sample1[i] - mean1)*(sample2[i] - mean2);
525 cov += cov_i;
526 }
527 if (N > 1) return cov/(N-1);
528 else return 0.0;
529 }
double mean(const std::vector< int > &sample) Calculate the mean of a sample. Definition MathUtils.h:397 References mean(). Referenced by correlation(). ◆ divide() [1/6]
template<size_t DbnN, typename... AxisT>
Calculate the division of a BinnedDbn and a BinnedEstimate. Definition at line 1411 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 1174 of file BinnedDbn.h. 1174 {
1175
1176 if (numer != denom) {
1178 }
1179
1180 BinnedEstimate<AxisT...> rtn = numer.mkEstimate();
1182 if (rtn.hasAnnotation("ScaledBy")) rtn.rmAnnotation("ScaledBy");
1183
1184 for (const auto& b_num : numer.bins(true, true)) {
1185 const size_t idx = b_num.index();
1187 double v, e;
1188 if (isZero(b_den.effNumEntries())) {
1189 v = std::numeric_limits<double>::quiet_NaN();
1190 e = std::numeric_limits<double>::quiet_NaN();
1191 }
1192 else {
1193 if constexpr(DbnN > sizeof...(AxisT)) {
1194 v = b_num.mean(DbnN) / b_den.mean(DbnN);
1198 }
1199 else {
1200 v = b_num.sumW() / b_den.sumW();
1204 }
1205 }
1206 rtn.bin(idx).set(v, {-e, e}); // @todo put "stats" as source?
1207 }
1209
1210 return rtn;
1211 }
std::vector< size_t > maskedBins() const noexcept Definition BinnedStorage.h:379 std::enable_if_t< std::is_floating_point_v< NUM >, bool > isZero(NUM val, double tolerance=1e-5) Compare a number to zero. Definition MathUtils.h:63 References YODA::BinnedStorage< BinContentT, AxisT >::bin(), YODA::BinnedStorage< BinContentT, AxisT >::bins(), isZero(), YODA::BinnedStorage< BinContentT, AxisT >::maskedBins(), YODA::DbnStorage< DbnN, AxisT >::mkEstimate(), YODA::AnalysisObject::path(), and sqr(). Referenced by divide(), divide(), efficiency(), efficiency(), efficiency(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), operator/(), and operator/(). ◆ divide() [3/6]
template<typename... AxisT>
Divide two BinnedEstimates. Definition at line 1180 of file BinnedEstimate.h. 1181 {
1182 if (numer != denom) {
1184 }
1185
1186 BinnedEstimate<AxisT...> rtn(numer.binning());
1188 if (rtn.hasAnnotation("ScaledBy")) rtn.rmAnnotation("ScaledBy");
1189
1190 for (const auto& b_num : numer.bins(true, true)) {
1191 const size_t idx = b_num.index();
1192 rtn.bin(idx) = divide(b_num, denom.bin(idx), pat_uncorr);
1193 }
1195
1196 return rtn;
1197 }
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:214 bool hasAnnotation(const std::string &name) const Check if an annotation is defined. Definition AnalysisObject.h:132 void set(const double val, const std::pair< double, double > &err, const std::string source="") Set both central value and uncertainty component. Definition Estimate.h:181 std::enable_if_t< std::conjunction_v< std::is_arithmetic< Num >... >, double > add_quad(Num ... vals) Named number-type addition in quadrature operation. Definition MathUtils.h:223 References add_quad(), YODA::AnalysisObject::hasAnnotation(), YODA::AnalysisObject::path(), YODA::Counter::relErr(), YODA::AnalysisObject::rmAnnotation(), YODA::Estimate::set(), YODA::AnalysisObject::setPath(), and YODA::Counter::val(). ◆ divide() [5/6]
Divide two Estimate objects. Definition at line 684 of file Estimate.h. 685 {
686
687 Estimate rtn;
690
691 // get error sources
692 std::vector<std::string> sources = numer.sources();
693 std::vector<std::string> tmp = denom.sources();
694 sources.insert(std::end(sources),
695 std::make_move_iterator(std::begin(tmp)),
696 std::make_move_iterator(std::end(tmp)));
697 std::sort(sources.begin(), sources.end());
698 sources.erase( std::unique(sources.begin(), sources.end()), sources.end() );
699
700 std::smatch match;
701 const std::regex re(pat_uncorr, std::regex_constants::icase);
702 for (const std::string& src : sources) {
703 if (std::regex_search(src, match, re)) {
704 // treat as uncorrelated between AOs:
705 // add relative errors in quadrature
706 double n_dn = 0.0, n_up = 0.0;
708 n_dn = numer.relErrDown(src);
709 n_up = numer.relErrUp(src);
710 }
711 double d_dn = 0.0, d_up = 0.0;
713 d_dn = denom.relErrDown(src);
714 d_up = denom.relErrUp(src);
715 }
716 const double new_dn = fabs(newVal) * std::sqrt(n_dn*n_dn + d_dn*d_dn);
717 const double new_up = fabs(newVal) * std::sqrt(n_up*n_up + d_up*d_up);
718 rtn.setErr({-new_dn,new_up}, src);
719 }
720 else {
721 // treat as correlated between AOs:
722 // work out correlated ratio: R+dR = (N+dN)/(D+dD)
725 n_dn += numer.errDown(src);
726 n_up += numer.errUp(src);
727 }
730 d_dn += denom.errDown(src);
731 d_up += denom.errUp(src);
732 }
733 double new_dn = std::numeric_limits<double>::quiet_NaN();
734 double new_up = std::numeric_limits<double>::quiet_NaN();
735 if (d_dn) new_dn = n_dn / d_dn - newVal;
736 if (d_up) new_up = n_up / d_up - newVal;
737 rtn.setErr({new_dn, new_up}, src);
738 }
739 }
740
741 return rtn;
742 }
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 368 of file Estimate0D.h. 369 {
374 return rtn;
375 }
BinnedEstimate< AxisT... > divide(const BinnedDbn< DbnN, AxisT... > &numer, const BinnedDbn< DbnN, AxisT... > &denom) Divide two BinnedDbn objects. Definition BinnedDbn.h:1174 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 1244 of file BinnedDbn.h. 1244 {
1245
1246 if (accepted != total) {
1248 }
1249
1250 BinnedEstimate<AxisT...> rtn = divide(accepted, total);
1251
1252 for (const auto& b_acc : accepted.bins(true, true)) {
1254 auto& b_rtn = rtn.bin(b_acc.index());
1255
1256 // Check that the numerator is consistent with being a subset of the denominator
1258 if (b_acc.numEntries() > b_tot.numEntries())
1259 throw UserError("Attempt to calculate an efficiency when the numerator is not a subset of the denominator: "
1260 + Utils::toStr(b_acc.numEntries()) + " entries / " + Utils::toStr(b_tot.numEntries()) + " entries");
1261
1262 // If no entries on the denominator, set eff = err = 0 and move to the next bin
1263 double eff = std::numeric_limits<double>::quiet_NaN();
1264 double err = std::numeric_limits<double>::quiet_NaN();
1265 if (!isZero(b_tot.effNumEntries())) {
1266 eff = b_rtn.val();
1267 err = sqrt(fabs( add((1.0-2.0*eff)*b_acc.sumW2(), sqr(eff)*b_tot.sumW2()) / sqr(b_tot.sumW()) ));
1268 }
1269 b_rtn.setErr({-err, err}); // @todo put "stats" as source?
1270 }
1271 return rtn;
1272 }
References add(), YODA::BinnedStorage< BinContentT, AxisT >::bin(), YODA::BinnedStorage< BinContentT, AxisT >::bins(), divide(), isZero(), and sqr(). Referenced by efficiency(), and efficiency(). ◆ efficiency() [2/5]
template<typename... AxisT>
Calculate a binned efficiency ratio of two BinnedEstimate objects.
Definition at line 1234 of file BinnedEstimate.h. 1235 {
1236
1237 if (accepted != total) {
1239 }
1240
1241 BinnedEstimate<AxisT...> rtn(accepted.binning());
1242
1243 for (const auto& b_acc : accepted.bins(true, true)) {
1244 Estimate est;
1245 const size_t idx = b_acc.index();
1246 try {
1247 est = efficiency(b_acc, total.bin(idx), pat_uncorr);
1248 } catch (const UserError& e) {
1249 //
1250 }
1251 rtn.bin(idx).set(est);
1252 }
1253 return rtn;
1254 }
References YODA::BinnedStorage< BinContentT, AxisT >::bin(), YODA::BinnedStorage< BinContentT, AxisT >::binning(), YODA::BinnedStorage< BinContentT, AxisT >::bins(), and efficiency(). ◆ efficiency() [3/5]
Calculate an efficiency ratio of two counters.
Note that an efficiency is not the same thing as a standard division of two histograms: the errors must be treated as correlated
Definition at line 34 of file Counter.cc. 34 {
36
37 // Check that the numerator is consistent with being a subset of the denominator (NOT effNumEntries here!)
39 throw UserError("Attempt to calculate an efficiency when the numerator is not a subset of the denominator");
40
41 // If no entries on the denominator, set eff = err = 0 and move to the next bin
44 double eff = std::numeric_limits<double>::quiet_NaN();
45 double err = std::numeric_limits<double>::quiet_NaN();
49 }
50
51 tmp.set(eff, {-err, err});
52 return tmp;
53 }
Error for problems introduced outside YODA, to put it nicely. Definition Exceptions.h:86 References divide(), YODA::Counter::numEntries(), YODA::Estimate::set(), sqr(), YODA::Counter::sumW(), and YODA::Counter::sumW2(). ◆ efficiency() [4/5]
Divide two Estimate objects using binomial statistics. Check that the numerator is consistent with being a subset of the denominator
Definition at line 765 of file Estimate.h. 766 {
767
773 if (acc_val > tot_val)
774 throw UserError("Attempt to calculate an efficiency when the numerator is not a subset of the denominator: "
775 + Utils::toStr(acc_val) + " / " + Utils::toStr(tot_val));
776
778
779 // get error sources
780 std::vector<std::string> sources = accepted.sources();
781 std::vector<std::string> tmp = total.sources();
782 sources.insert(std::end(sources),
783 std::make_move_iterator(std::begin(tmp)),
784 std::make_move_iterator(std::end(tmp)));
785 std::sort(sources.begin(), sources.end());
786 sources.erase( std::unique(sources.begin(), sources.end()), sources.end() );
787
788 // set binomial error for uncorrelated error sources
789 std::smatch match;
791 const std::regex re(pat_uncorr, std::regex_constants::icase);
792 for (const std::string& src : sources) {
793 double err = std::numeric_limits<double>::quiet_NaN();
794 if (!tot_val) {
795 rtn.setErr({-err,err}, src);
796 continue;
797 }
798 else if (std::regex_search(src, match, re)) {
802 rtn.setErr({-err,err}, src);
803 continue;
804 }
805 }
806
807 return rtn;
808 }
double totalErrAvg(const std::string &pat_match="") const The average of the total downward/upward uncertainty shifts, which are taken to be the signed quadrat... Definition Estimate.h:429 double relTotalErrAvg(const std::string &pat_match="") const noexcept The relative average of the quad-sum-based total downward/upward uncertainty components. Definition Estimate.h:476 References add(), divide(), YODA::Estimate::relTotalErrAvg(), YODA::Estimate::setErr(), YODA::Estimate::sources(), sqr(), YODA::Estimate::totalErrAvg(), and YODA::Estimate::val(). ◆ efficiency() [5/5]
Divide two Estimate0D objects using binomial statistics. Definition at line 398 of file Estimate0D.h. 399 {
404 return rtn;
405 }
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:1244 References efficiency(), YODA::AnalysisObject::hasAnnotation(), YODA::AnalysisObject::path(), YODA::AnalysisObject::rmAnnotation(), and YODA::AnalysisObject::setPath(). ◆ effNumEntries() [1/2]
Calculate the effective number of entries of a sample. Definition at line 381 of file MathUtils.h. References isZero(), and sqr(). Referenced by effNumEntries(), YODA::DbnBase< N >::relErrW(), YODA::DbnBase< N >::relStdErr(), RMS(), stdErr(), stdErr(), and variance(). ◆ effNumEntries() [2/2]
Calculate the effective number of entries of a sample. Definition at line 387 of file MathUtils.h. 387 {
388 double sumW = 0.0, sumW2 = 0.0;
389 for (size_t i = 0; i < weights.size(); ++i) {
390 sumW += weights[i];
391 sumW2 += sqr(weights[i]);
392 }
393 return effNumEntries(sumW, sumW2);
394 }
References effNumEntries(), and sqr(). ◆ fuzzyEquals() [1/2]
template<typename N1 , typename N2 >
Compare two numbers for equality with a degree of fuzziness. This version for floating point types (if any argument is FP) has a degree of fuzziness expressed by the fractional tolerance parameter, for floating point safety. Definition at line 96 of file MathUtils.h. 96 {
97 const double absavg = (std::abs(a) + std::abs(b))/2.0;
98 const double absdiff = std::abs(a - b);
100 return rtn;
101 }
References isZero(). Referenced by YODA::Axis< T, isCAxis< T > >::Axis(), fuzzyGtrEquals(), fuzzyLessEquals(), YODA::Axis< T, isCAxis< T > >::hasSameEdges(), operator==(), and subtract(). ◆ fuzzyEquals() [2/2]
template<typename N1 , typename N2 >
Compare two numbers for equality with a degree of fuzziness. Simpler SFINAE template specialisation for integers, since there is no FP precision issue. Definition at line 110 of file MathUtils.h. 110 { //< NB. unused tolerance parameter for ints, still needs a default value!
111 return a == b;
112 }
◆ fuzzyGtrEquals()
template<typename N1 , typename N2 >
Compare two numbers for >= with a degree of fuzziness. The tolerance parameter on the equality test is as for Definition at line 125 of file MathUtils.h. 125 {
127 }
std::enable_if_t< std::is_arithmetic_v< N1 > &&std::is_arithmetic_v< N2 > &&(std::is_floating_point_v< N1 >||std::is_floating_point_v< N2 >), bool > fuzzyEquals(N1 a, N2 b, double tolerance=1e-5) Compare two numbers for equality with a degree of fuzziness. Definition MathUtils.h:96 References fuzzyEquals(). Referenced by YODA::Axis< T, isCAxis< T > >::Axis(). ◆ fuzzyLessEquals()
template<typename N1 , typename N2 >
Compare two floating point numbers for <= with a degree of fuzziness. The tolerance parameter on the equality test is as for Definition at line 135 of file MathUtils.h. References fuzzyEquals(). Referenced by variance(). ◆ getDataPath()
Get the path to the installed share/YODA/ data directory. Definition at line 26 of file Paths.cc. 26 {
27 BrInitError error;
28 br_init_lib(&error);
30 const string sharedir(temp);
31 free(temp);
32 return sharedir + "/YODA";
33 }
References br_find_data_dir, and br_init_lib. Referenced by getYodaDataPath(). ◆ getLibPath()
Get the path to the directory containing libYODA. Definition at line 17 of file Paths.cc. 17 {
18 BrInitError error;
19 br_init_lib(&error);
21 const string libdir(temp);
22 free(temp);
23 return libdir;
24 }
References br_find_lib_dir, and br_init_lib. ◆ getYodaDataPath()
YODA data paths. Definition at line 35 of file Paths.cc. 35 {
36 vector<string> dirs;
37 // Use the YODA data path variable if set...
38 const char* env = getenv("YODA_DATA_PATH");
39 if (env) dirs = Utils::pathsplit(env);
40 // ... then, unless the path ends in :: ...
41 if (!env || strlen(env) < 2 || string(env).substr(strlen(env)-2) != "::") {
42 // ... fall back to the YODA data install path
43 dirs.push_back(getDataPath());
44 }
45 return dirs;
46 }
std::string getDataPath() Get the path to the installed share/YODA/ data directory. Definition Paths.cc:26 References getDataPath(). ◆ H5DataSet() [1/2]
template<typename T >
Helper method to construct an empty YODA_H5::DataSet.
Definition at line 52 of file H5Utils.h. 53 {
54
55 YODA_H5::DataSetCreateProps props;
56 if (compress) { // enable compression
57 props.add(YODA_H5::Chunking(vector<hsize_t>{1,chunksize}));
58 props.add(YODA_H5::Deflate(9));
59 }
60 // create the dataset
61 return h5file.createDataSet(label, YODA_H5::DataSpace({nrows,chunksize}),
62 YODA_H5::create_datatype<T>(), props);
63 }
◆ H5DataSet() [2/2]
template<typename T >
Helper method to construct and fill a YODA_H5::DataSet.
Definition at line 35 of file H5Utils.h. 36 {
37
38 YODA_H5::DataSetCreateProps props;
39 if (compress && data.size()) {
40 props.add(YODA_H5::Chunking(vector<hsize_t>{data.size()}));
41 props.add(YODA_H5::Deflate(9));
42 }
43 return h5file.createDataSet(label, std::move(data), props);
44 }
Referenced by YODA::WriterH5::writeAOS(), and YODA::EdgeHandler< T >::writeToFile(). ◆ index_between()
template<typename NUM >
Return the bin index of the given value, val, given a vector of bin edges. NB. The binedges vector must be sorted Definition at line 361 of file MathUtils.h. 361 {
363 int index = -1;
364 for (size_t i = 1; i < binedges.size(); ++i) {
365 if (val < binedges[i]) {
366 index = i-1;
367 break;
368 }
369 }
370 assert(inRange(index, -1, binedges.size()-1));
371 return index;
372 }
bool inRange(NUM value, NUM low, NUM high, RangeBoundary lowbound=CLOSED, RangeBoundary highbound=OPEN) Determine if value is in the range low to high, for floating point numbers. Definition MathUtils.h:164 References inRange(). ◆ inRange() [1/4]
Determine if value is in the range low to high, for integer types. Interval boundary types are defined by lowbound and highbound.
Definition at line 189 of file MathUtils.h. 190 {
191 if (lowbound == OPEN && highbound == OPEN) {
192 return (value > low && value < high);
193 } else if (lowbound == OPEN && highbound == CLOSED) {
194 return (value > low && value <= high);
195 } else if (lowbound == CLOSED && highbound == OPEN) {
196 return (value >= low && value < high);
197 } else { // if (lowbound == CLOSED && highbound == CLOSED) {
198 return (value >= low && value <= high);
199 }
200 }
◆ inRange() [2/4]
Alternative version of Definition at line 203 of file MathUtils.h. References inRange(). ◆ inRange() [3/4]
template<typename NUM >
Determine if value is in the range low to high, for floating point numbers. Interval boundary types are defined by lowbound and highbound.
Definition at line 164 of file MathUtils.h. 165 {
166 if (lowbound == OPEN && highbound == OPEN) {
167 return (value > low && value < high);
168 } else if (lowbound == OPEN && highbound == CLOSED) {
169 return (value > low && value <= high);
170 } else if (lowbound == CLOSED && highbound == OPEN) {
171 return (value >= low && value < high);
172 } else { // if (lowbound == CLOSED && highbound == CLOSED) {
173 return (value >= low && value <= high);
174 }
175 }
Referenced by index_between(), inRange(), and inRange(). ◆ inRange() [4/4]
template<typename NUM >
Alternative version of inRange for doubles, which accepts a pair for the range arguments. Definition at line 179 of file MathUtils.h. References inRange(). ◆ isNaN()
template<typename NUM >
◆ isZero() [1/2]
template<typename NUM >
Compare a number to zero. This version for floating point types has a degree of fuzziness expressed by the absolute tolerance parameter, for floating point safety. Definition at line 63 of file MathUtils.h. 63 {
64 return fabs(val) < tolerance;
65 }
Referenced by divide(), efficiency(), effNumEntries(), fuzzyEquals(), and sign(). ◆ isZero() [2/2]
template<typename NUM >
Compare a number to zero. SFINAE template specialisation for integers, since there is no FP precision issue. Definition at line 73 of file MathUtils.h. 73 {
74 return val==0;
75 }
◆ linspace()
Make a list of nbins + 1 values uniformly spaced between xmin and xmax inclusive.
Definition at line 267 of file MathUtils.h. 267 {
270 std::vector<double> rtn;
271 const double interval = (xmax-xmin)/static_cast<double>(nbins);
272 for (size_t i = 0; i < nbins; ++i) {
273 rtn.push_back(xmin + i*interval);
274 }
275 assert(rtn.size() == nbins);
276 if (include_end) rtn.push_back(xmax); // exact xmax, not result of n * interval
277 return rtn;
278 }
Referenced by logspace(), and pdfspace(). ◆ logspace()
Make a list of nbins + 1 values uniformly spaced in log(x) between xmin and xmax inclusive.
Definition at line 286 of file MathUtils.h. 286 {
290 const double logxmin = std::log(xmin);
291 const double logxmax = std::log(xmax);
293 assert(logvals.size() == nbins+1);
294 std::vector<double> rtn; rtn.reserve(logvals.size());
295 rtn.push_back(xmin);
296 for (size_t i = 1; i < logvals.size()-1; ++i) {
297 rtn.push_back(std::exp(logvals[i]));
298 }
299 assert(rtn.size() == nbins);
300 if (include_end) rtn.push_back(xmax);
301 return rtn;
302 }
std::vector< double > linspace(size_t nbins, double xmin, double xmax, bool include_end=true) Make a list of nbins + 1 values uniformly spaced between xmin and xmax inclusive. Definition MathUtils.h:267 References linspace(). ◆ mean() [1/3]
Calculate the weighted mean of a sample. Definition at line 406 of file MathUtils.h. 406 {
407 return sumW? sumWX / sumW : std::numeric_limits<double>::quiet_NaN();
408 }
◆ mean() [2/3]
Calculate the weighted mean of a sample. Definition at line 411 of file MathUtils.h. 412 {
414 double sumWX = 0., sumW = 0.;
415 for (size_t i = 0; i < sample.size(); ++i) {
416 sumW += weights[i];
417 sumWX += weights[i]*sample[i];
418 }
419 return mean(sumWX, sumW);
420 }
References mean(). ◆ mean() [3/3]
Calculate the mean of a sample. Definition at line 397 of file MathUtils.h. 397 {
399 for (size_t i=0; i<sample.size(); ++i) {
400 mean += sample[i];
401 }
402 return mean/sample.size();
403 }
References mean(). Referenced by covariance(), YODA::DbnBase< N >::mean(), mean(), mean(), YODA::DbnBase< N >::relStdErr(), YODA::XDbnMixin< Derived >::xMean(), YODA::XStatsMixin< Derived >::xMean(), YODA::YDbnMixin< Derived >::yMean(), YODA::YStatsMixin< Derived >::yMean(), zipProfiles(), YODA::ZDbnMixin< Derived >::zMean(), and YODA::ZStatsMixin< Derived >::zMean(). ◆ mkAxisConfig()
template<typename A , typename... As>
Helper function to construct the axis config. Definition at line 58 of file BinningUtils.h. 58 {
60 }
◆ mkIntegral()
template<size_t DbnN, typename... AxisT>
Convert a BinnedDbn to a BinnedEstimate representing the integral of the histogram.
The includeunderflow param chooses whether the underflow bin is included in the integral numbers as an offset. Definition at line 1293 of file BinnedDbn.h. 1293 {
1294
1296
1297 double sumW = 0.0, sumW2 = 0.0;
1298 for (const auto& b : histo.bins(includeOverflows)) {
1299 sumW += b.sumW();
1300 sumW2 += b.sumW2();
1301 const double e = sqrt(sumW2);
1302 rtn.bin(b.index()).set(sumW, {-e, e});
1303 }
1304
1305 return rtn;
1306 }
References YODA::BinnedStorage< BinContentT, AxisT >::bins(), and YODA::DbnStorage< DbnN, AxisT >::mkEstimate(). Referenced by mkIntegralEff(). ◆ mkIntegralEff()
template<size_t DbnN, typename... AxisT>
Convert a BinnedDbn to a BinnedEstimate where each bin is a fraction of the total.
The includeunderflow param behaves as for toIntegral, and applies to both the initial integration and the integral used for the scaling. The includeoverflow param applies only to obtaining the scaling factor.
Definition at line 1322 of file BinnedDbn.h. 1322 {
1323
1326
1327 // If the integral is empty, the (integrated) efficiency values may as well all be zero, so return here
1331 if (!integral) return rtn;
1332
1334 for (const auto& b : rtn.bins(includeOverflows)) {
1335 const double eff = b.val() / integral;
1336 const double err = sqrt(std::abs( ((1-2*eff)*sqr(b.relTotalErrAvg()) + sqr(eff)*sqr(integral_err)) / sqr(integral) ));
1337 b.set(eff, {-err,err});
1338 }
1339
1340 return rtn;
1341 }
double integralError(const bool includeOverflows=true) const noexcept Get the total volume error of the histogram. Definition BinnedDbn.h:473 double integral(const bool includeOverflows=true) const noexcept Get the total volume of the histogram. Definition BinnedDbn.h:468 BinnedEstimate< AxisT... > mkIntegral(const BinnedDbn< DbnN, AxisT... > &histo, const bool includeOverflows=true) Convert a BinnedDbn to a BinnedEstimate representing the integral of the histogram. Definition BinnedDbn.h:1293 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 19 of file Reader.cc. 19 {
20 // Determine the format from the string (a file or file extension)
21 const size_t lastdot = name.find_last_of(".");
22 string fmt = Utils::toLower(lastdot == string::npos ? name : name.substr(lastdot+1));
23 if (fmt == "gz") {
24 #ifndef HAVE_LIBZ
26 #endif
27 const size_t lastbutonedot = (lastdot == string::npos) ? string::npos : name.find_last_of(".", lastdot-1);
28 fmt = Utils::toLower(lastbutonedot == string::npos ? name : name.substr(lastbutonedot+1));
29 }
30 // Create the appropriate Reader
31 #ifdef HAVE_HDF5
32 if (Utils::startswith(fmt, "h5")) return ReaderH5::create();
33 #endif
34 if (Utils::startswith(fmt, "yoda")) return ReaderYODA::create();
35 if (Utils::startswith(fmt, "dat" )) return ReaderFLAT::create();
36 if (Utils::startswith(fmt, "flat")) return ReaderFLAT::create();
37 throw UserError("Format cannot be identified from string '" + name + "'");
38 }
References YODA::ReaderFLAT::create(), YODA::ReaderH5::create(), and YODA::ReaderYODA::create(). ◆ mkTypeString() [1/2]
template<ssize_t DbnN, typename A , typename... As>
Helper function to construct the BinnedDbn and BinnedEstimate type names. Definition at line 65 of file BinningUtils.h. 65 {
66
67 constexpr size_t N = sizeof...(As)+1;
68
70 if constexpr (DbnN < 0) {
71 return "Estimate"+std::to_string(N)+"D";
72 }
73 if constexpr (DbnN == N+1) {
74 return "Profile"+std::to_string(N)+"D";
75 }
76 if constexpr (DbnN == N) {
77 return "Histo"+std::to_string(N)+"D";
78 }
79 }
80
81 std::string type = "Binned";
82 if (DbnN < 0) type += "Estimate";
83 else if (DbnN == N) type += "Histo";
84 else if (DbnN == N+1) type += "Profile";
85 else type += "Dbn" + std::to_string(DbnN);
86
87 std::string axes = (TypeID<A>::name() + ... + (std::string{","} + TypeID<As>::name()));
88
89 return (type + "<" + axes + ">");
90 }
typename std::conjunction< std::is_floating_point< EdgeT >... > all_CAxes Definition BinningUtils.h:18 References YODA::TypeID< T >::name(). Referenced by mkTypeString(). ◆ mkTypeString() [2/2]
template<typename A , typename... As>
Same as above, but for non-Dbn bin contents. Definition at line 94 of file BinningUtils.h. std::string mkTypeString() Helper function to construct the BinnedDbn and BinnedEstimate type names. Definition BinningUtils.h:65 References mkTypeString(). ◆ mkWriter()
Factory function to make a writer object by format name or a filename. <
<
Definition at line 29 of file Writer.cc. 29 {
30 // Determine the format from the string (a file or file extension)
31 const size_t lastdot = name.find_last_of(".");
32 string fmt = Utils::toLower(lastdot == string::npos ? name : name.substr(lastdot+1));
33 const bool compress = (fmt == "gz"s) || (fmt == "h5"s && enableH5compression);
34 //cout << "***" << compress << endl;
35 if (compress && fmt == "gz"s) {
36 #ifndef HAVE_LIBZ
38 #endif
39 const size_t lastbutonedot = (lastdot == string::npos) ? string::npos : name.find_last_of(".", lastdot-1);
40 fmt = Utils::toLower(lastbutonedot == string::npos ? name : name.substr(lastbutonedot+1));
41 }
42 // Create the appropriate Writer
43 Writer* w = nullptr;
44 #ifdef HAVE_HDF5
45 if (Utils::startswith(fmt, "h5")) w = &WriterH5::create();
46 #endif
47 if (Utils::startswith(fmt, "yoda")) w = &WriterYODA::create();
48 else if (Utils::startswith(fmt, "dat" )) w = &WriterFLAT::create();
49 else if (Utils::startswith(fmt, "flat")) w = &WriterFLAT::create();
50 if (!w) throw UserError("Format cannot be identified from string '" + name + "'");
51 w->useCompression(compress);
52 return *w;
53 }
References YODA::WriterFLAT::create(), YODA::WriterH5::create(), YODA::WriterYODA::create(), enableH5compression, and YODA::Writer::useCompression(). Referenced by write(), write(), write(), write(), write(), and write(). ◆ naiveChi2()
Calculate the error-weighted chi2 statistic between two samples.
Definition at line 549 of file MathUtils.h. 550 {},
551 const std::vector<double>& s2errors = std::vector<double>{}) {
552 if (sample1.size() != sample2.size()) {
553 throw RangeError("Inputs should have equal length!");
554 }
555 if (s1errors.size() && sample1.size() != s1errors.size()) {
556 throw RangeError("Inputs should have equal length!");
557 }
558 if (s2errors.size() && sample2.size() != s2errors.size()) {
559 throw RangeError("Inputs should have equal length!");
560 }
561 const size_t N = sample1.size();
562 double chi2 = 0.0;
563 for (size_t i = 0; i < N; ++i) {
565 if (s1errors.size()) {
567 }
568 chi2 += temp;
569 }
570 return chi2;
571 }
◆ naiveChi2reduced()
Calculate the error-weighted reduced chi2 statistic between two samples.
Definition at line 579 of file MathUtils.h. 580 {},
581 const std::vector<double>& s2errors = std::vector<double>{}) {
582 if (sample1.empty()) throw RangeError("Inputs should not have 0 length!");
584 }
double naiveChi2(const std::vector< double > &sample1, const std::vector< double > &sample2, const std::vector< double > &s1errors=std::vector< double >{}, const std::vector< double > &s2errors=std::vector< double >{}) Calculate the error-weighted chi2 statistic between two samples. Definition MathUtils.h:549 ◆ notNaN()
template<typename NUM >
Check if a number is non-NaN. Definition at line 85 of file MathUtils.h. 85{ return !std::isnan(val); }
◆ nullifyIfDiscCoord() [1/2]
template<typename CoordT >
Nullifies coordinate if it is discrete. Definition at line 19 of file Binning.h. 19 {
20 return null;
21 }
Referenced by containsNan(). ◆ nullifyIfDiscCoord() [2/2]
template<typename CoordT >
◆ operator!=()◆ operator*() [1/3]◆ operator*() [2/3]◆ operator*() [3/3]◆ operator+() [1/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1371 of file BinnedDbn.h. References add(). ◆ operator+() [2/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1359 of file BinnedDbn.h. References add(). ◆ operator+() [3/17]
template<size_t DbnN, typename... AxisT>
Add two BinnedDbn objects. Definition at line 1142 of file BinnedDbn.h. 1142 {
1143 first += std::move(second);
1144 return first;
1145 }
◆ operator+() [4/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1149 of file BinnedDbn.h. 1149 {
1150 first += second;
1151 return first;
1152 }
◆ operator+() [5/17]
template<typename... AxisT>
Add two BinnedEstimates. Definition at line 1155 of file BinnedEstimate.h. 1155 {
1156 first += std::move(second);
1157 return first;
1158 }
◆ operator+() [6/17]
template<typename... AxisT>
Add two BinnedEstimates. Definition at line 1146 of file BinnedEstimate.h. 1146 {
1147 first += second;
1148 return first;
1149 }
◆ operator+() [7/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1365 of file BinnedDbn.h. References add(). ◆ operator+() [8/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1353 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 660 of file Estimate.h. 660 {
661 lhs += rhs;
662 return lhs;
663 }
◆ operator+() [15/17]Add two Estimate objects. Definition at line 666 of file Estimate.h. 666 {
667 lhs += std::move(rhs);
668 return lhs;
669 }
◆ operator+() [16/17]
Add two Estimate0D objects. Definition at line 344 of file Estimate0D.h. 344 {
345 lhs += rhs;
346 return lhs;
347 }
◆ operator+() [17/17]
Add two Estimate0D objects. Definition at line 350 of file Estimate0D.h. 350 {
351 lhs += std::move(rhs);
352 return lhs;
353 }
◆ operator-() [1/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1403 of file BinnedDbn.h. References subtract(). ◆ operator-() [2/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1391 of file BinnedDbn.h. References subtract(). ◆ operator-() [3/17]
template<size_t DbnN, typename... AxisT>
Subtract one BinnedDbn object from another. Definition at line 1158 of file BinnedDbn.h. 1158 {
1159 first -= std::move(second);
1160 return first;
1161 }
◆ operator-() [4/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1165 of file BinnedDbn.h. 1165 {
1166 first -= second;
1167 return first;
1168 }
◆ operator-() [5/17]
template<typename... AxisT>
Subtract two BinnedEstimates. Definition at line 1172 of file BinnedEstimate.h. 1172 {
1173 first -= std::move(second);
1174 return first;
1175 }
◆ operator-() [6/17]
template<typename... AxisT>
Subtract two BinnedEstimates. Definition at line 1164 of file BinnedEstimate.h. 1164 {
1165 first -= second;
1166 return first;
1167 }
◆ operator-() [7/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1397 of file BinnedDbn.h. References subtract(). ◆ operator-() [8/17]
template<size_t DbnN, typename... AxisT>
Definition at line 1385 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 672 of file Estimate.h. 672 {
673 lhs -= rhs;
674 return lhs;
675 }
◆ operator-() [15/17]Subtract two Estimate objects. Definition at line 678 of file Estimate.h. 678 {
679 lhs -= std::move(rhs);
680 return lhs;
681 }
◆ operator-() [16/17]
Subtract two Estimate0D objects. Definition at line 356 of file Estimate0D.h. 356 {
357 lhs -= rhs;
358 return lhs;
359 }
◆ operator-() [17/17]
Subtract two Estimate0D objects. Definition at line 362 of file Estimate0D.h. 362 {
363 lhs -= std::move(rhs);
364 return lhs;
365 }
◆ operator/() [1/27]
template<size_t DbnN, typename... AxisT>
Definition at line 1435 of file BinnedDbn.h. References divide(). ◆ operator/() [2/27]
template<size_t DbnN, typename... AxisT>
Definition at line 1423 of file BinnedDbn.h. References divide(). ◆ operator/() [3/27]
template<size_t DbnN, typename... AxisT>
Definition at line 1233 of file BinnedDbn.h. References divide(). ◆ operator/() [4/27]
template<size_t DbnN, typename... AxisT>
Definition at line 1227 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 1429 of file BinnedDbn.h. References divide(). ◆ operator/() [8/27]
template<size_t DbnN, typename... AxisT>
Definition at line 1417 of file BinnedDbn.h. References divide(). ◆ operator/() [9/27]
template<size_t DbnN, typename... AxisT>
Definition at line 1221 of file BinnedDbn.h. References divide(). ◆ operator/() [10/27]
template<size_t DbnN, typename... AxisT>
Definition at line 1215 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 511 of file Point.h. 511 {
512 #define LT_IF_NOT_EQ(a,b) { if (!fuzzyEquals(a, b)) return a < b; }
513 for (size_t i = 0; i < N; ++i) {
517 }
518 #undef LT_IF_NOT_EQ
519 return false;
520 }
#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 492 of file Point.h. 492 {
493 // Compare valitions
494 for (size_t i = 0; i < N; ++i) {
498 }
499 return true;
500 }
References YODA::PointBase< N >::errs(), fuzzyEquals(), and YODA::PointBase< N >::vals(). ◆ operator>()◆ operator>=()◆ pdfspace()
Make a list of nbins + 1 values spaced with density ~ f(x) between xmin and end inclusive.
The density function fn will be evaluated at nsample uniformly distributed points between xmin and xmax, its integral approximated via the Trapezium Rule and used to normalize the distribution, and nbins + 1 edges then selected to (approximately) divide into bins each containing fraction 1/nbins of the integral.
Definition at line 328 of file MathUtils.h. 328 {
329 const double dx = (xmax-xmin)/(double)nsample;
331 std::vector<double> ys(0, nsample);
332 auto posfn = [&](double x){return std::max(fn(x), 0.0);};
333 std::transform(xs.begin(), xs.end(), ys.begin(), posfn);
334 std::vector<double> areas; areas.reserve(nsample);
335 double areasum = 0;
336 for (size_t i = 0; i < ys.size()-1; ++i) {
337 const double area = (ys[i] + ys[i+1])*dx/2.0;
338 areas[i] = area;
339 areasum += area;
340 }
341 const double df = areasum/(double)nbins;
342 std::vector<double> xedges{xmin}; xedges.reserve(nbins+1);
343 double fsum = 0;
344 for (size_t i = 0; i < nsample-1; ++i) {
345 fsum += areas[i];
346 if (fsum > df) {
347 fsum = 0;
348 xedges.push_back(xs[i+1]);
349 }
350 }
351 xedges.push_back(xmax);
352 assert(xedges.size() == nbins+1);
353 return xedges;
354 }
References linspace(). ◆ read() [1/4]
Read in a collection of objects from file filename. This version returns a vector by value, involving copying, and is hence less CPU efficient than the alternative version where a vector is filled by reference. The appropriate format reader will be determined from the filename. Definition at line 98 of file IO.h. 100 {
101 std::vector<AnalysisObject*> rtn;
102 read(filename, rtn, match, unmatch);
103 return rtn;
104 }
void read(const std::string &filename, std::vector< AnalysisObject * > &aos, const std::string &match="", const std::string &unmatch="") Read in a collection of objects objs from file filename. Definition IO.h:85 References read(). ◆ read() [2/4]
Read in a collection of objects objs from file filename. This version fills (actually, appends to) a supplied vector, avoiding copying, and is hence CPU efficient. The appropriate format reader will be determined from the filename.
Definition at line 85 of file IO.h. 87 {
89 r.read(filename, aos, match, unmatch);
90 }
std::enable_if_t< YODA::Pushable< CONT, AnalysisObject * >::value > read(std::istream &stream, CONT &aos, const std::string &match="", const std::string &unmatch="") Read in a collection of objects objs from output stream stream. Definition Reader.h:62 Reader & mkReader(const std::string &format_name) Factory function to make a reader object by format name or a filename. Definition Reader.cc:19 References mkReader(), and YODA::Reader::read(). ◆ read() [3/4]
Read in a collection of objects from stream is, expecting format fmt. This version returns a vector by value, involving copying, and is hence less CPU efficient than the alternative version where a vector is filled by reference. Definition at line 129 of file IO.h. 131 {
132 std::vector<AnalysisObject*> rtn;
133 read(is, rtn, fmt, match, unmatch);
134 return rtn;
135 }
References read(). ◆ read() [4/4]
Read in a collection of objects objs from stream is, expecting format fmt. This version fills (actually, appends to) a supplied vector, avoiding copying, and is hence CPU efficient.
Definition at line 118 of file IO.h. References mkReader(), and YODA::Reader::read(). ◆ RMS() [1/2]
Calculate the weighted RMS of a sample. Definition at line 495 of file MathUtils.h. 495 {
496 // Weighted RMS defined as
497 // rms = sqrt(sum{w x^2} / sum{w})
499 if (effN == 0) return std::numeric_limits<double>::quiet_NaN();
500 const double meanSq = sumWX2 / sumW;
501 return std::sqrt(meanSq);
502 }
double effNumEntries(const double sumW, const double sumW2) Calculate the effective number of entries of a sample. Definition MathUtils.h:381 References effNumEntries(). Referenced by YODA::DbnBase< N >::RMS(), RMS(), YODA::XDbnMixin< Derived >::xRMS(), YODA::YDbnMixin< Derived >::yRMS(), and YODA::ZDbnMixin< Derived >::zRMS(). ◆ RMS() [2/2]
Calculate the weighted RMS of a sample. Definition at line 505 of file MathUtils.h. ◆ sign() [1/3]
◆ sign() [2/3]
◆ sign() [3/3]
◆ sqr()
template<typename NUM >
Named number-type squaring operation. Definition at line 216 of file MathUtils.h. 216 {
217 return a*a;
218 }
Referenced by add_quad(), YODA::EstimateStorage< AxisT >::covarianceMatrix(), divide(), efficiency(), efficiency(), efficiency(), effNumEntries(), effNumEntries(), YODA::DbnBase< N >::fill(), YODA::FillableStorage< FillDim, BinContentT, AxisT >::fill(), mkIntegralEff(), RMS(), YODA::DbnBase< N >::scale(), YODA::DbnBase< N >::scaleW(), variance(), and variance(). ◆ stdDev() [1/2]
Calculate the weighted standard deviation of a sample. Definition at line 464 of file MathUtils.h. 465 {
467 }
double variance(const double sumWX, const double sumW, const double sumWX2, const double sumW2) Calculate the weighted variance of a sample. Definition MathUtils.h:427 References variance(). Referenced by YODA::XDbnMixin< Derived >::xStdDev(), YODA::XStatsMixin< Derived >::xStdDev(), YODA::YDbnMixin< Derived >::yStdDev(), YODA::YStatsMixin< Derived >::yStdDev(), YODA::ZDbnMixin< Derived >::zStdDev(), and YODA::ZStatsMixin< Derived >::zStdDev(). ◆ stdDev() [2/2]
Calculate the weighted variance of a sample. Definition at line 470 of file MathUtils.h. References variance(). ◆ stdErr() [1/2]
Calculate the weighted standard error of a sample. Definition at line 476 of file MathUtils.h. 477 {
479 if (effN == 0) return std::numeric_limits<double>::quiet_NaN();
481 return std::sqrt(var / effN);
482 }
References effNumEntries(), and variance(). Referenced by YODA::DbnBase< N >::relStdErr(), YODA::DbnBase< N >::stdErr(), YODA::XDbnMixin< Derived >::xStdErr(), YODA::XStatsMixin< Derived >::xStdErr(), YODA::YDbnMixin< Derived >::yStdErr(), YODA::YStatsMixin< Derived >::yStdErr(), zipProfiles(), YODA::ZDbnMixin< Derived >::zStdErr(), and YODA::ZStatsMixin< Derived >::zStdErr(). ◆ stdErr() [2/2]
Calculate the weighted variance of a sample. Definition at line 485 of file MathUtils.h. 486 {
489 if (effN == 0) return std::numeric_limits<double>::quiet_NaN();
491 return std::sqrt(var / effN);
492 }
References effNumEntries(), and variance(). ◆ subtract() [1/2]
template<size_t DbnN, typename... AxisT>
Calculate the subtraction of a BinnedEstimate from a BinnedDbn. Definition at line 1379 of file BinnedDbn.h. References YODA::DbnStorage< DbnN, AxisT >::mkEstimate(). Referenced by add(), asymm(), operator-(), operator-(), operator-(), operator-(), and variance(). ◆ subtract() [2/2]
Subtract two numbers with FP fuzziness. Definition at line 247 of file MathUtils.h. References fuzzyEquals(). ◆ transform() [1/6]
template<typename... AxisT, typename FN >
Definition at line 1281 of file BinnedEstimate.h. 1281 {
1283 }
Definition Transformation.h:29 void transform(BinnedEstimate< AxisT... > &est, const Trf< 1 > &fn) Definition BinnedEstimate.h:1274 References transform(). ◆ transform() [2/6]
template<typename... AxisT>
Definition at line 1274 of file BinnedEstimate.h. 1274 {
1275 for (auto& b : est.bins(true, true)) {
1276 b.transform(fn);
1277 }
1278 }
References YODA::BinnedStorage< BinContentT, AxisT >::bins(). Referenced by transform(), transform(), transform(), transformX(), transformY(), and transformZ(). ◆ transform() [3/6]
template<typename FN >
Definition at line 333 of file Estimate0D.h. References transform(). ◆ transform() [4/6]
Definition at line 328 of file Estimate0D.h. 328 {
329 est.transform(fn);
330 }
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 877 of file Scatter.h. References transform(). ◆ transform() [6/6]
template<size_t N>
Definition at line 870 of file Scatter.h. 870 {
871 for (auto& p : s.points()) {
872 p.transform(i, fn);
873 }
874 }
References YODA::ScatterND< N >::points(). ◆ transformX()
template<size_t N, typename FN >
Definition at line 882 of file Scatter.h. References transform(). ◆ transformY()
template<size_t N, typename FN >
Definition at line 887 of file Scatter.h. References transform(). ◆ transformZ()
template<size_t N, typename FN >
Definition at line 892 of file Scatter.h. References transform(). ◆ variance() [1/2]
Calculate the weighted variance of a sample. Weighted variance defined as sig2 = ( sum(wx**2) * sum(w) - sum(wx)**2 ) / ( sum(w)**2 - sum(w**2) ) see http://en.wikipedia.org/wiki/Weighted_mean
We take the modulus of the weighted variance since the ratio can be negative with weighted means
Definition at line 427 of file MathUtils.h. 428 {
434 // if (fabs(num) < 1e-10 && fabs(den) < 1e-10) {
435 // return std::numeric_limits<double>::quiet_NaN();
436 // }
441 return den? fabs(num/den): std::numeric_limits<double>::quiet_NaN();
442 }
References sqr(), and subtract(). Referenced by stdDev(), stdDev(), stdErr(), stdErr(), YODA::DbnBase< N >::variance(), variance(), YODA::XDbnMixin< Derived >::xVariance(), YODA::XStatsMixin< Derived >::xVariance(), YODA::YDbnMixin< Derived >::yVariance(), YODA::YStatsMixin< Derived >::yVariance(), YODA::ZDbnMixin< Derived >::zVariance(), and YODA::ZStatsMixin< Derived >::zVariance(). ◆ variance() [2/2]
Calculate the weighted variance of a sample. Definition at line 445 of file MathUtils.h. 446 {
449 //throw LowStatsError("Requested variance of a distribution with only one effective entry");
450 return std::numeric_limits<double>::quiet_NaN();
451 }
452 double sumWX = 0., sumW = 0.;
453 double sumWX2 = 0., sumW2 = 0.;
454 for (size_t i = 0; i < sample.size(); ++i) {
455 sumW += weights[i];
456 sumWX += weights[i]*sample[i];
457 sumW2 += sqr(weights[i]);
458 sumWX2 += weights[i]*sqr(sample[i]);
459 }
461 }
std::enable_if_t< std::is_arithmetic_v< N1 > &&std::is_arithmetic_v< N2 >, bool > fuzzyLessEquals(N1 a, N2 b, double tolerance=1e-5) Compare two floating point numbers for <= with a degree of fuzziness. Definition MathUtils.h:135 References effNumEntries(), fuzzyLessEquals(), sqr(), and variance(). ◆ version()
Namespaced version string function. Definition at line 25 of file YodaConfig.h. References YODA_VERSION. ◆ write() [1/6]
Write out object ao to file filename. Definition at line 19 of file IO.h. 19 {
22 w.write(filename, ao);
23 }
void write(const std::string &filename, const AnalysisObject &ao) Write out object ao to file filename. Definition Writer.cc:56 void setPrecision(int precision) Set precision of numerical quantities in this writer's output. Definition Writer.h:176 Writer & mkWriter(const std::string &format_name) Factory function to make a writer object by format name or a filename. Definition Writer.cc:29 References mkWriter(), YODA::Writer::setPrecision(), and YODA::Writer::write(). Referenced by YODA::H5DataSetWriter< T >::writeSlice(). ◆ 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 1451 of file BinnedDbn.h. 1452 {
1453
1454 // Check profiles have the same binning
1455 if ( !((p1 == others) && ...) )
1457
1458 // Construct resulting Scatter whose coordinates
1459 // are given by the unbinned means
1460 constexpr size_t N = sizeof...(Args)+1;
1461 ScatterND<N> rtn;
1463 for (const auto& b1 : p1.bins()) {
1464 typename ScatterND<N>::NdVal vals = { b1.mean(DbnN), others.bin(b1.binIndex()).mean(DbnN) ... };
1465 typename ScatterND<N>::NdVal errs = { b1.stdErr(DbnN), others.bin(b1.binIndex()).stdErr(DbnN) ... };
1466 rtn.addPoint(vals, errs);
1467 }
1468 return rtn;
1469 }
void setAnnotation(const std::string &name, const T &value) Add or set an annotation by name (templated for remaining types) Definition AnalysisObject.h:182 References YODA::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. ◆ enableH5compression
Definition at line 28 of file Writer.h. Referenced by mkWriter(), and YODA::Writer::write(). ◆ 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 28 of file WriterYODA.cc. ◆ YODA_H5_FORMAT_VERSION
YODA text-format version
Definition at line 27 of file WriterH5.cc. Referenced by YODA::WriterH5::writeAOS(). Generated on Fri Mar 7 2025 09:06:40 for YODA - Yet more Objects for Data Analysis by |