BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSOutputROOTEventHistograms.hh
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) BDSIM Collaboration, 2001 - 2026.
3
4This file is part of BDSIM.
5
6BDSIM is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published
8by the Free Software Foundation version 3 of the License.
9
10BDSIM is distributed in the hope that it will be useful, but
11WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef BDSOUTPUTROOTEVENTHISTOGRAMS_H
19#define BDSOUTPUTROOTEVENTHISTOGRAMS_H
20
21#include <string>
22#include <vector>
23
24#ifdef USE_BOOST
25#include <boost/histogram.hpp>
26#endif
27
28#ifndef __ROOTBUILD__
29#include "globals.hh"
30#endif
31
32#include "Rtypes.h"
33#include "TObject.h"
34#include "BDSBH4DBase.hh"
35
36class TH1D;
37class TH2D;
38class TH3D;
39
46class BDSOutputROOTEventHistograms: public TObject
47{
48public:
52 BDSOutputROOTEventHistograms(std::vector<TH1D*>& histogram1DIn,
53 std::vector<TH2D*>& histogram2DIn,
54 std::vector<TH3D*>& histogram3DIn,
55 std::vector<BDSBH4DBase*>& histograms4DIn);
57
59 int Create1DHistogramSTD(std::string name, std::string title,
60 int nbins, double xmin, double xmax);
61
62#ifndef __ROOTBUILD__
63 G4int Create1DHistogram(G4String name, G4String title,
64 G4int nbins, G4double xmin, G4double xmax);
65 G4int Create1DHistogram(G4String name, G4String title,
66 std::vector<double>& edges);
67 G4int Create2DHistogram(G4String name, G4String title,
68 G4int nxbins, G4double xmin, G4double xmax,
69 G4int nybins, G4double ymin, G4double ymax);
70 G4int Create2DHistogram(G4String name, G4String title,
71 std::vector<double>& xedges,
72 std::vector<double>& yedges);
73 G4int Create3DHistogram(G4String name, G4String title,
74 G4int nxbins, G4double xmin, G4double xmax,
75 G4int nybins, G4double ymin, G4double ymax,
76 G4int nzbins, G4double zmin, G4double zmax);
77 G4int Create3DHistogram(G4String name, G4String title,
78 std::vector<double>& xedges,
79 std::vector<double>& yedges,
80 std::vector<double>& zedges);
81 G4int Create4DHistogram(const G4String& name,
82 const G4String& title,
83 const G4String& eScale,
84 const std::vector<double>& eBinsEdges,
85 unsigned int nxbins, G4double xmin, G4double xmax,
86 unsigned int nybins, G4double ymin, G4double ymax,
87 unsigned int nzbins, G4double zmin, G4double zmax,
88 unsigned int nebins, G4double emin, G4double emax);
89
90 void Fill1DHistogram(G4int histoId, G4double value, G4double weight = 1.0);
91 void Fill2DHistogram(G4int histoId, G4double xValue, G4double yValue, G4double weight = 1.0);
92 void Fill3DHistogram(G4int histoId, G4double xValue, G4double yValue, G4double zValue, G4double weight = 1.0);
93 void Fill4DHistogram(G4int histoId, G4double xValue, G4double yValue, G4double zvalue, G4double eValue);
94
97 void Set3DHistogramBinContent(G4int histoId,
98 G4int globalBinID,
99 G4double value);
100
101 void Set4DHistogramBinContent(G4int histoId,
102 G4int x,
103 G4int y,
104 G4int z,
105 G4int e,
106 G4double value);
107
109 void AccumulateHistogram3D(G4int histoId,
110 TH3D* otherHistogram);
111 void AccumulateHistogram4D(G4int histoId,
112 BDSBH4DBase* otherHistogram);
113#endif
115 virtual void Flush();
116
118 void Fill(const BDSOutputROOTEventHistograms* rhs);
119
122
124 std::vector<TH1D*>& Get1DHistograms() {return histograms1D;}
125 std::vector<TH2D*>& Get2DHistograms() {return histograms2D;}
126 std::vector<TH3D*>& Get3DHistograms() {return histograms3D;}
127 std::vector<BDSBH4DBase*>& Get4DHistograms() {return histograms4D;}
128 TH1D* Get1DHistogram(int iHisto) const {return histograms1D[iHisto];}
129 TH2D* Get2DHistogram(int iHisto) const {return histograms2D[iHisto];}
130 TH3D* Get3DHistogram(int iHisto) const {return histograms3D[iHisto];}
131 BDSBH4DBase* Get4DHistogram(int iHisto) const {return histograms4D[iHisto];}
133
134private:
135 std::vector<TH1D*> histograms1D;
136 std::vector<TH2D*> histograms2D;
137 std::vector<TH3D*> histograms3D;
138 std::vector<BDSBH4DBase*> histograms4D;
139
141};
142
143#endif
Base class for the 4D histogram classes.
Holder for a set of histograms to be stored.
std::vector< BDSBH4DBase * > & Get4DHistograms()
Accessors.
std::vector< TH2D * > & Get2DHistograms()
Accessors.
std::vector< TH3D * > & Get3DHistograms()
Accessors.
TH2D * Get2DHistogram(int iHisto) const
Accessors.
virtual void Flush()
Flush the contents.
std::vector< TH1D * > & Get1DHistograms()
Accessors.
void AccumulateHistogram3D(G4int histoId, TH3D *otherHistogram)
Add the values from one supplied 3D histogram to another. Uses TH3-Add().
BDSBH4DBase * Get4DHistogram(int iHisto) const
Accessors.
TH1D * Get1DHistogram(int iHisto) const
Accessors.
int Create1DHistogramSTD(std::string name, std::string title, int nbins, double xmin, double xmax)
Interface function to create a 1D histogram using only standard types.
void Fill(const BDSOutputROOTEventHistograms *rhs)
Copy (using the TH->Clone) method from another instance.
void FillSimple(const BDSOutputROOTEventHistograms *rhs)
Copy (without using the TH->Clone) method from another instance. (Quicker).
void Set3DHistogramBinContent(G4int histoId, G4int globalBinID, G4double value)
TH3D * Get3DHistogram(int iHisto) const
Accessors.