// // functions.hpp // mc_electron // // Created by Christian Reiling on 07.02.19. // Copyright © 2019 Christian Reiling. All rights reserved. // #ifndef functions_hpp #define functions_hpp #include #include #include #include #include #include typedef blitz::TinyVector vec3; // Custom Error Type struct MyException : public std::exception { std::string s; MyException(std::string errorMessage) : s(errorMessage) {} ~MyException() throw () {} const char* what() const throw() { return s.c_str(); } }; // Read Parameters from file double getParameter(std::string parName); //String Manipulations for Read in from files std::string getEnv (std::string envName); // string version of C function getenv. void makePath (std::string &path); // append '/' if necessary to path. bool checkIgnoreLine(std::string lineFromFile); // true if line is empty or starts with # void removeLeadingWhites(std::string &lineFromFile); void replaceDelimiter(std::string &lineFromFile); // replaces delimiter (';'',''=') with whitespace // Calculate Kinematic Relations double get_Speed_from_Ekin_eV(double Ekin_eV, double mass_eV); double get_gamma_from_Ekin_eV(double Ekin_eV, double mass_eV); double get_beta_from_gamma(double gamma); double get_Ekin_eV_from_speed(double Speed, double mass_eV); double get_gamma_from_beta(double beta); // Operations on 3 dimensional Vectors double get_vecAbs(vec3 vec); vec3 get_Newdirection(vec3 oldDir, double theta,double phi); // Calculates new Direction after Interaction with (theta, phi) // Functions for Random Sampling vec3 roll_uniform_direction(ranlib::Uniform *rngUni); double roll_MBEnergy(double Temp_K,double mass_eV,ranlib::NormalUnit *rngNormal); double doRejectionMethod(double pdf(double), double xmin, double xmax, double pmax, ranlib::Uniform *rngUni); #endif /* functions_hpp */