CbmRoot
Loading...
Searching...
No Matches
HistogramCollection.h
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] */
4#pragma once
5
6#include <memory>
7#include <optional>
8#include <string>
9#include <vector>
10
11class TH1;
12
13namespace cbm::algo
14{
15 class StorableRecoResults;
16}
17
18namespace cbm::explore
19{
20
21 struct Folder {
22 std::string path;
23 std::string name;
24 };
25
26 struct Histo {
27 std::string path;
28 TH1* histo;
29 };
30
31 struct HistoData {
33 std::optional<uint32_t> sensor;
34
35 bool Skip(uint32_t address) const
36 {
37 if (not sensor) return false;
38 return address != *sensor;
39 }
40 };
41
43
44 public:
46 virtual ~HistogramCollection();
47
49 void Reset();
50
51 TH1* GetHisto(const std::string& name) const;
52 std::string GetHistoPath(const std::string& name) const;
53 std::vector<Histo> GetHistos() const { return fHistos; }
54
55 std::vector<Folder> GetFolders() const { return fFolders; }
56
57 void Div(const HistogramCollection& other);
58
59 virtual void FillHistos(HistoData fill) = 0;
60
61 protected:
62 template<typename Histo_t>
63 void CreateHisto(Histo_t*& histo, const char* folder, const char* name, const char* title, int nbins, double xlow,
64 double xmax)
65 {
66 histo = new Histo_t(name, title, nbins, xlow, xmax);
67 histo->SetDirectory(nullptr);
68 fHistos.push_back({.path = folder, .histo = histo});
69 }
70
71 void CreateFolder(const char* path, const char* name);
72
73 private:
74 std::vector<Folder> fFolders;
75 std::vector<Histo> fHistos;
76 };
77
78} // namespace cbm::explore
std::vector< Folder > GetFolders() const
void CreateHisto(Histo_t *&histo, const char *folder, const char *name, const char *title, int nbins, double xlow, double xmax)
std::vector< Histo > GetHistos() const
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)
virtual void FillHistos(HistoData fill)=0
bool Skip(uint32_t address) const
std::optional< uint32_t > sensor
algo::StorableRecoResults * data