1
0
Fork 0
mirror of https://github.com/gwm17/Mask.git synced 2024-11-22 18:28:51 -05:00

Modified reading in of layered target data to be more intuitive, which lead to finding and fixing a bug in the logic for handling zero thickness or zero energy EnergyLoss::GetEnergyLoss calls

This commit is contained in:
Gordon McCann 2021-10-08 15:41:23 -04:00
parent e24b949e48
commit 1a10000556
4 changed files with 24 additions and 24 deletions

View File

@ -14,15 +14,13 @@
*/
struct ELossException : public std::exception {
ELossException(const std::string& error) {
m_error = error;
m_error = "Failure to calculate particle energy loss. Reason: " + error + " See KinematicsExceptions.h for documentation.";
}
std::string m_error;
const char* what() const noexcept {
std::string err_str = "Failure to calculate particle energy loss. Reason: ";
err_str += m_error + " See KinematicsExceptions.h for documentation.";
return err_str.c_str();
return m_error.c_str();
};
};

View File

@ -8,15 +8,14 @@ Z A (order is target, projectile, ejectile, break1, break3(if pure decay is targ
1 1
2 4
----------Target Information----------
Name: test_targ
Layers: 1
~Layer1
NumberOfLayers: 2
begin_layer
Thickness(ug/cm^2): 50
Z A Stoich
1 2 2
6 12 1
0
~
begin_elements (Z, A, Stoich.)
element 1 2 2
element 6 12 1
end_elements
end_layer
----------Sampling Information----------
NumberOfSamples: 100000
BeamMeanEnergy(MeV): 0.87 BeamEnergySigma(MeV): 0.0

View File

@ -50,6 +50,9 @@ namespace Mask {
MP = MassLookup::GetInstance().FindMass(ZP, AP)*MEV2U;
}
if(thickness == 0.0 || e_initial == 0.0)
return 0;
double e_final = e_initial;
double x_traversed = 0;
double x_step = 0.25*thickness; //initial step in x
@ -58,10 +61,6 @@ namespace Mask {
int depth=0;
if(thickness == 0.0 || e_initial == 0.0)
return 0;
bool go = true;
while(go) {
//If intial guess of step size is too large, shrink until in range

View File

@ -93,17 +93,21 @@ namespace Mask {
double thickness;
getline(input, junk);
getline(input, junk);
input>>junk>>junk;
input>>junk>>nlayers;
for(int i=0; i<nlayers; i++)
{
input>>junk>>junk>>thickness;
getline(input, junk);
getline(input, junk);
avec.clear(); zvec.clear(); svec.clear();
while(input>>z) {
if(z == 0) break;
input>>a>>s;
while(input>>junk)
{
if(junk == "begin_elements")
{
input>>junk>>junk>>junk;
continue;
}
else if (junk == "end_elements")
break;
input>>z>>a>>s;
zvec.push_back(z); avec.push_back(a); svec.push_back(s);
}
sys->AddTargetLayer(zvec, avec, svec, thickness);