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) Royal Holloway,
3University of London 2001 - 2023.
4
5This file is part of BDSIM.
6
7BDSIM is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published
9by the Free Software Foundation version 3 of the License.
10
11BDSIM is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#include "BDSBH4DBase.hh"
20#include "BDSDebug.hh"
21#include "BDSException.hh"
22
23#include "TFile.h"
24
25#include <string>
26
27ClassImp(BDSBH4DBase)
28
29BDSBH4DBase::BDSBH4DBase():
30 h_nxbins(0),
31 h_nybins(0),
32 h_nzbins(0),
33 h_nebins(0),
34 h_xmin(0), h_xmax(0),
35 h_ymin(0), h_ymax(0),
36 h_zmin(0), h_zmax(0),
37 h_emin(0), h_emax(0),
38 h_entries(0)
39{;}
40
41BDSBH4DBase::BDSBH4DBase(unsigned int nXBinsIn, unsigned int nYBinsIn,
42 unsigned int nZBinsIn, unsigned int nEBinsIn,
43 double xMinIn, double xMaxIn, double yMinIn, double yMaxIn,
44 double zMinIn, double zMaxIn, double eMinIn, double eMaxIn,
45 const std::string& nameIn,
46 const std::string& titleIn,
47 const std::string& escaleIn):
48 h_nxbins(nXBinsIn), h_nybins(nYBinsIn), h_nzbins(nZBinsIn), h_nebins(nEBinsIn),
49 h_xmin(xMinIn), h_xmax(xMaxIn),
50 h_ymin(yMinIn), h_ymax(yMaxIn),
51 h_zmin(zMinIn), h_zmax(zMaxIn),
52 h_emin(eMinIn), h_emax(eMaxIn),
53 h_name(nameIn),
54 h_title(titleIn),
55 h_escale(escaleIn),
56 h_entries(0)
57{;}
58
59BDSBH4DBase::BDSBH4DBase(unsigned int nXBinsIn, unsigned int nYBinsIn, unsigned int nZBinsIn,
60 double xMinIn, double xMaxIn,
61 double yMinIn, double yMaxIn,
62 double zMinIn, double zMaxIn,
63 const std::string& nameIn,
64 const std::string& titleIn,
65 const std::string& escaleIn,
66 const std::vector<double>& eBinEdgesIn):
67 h_nxbins(nXBinsIn), h_nybins(nYBinsIn), h_nzbins(nZBinsIn),
68 h_xmin(xMinIn), h_xmax(xMaxIn),
69 h_ymin(yMinIn), h_ymax(yMaxIn),
70 h_zmin(zMinIn), h_zmax(zMaxIn),
71 h_name(nameIn),
72 h_title(titleIn),
73 h_escale(escaleIn),
74 h_ebinsedges(eBinEdgesIn),
75 h_entries(0)
76{
77 if (eBinEdgesIn.size() < 2)
78 {throw BDSException(__METHOD_NAME__, "bin edges vector must be at least 2 numbers");}
79 h_nebins = (unsigned int)(eBinEdgesIn.size() - 1);
80 h_emin = eBinEdgesIn[0];
81 h_emax = eBinEdgesIn.back();
82}
83
84int BDSBH4DBase::GetNbinsX() const
85{
86 return static_cast<int>(h_nxbins);
87}
88
89int BDSBH4DBase::GetNbinsY() const
90{
91 return static_cast<int>(h_nybins);
92}
93
94int BDSBH4DBase::GetNbinsZ() const
95{
96 return static_cast<int>(h_nzbins);
97}
98
99int BDSBH4DBase::GetNbinsE() const
100{
101 return static_cast<int>(h_nebins);
102}
103
104const char* BDSBH4DBase::GetName() const
105{
106 return h_name.c_str();
107}
108
109const char* BDSBH4DBase::GetTitle() const
110{
111 return h_title.c_str();
112}
113
114unsigned long BDSBH4DBase::GetEntries_BDSBH4D()
115{
116 return h_entries;
117}
118
119void BDSBH4DBase::SetName(const char* name)
120{
121 h_name = std::string(name);
122}
123
124void BDSBH4DBase::SetTitle(const char* title)
125{
126 h_title = std::string(title);
127}
128
129void BDSBH4DBase::SetEntries_BDSBH4D(double i)
130{
131 h_entries = static_cast<unsigned long>(i);
132}
Base class for the 4D histogram classes.
Definition: BDSBH4DBase.hh:37
General exception with possible name of object and message.
Definition: BDSException.hh:35