Commit 642d97d5 authored by ext-calvo_p's avatar ext-calvo_p
Browse files

Resolve "Bethe-Bloch threshold"

parent 4a699d99
......@@ -91,7 +91,8 @@ namespace {
CollimatorPhysics::CollimatorPhysics(const std::string &name,
ElementBase *element,
std::string &material,
bool enableRutherford):
bool enableRutherford,
double lowEnergyThr):
ParticleMatterInteractionHandler(name, element),
T_m(0.0),
dT_m(0.0),
......@@ -113,7 +114,8 @@ CollimatorPhysics::CollimatorPhysics(const std::string &name,
Eavg_m(0.0),
Emax_m(0.0),
Emin_m(0.0),
enableRutherford_m(enableRutherford)
enableRutherford_m(enableRutherford),
lowEnergyThr_m(lowEnergyThr)
{
gsl_rng_env_setup();
......@@ -339,7 +341,7 @@ bool CollimatorPhysics::computeEnergyLoss(Vector_t &P,
beta = std::sqrt(1.0 - 1.0 / std::pow(gamma, 2));
P = gamma * beta * P / euclidean_norm(P);
bool stopped = (Ekin < 10 || dEdx > 0);
bool stopped = (Ekin < lowEnergyThr_m * 1e3 || dEdx > 0);
return stopped;
}
......
......@@ -67,7 +67,8 @@ public:
CollimatorPhysics(const std::string &name,
ElementBase *element,
std::string &mat,
bool enableRutherford);
bool enableRutherford,
double lowEnergyThr);
~CollimatorPhysics();
virtual void apply(PartBunchBase<double, 3> *bunch,
......@@ -156,6 +157,7 @@ private:
std::unique_ptr<LossDataSink> lossDs_m;
bool enableRutherford_m;
double lowEnergyThr_m;
IpplTimings::TimerRef DegraderApplyTimer_m;
IpplTimings::TimerRef DegraderLoopTimer_m;
......
......@@ -40,6 +40,7 @@ namespace {
TYPE,
MATERIAL,
ENABLERUTHERFORD,
LOWENERGYTHR,
SIZE
};
}
......@@ -58,6 +59,9 @@ ParticleMatterInteraction::ParticleMatterInteraction():
itsAttr[ENABLERUTHERFORD] = Attributes::makeBool
("ENABLERUTHERFORD", "Enable large angle scattering", true);
itsAttr[LOWENERGYTHR] = Attributes::makeReal
("LOWENERGYTHR", "Lower Energy threshold for energy loss calculation [MeV]. Default = 0.01 MeV", 0.01);
ParticleMatterInteraction* defParticleMatterInteraction = clone("UNNAMED_PARTICLEMATTERINTERACTION");
defParticleMatterInteraction->builtin = true;
......@@ -118,15 +122,16 @@ void ParticleMatterInteraction::update() {
void ParticleMatterInteraction::initParticleMatterInteractionHandler(ElementBase& element) {
std::string material = Attributes::getString(itsAttr[MATERIAL]);
bool enableRutherford = Attributes::getBool(itsAttr[ENABLERUTHERFORD]);
const std::string type = Attributes::getString(itsAttr[TYPE]);
std::string material = Attributes::getString(itsAttr[MATERIAL]);
bool enableRutherford = Attributes::getBool(itsAttr[ENABLERUTHERFORD]);
double lowEnergyThr = Attributes::getReal(itsAttr[LOWENERGYTHR]);
if (type.empty()) {
throw OpalException("ParticleMatterInteraction::initParticleMatterInteractionHandler",
"TYPE is not defined for PARTICLEMATTERINTERACTION");
} else if (type == "COLLIMATOR" || type == "DEGRADER") {
handler_m = new CollimatorPhysics(getOpalName(), &element, material, enableRutherford);
handler_m = new CollimatorPhysics(getOpalName(), &element, material, enableRutherford, lowEnergyThr);
*gmsg << *this << endl;
} else if (type == "BEAMSTRIPPING") {
handler_m = new BeamStrippingPhysics(getOpalName(), &element);
......@@ -146,9 +151,11 @@ void ParticleMatterInteraction::print(std::ostream& os) const {
os << "* ************* P A R T I C L E M A T T E R I N T E R A C T I O N ****************** " << std::endl;
os << "* PARTICLEMATTERINTERACTION " << getOpalName() << '\n'
<< "* TYPE " << Attributes::getString(itsAttr[TYPE]) << '\n';
if ( Attributes::getString(itsAttr[TYPE]) != "BEAMSTRIPPING" )
if ( Attributes::getString(itsAttr[TYPE]) != "BEAMSTRIPPING" ) {
os << "* MATERIAL " << Attributes::getString(itsAttr[MATERIAL]) << '\n';
os << "* LOWENERGYTHR " << Attributes::getReal(itsAttr[LOWENERGYTHR]) << " MeV" << '\n';
}
os << "* ********************************************************************************** " << std::endl;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment