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 > 0 and finite in mesh \"" + mesh.
name +
"\"");}
55 {
throw BDSException(__METHOD_NAME__,
"ysize must be > 0 and finite in mesh \"" + mesh.
name +
"\"");}
57 {
throw BDSException(__METHOD_NAME__,
"zsize must be > 0 and finite in mesh \"" + mesh.
name +
"\"");}
59 {
throw BDSException(__METHOD_NAME__,
"nx must be > 0 and finite in mesh \"" + mesh.
name +
"\"");}
61 {
throw BDSException(__METHOD_NAME__,
"ny must be > 0 and finite in mesh \"" + mesh.
name +
"\"");}
63 {
throw BDSException(__METHOD_NAME__,
"nz must be > 0 and finite in mesh \"" + mesh.
name +
"\"");}
65 else if (geometryType ==
"cylindrical")
68 {
throw BDSException(__METHOD_NAME__,
"zsize must be > 0 and finite in mesh \"" + mesh.
name +
"\"");}
70 {
throw BDSException(__METHOD_NAME__,
"rsize must be > 0 and finite in mesh \"" + mesh.
name +
"\"");}
72 {
throw BDSException(__METHOD_NAME__,
"nz must be > 0 and finite in mesh \"" + mesh.
name +
"\"");}
74 {
throw BDSException(__METHOD_NAME__,
"nphi must be > 0 and finite in mesh \"" + mesh.
name +
"\"");}
76 {
throw BDSException(__METHOD_NAME__,
"nr must be > 0 and finite in mesh \"" + mesh.
name +
"\"");}
79 xLow = -0.5*mesh.
xsize * CLHEP::m;
80 xHigh = 0.5*mesh.
xsize * CLHEP::m;
81 yLow = -0.5*mesh.
ysize * CLHEP::m;
82 yHigh = 0.5*mesh.
ysize * CLHEP::m;
83 zLow = -0.5*mesh.
zsize * CLHEP::m;
84 zHigh = 0.5*mesh.
zsize * CLHEP::m;
86 rHigh = mesh.
rsize * CLHEP::m;
87 eLow = mesh.
eLow* CLHEP::GeV;
88 eHigh = mesh.
eHigh* CLHEP::GeV;
98 std::ifstream file(BinsEdgesFile.c_str());
103 std::istream_iterator<double> it(file);
104 std::istream_iterator<double> end;
105 std::back_insert_iterator<std::vector<double>> it2(eBinsEdges);
107 std::copy(it, end, it2);
110 {
throw BDSException(__METHOD_NAME__,
"eBinsEdgesFilenamePath must be the path to a .txt file");}
112 nBinsE = (G4int)eBinsEdges.size()-1;
113 eLow = eBinsEdges[0];
114 eHigh = eBinsEdges[nBinsE];
120 if (eScale ==
"linear")
121 {energyAxis =
new boost_histogram_linear_axis(nBinsE, eLow, eHigh,
"energy");}
122 else if (eScale ==
"log")
123 {energyAxis =
new boost_histogram_log_axis(nBinsE, eLow, eHigh,
"energy");}
124 else if (eScale ==
"user")
126 std::vector<double> eBinsEdgesEnergyAxis = eBinsEdges;
127 std::for_each(eBinsEdgesEnergyAxis.begin(), eBinsEdgesEnergyAxis.end(), [](
double& el){el *= CLHEP::GeV;});
128 energyAxis =
new boost_histogram_variable_axis(eBinsEdgesEnergyAxis,
"energy");
131 {
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())