C4Momentum.h
//-----------------------------------------------------------------------------
// $Header: /tmp_mnt/asis/offline/ceres/cool/project/RCS/C4Momentum.h,v 2.1 1996/10/04 08:43:37 voigt Exp $
//
// COOL Program Library
// Copyright (C) CERES collaboration, 1996
//
// Declaration of class C4Momentum.
//
//-----------------------------------------------------------------------------
#ifndef C4MOMENTUM_H
#define C4MOMENTUM_H
#include <math.h>
#include <iostream.h>
#include "C3Momentum.h"
#include "cool.h"
class C4Momentum : public C3Momentum {
public:
C4Momentum();
C4Momentum(C3Momentum p);
C4Momentum(double mass, C3Momentum p);
C4Momentum(const C4Momentum& q);
~C4Momentum();
public:
double getE() const { return E; }
inline double getAbs() const;
double getM() const { return getAbs(); }
void setM(double newM);
public:
friend C4Momentum operator + (const C4Momentum&, const C4Momentum&);
friend C4Momentum operator - (const C4Momentum&, const C4Momentum&);
friend C4Momentum operator - (const C4Momentum&);
friend C4Momentum operator * (const double, const C4Momentum&);
friend C4Momentum operator * (const C4Momentum&, const double);
friend C4Momentum operator / (const C4Momentum&, const double);
friend double operator * (const C4Momentum&, const C4Momentum&);
C4Momentum& operator = (const C4Momentum&);
C4Momentum& operator -= (const C4Momentum&);
C4Momentum& operator += (const C4Momentum&);
C4Momentum& operator *= (const double);
C4Momentum& operator /= (const double);
friend CBoolean operator == (const C4Momentum&, const C4Momentum&);
friend CBoolean operator != (const C4Momentum&, const C4Momentum&);
double getRapidity() const ;
private:
double E;
};
ostream& operator<< (ostream&, const C4Momentum&);
inline void C4Momentum::setM(double newM)
{
E = sqrt(newM*newM + getP()*getP());
}
inline double C4Momentum::getAbs() const
{
double E2 = E*E;
double p2 = getP() * getP();
return (E2>p2 ? sqrt(E2 - p2) : 0);
}
inline double abs(const C4Momentum& a)
{
return a.getAbs();
}
inline C4Momentum operator + (const C4Momentum& a, const C4Momentum& b)
{
C4Momentum q;
q = a.getP() + b.getP();
q.E = a.E + b.E;
return q;
}
inline C4Momentum operator - (const C4Momentum& a, const C4Momentum& b)
{
C4Momentum q;
q = a.getP() - b.getP();
q.E = a.E - b.E;
return q;
}
inline C4Momentum operator - (const C4Momentum& a)
{
C4Momentum q;
q = -a.getP();
q.E = -a.E;
return q;
}
inline double operator * (const C4Momentum& a, const C4Momentum& b)
{
return a.E*b.E - a.getP() * b.getP();
}
inline C4Momentum operator * (const double c, const C4Momentum& a)
{
C4Momentum q;
q = c * a.getP();
q.E = c * a.E;
return q;
}
inline C4Momentum operator * (const C4Momentum& a, const double c)
{
C4Momentum q(c * a);
return q;
}
inline C4Momentum operator / (const C4Momentum& a, const double c)
{
C4Momentum q;
q = a.getP() / c;
q.E = a.E / c;
return q;
}
inline C4Momentum& C4Momentum::operator -= (const C4Momentum& a)
{
*this = *this - a;
return *this;
}
inline C4Momentum& C4Momentum::operator += (const C4Momentum& a)
{
*this = *this + a;
return *this;
}
inline C4Momentum& C4Momentum::operator *= (const double c)
{
*this = *this * c;
return *this;
}
inline C4Momentum& C4Momentum::operator /= (const double c)
{
*this = *this / c;
return *this;
}
inline CBoolean operator == (const C4Momentum& a, const C4Momentum& b)
{
return (a.E == b.E && a.getP() == b.getP());
}
inline CBoolean operator != (const C4Momentum& a, const C4Momentum& b)
{
return (a.E != b.E || a.getP() != b.getP());
}
inline double C4Momentum::getRapidity() const
{
return (0.5 * log((E+getZ())/(E-getZ())));
}
#endif /* C4MOMENTUM_H */