Commit b3f71913 authored by ext-calvo_p's avatar ext-calvo_p
Browse files

Merge branch '530-cleanup-src-remove-using-namespace-std' into 'master'

Resolve "cleanup src: remove using namespace std"

Closes #530

See merge request !349
parents e7812d0b 0530b5ea
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
// /DTA // /DTA
#define MAX_NUM_INSTANCES 10 #define MAX_NUM_INSTANCES 10
using namespace std;
// Class OpalData::ClearReference // Class OpalData::ClearReference
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
...@@ -524,8 +524,8 @@ void OpalData::define(Object *newObject) { ...@@ -524,8 +524,8 @@ void OpalData::define(Object *newObject) {
if(table->isDependent(name)) { if(table->isDependent(name)) {
if(Options::info) { if(Options::info) {
cerr << endl << "Erasing dependent table \"" << tableName std::cerr << std::endl << "Erasing dependent table \""
<< "\"." << endl << endl; << tableName << "\"." << std::endl;
} }
// Remove table from directory. // Remove table from directory.
...@@ -599,8 +599,8 @@ void OpalData::makeDirty(Object *obj) { ...@@ -599,8 +599,8 @@ void OpalData::makeDirty(Object *obj) {
void OpalData::printNames(std::ostream &os, const std::string &pattern) { void OpalData::printNames(std::ostream &os, const std::string &pattern) {
int column = 0; int column = 0;
RegularExpression regex(pattern); RegularExpression regex(pattern);
os << endl << "Object names matching the pattern \"" os << std::endl << "Object names matching the pattern \""
<< pattern << "\":" << endl; << pattern << "\":" << std::endl;
for(ObjectDir::const_iterator index = p->mainDirectory.begin(); for(ObjectDir::const_iterator index = p->mainDirectory.begin();
index != p->mainDirectory.end(); ++index) { index != p->mainDirectory.end(); ++index) {
...@@ -617,14 +617,14 @@ void OpalData::printNames(std::ostream &os, const std::string &pattern) { ...@@ -617,14 +617,14 @@ void OpalData::printNames(std::ostream &os, const std::string &pattern) {
column++; column++;
} while((column % 20) != 0); } while((column % 20) != 0);
} else { } else {
os << endl; os << std::endl;
column = 0; column = 0;
} }
} }
} }
if(column) os << endl; if(column) os << std::endl;
os << endl; os << std::endl;
} }
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "AbstractObjects/RangeRep.h" #include "AbstractObjects/RangeRep.h"
#include "AbstractObjects/Element.h" #include "AbstractObjects/Element.h"
#include <iostream> #include <iostream>
using namespace std;
// Class RangeRep // Class RangeRep
......
...@@ -54,7 +54,6 @@ ...@@ -54,7 +54,6 @@
class Beamline; class Beamline;
class PartData; class PartData;
using Physics::c;
typedef FTps<double, 6> Series; typedef FTps<double, 6> Series;
...@@ -183,7 +182,7 @@ void LieMapper::visitMonitor(const Monitor &corr) { ...@@ -183,7 +182,7 @@ void LieMapper::visitMonitor(const Monitor &corr) {
void LieMapper::visitMultipole(const Multipole &mult) { void LieMapper::visitMultipole(const Multipole &mult) {
double length = mult.getElementLength() * flip_s; double length = mult.getElementLength() * flip_s;
const BMultipoleField &field = mult.getField(); const BMultipoleField &field = mult.getField();
double scale = (flip_B * itsReference.getQ() * c) / itsReference.getP(); double scale = (flip_B * itsReference.getQ() * Physics::c) / itsReference.getP();
if(length) { if(length) {
// Normal case: Finite-length multipole, field coefficients are B. // Normal case: Finite-length multipole, field coefficients are B.
...@@ -231,7 +230,7 @@ void LieMapper::visitRBend(const RBend &bend) { ...@@ -231,7 +230,7 @@ void LieMapper::visitRBend(const RBend &bend) {
// Geometry. // Geometry.
const RBendGeometry &geometry = bend.getGeometry(); const RBendGeometry &geometry = bend.getGeometry();
double length = flip_s * geometry.getElementLength(); double length = flip_s * geometry.getElementLength();
double scale = (flip_B * itsReference.getQ() * c) / itsReference.getP(); double scale = (flip_B * itsReference.getQ() * Physics::c) / itsReference.getP();
const BMultipoleField &field = bend.getField(); const BMultipoleField &field = bend.getField();
if(length) { if(length) {
...@@ -313,7 +312,7 @@ void LieMapper::visitRFCavity(const RFCavity &as) { ...@@ -313,7 +312,7 @@ void LieMapper::visitRFCavity(const RFCavity &as) {
// Compute Hamiltonian. // Compute Hamiltonian.
static const Series t = Series::makeVariable(AbstractMapper::T); static const Series t = Series::makeVariable(AbstractMapper::T);
Series H = peak * cos(as.getPhase() + (freq / c) * t); Series H = peak * cos(as.getPhase() + (freq / Physics::c) * t);
// Build map. // Build map.
DragtFinnMap<3> theMap = DragtFinnMap<3>::factorSimple(H); DragtFinnMap<3> theMap = DragtFinnMap<3>::factorSimple(H);
...@@ -333,7 +332,7 @@ void LieMapper::visitRFQuadrupole(const RFQuadrupole &rfq) { ...@@ -333,7 +332,7 @@ void LieMapper::visitRFQuadrupole(const RFQuadrupole &rfq) {
void LieMapper::visitSBend(const SBend &bend) { void LieMapper::visitSBend(const SBend &bend) {
const PlanarArcGeometry &geometry = bend.getGeometry(); const PlanarArcGeometry &geometry = bend.getGeometry();
double length = flip_s * geometry.getElementLength(); double length = flip_s * geometry.getElementLength();
double scale = (flip_B * itsReference.getQ() * c) / itsReference.getP(); double scale = (flip_B * itsReference.getQ() * Physics::c) / itsReference.getP();
const BMultipoleField &field = bend.getField(); const BMultipoleField &field = bend.getField();
if(length) { if(length) {
...@@ -417,7 +416,7 @@ void LieMapper::visitSolenoid(const Solenoid &solenoid) { ...@@ -417,7 +416,7 @@ void LieMapper::visitSolenoid(const Solenoid &solenoid) {
double length = flip_s * solenoid.getElementLength(); double length = flip_s * solenoid.getElementLength();
if(length) { if(length) {
double ks = (flip_B * itsReference.getQ() * solenoid.getBz() * c) / double ks = (flip_B * itsReference.getQ() * solenoid.getBz() * Physics::c) /
(2.0 * itsReference.getP()); (2.0 * itsReference.getP());
if(ks) { if(ks) {
......
...@@ -29,8 +29,6 @@ ...@@ -29,8 +29,6 @@
#include "FixedAlgebra/FVps.h" #include "FixedAlgebra/FVps.h"
#include "Physics/Physics.h" #include "Physics/Physics.h"
using Physics::c;
// Class MPSplitIntegrator // Class MPSplitIntegrator
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
...@@ -82,7 +80,7 @@ void MPSplitIntegrator::trackMap(FVps<double, 6> &map, ...@@ -82,7 +80,7 @@ void MPSplitIntegrator::trackMap(FVps<double, 6> &map,
double length = itsMultipole->getElementLength(); double length = itsMultipole->getElementLength();
if(revTrack) length = - length; if(revTrack) length = - length;
BMultipoleField field = itsMultipole->getField(); BMultipoleField field = itsMultipole->getField();
double scale = (ref.getQ() * c) / (ref.getP()); double scale = (ref.getQ() * Physics::c) / (ref.getP());
if(revBeam) scale = - scale; if(revBeam) scale = - scale;
if(length) { if(length) {
...@@ -112,7 +110,7 @@ void MPSplitIntegrator::trackParticle(OpalParticle &part, const PartData &ref, ...@@ -112,7 +110,7 @@ void MPSplitIntegrator::trackParticle(OpalParticle &part, const PartData &ref,
double length = itsMultipole->getElementLength(); double length = itsMultipole->getElementLength();
if(revTrack) length = - length; if(revTrack) length = - length;
BMultipoleField field = itsMultipole->getField(); BMultipoleField field = itsMultipole->getField();
double scale = (ref.getQ() * c) / (ref.getP()); double scale = (ref.getQ() * Physics::c) / (ref.getP());
if(revBeam) scale = - scale; if(revBeam) scale = - scale;
if(length) { if(length) {
...@@ -143,7 +141,7 @@ void MPSplitIntegrator::trackBunch(PartBunchBase<double, 3> *bunch, ...@@ -143,7 +141,7 @@ void MPSplitIntegrator::trackBunch(PartBunchBase<double, 3> *bunch,
double length = itsMultipole->getElementLength(); double length = itsMultipole->getElementLength();
if(revTrack) length = - length; if(revTrack) length = - length;
BMultipoleField field = itsMultipole->getField(); BMultipoleField field = itsMultipole->getField();
double scale = (ref.getQ() * c) / (ref.getP()); double scale = (ref.getQ() * Physics::c) / (ref.getP());
if(revBeam) scale = - scale; if(revBeam) scale = - scale;
if(length) { if(length) {
......
...@@ -306,7 +306,7 @@ void MapAnalyser::normalizeEigen_m(cfMatrix_t& eigenVecM, cfMatrix_t& invEigenVe ...@@ -306,7 +306,7 @@ void MapAnalyser::normalizeEigen_m(cfMatrix_t& eigenVecM, cfMatrix_t& invEigenVe
for (int j = 0; j < 6; j += 2){ for (int j = 0; j < 6; j += 2){
temp += 2 * (eigenVecM[j][i] * std::conj(eigenVecM[j+1][i])).imag(); temp += 2 * (eigenVecM[j][i] * std::conj(eigenVecM[j+1][i])).imag();
} }
temp = std::fabs(temp); temp = std::abs(temp);
if (temp > 1e-10){ if (temp > 1e-10){
for (int j = 0; j < 6; j++){ for (int j = 0; j < 6; j++){
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <limits> #include <limits>
#include <vector> #include <vector>
#include <numeric> #include <numeric>
#include <cmath>
#include "AbstractObjects/Element.h" #include "AbstractObjects/Element.h"
#include "AbstractObjects/OpalData.h" #include "AbstractObjects/OpalData.h"
...@@ -82,9 +83,6 @@ ...@@ -82,9 +83,6 @@
#include "Structure/DataSink.h" #include "Structure/DataSink.h"
#include "Structure/LossDataSink.h" #include "Structure/LossDataSink.h"
using Physics::pi;
using Physics::q_e;
constexpr double c_mmtns = Physics::c * 1.0e-6; // m/s --> mm/ns constexpr double c_mmtns = Physics::c * 1.0e-6; // m/s --> mm/ns
...@@ -348,13 +346,13 @@ void ParallelCyclotronTracker::visitRing(const Ring &ring) { ...@@ -348,13 +346,13 @@ void ParallelCyclotronTracker::visitRing(const Ring &ring) {
referencePz = 0.0; referencePz = 0.0;
referencePtot = itsReference.getGamma() * itsReference.getBeta(); referencePtot = itsReference.getGamma() * itsReference.getBeta();
referencePt = sqrt(referencePtot * referencePtot - referencePr * referencePr); referencePt = std::sqrt(referencePtot * referencePtot - referencePr * referencePr);
if(referencePtot < 0.0) if(referencePtot < 0.0)
referencePt *= -1.0; referencePt *= -1.0;
sinRefTheta_m = sin(referenceTheta * Physics::deg2rad); sinRefTheta_m = std::sin(referenceTheta * Physics::deg2rad);
cosRefTheta_m = cos(referenceTheta * Physics::deg2rad); cosRefTheta_m = std::cos(referenceTheta * Physics::deg2rad);
double BcParameter[8] = {}; // zero initialise array double BcParameter[8] = {}; // zero initialise array
...@@ -447,7 +445,7 @@ void ParallelCyclotronTracker::visitCyclotron(const Cyclotron &cycl) { ...@@ -447,7 +445,7 @@ void ParallelCyclotronTracker::visitCyclotron(const Cyclotron &cycl) {
} else { } else {
referencePt = sqrt(insqrt); referencePt = std::sqrt(insqrt);
} }
if(referencePtot < 0.0) if(referencePtot < 0.0)
...@@ -483,8 +481,8 @@ void ParallelCyclotronTracker::visitCyclotron(const Cyclotron &cycl) { ...@@ -483,8 +481,8 @@ void ParallelCyclotronTracker::visitCyclotron(const Cyclotron &cycl) {
} }
} }
sinRefTheta_m = sin(referenceTheta * Physics::deg2rad); sinRefTheta_m = std::sin(referenceTheta * Physics::deg2rad);
cosRefTheta_m = cos(referenceTheta * Physics::deg2rad); cosRefTheta_m = std::cos(referenceTheta * Physics::deg2rad);
*gmsg << endl; *gmsg << endl;
*gmsg << "* Bunch global starting position:" << endl; *gmsg << "* Bunch global starting position:" << endl;
...@@ -1366,7 +1364,7 @@ void ParallelCyclotronTracker::MtsTracker() { ...@@ -1366,7 +1364,7 @@ void ParallelCyclotronTracker::MtsTracker() {
// INFOMSG("No space charge Effects are included!"<<endl;); // INFOMSG("No space charge Effects are included!"<<endl;);
if((step_m % Options::repartFreq * 100) == 0) { //TODO: why * 100? if((step_m % Options::repartFreq * 100) == 0) { //TODO: why * 100?
Vector_t const meanP = calcMeanP(); Vector_t const meanP = calcMeanP();
double const phi = calculateAngle(meanP(0), meanP(1)) - 0.5 * pi; double const phi = calculateAngle(meanP(0), meanP(1)) - 0.5 * Physics::pi;
Vector_t const meanR = calcMeanR(); Vector_t const meanR = calcMeanR();
globalToLocal(itsBunch_m->R, phi, meanR); globalToLocal(itsBunch_m->R, phi, meanR);
itsBunch_m->updateNumTotal(); itsBunch_m->updateNumTotal();
...@@ -1571,8 +1569,8 @@ bool ParallelCyclotronTracker::checkGapCross(Vector_t Rold, Vector_t Rnew, ...@@ -1571,8 +1569,8 @@ bool ParallelCyclotronTracker::checkGapCross(Vector_t Rold, Vector_t Rnew,
bool ParallelCyclotronTracker::RFkick(RFCavity * rfcavity, const double t, const double dt, const int Pindex){ bool ParallelCyclotronTracker::RFkick(RFCavity * rfcavity, const double t, const double dt, const int Pindex){
// For OPAL 2.0: As long as the RFCavity is in mm, we have to change R to mm here -DW // For OPAL 2.0: As long as the RFCavity is in mm, we have to change R to mm here -DW
double radius = sqrt(pow(1000.0 * itsBunch_m->R[Pindex](0), 2.0) + pow(1000.0 * itsBunch_m->R[Pindex](1), 2.0) double radius = std::sqrt(std::pow(1000.0 * itsBunch_m->R[Pindex](0), 2.0) + std::pow(1000.0 * itsBunch_m->R[Pindex](1), 2.0)
- pow(rfcavity->getPerpenDistance() , 2.0)); - std::pow(rfcavity->getPerpenDistance() , 2.0));
double rmin = rfcavity->getRmin(); double rmin = rfcavity->getRmin();
double rmax = rfcavity->getRmax(); double rmax = rfcavity->getRmax();
double nomalRadius = (radius - rmin) / (rmax - rmin); double nomalRadius = (radius - rmin) / (rmax - rmin);
...@@ -1740,8 +1738,8 @@ void ParallelCyclotronTracker::globalToLocal(ParticleAttrib<Vector_t> & particle ...@@ -1740,8 +1738,8 @@ void ParallelCyclotronTracker::globalToLocal(ParticleAttrib<Vector_t> & particle
IpplTimings::startTimer(TransformTimer_m); IpplTimings::startTimer(TransformTimer_m);
particleVectors -= translationToGlobal; particleVectors -= translationToGlobal;
Tenzor<double, 3> const rotation( cos(phi), sin(phi), 0, Tenzor<double, 3> const rotation( std::cos(phi), std::sin(phi), 0,
-sin(phi), cos(phi), 0, -std::sin(phi), std::cos(phi), 0,
0, 0, 1); // clockwise rotation 0, 0, 1); // clockwise rotation
for(unsigned int i = 0; i < itsBunch_m->getLocalNum(); ++i) { for(unsigned int i = 0; i < itsBunch_m->getLocalNum(); ++i) {
...@@ -1754,8 +1752,8 @@ void ParallelCyclotronTracker::globalToLocal(ParticleAttrib<Vector_t> & particle ...@@ -1754,8 +1752,8 @@ void ParallelCyclotronTracker::globalToLocal(ParticleAttrib<Vector_t> & particle
void ParallelCyclotronTracker::localToGlobal(ParticleAttrib<Vector_t> & particleVectors, void ParallelCyclotronTracker::localToGlobal(ParticleAttrib<Vector_t> & particleVectors,
double phi, Vector_t const translationToGlobal) { double phi, Vector_t const translationToGlobal) {
IpplTimings::startTimer(TransformTimer_m); IpplTimings::startTimer(TransformTimer_m);
Tenzor<double, 3> const rotation(cos(phi), -sin(phi), 0, Tenzor<double, 3> const rotation(std::cos(phi), -std::sin(phi), 0,
sin(phi), cos(phi), 0, std::sin(phi), std::cos(phi), 0,
0, 0, 1); // counter-clockwise rotation 0, 0, 1); // counter-clockwise rotation
for(unsigned int i = 0; i < itsBunch_m->getLocalNum(); ++i) { for(unsigned int i = 0; i < itsBunch_m->getLocalNum(); ++i) {
...@@ -1900,9 +1898,9 @@ inline void ParallelCyclotronTracker::normalizeQuaternion(Quaternion_t & quatern ...@@ -1900,9 +1898,9 @@ inline void ParallelCyclotronTracker::normalizeQuaternion(Quaternion_t & quatern
double tolerance = 1.0e-10; double tolerance = 1.0e-10;
double length2 = dot(quaternion, quaternion); double length2 = dot(quaternion, quaternion);
if (fabs(length2) > tolerance && fabs(length2 - 1.0f) > tolerance) { if (std::abs(length2) > tolerance && std::abs(length2 - 1.0f) > tolerance) {
double length = sqrt(length2); double length = std::sqrt(length2);
quaternion /= length; quaternion /= length;
} }
} }
...@@ -1912,9 +1910,9 @@ inline void ParallelCyclotronTracker::normalizeVector(Vector_t & vector) { ...@@ -1912,9 +1910,9 @@ inline void ParallelCyclotronTracker::normalizeVector(Vector_t & vector) {
double tolerance = 1.0e-10; double tolerance = 1.0e-10;
double length2 = dot(vector, vector); double length2 = dot(vector, vector);
if (fabs(length2) > tolerance && fabs(length2 - 1.0f) > tolerance) { if (std::abs(length2) > tolerance && std::abs(length2 - 1.0f) > tolerance) {
double length = sqrt(length2); double length = std::sqrt(length2);
vector /= length; vector /= length;
} }
} }
...@@ -1922,8 +1920,8 @@ inline void ParallelCyclotronTracker::normalizeVector(Vector_t & vector) { ...@@ -1922,8 +1920,8 @@ inline void ParallelCyclotronTracker::normalizeVector(Vector_t & vector) {
inline void ParallelCyclotronTracker::rotateAroundZ(ParticleAttrib<Vector_t> & particleVectors, double const phi) { inline void ParallelCyclotronTracker::rotateAroundZ(ParticleAttrib<Vector_t> & particleVectors, double const phi) {
// Clockwise rotation of particles 'particleVectors' by 'phi' around Z axis // Clockwise rotation of particles 'particleVectors' by 'phi' around Z axis
Tenzor<double, 3> const rotation( cos(phi), sin(phi), 0, Tenzor<double, 3> const rotation( std::cos(phi), std::sin(phi), 0,
-sin(phi), cos(phi), 0, -std::sin(phi), std::cos(phi), 0,
0, 0, 1); 0, 0, 1);
for(unsigned int i = 0; i < itsBunch_m->getLocalNum(); ++i) { for(unsigned int i = 0; i < itsBunch_m->getLocalNum(); ++i) {
...@@ -1935,8 +1933,8 @@ inline void ParallelCyclotronTracker::rotateAroundZ(ParticleAttrib<Vector_t> & p ...@@ -1935,8 +1933,8 @@ inline void ParallelCyclotronTracker::rotateAroundZ(ParticleAttrib<Vector_t> & p
inline void ParallelCyclotronTracker::rotateAroundZ(Vector_t & myVector, double const phi) { inline void ParallelCyclotronTracker::rotateAroundZ(Vector_t & myVector, double const phi) {
// Clockwise rotation of single vector 'myVector' by 'phi' around Z axis // Clockwise rotation of single vector 'myVector' by 'phi' around Z axis
Tenzor<double, 3> const rotation( cos(phi), sin(phi), 0, Tenzor<double, 3> const rotation( std::cos(phi), std::sin(phi), 0,
-sin(phi), cos(phi), 0, -std::sin(phi), std::cos(phi), 0,
0, 0, 1); 0, 0, 1);
myVector = dot(rotation, myVector); myVector = dot(rotation, myVector);
...@@ -1946,8 +1944,8 @@ inline void ParallelCyclotronTracker::rotateAroundX(ParticleAttrib<Vector_t> & p ...@@ -1946,8 +1944,8 @@ inline void ParallelCyclotronTracker::rotateAroundX(ParticleAttrib<Vector_t> & p
// Clockwise rotation of particles 'particleVectors' by 'psi' around X axis // Clockwise rotation of particles 'particleVectors' by 'psi' around X axis
Tenzor<double, 3> const rotation(1, 0, 0, Tenzor<double, 3> const rotation(1, 0, 0,
0, cos(psi), sin(psi), 0, std::cos(psi), std::sin(psi),
0, -sin(psi), cos(psi)); 0, -std::sin(psi), std::cos(psi));
for(unsigned int i = 0; i < itsBunch_m->getLocalNum(); ++i) { for(unsigned int i = 0; i < itsBunch_m->getLocalNum(); ++i) {
...@@ -1959,8 +1957,8 @@ inline void ParallelCyclotronTracker::rotateAroundX(Vector_t & myVector, double ...@@ -1959,8 +1957,8 @@ inline void ParallelCyclotronTracker::rotateAroundX(Vector_t & myVector, double
// Clockwise rotation of single vector 'myVector' by 'psi' around X axis // Clockwise rotation of single vector 'myVector' by 'psi' around X axis
Tenzor<double, 3> const rotation(1, 0, 0, Tenzor<double, 3> const rotation(1, 0, 0,
0, cos(psi), sin(psi), 0, std::cos(psi), std::sin(psi),
0, -sin(psi), cos(psi)); 0, -std::sin(psi), std::cos(psi));
myVector = dot(rotation, myVector); myVector = dot(rotation, myVector);
} }
...@@ -1972,12 +1970,12 @@ inline void ParallelCyclotronTracker::getQuaternionTwoVectors(Vector_t u, Vector ...@@ -1972,12 +1970,12 @@ inline void ParallelCyclotronTracker::getQuaternionTwoVectors(Vector_t u, Vector
normalizeVector(v); normalizeVector(v);
double k_cos_theta = dot(u, v); double k_cos_theta = dot(u, v);
double k = sqrt(dot(u, u) * dot(v, v)); double k = std::sqrt(dot(u, u) * dot(v, v));
double tolerance1 = 1.0e-5; double tolerance1 = 1.0e-5;
double tolerance2 = 1.0e-8; double tolerance2 = 1.0e-8;
Vector_t resultVectorComponent; Vector_t resultVectorComponent;
if (fabs(k_cos_theta / k + 1.0) < tolerance1) { if (std::abs(k_cos_theta / k + 1.0) < tolerance1) {
// u and v are almost exactly antiparallel so we need to do // u and v are almost exactly antiparallel so we need to do
// 180 degree rotation around any vector orthogonal to u // 180 degree rotation around any vector orthogonal to u
...@@ -1989,13 +1987,13 @@ inline void ParallelCyclotronTracker::getQuaternionTwoVectors(Vector_t u, Vector ...@@ -1989,13 +1987,13 @@ inline void ParallelCyclotronTracker::getQuaternionTwoVectors(Vector_t u, Vector
resultVectorComponent = cross(u, zaxis); resultVectorComponent = cross(u, zaxis);
} }
double halfAngle = 0.5 * pi; double halfAngle = 0.5 * Physics::pi;
double sinHalfAngle = sin(halfAngle); double sinHalfAngle = std::sin(halfAngle);
resultVectorComponent *= sinHalfAngle; resultVectorComponent *= sinHalfAngle;
k = 0.0; k = 0.0;
k_cos_theta = cos(halfAngle); k_cos_theta = std::cos(halfAngle);
} else { } else {
...@@ -2025,7 +2023,7 @@ bool ParallelCyclotronTracker::push(double h) { ...@@ -2025,7 +2023,7 @@ bool ParallelCyclotronTracker::push(double h) {
bool flagNeedUpdate = false; bool flagNeedUpdate = false;
for(unsigned int i = 0; i < itsBunch_m->getLocalNum(); ++i) { for(unsigned int i = 0; i < itsBunch_m->getLocalNum(); ++i) {
Vector_t const oldR = itsBunch_m->R[i]; Vector_t const oldR = itsBunch_m->R[i];
double const gamma = sqrt(1.0 + dot(itsBunch_m->P[i], itsBunch_m->P[i])); double const gamma = std::sqrt(1.0 + dot(itsBunch_m->P[i], itsBunch_m->P[i]));
double const c_gamma = Physics::c / gamma; double const c_gamma = Physics::c / gamma;
Vector_t const v = itsBunch_m->P[i] * c_gamma; Vector_t const v = itsBunch_m->P[i] * c_gamma;
itsBunch_m->R[i] += h * v; itsBunch_m->R[i] += h * v;
...@@ -2038,7 +2036,7 @@ bool ParallelCyclotronTracker::push(double h) { ...@@ -2038,7 +2036,7 @@ bool ParallelCyclotronTracker::push(double h) {
if(distOld > 0.0) tagCrossing = true; if(distOld > 0.0) tagCrossing = true;
} }
if(tagCrossing) { if(tagCrossing) {
double const dt1 = distOld / sqrt(dot(v, v)); double const dt1 = distOld / std::sqrt(dot(v, v));
double const dt2 = h - dt1; double const dt2 = h - dt1;
// Retrack particle from the old postion to cavity gap point // Retrack particle from the old postion to cavity gap point
...@@ -2065,7 +2063,7 @@ bool ParallelCyclotronTracker::kick(double h) { ...@@ -2065,7 +2063,7 @@ bool ParallelCyclotronTracker::kick(double h) {
bool flagNeedUpdate = false; bool flagNeedUpdate = false;
BorisPusher pusher; BorisPusher pusher;
double const q = itsBunch_m->Q[0] / q_e; // For now all particles have the same charge double const q = itsBunch_m->Q[0] / Physics::q_e; // For now all particles have the same charge
double const M = itsBunch_m->M[0] * 1.0e9; // For now all particles have the same rest energy double const M = itsBunch_m->M[0] * 1.0e9; // For now all particles have the same rest energy
for(unsigned int i = 0; i < itsBunch_m->getLocalNum(); ++i) { for(unsigned int i = 0; i < itsBunch_m->getLocalNum(); ++i) {
...@@ -2246,10 +2244,10 @@ bool ParallelCyclotronTracker::deleteParticle(bool flagNeedUpdate){ ...@@ -2246,10 +2244,10 @@ bool ParallelCyclotronTracker::deleteParticle(bool flagNeedUpdate){
Vector_t const meanP = calcMeanP(); Vector_t const meanP = calcMeanP();
// Bunch (local) azimuth at meanR w.r.t. y-axis // Bunch (local) azimuth at meanR w.r.t. y-axis
double const phi = calculateAngle(meanP(0), meanP(1)) - 0.5 * pi; double const phi = calculateAngle(meanP(0), meanP(1)) - 0.5 * Physics::pi;
// Bunch (local) elevation at meanR w.r.t. xy plane // Bunch (local) elevation at meanR w.r.t. xy plane
double const psi = 0.5 * pi - acos(meanP(2) / sqrt(dot(meanP, meanP))); double const psi = 0.5 * Physics::pi - std::acos(meanP(2) / std::sqrt(dot(meanP, meanP)));
// For statistics data, the bunch is transformed into a local coordinate system // For statistics data, the bunch is transformed into a local coordinate system
// with meanP in direction of y-axis -DW // with meanP in direction of y-axis -DW
...@@ -2396,10 +2394,10 @@ void ParallelCyclotronTracker::initDistInGlobalFrame() { ...@@ -2396,10 +2394,10 @@ void ParallelCyclotronTracker::initDistInGlobalFrame() {
Vector_t const meanP = calcMeanP(); Vector_t const meanP = calcMeanP();
// Bunch (local) azimuth at meanR w.r.t. y-axis // Bunch (local) azimuth at meanR w.r.t. y-axis
double const phi = calculateAngle(meanP(0), meanP(1)) - 0.5 * pi; double const phi = calculateAngle(meanP(0), meanP(1)) - 0.5 * Physics::pi;
// Bunch (local) elevation at meanR w.r.t. xy plane // Bunch (local) elevation at meanR w.r.t. xy plane
double const psi = 0.5 * pi