19#include "BDSException.hh"
20#include "BDSExtent.hh"
21#include "BDSScorerMeshInfo.hh"
22#include "BDSUtilities.hh"
24#include "BDSBH4DTypeDefs.hh"
29#include "parser/scorermesh.h"
31#include "CLHEP/Units/SystemOfUnits.h"
40 name = G4String(mesh.
name);
49 if (geometryType ==
"box")
52 {
throw BDSException(__METHOD_NAME__,
"xsize must be > 0 and finite in mesh \"" + mesh.
name +
"\"");}
54 {
throw BDSException(__METHOD_NAME__,
"ysize must be > 0 and finite in mesh \"" + mesh.
name +
"\"");}
56 {
throw BDSException(__METHOD_NAME__,
"zsize must be > 0 and finite in mesh \"" + mesh.
name +
"\"");}
58 {
throw BDSException(__METHOD_NAME__,
"nx must be > 0 and finite in mesh \"" + mesh.
name +
"\"");}
60 {
throw BDSException(__METHOD_NAME__,
"ny must be > 0 and finite in mesh \"" + mesh.
name +
"\"");}
62 {
throw BDSException(__METHOD_NAME__,
"nz must be > 0 and finite in mesh \"" + mesh.
name +
"\"");}
64 else if (geometryType ==
"cylindrical")
67 {
throw BDSException(__METHOD_NAME__,
"zsize must be > 0 and finite in mesh \"" + mesh.
name +
"\"");}
69 {
throw BDSException(__METHOD_NAME__,
"rHigh must be > 0 and finite in mesh \"" + mesh.
name +
"\"");}
71 {
throw BDSException(__METHOD_NAME__,
"nz must be > 0 and finite in mesh \"" + mesh.
name +
"\"");}
73 {
throw BDSException(__METHOD_NAME__,
"nphi must be > 0 and finite in mesh \"" + mesh.
name +
"\"");}
75 {
throw BDSException(__METHOD_NAME__,
"nr must be > 0 and finite in mesh \"" + mesh.
name +
"\"");}
78 xLow = -0.5*mesh.
xsize * CLHEP::m;
79 xHigh = 0.5*mesh.
xsize * CLHEP::m;
80 yLow = -0.5*mesh.
ysize * CLHEP::m;
81 yHigh = 0.5*mesh.
ysize * CLHEP::m;
82 zLow = -0.5*mesh.
zsize * CLHEP::m;
83 zHigh = 0.5*mesh.
zsize * CLHEP::m;
84 rInner = mesh.
rInner * CLHEP::m;
85 rOuter = mesh.
rOuter * CLHEP::m;
86 eLow = mesh.
eLow * CLHEP::GeV;
87 eHigh = mesh.
eHigh * CLHEP::GeV;
94 BDSExtent extentCylindrical(-rOuter, rOuter,
102 std::ifstream file(BinsEdgesFile.c_str());
107 std::istream_iterator<double> it(file);
108 std::istream_iterator<double> end;
109 std::back_insert_iterator<std::vector<double>> it2(eBinsEdges);
111 std::copy(it, end, it2);
114 {
throw BDSException(__METHOD_NAME__,
"eBinsEdgesFilenamePath must be the path to a .txt file");}
116 nBinsE = (G4int)eBinsEdges.size()-1;
117 eLow = eBinsEdges[0];
118 eHigh = eBinsEdges[nBinsE];
124 if (eScale ==
"linear")
125 {energyAxis =
new boost_histogram_linear_axis(nBinsE, eLow, eHigh,
"energy");}
126 else if (eScale ==
"log")
127 {energyAxis =
new boost_histogram_log_axis(nBinsE, eLow, eHigh,
"energy");}
128 else if (eScale ==
"user")
130 std::vector<double> eBinsEdgesEnergyAxis = eBinsEdges;
131 std::for_each(eBinsEdgesEnergyAxis.begin(), eBinsEdgesEnergyAxis.end(), [](
double& el){el *= CLHEP::GeV;});
132 energyAxis =
new boost_histogram_variable_axis(eBinsEdgesEnergyAxis,
"energy");
135 {
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.
void ExpandToEncompass(const BDSExtent &other)
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.
double rInner
Inner radius of cylindrical scoring mesh.
int nz
Number of bins in z.
std::string eScale
E scaling type.
std::string name
Name of this placement.
double rOuter
Outer radius of cylindrical scoring mesh.
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.
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())