Added myexeption to throw errors and show using MyExeption class.
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "functions.hpp"
|
||||
|
||||
#include "myexeption.h"
|
||||
#include <sstream>
|
||||
|
||||
using namespace std;
|
||||
@@ -23,11 +24,11 @@ double calc_Ekin_eV_from_speed(double Speed_ms, double mass_eV) {
|
||||
if (beta>=1) {
|
||||
stringstream ss;
|
||||
ss<<"calc_Ekin_eV_from_speed(): Input speed v="<<Speed_ms<<" m/s equal or exeeds speed of light.";
|
||||
throw (ss.str());
|
||||
throw MyException(ss.str());
|
||||
} else if (beta<0) {
|
||||
stringstream ss;
|
||||
ss<<"calc_Ekin_eV_from_speed(): Input speed v="<<Speed_ms<<" m/s is expected to be absolute value therfore >0.";
|
||||
throw (ss.str());
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
double gamma = calc_gamma_from_beta(beta);
|
||||
return ( (gamma-1) * mass_eV );
|
||||
@@ -37,11 +38,11 @@ double calc_gamma_from_beta(double beta) {
|
||||
if (beta>=1) {
|
||||
stringstream ss;
|
||||
ss<<"calc_gamma_from_beta(): Input beta ="<<beta<<" equal or exeeds 1.";
|
||||
throw (ss.str());
|
||||
throw MyException(ss.str());
|
||||
} else if (beta<0) {
|
||||
stringstream ss;
|
||||
ss<<"calc_gamma_from_beta(): Input beta ="<<beta<<" negative.";
|
||||
throw (ss.str());
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
|
||||
return( pow(1 - pow(beta,2),-0.5) ) ;
|
||||
@@ -51,7 +52,7 @@ double calc_Speed_from_Ekin_eV(double Ekin_eV, double mass_eV) {
|
||||
if (Ekin_eV<0) {
|
||||
stringstream ss;
|
||||
ss<<"calc_Speed_from_Ekin_eV(): Input Ekin_eV ="<<Ekin_eV<<" negative.";
|
||||
throw (ss.str());
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
|
||||
double gamma = calc_gamma_from_Ekin_eV(Ekin_eV, mass_eV);
|
||||
@@ -63,7 +64,7 @@ double calc_gamma_from_Ekin_eV(double Ekin_eV, double mass_eV) {
|
||||
if (Ekin_eV<0) {
|
||||
stringstream ss;
|
||||
ss<<"calc_gamma_from_Ekin_eV(): Input Ekin_eV ="<<Ekin_eV<<" negative.";
|
||||
throw (ss.str());
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
return (1. + Ekin_eV/mass_eV);
|
||||
}
|
||||
@@ -72,7 +73,7 @@ double calc_beta_from_gamma(double gamma) {
|
||||
if (gamma<1) {
|
||||
stringstream ss;
|
||||
ss<<"calc_beta_from_gamma(): Input gamma ="<<gamma<<" smaller 1.";
|
||||
throw (ss.str());
|
||||
throw MyException(ss.str());
|
||||
}
|
||||
return( sqrt(1 - pow(gamma,-2)) );
|
||||
}
|
||||
@@ -112,7 +113,7 @@ endloops:
|
||||
for (int j = 0;j<3;j++) {
|
||||
cout<<"phi1c["<<j<<"]="<<phi_new_candidates[j]<<endl;
|
||||
}
|
||||
throw ("Interaction::getElaNewDir: phi1 not found.");
|
||||
throw MyException("Interaction::getElaNewDir: phi1 not found.");
|
||||
}
|
||||
return(vec3(sin(theta_new)*cos(phi_new) , sin(theta_new)*sin(phi_new) , cos(theta_new)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user