File indexing completed on 2024-09-27 07:03:26
0001
0002
0003
0004 #pragma once
0005
0006 #include <TROOT.h>
0007 #include <TNamed.h>
0008 #include <TPad.h>
0009 #include <TAxis.h>
0010 #include <TH2D.h>
0011 #include <TMath.h>
0012 #include <TFrame.h>
0013 #include <stdexcept>
0014
0015
0016
0017
0018 class Hist4D : public TNamed {
0019 public:
0020
0021
0022
0023
0024
0025
0026
0027
0028 TAxis* _w_axis = nullptr;
0029 TAxis* _x_axis = nullptr;
0030 TAxis* _y_axis = nullptr;
0031 TAxis* _z_axis = nullptr;
0032 TH2D* _axes = nullptr;
0033 std::vector<TH2D*> _hists;
0034 Double_t _minimum = TMath::QuietNaN();
0035 Double_t _maximum = TMath::QuietNaN();
0036
0037 void CreateHists();
0038 void CreateAxes();
0039
0040 public:
0041 Hist4D() { }
0042 Hist4D(
0043 char const* name, char const* title,
0044 Int_t nbins_w, Double_t const* bins_w,
0045 Int_t nbins_x, Double_t const* bins_x,
0046 Int_t nbins_y, Double_t const* bins_y,
0047 Int_t nbins_z, Double_t const* bins_z);
0048 Hist4D(
0049 char const* name, char const* title,
0050 Int_t nbins_w, Double_t w_lower, Double_t w_upper,
0051 Int_t nbins_x, Double_t x_lower, Double_t x_upper,
0052 Int_t nbins_y, Double_t y_lower, Double_t y_upper,
0053 Int_t nbins_z, Double_t z_lower, Double_t z_upper);
0054 ~Hist4D();
0055
0056 static bool CheckConsistency(Hist4D const* h1, Hist4D const* h2);
0057 static bool CheckAxisLimits(TAxis const* ax1, TAxis const* ax2);
0058 static bool CheckBinLimits(TAxis const* ax1, TAxis const* ax2);
0059 static bool CheckBinLabels(TAxis const* ax1, TAxis const* ax2);
0060
0061 virtual TObject* Clone(char const* new_name = "_clone") const override;
0062
0063 void Fill(Double_t w, Double_t x, Double_t y, Double_t z);
0064 void Fill(Double_t w, Double_t x, Double_t y, Double_t z, Double_t weight);
0065
0066 Double_t GetEntries();
0067
0068 Bool_t IsEmpty() const;
0069
0070 TAxis* GetWaxis() {
0071 return _w_axis;
0072 }
0073 TAxis* GetXaxis() {
0074 return _x_axis;
0075 }
0076 TAxis* GetYaxis() {
0077 return _y_axis;
0078 }
0079 TAxis* GetZaxis() {
0080 return _z_axis;
0081 }
0082
0083 void SetMinimum(Double_t min = TMath::QuietNaN()) {
0084 _minimum = min;
0085 }
0086 void SetMaximum(Double_t max = TMath::QuietNaN()) {
0087 _maximum = max;
0088 }
0089
0090 void Divide(Hist4D* other);
0091 void Scale(Double_t c);
0092
0093 TH2D* ProjectionYZ(char const* pname = "_pyz");
0094 TH2D* ProjectionWX(
0095 char const* pname = "_pwx",
0096 Int_t firstbiny = 0, Int_t lastbiny = -1,
0097 Int_t firstbinz = 0, Int_t lastbinz = -1);
0098 virtual void Draw(char const* options = "col") override {
0099 if (!gPad) {
0100 gROOT->MakeDefCanvas();
0101 }
0102 DrawPad(gPad, options);
0103 }
0104 void DrawPad(TVirtualPad* pad, char const* options = "col");
0105
0106 ClassDefOverride(Hist4D, 1);
0107 };