CbmRoot
Loading...
Searching...
No Matches
HistogramCollection.cxx
Go to the documentation of this file.
1/* Copyright (C) 2023 FIAS Frankfurt Institute for Advanced Studies, Frankfurt / Main
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Felix Weiglhofer [committer] */
5
6#include <TH1.h>
7
8#include <fmt/format.h>
9
10using namespace cbm::explore;
11
13
15{
16 for (auto& histo : fHistos) {
17 histo.histo->Reset();
18 }
19}
20
21TH1* HistogramCollection::GetHisto(const std::string& name) const
22{
23 for (auto& histo : fHistos) {
24 if (histo.histo->GetName() == name) { return histo.histo; }
25 }
26 return nullptr;
27}
28
29std::string HistogramCollection::GetHistoPath(const std::string& name) const
30{
31 for (auto& histo : fHistos) {
32 if (histo.histo->GetName() == name) { return histo.path; }
33 }
34 return "";
35}
36
38{
39 for (auto& histo : fHistos) {
40 auto otherHisto = other.GetHisto(histo.histo->GetName());
41 if (not otherHisto) {
42 throw std::runtime_error(
43 fmt::format("Cannot divide histograms, because they do not match: No histogram with name "
44 "{} found in other collection.",
45 histo.histo->GetName()));
46 }
47 histo.histo->Divide(otherHisto);
48 }
49}
50
51void HistogramCollection::CreateFolder(const char* path, const char* name)
52{
53 fFolders.push_back({.path = path, .name = name});
54}
void CreateFolder(const char *path, const char *name)
TH1 * GetHisto(const std::string &name) const
std::string GetHistoPath(const std::string &name) const
void Reset()
Clear all histograms.
void Div(const HistogramCollection &other)