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 { struct ELossException : public std::exception {
ELossException(const std::string& error) { 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; std::string m_error;
const char* what() const noexcept { const char* what() const noexcept {
std::string err_str = "Failure to calculate particle energy loss. Reason: "; return m_error.c_str();
err_str += m_error + " See KinematicsExceptions.h for documentation.";
return err_str.c_str();
}; };
}; };

View File

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

View File

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

View File

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