예제 #1
0
//Original Boost
inline bool Vec4D::Boost( const Vec3D& boost )
{
    VEC3D_T s=boost.Norm();

    if( s >= (VEC3D_T)1. ) {
        return false;     // boost is invalid
    }

    Vec3D e_boost;
    VEC3D_T gamma=1./sqrt(1.-(boost*boost));
    if( s != (VEC3D_T)0 ) {
        e_boost=boost/s;
    }
    else {
        return true;      // no boost required, boost=0..
    }


    VEC3D_T par=(r*e_boost);
    Vec4D t(gamma*(r0-(boost*r)),
            gamma*(par*e_boost-r0*boost)+r-par*e_boost);

    *this=t;

    if(gamma >=1.0E+6) {
        std::cout <<"Boost: Boost accuracy may be lost " << std::endl;
        std::cout <<"       Boost is too large > 1E+6 " << std::endl;
    }

    return true;
}
예제 #2
0
파일: Particle.hpp 프로젝트: sfegan/ChiLA
  /** Overloaded class constructor. Construct a particle with
      specified 4-position, 3-velocity direction, energy, 
      rest mass and charge

      \param   _r: 4-position: (c*t, x, y, z)            [cm]
      \param    v: direction of velocity           [unitless]
      \param    E: energy                               [erg]
      \param data: PDG data for particle
  */
  inline Particle::Particle(const Vec4D& _r, const Vec3D& v_hat, double E, 
			    const PDGData* data):
    r(_r), p(E,v_hat*(sqrt(E*E-data->mass*data->mass)/v_hat.Norm())), 
    m2c4(data->mass*data->mass), charge(double(data->charge))
  {
    // nothing to see here
  }
예제 #3
0
파일: Particle.hpp 프로젝트: sfegan/ChiLA
  /** Overloaded class constructor. Construct a particle with
      specified 4-position, 3-velocity direction, energy, 
      rest mass and charge

      \param  _r: 4-position: (c*t, x, y, z)            [cm]
      \param   v: direction of velocity           [unitless]
      \param   E: energy                               [erg]
      \param mc2: rest mass                            [erg]
      \param   q: charge in units of electron charge     [e] 
  */
  inline Particle::Particle(const Vec4D& _r, const Vec3D& v_hat, double E, 
			    double mc2, double q):
    r(_r), p(E,v_hat*(sqrt(E*E-mc2*mc2)/v_hat.Norm())), 
    m2c4(mc2*mc2), charge(q)
  {
    // nothing to see here
  }
예제 #4
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/// Method to return a normalized direction vector
inline Vec3D Vec4D::GetDirection()
{
    if(r.Norm2()==0.)
    {
        return r;
    }
    else
    {
        VEC3D_T norm = r.Norm();
        Vec3D r1 = r/norm;
        return r1;
    }
}
예제 #5
0
//new Vec4D that takes Vec4D
//note no further computation of gamma is required
inline bool Vec4D::Boost4D( const Vec4D& boost4D )
{
    /*Here we begin by taking Vec4D and extracting
    beta-gamma boost vector parameter as Vec3D
    boost after dividing by gamma and last
    coordinate as scalar gamma*/

    //VEC3D_T _n = Norm2();

    VEC3D_T gamma = boost4D.r0;
    Vec3D boost = (boost4D.r)/gamma;

    VEC3D_T s = boost.Norm();

    if(s > (VEC3D_T) 1) {
        return false;
    }

    Vec3D e_boost;

    if( s != (VEC3D_T)0 ) {
        e_boost=boost/s;
    }
    else {
        return true;      // no boost required, boost=0..
    }

    //change the boosting specifics by factoring to preserve precision
    VEC3D_T par=(r*e_boost);
    Vec4D t(gamma*r0-(boost4D.r)*r,
            r - par*e_boost + gamma*(par*e_boost) - (boost4D.r)*r0);

    /*VEC3D_T _n2 = t.Norm2();
    std::cout << _n2;
    if(_n>_n2)
    {
      t.r0+=sqrt(_n-_n2);
    }
    else if(_n<_n2)
    {
      t.r0-=sqrt(_n-_n2);
    }*/

    *this=t;

    return true;

}
예제 #6
0
파일: VSOMirror.cpp 프로젝트: sfegan/ChiLA
void VSOMirror::calculateRotationVector()
{
  Vec3D rrot(0,-fTelescope->reflectorRotation(),0);
  Vec3D align(fAlign);
  align.Rotate(rrot);
  Vec3D normalize = align^Vec3D(0,1,0);
  double sintheta = normalize.Norm();
  if(sintheta == 0)
    {
      fRotationVector = rrot;
    }
  else 
    {
      double costheta = align*Vec3D(0,1,0);
      normalize *= atan(sintheta/costheta)/sintheta;
      fRotationVector = rrot & normalize;
    }
}
예제 #7
0
파일: Particle.hpp 프로젝트: sfegan/ChiLA
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 /// Reset the direction of propagation, keeping energy fixed
 /// \param v_hat: Direction of proagation, i.e. (vx/v, vy/v, vz/v)
 inline void Particle::SetDirection( const Vec3D& v_hat)
 {
   p.r = v_hat*(sqrt(p.r0*p.r0-m2c4)/v_hat.Norm());
 }