diff --git a/catima.cpp b/catima.cpp index d88489a..3592c20 100644 --- a/catima.cpp +++ b/catima.cpp @@ -418,4 +418,20 @@ double calculate_tof_from_E(Projectile p, double Eout, const Material &t, const return res; } +double w_magnification(Projectile p, double Ein, const Material &t, const Config &c){ + double res = 1.0; + if(t.density()<= 0.0 || t.thickness()<=0){ + return res; + } + std::vector energies{0.99*Ein, Ein, 1.1*Ein}; + auto eres = energy_out(p,energies,t,c); + if(eres[0]>0.0 && eres[1]>0.0 && eres[2]>0.0){ + res = energies[1]*(eres[2]-eres[0])/(eres[1]*(energies[2]-energies[0])); + } + else { + res = 0.0; + } + return res; +} + } // end of atima namespace diff --git a/catima.h b/catima.h index a4efbe6..8608d27 100644 --- a/catima.h +++ b/catima.h @@ -209,6 +209,11 @@ namespace catima{ */ double calculate_tof_from_E(Projectile p, double Eout, const Material &t, const Config &c=default_config); + /** + * returns energy magnification after passing material t + */ + double w_magnification(Projectile p, double Ein, const Material &t, const Config &c=default_config); + class DataPoint; /** * calculates DataPoint for Projectile Material combinatino diff --git a/catima.pyx b/catima.pyx index 88afac6..78ff5f8 100644 --- a/catima.pyx +++ b/catima.pyx @@ -450,6 +450,11 @@ def energy_out(Projectile projectile, Material material, energy = None, Config c energy = projectile.T() return catimac.energy_out(projectile.cbase, energy, material.cbase, config.cbase) +def w_magnification(Projectile projectile, Material material, energy = None, Config config = default_config): + if(energy is None): + energy = projectile.T() + return catimac.w_magnification(projectile.cbase,energy, material.cbase, config.cbase) + def sezi_dedx_e(Projectile projectile, Target t): return catimac.sezi_dedx_e(projectile.cbase, t.cbase) diff --git a/catimac.pxd b/catimac.pxd index 8edc2ad..ba77aba 100644 --- a/catimac.pxd +++ b/catimac.pxd @@ -87,6 +87,8 @@ cdef extern from "catima/catima.h" namespace "catima": cdef Result calculate(Projectile &p, const Material &t, const Config &c); cdef MultiResult calculate(Projectile &p, const Layers &layers, const Config &c); + cdef double w_magnification(Projectile p, double E, const Material &t, const Config &c); + cdef extern from "catima/calculations.h" namespace "catima": cdef double bethek_lindhard(const Projectile &p); cdef double bethek_lindhard_X(const Projectile &p);