|
ROOT
Reference Guide |
|
Go to the documentation of this file.
17 #ifndef ROOT_RDF_RMERGEABLEVALUE
18 #define ROOT_RDF_RMERGEABLEVALUE
33 class RMergeableValue;
35 template <
typename T,
typename... Ts>
36 std::unique_ptr<RMergeableValue<T>>
MergeValues(std::unique_ptr<RMergeableValue<T>> OutputMergeable,
37 std::unique_ptr<RMergeableValue<Ts>>... InputMergeables);
39 template <
typename T,
typename... Ts>
40 void MergeValues(RMergeableValue<T> &OutputMergeable,
const RMergeableValue<Ts> &... InputMergeables);
128 template <
typename T>
131 template <
typename T1,
typename... Ts>
134 template <
typename T1,
typename... Ts>
196 this->
fValue += othercast.fValue;
197 }
catch (
const std::bad_cast &) {
198 throw std::invalid_argument(
"Results from different actions cannot be merged together.");
232 template <
typename T>
254 l.Add(
const_cast<T *
>(&(othercast.fValue)));
256 }
catch (
const std::bad_cast &) {
257 throw std::invalid_argument(
"Results from different actions cannot be merged together.");
276 template <
typename T>
283 this->
fValue = std::max(this->fValue, othercast.
fValue);
284 }
catch (
const std::bad_cast &) {
285 throw std::invalid_argument(
"Results from different actions cannot be merged together.");
336 const auto &othercast =
dynamic_cast<const RMergeableMean &
>(other);
337 const auto &othervalue = othercast.
fValue;
338 const auto &othercounts = othercast.fCounts;
341 const auto num = this->
fValue * fCounts + othervalue * othercounts;
345 this->
fValue = num / denum;
347 }
catch (
const std::bad_cast &) {
348 throw std::invalid_argument(
"Results from different actions cannot be merged together.");
368 template <
typename T>
375 this->
fValue = std::min(this->fValue, othercast.
fValue);
376 }
catch (
const std::bad_cast &) {
377 throw std::invalid_argument(
"Results from different actions cannot be merged together.");
431 const auto &othercounts = othercast.
fCounts;
432 const auto &othermean = othercast.fMean;
437 const auto othervariance =
std::pow(othercast.fValue, 2);
439 const auto delta = othermean -
fMean;
441 const auto m_a = thisvariance * (
fCounts - 1);
442 const auto m_b = othervariance * (othercounts - 1);
446 const auto M2 = m_a + m_b +
std::pow(delta, 2) *
fCounts * othercounts / sumcounts;
448 const auto meannum =
fMean *
fCounts + othermean * othercounts;
452 fMean = meannum / sumcounts;
454 }
catch (
const std::bad_cast &) {
455 throw std::invalid_argument(
"Results from different actions cannot be merged together.");
479 template <
typename T>
486 this->
fValue += othercast.fValue;
487 }
catch (
const std::bad_cast &) {
488 throw std::invalid_argument(
"Results from different actions cannot be merged together.");
513 template <
class... Ts>
514 using conjunction = std::is_same<bool_pack<
true, Ts::value...>, bool_pack<Ts::value...,
true>>;
539 template <
typename T,
typename... Ts>
544 static_assert(conjunction<std::is_same<Ts, T>...>::value,
"Values must all be of the same type.");
547 using expander =
int[];
549 (
void)expander{0, (OutputMergeable->Merge(*InputMergeables), 0)...};
551 return OutputMergeable;
573 template <
typename T,
typename... Ts>
577 static_assert(conjunction<std::is_same<Ts, T>...>::value,
"Values must all be of the same type.");
580 using expander =
int[];
582 (
void)expander{0, (OutputMergeable.
Merge(InputMergeables), 0)...};
RMergeableStdDev()=default
Default constructor.
void Merge(const RMergeableValue< T > &other) final
Aggregate the information contained in another RMergeableValue into this.
RMergeableSum()=default
Default constructor.
void Merge(const RMergeableValue< Double_t > &other) final
Aggregate the information contained in another RMergeableValue into this.
Double_t fMean
Average of the set.
RMergeableSum(RMergeableSum &&)=default
RMergeableMin(RMergeableMin &&)=default
RMergeableMean(RMergeableMean &&)=default
ULong64_t fCounts
Number of entries of the set.
RMergeableValue()=default
Default constructor.
RMergeableMin(const RMergeableMin &)=delete
RMergeableMax(const T &value)
Constructor that initializes data members.
RMergeableCount(const RMergeableCount &)=delete
friend void MergeValues(RMergeableValue< T1 > &OutputMergeable, const RMergeableValue< Ts > &... InputMergeables)
RMergeableStdDev(Double_t value, ULong64_t counts, Double_t mean)
Constructor that initializes data members.
std::unique_ptr< RMergeableValue< T > > MergeValues(std::unique_ptr< RMergeableValue< T >> OutputMergeable, std::unique_ptr< RMergeableValue< Ts >>... InputMergeables)
Merge multiple RMergeableValue objects into one.
Specialization of RMergeableValue for the Mean action.
RMergeableFill()=default
Default constructor.
RMergeableFill(const T &value)
Constructor that initializes data members.
friend std::unique_ptr< RMergeableValue< T1 > > MergeValues(std::unique_ptr< RMergeableValue< T1 >> OutputMergeable, std::unique_ptr< RMergeableValue< Ts >>... InputMergeables)
RMergeableValue(const T &value)
Constructor taking the action result by const reference.
RMergeableMax()=default
Default constructor.
RMergeableMax(RMergeableMax &&)=default
virtual void Merge(const RMergeableValue< T > &)=0
Aggregate the information contained in another RMergeableValue into this.
RMergeableStdDev(RMergeableStdDev &&)=default
RMergeableSum(const T &value)
Constructor that initializes data members.
RMergeableCount()=default
Default constructor.
RMergeableMin()=default
Default constructor.
ULong64_t fCounts
The number of entries used to compute the mean.
virtual ~RMergeableValueBase()=default
RMergeableCount(RMergeableCount &&)=default
A result of an RDataFrame execution, that knows how to merge with other results of the same type.
const T & GetValue() const
Retrieve the result wrapped by this mergeable.
RMergeableFill(RMergeableFill &&)=default
Specialization of RMergeableValue for the StdDev action.
RMergeableValueBase()=default
Default constructor.
RMergeableMean()=default
Default constructor.
Specialization of RMergeableValue for histograms and statistics.
RMergeableMin(const T &value)
Constructor that initializes data members.
RMergeableMax(const RMergeableMax &)=delete
typedef void((*Func_t)())
RMergeableFill(const RMergeableFill &)=delete
Specialization of RMergeableValue for the Count action.
void Merge(const RMergeableValue< Double_t > &other) final
Aggregate the information contained in another RMergeableValue into this.
unsigned long long ULong64_t
RMergeableMean(const RMergeableMean &)=delete
RMergeableSum(const RMergeableSum &)=delete
RMergeableStdDev(const RMergeableStdDev &)=delete
RMergeableCount(ULong64_t value)
Constructor that initializes data members.
Base class of RMergeableValue.
RMergeableMean(Double_t value, ULong64_t counts)
Constructor that initializes data members.
void Merge(const RMergeableValue< T > &other) final
Aggregate the information contained in another RMergeableValue into this.
double pow(double, double)
void Merge(const RMergeableValue< T > &other) final
Aggregate the information contained in another RMergeableValue into this.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
void Merge(const RMergeableValue< ULong64_t > &other) final
Aggregate the information contained in another RMergeableValue into this.
void Merge(const RMergeableValue< T > &other) final
Aggregate the information contained in another RMergeableValue into this.