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

248 lines
8.9 KiB
C
Raw Normal View History

2017-07-25 12:19:11 -04:00
/*
* Author: Andrej Prochazka
* Copyright(C) 2017
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CPPATIMA_H
#define CPPATIMA_H
#include <utility>
2018-02-14 05:53:56 -05:00
#include <vector>
2017-07-25 12:19:11 -04:00
// #define NDEBUG
2018-10-21 16:08:16 -04:00
#include "catima/build_config.h"
2017-07-25 12:19:11 -04:00
#include "catima/config.h"
#include "catima/constants.h"
#include "catima/structures.h"
#include "catima/calculations.h"
#include "catima/material_database.h"
2018-02-26 17:20:42 -05:00
#include "catima/storage.h"
2017-07-25 12:19:11 -04:00
namespace catima{
/**
* calculate dEdx for projectile-Material combination
* @param p - Projectile
* @param mat - Material
* @return dEdx
*/
2020-08-05 12:20:16 -04:00
double dedx(const Projectile &p, const Material &mat, const Config &c=default_config);
2019-05-13 14:51:09 -04:00
2017-07-25 12:19:11 -04:00
/**
* calculate energy loss straggling variance for projectile-Material combination
* @param p - Projectile
2019-05-13 14:51:09 -04:00
* @param t - Material
2017-07-25 12:19:11 -04:00
* @return dOmega^2/dx
*/
2020-08-05 12:20:16 -04:00
double domega2dx(const Projectile &p, const Material &t, const Config &c=default_config);
2017-07-25 12:19:11 -04:00
/**
* calculates variance of angular scattering of Projectile p on Material m
*/
2020-08-05 12:20:16 -04:00
double da2dx(const Projectile &p, const Material &m, const Config &c=default_config);
2017-07-25 12:19:11 -04:00
/**
* returns the range of the Projectile in Material calculated from range spline
* @param p - Projectile
2019-05-13 14:51:09 -04:00
* @param t - Material
2017-07-25 12:19:11 -04:00
* @return range
*/
2020-08-05 12:20:16 -04:00
double range(const Projectile &p, const Material &t, const Config &c=default_config);
2017-07-25 12:19:11 -04:00
/**
* returns the dEdx calculated from range spline as derivative
* @param p - Projectile
2019-05-13 14:51:09 -04:00
* @param t - Material
2017-07-25 12:19:11 -04:00
* @return range
*/
2020-08-05 12:20:16 -04:00
double dedx_from_range(const Projectile &p, const Material &t, const Config &c=default_config);
2017-07-25 12:19:11 -04:00
2018-02-14 05:53:56 -05:00
/**
* returns the dEdx calculated from range spline as derivative
* @param p - Projectile
* @param T - energy vector
* @param mat - Material
* @return range
*/
2020-08-05 12:20:16 -04:00
std::vector<double> dedx_from_range(const Projectile &p, const std::vector<double> &T, const Material &t, const Config &c=default_config);
2018-02-14 05:53:56 -05:00
2017-07-25 12:19:11 -04:00
/**
* returns the range straggling of the Projectile in Material from spline
* @param p - Projectile
* @param T - energy in MeV/u
* @param mat - Material
* @return range straggling
*/
2020-08-05 12:20:16 -04:00
double range_straggling(const Projectile &p, double T, const Material &t, const Config &c=default_config);
2017-07-25 12:19:11 -04:00
/**
* returns the range variance of the Projectile in Material from spline
* @param p - Projectile
* @param T - energy in MeV/u
* @param mat - Material
* @return range straggling
*/
2020-08-05 12:20:16 -04:00
double range_variance(const Projectile &p, double T, const Material &t, const Config &c=default_config);
2017-07-25 12:19:11 -04:00
/**
* returns the range variance per dE, calculated as derivative of range variance spline
* @param p - Projectile
* @param T - energy in MeV/u
* @param mat - Material
* @return range variance / dE
*/
2020-08-05 12:20:16 -04:00
double domega2de(const Projectile &p, double T, const Material &t, const Config &c=default_config);
2017-07-25 12:19:11 -04:00
/**
* returns the angular variance per dE, calculated as derivative of angular variance spline
* @param p - Projectile
* @param T - energy in MeV/u
* @param mat - Material
* @return angular variance / dE
*/
2020-08-05 12:20:16 -04:00
double da2de(const Projectile &p, double T, const Material &t, const Config &c=default_config);
2017-07-25 12:19:11 -04:00
2020-12-16 16:53:44 -05:00
/**
* returns the planar RMS angular straggling in rad
* @param p - Projectile
* @param t - Material class
* @param c - Config class
* @return angular RMS straggling in rad
*/
double angular_straggling(Projectile p, const Material &t, const Config &c=default_config);
/**
* returns the planar RMS angular variance in rad
* @param p - Projectile
* @param t - Material class
* @param c - Config class
* @return angular RMS variance in rad
*/
double angular_variance(Projectile p, const Material &t, const Config &c=default_config, int order = 0);
2020-12-16 16:53:44 -05:00
2017-07-25 12:19:11 -04:00
/**
* calculates angular scattering in the material from difference of incoming a nd outgoing energies
* @param p - Projectile
* @param T - incoming energy
* @param Tout - outcoming energy
* @param mat - Material
* @return angular straggling
*/
2020-12-16 16:53:44 -05:00
double angular_straggling_from_E(const Projectile &p, double T, double Tout,Material t, const Config &c=default_config);
2017-07-25 12:19:11 -04:00
/**
* calculates Energy straggling in the material from difference of incoming a nd outgoing energies
* @param p - Projectile
* @param T - incoming energy
* @param Tout - outcoming energy
* @param mat - Material
* @return angular straggling
*/
2020-08-05 12:20:16 -04:00
double energy_straggling_from_E(const Projectile &p, double T, double Tout,const Material &t, const Config &c=default_config);
2020-12-16 16:53:44 -05:00
2017-07-25 12:19:11 -04:00
/**
* calculates outcoming energy from range spline
* @param T - incoming energy
* @thickness - thicnkess of the target in g/cm2
* @range_spline - precaclulated range spline for material
* @return outcoming energy after the thickness in Mev/u
*/
2018-10-21 16:08:16 -04:00
double energy_out(double T, double thickness, const Interpolator &range_spline);
2017-07-25 12:19:11 -04:00
/**
* calculates outcoming energy
* @p - Projectile
* @t - Material
* @param T - incoming energy
* @return outcoming energy after the material in Mev/u
*/
2020-08-05 12:20:16 -04:00
double energy_out(const Projectile &p, const Material &t, const Config &c=default_config);
2017-07-25 12:19:11 -04:00
2018-02-14 05:53:56 -05:00
/**
* calculates outcoming energy
* @p - Projectile
* @t - Material
* @param T - incoming energy vector
* @return outcoming energy after the material in Mev/u
*/
2020-08-05 12:20:16 -04:00
std::vector<double> energy_out(const Projectile &p, const std::vector<double> &T, const Material &t, const Config &c=default_config);
2018-02-14 05:53:56 -05:00
2017-07-25 12:19:11 -04:00
/**
* calculates all observables for projectile passing material
* @param p - Projectile
* @param mat - Material
* @return structure of Result
*/
2020-08-05 12:20:16 -04:00
Result calculate(Projectile p, const Material &t, const Config &c=default_config);
inline Result calculate(Projectile p, const Material &t, double T, const Config &c=default_config){
2017-07-25 12:19:11 -04:00
p.T = T;
return calculate(p, t, c);
}
/**
* wrapper to other calculate function with simplified arguments
* @param p - Projectile
* @param mat - Material
* @return structure of Result
*/
Result calculate(double pa, int pz, double T, double ta, double tz, double thickness, double density);
/**
* calculate observables for multiple layers of material defined by Layers
* @return results stored in MultiResult structure
*
*/
2022-03-23 10:35:57 -04:00
MultiResult calculate(const Projectile &p, const Phasespace &ps, const Layers &layers, const Config &c=default_config);
/**
* calculate observables for multiple layers of material defined by Layers
* @return results stored in MultiResult structure
*
*/
inline MultiResult calculate(const Projectile &p, const Layers &layers, const Config &c=default_config){
return calculate(p, {}, layers, c);
};
2020-08-05 12:20:16 -04:00
inline MultiResult calculate(Projectile p, double T, const Layers &layers, const Config &c=default_config){
return calculate(p(T), layers, c);
2017-07-25 12:19:11 -04:00
}
2019-05-13 14:51:09 -04:00
/// this calculate tof spline, at the moment it is not used
2020-08-05 12:20:16 -04:00
std::vector<double> calculate_tof(const Projectile p, const Material &t, const Config &c=default_config);
2017-07-25 12:19:11 -04:00
/**
* calculates TOF of the Projectile in Material
* this is used instead of precalculated TOF spline
* @return TOF in ns
*/
double calculate_tof_from_E(Projectile p, double Eout, const Material &t, const Config &c=default_config);
2018-02-14 09:04:49 -05:00
/**
* returns energy magnification after passing material t
*/
2020-08-05 12:20:16 -04:00
std::pair<double,double> w_magnification(const Projectile &p, double Ein, const Material &t, const Config &c=default_config);
2018-02-14 09:04:49 -05:00
2017-07-25 12:19:11 -04:00
class DataPoint;
/**
* calculates DataPoint for Projectile Material combinatino
* it substitute series of calls to calculate_* functions
* they are all combined here in 1 single function
* it has a perfomance gain to call this function if all splines are to be caclulated
*/
DataPoint calculate_DataPoint(Projectile p, const Material &t, const Config &c=default_config);
bool operator==(const Config &a, const Config&b);
}
#endif