20#include "BDSException.hh"
21#include "BDSExtent.hh"
22#include "BDSScorerMeshInfo.hh"
23#include "BDSUtilities.hh"
25#include "BDSBH4DTypeDefs.hh"
30#include "parser/scorermesh.h"
32#include "CLHEP/Units/SystemOfUnits.h"
41 name = G4String(mesh.
name);
50 if (geometryType ==
"box")
53 throw BDSException(__METHOD_NAME__,
"xsize must be finite in mesh \"" + mesh.
name +
"\"");
56 throw BDSException(__METHOD_NAME__,
"ysize must be finite in mesh \"" + mesh.
name +
"\"");
59 throw BDSException(__METHOD_NAME__,
"zsize must be finite in mesh \"" + mesh.
name +
"\"");
63 throw BDSException(__METHOD_NAME__,
"nx must be finite in mesh \"" + mesh.
name +
"\"");
66 throw BDSException(__METHOD_NAME__,
"ny must be finite in mesh \"" + mesh.
name +
"\"");
69 throw BDSException(__METHOD_NAME__,
"nz must be finite in mesh \"" + mesh.
name +
"\"");
73 else if (geometryType ==
"cylindrical")
76 throw BDSException(__METHOD_NAME__,
"zsize must be finite in mesh \"" + mesh.
name +
"\"");
79 throw BDSException(__METHOD_NAME__,
"rsize must be finite in mesh \"" + mesh.
name +
"\"");
82 throw BDSException(__METHOD_NAME__,
"nz must be finite in mesh \"" + mesh.
name +
"\"");
85 throw BDSException(__METHOD_NAME__,
"nphi must be finite in mesh \"" + mesh.
name +
"\"");
88 throw BDSException(__METHOD_NAME__,
"nr must be finite in mesh \"" + mesh.
name +
"\"");
93 xLow = -0.5*mesh.
xsize * CLHEP::m;
94 xHigh = 0.5*mesh.
xsize * CLHEP::m;
95 yLow = -0.5*mesh.
ysize * CLHEP::m;
96 yHigh = 0.5*mesh.
ysize * CLHEP::m;
97 zLow = -0.5*mesh.
zsize * CLHEP::m;
98 zHigh = 0.5*mesh.
zsize * CLHEP::m;
100 rHigh = mesh.
rsize * CLHEP::m;
101 eLow = mesh.
eLow* CLHEP::GeV;
102 eHigh = mesh.
eHigh* CLHEP::GeV;
109 if (eScale ==
"user")
112 std::ifstream file(BinsEdgesFile.c_str());
117 std::istream_iterator<double> it(file);
118 std::istream_iterator<double> end;
119 std::back_insert_iterator<std::vector<double>> it2(eBinsEdges);
121 std::copy(it, end, it2);
124 {
throw BDSException(__METHOD_NAME__,
"eBinsEdgesFilenamePath must be the path to a .txt file");}
126 nBinsE = (G4int)eBinsEdges.size()-1;
127 eLow = eBinsEdges[0];
128 eHigh = eBinsEdges[nBinsE];
134 if (eScale ==
"linear")
135 {energyAxis =
new boost_histogram_linear_axis(nBinsE, eLow, eHigh,
"energy");}
136 else if (eScale ==
"log")
137 {energyAxis =
new boost_histogram_log_axis(nBinsE, eLow, eHigh,
"energy");}
138 else if (eScale ==
"user")
140 std::vector<double> eBinsEdgesEnergyAxis = eBinsEdges;
141 std::for_each(eBinsEdgesEnergyAxis.begin(), eBinsEdgesEnergyAxis.end(), [](
double& el){el *= CLHEP::GeV;});
142 energyAxis =
new boost_histogram_variable_axis(eBinsEdgesEnergyAxis,
"energy");
145 {
throw BDSException(__METHOD_NAME__,
"eScale must be 'linear', 'log' or 'user' in mesh \"" + mesh.
name +
"\"");}
General exception with possible name of object and message.
Holder for +- extents in 3 dimensions.
ScorerMesh class for parser.
int ny
Number of bins in y.
int ne
Number of bins in E.
int nx
Number of bins in x.
int nphi
Number of bins in Phi.
int nz
Number of bins in z.
std::string eScale
E scaling type.
std::string name
Name of this placement.
double xsize
X total width.
double eHigh
E High limit.
int nr
Number of bins in R.
double ysize
Y total width.
std::string geometryType
Name of scorermesh geometry to use.
double rsize
R total length.
std::string eBinsEdgesFilenamePath
E bins edges filename path.
double zsize
Z total width.
G4String LowerCase(const G4String &str)
Utility function to simplify lots of syntax changes for pedantic g4 changes.
G4bool IsFinite(G4double value, G4double tolerance=std::numeric_limits< double >::epsilon())