CbmRoot
Loading...
Searching...
No Matches
Histogram.h
Go to the documentation of this file.
1/* Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergei Zharko [committer] */
4
9
10#pragma once
11
12#include "Accumulators.h"
13
14#include <boost/histogram.hpp>
15//#include <boost/histogram/algorithm/sum.hpp>
16#include <boost/histogram/serialization.hpp>
17#include <boost/serialization/access.hpp>
18#include <boost/serialization/base_object.hpp>
19#include <boost/serialization/string.hpp>
20#include <boost/serialization/vector.hpp>
21
22#include <algorithm>
23#include <cstdint>
24#include <memory>
25#include <numeric>
26#include <string>
27#include <tuple>
28#include <type_traits>
29
30#include <fmt/format.h>
31
32namespace cbm::algo::qa
33{
34 namespace bh = boost::histogram;
35
36 using RegularAxis_t = bh::axis::regular<>;
37
38 using Axes1D_t = std::tuple<RegularAxis_t>;
39 using Axes2D_t = std::tuple<RegularAxis_t, RegularAxis_t>;
40
41 using HistStorage_t = bh::weight_storage;
43
46 enum class EAxis : unsigned
47 {
48 X = 0,
49 Y,
50 Z
51 };
52
55 enum class EHistFlag : uint8_t
56 {
57 StoreVsTsId = 0b00000001,
58 OmitIntegrated = 0b00000010
59 };
60
65 public:
66 using Flags_t = std::underlying_type_t<EHistFlag>;
67
68 static constexpr std::string_view ksTsIdSuffix = "_ts_id";
69
71 HistogramMetadata() = default;
72
75 explicit HistogramMetadata(const std::string& msg)
76 {
77 if (!msg.empty()) {
78 fFlags = std::stoi(msg, nullptr, 16);
79 }
80 }
81
83 ~HistogramMetadata() = default;
84
87 bool CheckFlags() const
88 {
89 // The histogram must be plotted either vs TS, or over all TS
91 }
92
95 bool GetFlag(EHistFlag key) const { return static_cast<bool>(fFlags & static_cast<Flags_t>(key)); }
96
100 void SetFlag(EHistFlag key, bool flag = true)
101 {
102 flag ? (fFlags |= static_cast<Flags_t>(key)) : (fFlags &= ~static_cast<Flags_t>(key));
103 }
104
109 std::string ToString() const { return fmt::format("{0:02x}", fFlags); }
110
113 static std::pair<std::string, std::string> SeparateNameAndMetadata(const std::string& msg)
114 {
115 size_t pos = msg.find_last_of('!');
116 if (pos != msg.npos) {
117 return std::make_pair(msg.substr(0, pos), msg.substr(pos + 1));
118 }
119 else {
120 return std::make_pair(msg, "");
121 }
122 }
123
124 private:
126 template<class Archive>
128 void serialize(Archive& ar, const unsigned int /*version*/)
129 {
130 ar& fFlags;
131 }
132
134 };
135
139 public:
141 double GetTotSumW() const { return fTotSumW; }
142
144 double GetTotSumW2() const { return fTotSumW2; }
145
147 double GetTotSumWX() const { return fTotSumWX; }
148
150 double GetTotSumWX2() const { return fTotSumWX2; }
151
152 protected:
156 void UpdateTotalSums(double x, double w)
157 {
158 fTotSumW += w;
159 fTotSumW2 += w * w;
160 fTotSumWX += w * x;
161 fTotSumWX2 += w * x * x;
162 }
163
165 void Reset()
166 {
167 fTotSumW = 0;
168 fTotSumW2 = 0;
169 fTotSumWX = 0;
170 fTotSumWX2 = 0;
171 }
172
173 double fTotSumW = 0.;
174 double fTotSumW2 = 0.;
175 double fTotSumWX = 0.;
176 double fTotSumWX2 = 0.;
177
178 private:
181 template<class Archive>
182 void serialize(Archive& ar, const unsigned int /*version*/)
183 {
184 ar& fTotSumW;
185 ar& fTotSumW2;
186 ar& fTotSumWX;
187 ar& fTotSumWX2;
188 }
189 };
190
193 class TotalSums2D : public TotalSums1D {
194 public:
196 double GetTotSumWXY() const { return fTotSumWXY; }
197
199 double GetTotSumWY() const { return fTotSumWY; }
200
202 double GetTotSumWY2() const { return fTotSumWY2; }
203
204 protected:
206 void Reset()
207 {
209 fTotSumWXY = 0;
210 fTotSumWY = 0;
211 fTotSumWY2 = 0;
212 }
213
218 void UpdateTotalSums(double x, double y, double w)
219 {
221 fTotSumWXY += w * x * y;
222 fTotSumWY += w * y;
223 fTotSumWY2 += w * y * y;
224 }
225
226 double fTotSumWY = 0.;
227 double fTotSumWXY = 0.;
228 double fTotSumWY2 = 0.;
229
230 private:
233 template<class Archive>
234 void serialize(Archive& ar, const unsigned int /*version*/)
235 {
236 ar& boost::serialization::base_object<TotalSums1D>(*this);
237 ar& fTotSumWXY;
238 ar& fTotSumWY;
239 ar& fTotSumWY2;
240 }
241 };
242
243
249 template<class Axes, class Storage, class TotalSums>
250 class Histogram : public TotalSums {
251 protected:
252 using Hist_t = bh::histogram<Axes, Storage>; // TODO: Test in future
253 static constexpr unsigned Rank = std::tuple_size_v<Axes>;
254
255 public:
257 ~Histogram() = default;
258
261 template<EAxis A, unsigned IA = static_cast<unsigned>(A), std::enable_if_t<(IA < Rank), bool> = true>
262 double GetAxisMin() const
263 {
264 return fHistogram.template axis<IA>().value(0.);
265 }
266
269 template<EAxis A, unsigned IA = static_cast<unsigned>(A), std::enable_if_t<(IA < Rank), bool> = true>
270 double GetAxisMax() const
271 {
272 return fHistogram.template axis<IA>().value(static_cast<double>(GetAxisNbins<A>()));
273 }
274
278 template<EAxis A, unsigned IA = static_cast<unsigned>(A), std::enable_if_t<(IA < Rank), bool> = true>
279 uint32_t GetAxisNbins() const
280 {
281 return fHistogram.template axis<IA>().size();
282 }
283
285 // TODO: Gives different results, if weights are not 1 (investigate!)
286 double GetEntries() const
287 {
288 // return bh::algorithm::sum(fHistogram); // -> effective entries (but different to the ROOT ones: if w != 1)
289 return fEntries;
290 }
291
294 bool GetFlag(EHistFlag key) const { return fMetadata.GetFlag(key); }
295
297 const std::string& GetName() const { return fName; }
298
300 const HistogramMetadata& GetMetadata() const { return fMetadata; }
301
303 std::string GetMetadataString() const { return fMetadata.ToString(); }
304
306 uint32_t GetNbinsX() const { return GetAxisNbins<EAxis::X>(); }
307
309 double GetMinX() const { return GetAxisMin<EAxis::X>(); }
310
312 double GetMaxX() const { return GetAxisMax<EAxis::X>(); }
313
315 template<unsigned RankCheck = Rank, std::enable_if_t<(RankCheck > 1), bool> = true>
316 uint32_t GetNbinsY() const
317 {
318 return GetAxisNbins<EAxis::Y>();
319 }
320
322 template<unsigned RankCheck = Rank, std::enable_if_t<(RankCheck > 1), bool> = true>
323 double GetMinY() const
324 {
325 return GetAxisMin<EAxis::Y>();
326 }
327
329 template<unsigned RankCheck = Rank, std::enable_if_t<(RankCheck > 1), bool> = true>
330 double GetMaxY() const
331 {
332 return GetAxisMax<EAxis::Y>();
333 }
334
336 double GetMaximum() const
337 {
338 return *std::max_element(bh::indexed(fHistogram).begin(), bh::indexed(fHistogram).end());
339 }
340
342 double GetMinimum() const
343 {
344 return *std::min_element(bh::indexed(fHistogram).begin(), bh::indexed(fHistogram).end());
345 }
346
348 const std::string& GetTitle() const { return fTitle; }
349
351 void Reset()
352 {
353 TotalSums::Reset();
354 fHistogram.reset();
355 fEntries = 0;
356 }
357
361 void SetFlag(EHistFlag key, bool flag = true) { fMetadata.SetFlag(key, flag); }
362
365 void SetName(const std::string& name) { fName = name; }
366
370 void SetTitle(const std::string& title) { fTitle = title; }
371
373 //std::string ToString() const
374 //{
375 // std::stringstream msg;
376 // msg <<
377 //}
378
379 protected:
381 Histogram() = default;
382
385
386 //explicit Histogram(const Histogram<Axes, Storage>& h)
387 // : fHistogram(h.fHistogram)
388 // , fName(h.fName)
389 // , fTitle(h.fTitle)
390 // , fEntries(h.fEntries)
391 //{
392 //}
393
398 Histogram(const Hist_t& bhist, const std::string& name, const std::string title)
399 : fHistogram(bhist)
400 , fName(name)
401 , fTitle(title)
402 , fEntries(0)
404 {
405 }
406
410 inline static int GetBinBH(uint32_t iBin) { return (iBin > 0) ? iBin - 1 : -1; }
411
413 std::string fName = "";
414 std::string fTitle = "";
415 int fEntries = 0;
417
418
419 private:
421 template<class Archive>
423 void serialize(Archive& ar, const unsigned int /*version*/)
424 {
425 ar& boost::serialization::base_object<TotalSums>(*this);
426 ar& fHistogram;
427 ar& fName;
428 ar& fTitle;
429 ar& fEntries;
430 ar& fMetadata;
431 }
432 };
433
438
441 class H1D : public BaseH1D {
442 public:
449 H1D(const std::string& name, const std::string& title, uint32_t nBins, double xMin, double xMax)
450 : BaseH1D(bh::make_weighted_histogram(RegularAxis_t(nBins, xMin, xMax)), name, title)
451 {
452 }
453
455 H1D() = default;
456
458 H1D(const H1D&) = default;
459
461 H1D(H1D&&) = default;
462
464 H1D& operator=(const H1D&) = default;
465
467 H1D& operator=(H1D&&) = default;
468
473 int Fill(double x, double w = 1.)
474 {
475 auto cellIt = fHistogram(bh::weight(w), x);
476 ++fEntries;
477 int iBin = cellIt - fHistogram.begin();
478 if (iBin == 0 || iBin > static_cast<int>(GetNbinsX())) {
479 return -1; // ROOT TH1::Fill behaviour
480 }
481 // NOTE: In ROOT TH1 the total sums are updated only for non-overflow bins
482 BaseH1D::UpdateTotalSums(x, w);
483 return iBin;
484 }
485
488 auto GetBinAccumulator(uint32_t iBin) const { return fHistogram.at(Histogram::GetBinBH(iBin)); }
489
492 double GetBinContent(uint32_t iBin) const { return fHistogram.at(Histogram::GetBinBH(iBin)).value(); }
493
496 double GetBinError(uint32_t iBin) const { return std::sqrt(fHistogram.at(Histogram::GetBinBH(iBin)).variance()); }
497
498 private:
501 template<class Archive>
502 void serialize(Archive& ar, const unsigned int /*version*/)
503 {
504 ar& boost::serialization::base_object<BaseH1D>(*this);
505 }
506 };
507
510 class H2D : public BaseH2D {
511 public:
521 H2D(const std::string& name, const std::string& title, uint32_t nBinsX, double xMin, double xMax, uint32_t nBinsY,
522 double yMin, double yMax)
523 : BaseH2D(bh::make_weighted_histogram(RegularAxis_t(nBinsX, xMin, xMax), RegularAxis_t(nBinsY, yMin, yMax)), name,
524 title)
525 {
526 }
527
529 H2D() = default;
530
532 H2D(const H2D&) = default;
533
535 H2D(H2D&&) = default;
536
538 H2D& operator=(const H2D&) = default;
539
541 H2D& operator=(H2D&&) = default;
542
548 int Fill(double x, double y, double w = 1.)
549 {
550 auto cellIt = fHistogram(x, y, bh::weight(w));
551 ++fEntries;
552
553 int iBin = cellIt - fHistogram.begin();
554 uint32_t iBinX = iBin % (GetNbinsX() + 2);
555 if (iBinX == 0 || iBinX > GetNbinsX()) {
556 return -1;
557 }
558 uint32_t iBinY = iBin / (GetNbinsX() + 2);
559 if (iBinY == 0 || iBinY > GetNbinsY()) {
560 return -1;
561 }
562 // NOTE: In ROOT TH2 the total sums are updated only for non-overflow bins
563 BaseH2D::UpdateTotalSums(x, y, w);
564 return iBin;
565 }
566
570 auto GetBinAccumulator(uint32_t iBinX, uint32_t iBinY) const
571 {
572 return fHistogram.at(Histogram::GetBinBH(iBinX), Histogram::GetBinBH(iBinY));
573 }
574
578 double GetBinContent(uint32_t iBinX, uint32_t iBinY) const
579 {
580 return fHistogram.at(Histogram::GetBinBH(iBinX), Histogram::GetBinBH(iBinY)).value();
581 }
582
586 double GetBinError(uint32_t iBinX, uint32_t iBinY) const
587 {
588 return std::sqrt(fHistogram.at(Histogram::GetBinBH(iBinX), Histogram::GetBinBH(iBinY)).variance());
589 }
590
591 private:
594 template<class Archive>
595 void serialize(Archive& ar, const unsigned int /*version*/)
596 {
597 ar& boost::serialization::base_object<BaseH2D>(*this);
598 }
599 };
600
601 // TODO: Boost::histogram by default uses a different error calculation approach as ROOT TProfile. TODO: investigate
602
603 class Prof1D : public BaseProf1D {
604 public:
616 Prof1D(const std::string& name, const std::string& title, uint32_t nBinsX, double xMin, double xMax,
617 double yMin = 0., double yMax = 0.)
618 : BaseProf1D(bh::MakeRootStyleProfile(RegularAxis_t(nBinsX, xMin, xMax)), name, title)
619 , fYmin(yMin)
620 , fYmax(yMax)
621 {
622 }
623
625 Prof1D() = default;
626
628 Prof1D(const Prof1D&) = default;
629
631 Prof1D(Prof1D&&) = default;
632
634 Prof1D& operator=(const Prof1D&) = default;
635
637 Prof1D& operator=(Prof1D&&) = default;
638
644 int Fill(double x, double y, double w = 1.)
645 {
647 if ((fYmin != fYmax) && (y < fYmin || y > fYmax || std::isnan(y))) {
648 return -1;
649 }
650
651 auto cellIt = fHistogram(x, bh::sample(y), bh::weight(w));
652 ++fEntries;
653 int iBin = cellIt - fHistogram.begin();
654 if (iBin == 0 || iBin > static_cast<int>(GetNbinsX())) {
655 return -1; // ROOT TH1::Fill behaviour
656 }
657 // NOTE: In ROOT TProfile the total sums are updated only for non-overflow bins
658 BaseProf1D::UpdateTotalSums(x, w);
659 return iBin;
660 }
661
664 auto GetBinAccumulator(uint32_t iBin) const { return fHistogram.at(Histogram::GetBinBH(iBin)); }
665
668 double GetBinContent(uint32_t iBin) const { return fHistogram.at(Histogram::GetBinBH(iBin)).GetMean(); }
669
672 double GetBinCount(uint32_t iBin) const { return fHistogram.at(Histogram::GetBinBH(iBin)).GetEffCount(); }
673
676 double GetBinError(uint32_t iBin) const { return fHistogram.at(Histogram::GetBinBH(iBin)).GetSEM(); }
677
679 double GetMinY() const { return fYmin; }
680
682 double GetMaxY() const { return fYmax; }
683
684 private:
687 template<class Archive>
688 void serialize(Archive& ar, const unsigned int /*version*/)
689 {
690 ar& boost::serialization::base_object<BaseProf1D>(*this);
691 ar& fYmin;
692 ar& fYmax;
693 }
694
695 double fYmin = 0.;
696 double fYmax = 0.;
697 };
698
699 class Prof2D : public BaseProf2D {
700 public:
715 Prof2D(const std::string& name, const std::string& title, uint32_t nBinsX, double xMin, double xMax,
716 uint32_t nBinsY, double yMin, double yMax, double zMin = 0., double zMax = 0.)
717 : BaseProf2D(bh::MakeRootStyleProfile(RegularAxis_t(nBinsX, xMin, xMax), RegularAxis_t(nBinsY, yMin, yMax)), name,
718 title)
719 , fZmin(zMin)
720 , fZmax(zMax)
721 {
722 }
723
725 Prof2D() = default;
726
728 Prof2D(const Prof2D&) = default;
729
731 Prof2D(Prof2D&&) = default;
732
734 Prof2D& operator=(const Prof2D&) = default;
735
737 Prof2D& operator=(Prof2D&&) = default;
738
745 int Fill(double x, double y, double z, double w = 1.)
746 {
748 if ((fZmin != fZmax) && (z < fZmin || z > fZmax || std::isnan(z))) {
749 return -1;
750 }
751
752 auto cellIt = fHistogram(x, y, bh::sample(z), bh::weight(w));
753 ++fEntries;
754
755 int iBin = cellIt - fHistogram.begin();
756 uint32_t iBinX = iBin % (GetNbinsX() + 2);
757 if (iBinX == 0 || iBinX > GetNbinsX()) {
758 return -1;
759 }
760 uint32_t iBinY = iBin / (GetNbinsX() + 2);
761 if (iBinY == 0 || iBinY > GetNbinsY()) {
762 return -1;
763 }
764 // NOTE: In ROOT TProfile2D the total sums are updated only for non-overflow bins
765 BaseProf2D::UpdateTotalSums(x, y, w);
766 return iBin;
767 }
768
772 auto GetBinAccumulator(uint32_t iBinX, uint32_t iBinY) const
773 {
774 return fHistogram.at(Histogram::GetBinBH(iBinX), Histogram::GetBinBH(iBinY));
775 }
776
780 double GetBinContent(uint32_t iBinX, uint32_t iBinY) const
781 {
782 return fHistogram.at(Histogram::GetBinBH(iBinX), Histogram::GetBinBH(iBinY)).GetMean();
783 }
784
788 double GetBinCount(uint32_t iBinX, uint32_t iBinY) const
789 {
790 return fHistogram.at(Histogram::GetBinBH(iBinX), Histogram::GetBinBH(iBinY)).GetEffCount();
791 }
792
796 double GetBinError(uint32_t iBinX, uint32_t iBinY) const
797 {
798 return fHistogram.at(Histogram::GetBinBH(iBinX), Histogram::GetBinBH(iBinY)).GetSEM();
799 }
800
802 double GetMinZ() const { return fZmin; }
803
805 double GetMaxZ() const { return fZmax; }
806
807 private:
810 template<class Archive>
811 void serialize(Archive& ar, const unsigned int /*version*/)
812 {
813 ar& boost::serialization::base_object<BaseProf2D>(*this);
814 ar& fZmin;
815 ar& fZmax;
816 }
817
818 double fZmin = 0.;
819 double fZmax = 0.;
820 };
821
822} // namespace cbm::algo::qa
Custom accumulators for boost::histogram (header)
Data class with information on a STS local track.
1D-histogram
H1D & operator=(H1D &&)=default
Move assignment operator.
H1D(const H1D &)=default
Copy constructor.
double GetBinError(uint32_t iBin) const
Gets bin error.
Definition Histogram.h:496
H1D()=default
Default constructor.
auto GetBinAccumulator(uint32_t iBin) const
Gets underlying bin accumulator.
Definition Histogram.h:488
void serialize(Archive &ar, const unsigned int)
Definition Histogram.h:502
int Fill(double x, double w=1.)
Fills histogram.
Definition Histogram.h:473
H1D & operator=(const H1D &)=default
Copy assignment operator.
H1D(const std::string &name, const std::string &title, uint32_t nBins, double xMin, double xMax)
Constructor for 1D-histogram.
Definition Histogram.h:449
friend class boost::serialization::access
Serialization function.
Definition Histogram.h:500
double GetBinContent(uint32_t iBin) const
Gets bin content.
Definition Histogram.h:492
H1D(H1D &&)=default
Move constructor.
2D-histogram
H2D(const std::string &name, const std::string &title, uint32_t nBinsX, double xMin, double xMax, uint32_t nBinsY, double yMin, double yMax)
Constructor for 2D-histogram.
Definition Histogram.h:521
double GetBinError(uint32_t iBinX, uint32_t iBinY) const
Gets bin error.
Definition Histogram.h:586
H2D & operator=(H2D &&)=default
Move assignment operator.
H2D()=default
Default constructor.
auto GetBinAccumulator(uint32_t iBinX, uint32_t iBinY) const
Gets underlying bin accumulator.
Definition Histogram.h:570
H2D(const H2D &)=default
Copy constructor.
void serialize(Archive &ar, const unsigned int)
Definition Histogram.h:595
double GetBinContent(uint32_t iBinX, uint32_t iBinY) const
Gets bin content.
Definition Histogram.h:578
friend class boost::serialization::access
Serialization rule.
Definition Histogram.h:593
H2D(H2D &&)=default
Move constructor.
int Fill(double x, double y, double w=1.)
Fills histogram.
Definition Histogram.h:548
H2D & operator=(const H2D &)=default
Copy assignment operator.
Metadata of the histogram.
Definition Histogram.h:64
Flags_t fFlags
Flags collection for the histogram.
Definition Histogram.h:133
void serialize(Archive &ar, const unsigned int)
Serialization rule.
Definition Histogram.h:128
HistogramMetadata()=default
Default constructor.
static std::pair< std::string, std::string > SeparateNameAndMetadata(const std::string &msg)
Separates a name and metadata of histogram.
Definition Histogram.h:113
static constexpr std::string_view ksTsIdSuffix
Suffix of additional histograms vs. TS index.
Definition Histogram.h:68
std::string ToString() const
Converts the metadata to a string.
Definition Histogram.h:109
bool CheckFlags() const
Checks if the histogram flags configuration is valid.
Definition Histogram.h:87
~HistogramMetadata()=default
Destructor.
friend class boost::serialization::access
Definition Histogram.h:125
bool GetFlag(EHistFlag key) const
Get flag.
Definition Histogram.h:95
void SetFlag(EHistFlag key, bool flag=true)
Get flag.
Definition Histogram.h:100
std::underlying_type_t< EHistFlag > Flags_t
Definition Histogram.h:66
HistogramMetadata(const std::string &msg)
Constructor from the metadata string representation.
Definition Histogram.h:75
Interface to a histogram/profile.
Definition Histogram.h:250
const std::string & GetTitle() const
Gets title.
Definition Histogram.h:348
static int GetBinBH(uint32_t iBin)
Gets bin index in underlying boost histogram.
Definition Histogram.h:410
static constexpr unsigned Rank
Definition Histogram.h:253
std::string fTitle
Title of the histogram.
Definition Histogram.h:414
uint32_t GetAxisNbins() const
Gets number of bins in axis.
Definition Histogram.h:279
std::string fName
Name of the histogram.
Definition Histogram.h:413
void SetName(const std::string &name)
Sets name.
Definition Histogram.h:365
void serialize(Archive &ar, const unsigned int)
Serialization rule.
Definition Histogram.h:423
uint32_t GetNbinsY() const
Gets number of bins for y axis.
Definition Histogram.h:316
double GetMaximum() const
Gets maximum value.
Definition Histogram.h:336
double GetMaxY() const
Gets y-axis lower bound.
Definition Histogram.h:330
double GetAxisMin() const
Gets range lower bound of the selected axis.
Definition Histogram.h:262
void SetFlag(EHistFlag key, bool flag=true)
Get flag.
Definition Histogram.h:361
Histogram(const Hist_t &bhist, const std::string &name, const std::string title)
Constructor.
Definition Histogram.h:398
void Reset()
Resets the histogram.
Definition Histogram.h:351
bh::histogram< Axes, Storage > Hist_t
Definition Histogram.h:252
bool GetFlag(EHistFlag key) const
Get flag.
Definition Histogram.h:294
HistogramMetadata fMetadata
Meta-data for histogram.
Definition Histogram.h:416
double GetAxisMax() const
Gets range upper bound of the selected axis.
Definition Histogram.h:270
Histogram()=default
String representation of the histogram/profile.
Hist_t fHistogram
Underlying boost histogram.
Definition Histogram.h:412
void SetTitle(const std::string &title)
Sets title.
Definition Histogram.h:370
~Histogram()=default
Destructor.
Histogram(const Histogram< Axes, Storage, TotalSums > &h)=default
Copy constructor.
const std::string & GetName() const
Gets name.
Definition Histogram.h:297
double GetMinY() const
Gets y-axis lower bound.
Definition Histogram.h:323
double GetMaxX() const
Gets x-axis lower bound.
Definition Histogram.h:312
double GetEntries() const
Gets number of entries.
Definition Histogram.h:286
friend class boost::serialization::access
Definition Histogram.h:420
double GetMinimum() const
Gets minimum value.
Definition Histogram.h:342
double GetMinX() const
Gets x-axis lower bound.
Definition Histogram.h:309
std::string GetMetadataString() const
Gets metadata string.
Definition Histogram.h:303
int fEntries
Number of histogram entries.
Definition Histogram.h:415
uint32_t GetNbinsX() const
Gets number of bins for x axis.
Definition Histogram.h:306
const HistogramMetadata & GetMetadata() const
Gets metadata instance.
Definition Histogram.h:300
double fYmin
Lower bound of the profile y-axis.
Definition Histogram.h:695
double GetMaxY() const
Gets y-axis lower bound.
Definition Histogram.h:682
Prof1D(const Prof1D &)=default
Copy constructor.
Prof1D & operator=(const Prof1D &)=default
Copy assignment operator.
auto GetBinAccumulator(uint32_t iBin) const
Gets underlying bin accumulator.
Definition Histogram.h:664
double fYmax
Upper bound of the profile y-axis.
Definition Histogram.h:696
double GetMinY() const
Gets y-axis lower bound.
Definition Histogram.h:679
Prof1D(Prof1D &&)=default
Move constructor.
Prof1D(const std::string &name, const std::string &title, uint32_t nBinsX, double xMin, double xMax, double yMin=0., double yMax=0.)
Constructor for 2D-histogram.
Definition Histogram.h:616
void serialize(Archive &ar, const unsigned int)
Definition Histogram.h:688
Prof1D & operator=(Prof1D &&)=default
Move assignment operator.
int Fill(double x, double y, double w=1.)
Fills histogram.
Definition Histogram.h:644
double GetBinError(uint32_t iBin) const
Gets bin error.
Definition Histogram.h:676
Prof1D()=default
Default constructor.
friend class boost::serialization::access
Serialization rule.
Definition Histogram.h:686
double GetBinContent(uint32_t iBin) const
Gets bin content.
Definition Histogram.h:668
double GetBinCount(uint32_t iBin) const
Gets bin entries.
Definition Histogram.h:672
Prof2D(const Prof2D &)=default
Copy constructor.
int Fill(double x, double y, double z, double w=1.)
Fills histogram.
Definition Histogram.h:745
double GetBinCount(uint32_t iBinX, uint32_t iBinY) const
Gets bin entries.
Definition Histogram.h:788
Prof2D & operator=(const Prof2D &)=default
Copy assignment operator.
double GetBinError(uint32_t iBinX, uint32_t iBinY) const
Gets bin error.
Definition Histogram.h:796
Prof2D(Prof2D &&)=default
Move constructor.
auto GetBinAccumulator(uint32_t iBinX, uint32_t iBinY) const
Gets underlying bin accumulator.
Definition Histogram.h:772
Prof2D(const std::string &name, const std::string &title, uint32_t nBinsX, double xMin, double xMax, uint32_t nBinsY, double yMin, double yMax, double zMin=0., double zMax=0.)
Constructor for 2D-histogram.
Definition Histogram.h:715
Prof2D()=default
Default constructor.
double GetMaxZ() const
Gets z-axis lower bound.
Definition Histogram.h:805
double GetMinZ() const
Gets z-axis lower bound.
Definition Histogram.h:802
void serialize(Archive &ar, const unsigned int)
Definition Histogram.h:811
double fZmin
Lower bound of the profile z-axis.
Definition Histogram.h:818
double fZmax
Upper bound of the profile z-axis.
Definition Histogram.h:819
double GetBinContent(uint32_t iBinX, uint32_t iBinY) const
Gets bin content.
Definition Histogram.h:780
friend class boost::serialization::access
Serialization rule.
Definition Histogram.h:809
Prof2D & operator=(Prof2D &&)=default
Move assignment operator.
Storage for total sums of weights, squared weights, weights over x, weights over squared x.
Definition Histogram.h:138
void Reset()
Resets the sums.
Definition Histogram.h:165
double GetTotSumW() const
Gets total sum of weights.
Definition Histogram.h:141
double fTotSumWX
Total sum (over all bins) of weight over x products.
Definition Histogram.h:175
void UpdateTotalSums(double x, double w)
Updates the sums.
Definition Histogram.h:156
double GetTotSumW2() const
Gets total sum of squared weights.
Definition Histogram.h:144
double GetTotSumWX2() const
Gets total sum of weight over squared x products.
Definition Histogram.h:150
double fTotSumW
Total sum (over all bins) of weights.
Definition Histogram.h:173
double GetTotSumWX() const
Gets total sum of weight over x products.
Definition Histogram.h:147
double fTotSumW2
Total sum (over all bins) of squared weights.
Definition Histogram.h:174
friend class boost::serialization::access
Serialization rule.
Definition Histogram.h:180
double fTotSumWX2
Total sum (over all bins) of weight over square x products.
Definition Histogram.h:176
void serialize(Archive &ar, const unsigned int)
Definition Histogram.h:182
TotalSums1D including storage for total sums of w*x*y, w*y, w*y*y products.
Definition Histogram.h:193
double fTotSumWXY
Total sum (over all bins) of weight over square x products.
Definition Histogram.h:227
double GetTotSumWY() const
Gets total sum of weight over y products.
Definition Histogram.h:199
void serialize(Archive &ar, const unsigned int)
Definition Histogram.h:234
double GetTotSumWY2() const
Gets total sum of weight over squared y products.
Definition Histogram.h:202
double GetTotSumWXY() const
Gets total sum of weight over squared y products.
Definition Histogram.h:196
double fTotSumWY2
Total sum (over all bins) of weight over x over y products.
Definition Histogram.h:228
double fTotSumWY
Total sum (over all bins) of weight over y products.
Definition Histogram.h:226
friend class boost::serialization::access
Serialization rule.
Definition Histogram.h:232
void Reset()
Resets the sums.
Definition Histogram.h:206
void UpdateTotalSums(double x, double y, double w)
Updates the sums.
Definition Histogram.h:218
dense_storage< RootStyleProfileAccumulator< T > > RootStyleProfileStorage
Histogram< Axes2D_t, HistStorage_t, TotalSums2D > BaseH2D
Definition Histogram.h:435
std::tuple< RegularAxis_t > Axes1D_t
Definition Histogram.h:38
EHistFlag
Histogram control flags (bit masks)
Definition Histogram.h:56
@ StoreVsTsId
Store the histogram vs timeslice index.
@ OmitIntegrated
Omits storing integrated histogram.
bh::axis::regular<> RegularAxis_t
Definition Histogram.h:36
bh::RootStyleProfileStorage< double > ProfStorage_t
Definition Histogram.h:42
std::tuple< RegularAxis_t, RegularAxis_t > Axes2D_t
Definition Histogram.h:39
bh::weight_storage HistStorage_t
Definition Histogram.h:41