forked from AliceO2Group/O2Physics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHistogramManager.h
More file actions
122 lines (102 loc) · 5.49 KB
/
Copy pathHistogramManager.h
File metadata and controls
122 lines (102 loc) · 5.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
//
// Contact: iarsene@cern.ch, i.c.arsene@fys.uio.no
//
// Class to define and fill histograms
//
#ifndef PWGDQ_CORE_HISTOGRAMMANAGER_H_
#define PWGDQ_CORE_HISTOGRAMMANAGER_H_
#include <TArrayD.h>
#include <TAxis.h>
#include <THashList.h>
#include <TNamed.h>
#include <TString.h>
#include <Rtypes.h>
#include <RtypesCore.h>
#include <cstdint>
#include <list>
#include <map>
#include <string>
#include <vector>
class HistogramManager : public TNamed
{
public:
HistogramManager();
HistogramManager(const char* name, const char* title, const int maxNVars);
~HistogramManager() override;
enum Constants {
kNothing = -1
};
void SetMainHistogramList(THashList* list)
{
if (fMainList) {
delete fMainList;
}
fMainList = list;
}
// Create a new histogram class
void AddHistClass(const char* histClass);
// Create a new histogram in the class <histClass> with name <name> and title <title>
// The type of histogram is deduced from the parameters specified by the user
// The binning for at least one dimension needs to be specified, namely: nXbins, xmin, xmax, varX which will result in a TH1F histogram
// If the value for a variable is left as -1 then that is considered to not be used
// Up to 3 dimensional histograms can be defined with this function
// If isProfile = true, the last specified variable is the one being averaged
// For the case of TProfile3D, the user must use the varT to specify the averaged variable
// If specified, varW will be used as weight in the TH1::Fill() functions.
// If specified, the xLabels, yLabels, zLabels will be used to set the labels of the x,y,z axes, respectively.
// The axis titles will be set by default, if those were specified (e.g. taken from a Variable Manager)
// Otherwise these can be specified in the title string by separating them with semi-colons ";"
void AddHistogram(const char* histClass, const char* name, const char* title, bool isProfile,
int nXbins, double xmin, double xmax, int varX,
int nYbins = 0, double ymin = 0, double ymax = 0, int varY = -1,
int nZbins = 0, double zmin = 0, double zmax = 0, int varZ = -1,
const char* xLabels = "", const char* yLabels = "", const char* zLabels = "",
int varT = -1, int varW = -1, bool isdouble = false, bool isFillLabelx = false);
// Similar to the above function, with the difference that the user can specify non-equidistant binning
void AddHistogram(const char* histClass, const char* name, const char* title, bool isProfile,
int nXbins, double* xbins, int varX,
int nYbins = 0, double* ybins = nullptr, int varY = -1,
int nZbins = 0, double* zbins = nullptr, int varZ = -1,
const char* xLabels = "", const char* yLabels = "", const char* zLabels = "",
int varT = -1, int varW = -1, bool isdouble = false, bool isFillLabelx = false);
// Create a THn histogram (either THnF or THnSparse) with equidistant binning
void AddHistogram(const char* histClass, const char* name, const char* title,
int nDimensions, int* vars, int* nBins, double* xmin, double* xmax,
TString* axLabels = nullptr, int varW = -1, bool useSparse = kFALSE, bool isdouble = false);
// Create a THn histogram (either THnF or THnSparse) with non-equidistant binning
void AddHistogram(const char* histClass, const char* name, const char* title,
int nDimensions, int* vars, TArrayD* binLimits,
TString* axLabels = nullptr, int varW = -1, bool useSparse = kFALSE, bool isdouble = false);
void FillHistClass(const char* className, float* values);
void SetUseDefaultVariableNames(bool flag) { fUseDefaultVariableNames = flag; }
void SetDefaultVarNames(TString* vars, TString* units);
const bool* GetUsedVars() const { return fUsedVars; }
THashList* GetMainHistogramList() { return fMainList; } // get a histogram list
uint64_t GetAllocatedBins() const { return fBinsAllocated; }
void Print(Option_t*) const override;
private:
THashList* fMainList; // master histogram list
int fNVars; // number of variables handled (tipically from the Variable Manager)
bool* fUsedVars; //! flags of used variables
std::map<std::string, std::list<std::vector<int>>> fVariablesMap; //! map holding identifiers for all variables needed by histograms
// various
bool fUseDefaultVariableNames; //! toggle the usage of default variable names and units
uint64_t fBinsAllocated; //! number of allocated bins
TString* fVariableNames; //! variable names
TString* fVariableUnits; //! variable units
void MakeAxisLabels(TAxis* ax, const char* labels);
HistogramManager& operator=(const HistogramManager& c);
HistogramManager(const HistogramManager& c);
ClassDef(HistogramManager, 2)
};
#endif // PWGDQ_CORE_HISTOGRAMMANAGER_H_