/* * PhysicsUtil.cc * * Created on: May 26, 2017 * Author: nbarros */ #include #include #include #include using CLHEP::twopi; using CLHEP::m; using CLHEP::GeV; using CLHEP::MeV; using CLHEP::nm; namespace RAT{ namespace util { static const double LambdaE = twopi*1.973269602e-16 * m * GeV; double EnergyToWavelength(const double& energy) { if (energy <= 0.0) { RAT::Log::Die("EnergyToWavelength: Warning, zero or negative energy provided!\n"); return 0.0; } return (LambdaE/energy)/nm; } double WavelengthToEnergy(const double& wavelength) { if (wavelength <= 0.0) { RAT::Log::Die("WavelengthToEnergy: Warning, zero or negative wavelength provided!\n"); return 0.0; } return (LambdaE/wavelength)/MeV; } int round_2_int(const double& f) { return (int)(f >= 0.0 ? (f + 0.5) : (f - 0.5)); } int round_2_int(const float& f) { return (int)(f >= 0.0 ? (f + 0.5) : (f - 0.5)); } } }