BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSBH4DBase.cc
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#include "BDSBH4DBase.hh"
19#include "BDSDebug.hh"
20#include "BDSException.hh"
21
22#include "TFile.h"
23
24#include <string>
25
26ClassImp(BDSBH4DBase)
27
28BDSBH4DBase::BDSBH4DBase():
29 h_nxbins(0),
30 h_nybins(0),
31 h_nzbins(0),
32 h_nebins(0),
33 h_xmin(0), h_xmax(0),
34 h_ymin(0), h_ymax(0),
35 h_zmin(0), h_zmax(0),
36 h_emin(0), h_emax(0),
37 h_entries(0)
38{;}
39
40BDSBH4DBase::BDSBH4DBase(unsigned int nXBinsIn, unsigned int nYBinsIn,
41 unsigned int nZBinsIn, unsigned int nEBinsIn,
42 double xMinIn, double xMaxIn, double yMinIn, double yMaxIn,
43 double zMinIn, double zMaxIn, double eMinIn, double eMaxIn,
44 const std::string& nameIn,
45 const std::string& titleIn,
46 const std::string& escaleIn):
47 h_nxbins(nXBinsIn), h_nybins(nYBinsIn), h_nzbins(nZBinsIn), h_nebins(nEBinsIn),
48 h_xmin(xMinIn), h_xmax(xMaxIn),
49 h_ymin(yMinIn), h_ymax(yMaxIn),
50 h_zmin(zMinIn), h_zmax(zMaxIn),
51 h_emin(eMinIn), h_emax(eMaxIn),
52 h_name(nameIn),
53 h_title(titleIn),
54 h_escale(escaleIn),
55 h_entries(0)
56{;}
57
58BDSBH4DBase::BDSBH4DBase(unsigned int nXBinsIn, unsigned int nYBinsIn, unsigned int nZBinsIn,
59 double xMinIn, double xMaxIn,
60 double yMinIn, double yMaxIn,
61 double zMinIn, double zMaxIn,
62 const std::string& nameIn,
63 const std::string& titleIn,
64 const std::string& escaleIn,
65 const std::vector<double>& eBinEdgesIn):
66 h_nxbins(nXBinsIn), h_nybins(nYBinsIn), h_nzbins(nZBinsIn),
67 h_xmin(xMinIn), h_xmax(xMaxIn),
68 h_ymin(yMinIn), h_ymax(yMaxIn),
69 h_zmin(zMinIn), h_zmax(zMaxIn),
70 h_name(nameIn),
71 h_title(titleIn),
72 h_escale(escaleIn),
73 h_ebinsedges(eBinEdgesIn),
74 h_entries(0)
75{
76 if (eBinEdgesIn.size() < 2)
77 {throw BDSException(__METHOD_NAME__, "bin edges vector must be at least 2 numbers");}
78 h_nebins = (unsigned int)(eBinEdgesIn.size() - 1);
79 h_emin = eBinEdgesIn[0];
80 h_emax = eBinEdgesIn.back();
81}
82
83int BDSBH4DBase::GetNbinsX() const
84{
85 return static_cast<int>(h_nxbins);
86}
87
88int BDSBH4DBase::GetNbinsY() const
89{
90 return static_cast<int>(h_nybins);
91}
92
93int BDSBH4DBase::GetNbinsZ() const
94{
95 return static_cast<int>(h_nzbins);
96}
97
98int BDSBH4DBase::GetNbinsE() const
99{
100 return static_cast<int>(h_nebins);
101}
102
103const char* BDSBH4DBase::GetName() const
104{
105 return h_name.c_str();
106}
107
108const char* BDSBH4DBase::GetTitle() const
109{
110 return h_title.c_str();
111}
112
113unsigned long BDSBH4DBase::GetEntries_BDSBH4D() const
114{
115 return h_entries;
116}
117
118void BDSBH4DBase::SetName(const char* name)
119{
120 h_name = std::string(name);
121}
122
123void BDSBH4DBase::SetTitle(const char* title)
124{
125 h_title = std::string(title);
126}
127
128void BDSBH4DBase::SetEntries_BDSBH4D(double i)
129{
130 h_entries = static_cast<unsigned long>(i);
131}
Base class for the 4D histogram classes.
General exception with possible name of object and message.