ROOT  6.06/09
Reference Guide
THistStats.h
Go to the documentation of this file.
1 /// \file ROOT/THistStats.h
2 /// \ingroup Hist ROOT7
3 /// \author Axel Naumann <axel@cern.ch>
4 /// \date 2015-06-14
5 /// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
6 
7 /*************************************************************************
8  * Copyright (C) 1995-2015, Rene Brun and Fons Rademakers. *
9  * All rights reserved. *
10  * *
11  * For the licensing terms see $ROOTSYS/LICENSE. *
12  * For the list of contributors see $ROOTSYS/README/CREDITS. *
13  *************************************************************************/
14 
15 #ifndef ROOT7_THistStats_h
16 #define ROOT7_THistStats_h
17 
18 #include <vector>
19 #include "ROOT/RArrayView.h"
20 
21 namespace ROOT {
22 
23 namespace Detail {
24 template <int DIMENSIONS, class PRECISION> class THistImplBase;
25 }
26 
27 template<int DIMENSIONS, class PRECISION>
29 public:
30  using Coord_t = std::array<double, DIMENSIONS>;
32 
33  void Fill(const Coord_t& /*x*/, Weight_t /*weightN*/ = 1.) { ++fEntries; }
35  const std::array_view<Weight_t> /*weightN*/) {
36  fEntries += xN.size();
37  }
39  fEntries += xN.size();
40  }
41 
42  int64_t GetEntries() const { return fEntries; };
43 
44  std::vector<double>
46  PRECISION sqrtcont = std::sqrt(std::max(hist.GetBinContent(binidx), 0.));
47  return std::vector<double>{sqrtcont, sqrtcont};
48  }
49  private:
50  int64_t fEntries = 0;
51 };
52 
53 template<int DIMENSIONS, class PRECISION>
54 class THistStatUncertainty: public THistStatEntries<DIMENSIONS, PRECISION> {
55 public:
57  using typename Base_t::Coord_t;
58  using typename Base_t::Weight_t;
59 
60  void Fill(const Coord_t &x, Weight_t weightN = 1.) {
61  Base_t::Fill(x, weightN);
62  }
63 
65  const std::array_view<Weight_t> weightN) {
66  Base_t::FillN(xN, weightN);
67  }
68 
70  Base_t::FillN(xN);
71  }
72 };
73 
74 template<int DIMENSIONS, class PRECISION>
75 class THistStatMomentUncert: public THistStatUncertainty<DIMENSIONS, PRECISION> {
76 public:
78  using typename Base_t::Coord_t;
79  using typename Base_t::Weight_t;
80 
81  void Fill(const Coord_t &x, Weight_t weightN = 1.) {
82  Base_t::Fill(x, weightN);
83  }
84 
86  const std::array_view<Weight_t> weightN) {
87  Base_t::FillN(xN, weightN);
88  }
90  Base_t::FillN(xN);
91  }
92 };
93 
94 
95 template<int DIMENSIONS, class PRECISION>
96 class THistStatRuntime: public THistStatEntries<DIMENSIONS, PRECISION> {
97 public:
99  using typename Base_t::Coord_t;
100  using typename Base_t::Weight_t;
101 
102  THistStatRuntime(bool uncertainty, std::vector<bool> &moments);
103 
104  void Fill(const Coord_t &x, Weight_t weightN = 1.) {
105  Base_t::Fill(x, weightN);
106  }
107 
109  const std::array_view<Weight_t> weightN) {
110  Base_t::FillN(xN, weightN);
111  }
113  Base_t::FillN(xN);
114  }
115 };
116 
117 } // namespace ROOT
118 #endif
Namespace for new ROOT classes and functions.
Definition: ROOT.py:1
void Fill(const Coord_t &x, Weight_t weightN=1.)
Definition: THistStats.h:104
int64_t GetEntries() const
Definition: THistStats.h:42
double sqrt(double)
Double_t x[n]
Definition: legend1.C:17
#define PRECISION
Definition: MnPrint.cxx:26
void FillN(const std::array_view< Coord_t > xN)
Definition: THistStats.h:69
void FillN(const std::array_view< Coord_t > xN, const std::array_view< Weight_t > weightN)
Definition: THistStats.h:64
void FillN(const std::array_view< Coord_t > xN)
Definition: THistStats.h:112
void FillN(const std::array_view< Coord_t > xN)
Definition: THistStats.h:38
THistStatRuntime(bool uncertainty, std::vector< bool > &moments)
void Fill(const Coord_t &, Weight_t=1.)
Definition: THistStats.h:33
std::array< double, DIMENSIONS > Coord_t
Definition: THistStats.h:30
void FillN(const std::array_view< Coord_t > xN, const std::array_view< Weight_t >)
Definition: THistStats.h:34
void FillN(const std::array_view< Coord_t > xN, const std::array_view< Weight_t > weightN)
Definition: THistStats.h:108
constexpr size_type size() const noexcept
static void moments(ROOT::Math::Vavilov &v, double &integral, double &mean, double &variance, double &skewness, double &kurtosis)
void FillN(const std::array_view< Coord_t > xN, const std::array_view< Weight_t > weightN)
Definition: THistStats.h:85
void Fill(const Coord_t &x, Weight_t weightN=1.)
Definition: THistStats.h:60
void FillN(const std::array_view< Coord_t > xN)
Definition: THistStats.h:89
static Vc_ALWAYS_INLINE int_v max(const int_v &x, const int_v &y)
Definition: vector.h:440
void Fill(const Coord_t &x, Weight_t weightN=1.)
Definition: THistStats.h:81
Interface class for THistImpl.
Definition: THistImpl.h:114
std::vector< double > GetBinUncertainties(int binidx, const Detail::THistImplBase< DIMENSIONS, PRECISION > &hist) const
Definition: THistStats.h:45
virtual PRECISION GetBinContent(int binidx) const =0
Get the bin content (sum of weights) for bin index binidx.