// Ali4Vector c;
// c.SetVector(x0,x);
// c.GetVector(vec,"car");
-// c.Info("cyl");
+// c.Data("cyl");
// c=a+b;
// c=a-b;
// c=a*5;
///////////////////////////////////////////////////////////////////////////
#include "Ali4Vector.h"
+#include "Riostream.h"
ClassImp(Ali4Vector) // Class implementation to enable ROOT I/O
// Creation of a contravariant 4-vector and initialisation of parameters.
// All values are initialised to 0.
// Scalar mode is initially selected.
+ SetZero();
fScalar=1;
- fV2=0;
- fDv2=0;
- fV0=0;
- fDv0=0;
- fDresult=0;
- Double_t a[3]={0,0,0};
- fV.SetVector(a,"sph");
}
///////////////////////////////////////////////////////////////////////////
Ali4Vector::~Ali4Vector()
// Destructor to delete dynamically allocated memory
}
///////////////////////////////////////////////////////////////////////////
-void Ali4Vector::SetVector(Double_t v0,Ali3Vector v)
+Ali4Vector::Ali4Vector(const Ali4Vector& v)
+{
+// Copy constructor
+ fScalar=v.fScalar;
+ fV2=v.fV2;
+ fDv2=v.fDv2;
+ fV0=v.fV0;
+ fDv0=v.fDv0;
+ fDresult=v.fDresult;
+ fV=v.fV;
+}
+///////////////////////////////////////////////////////////////////////////
+void Ali4Vector::Load(Ali4Vector& q)
+{
+// Load all attributes of the input Ali4Vector into this Ali4Vector object.
+ Int_t temp1=q.GetScalarFlag();
+ Double_t temp2=q.GetResultError();
+ Double_t a[4];
+ q.GetVector(a,"sph");
+ SetVector(a,"sph");
+ q.GetErrors(a,"car");
+ SetErrors(a,"car");
+ fScalar=temp1;
+ fDresult=temp2;
+}
+///////////////////////////////////////////////////////////////////////////
+void Ali4Vector::SetZero()
+{
+// (Re)set all attributes to zero.
+// Note : The (de)selection of the scalar mode is not modified.
+ fV2=0;
+ fDv2=0;
+ fV0=0;
+ fDv0=0;
+ fDresult=0;
+ fV.SetZero();
+}
+///////////////////////////////////////////////////////////////////////////
+void Ali4Vector::SetVector(Double_t v0,Ali3Vector& v)
{
// Store contravariant vector.
// The error on the scalar part is initialised to 0.
}
}
///////////////////////////////////////////////////////////////////////////
-Double_t Ali4Vector::GetResultError()
+Double_t Ali4Vector::GetResultError() const
{
// Provide the error on the result of an operation yielding a scalar
// E.g. GetScalar(), GetInvariant() or Dot()
fDresult=0;
}
///////////////////////////////////////////////////////////////////////////
-void Ali4Vector::Set3Vector(Ali3Vector v)
+void Ali4Vector::Set3Vector(Ali3Vector& v)
{
// Set the 3-vector part, the errors are taken from the input Ali3Vector
// Scalar mode : The scalar part and its error are not modified,
}
}
///////////////////////////////////////////////////////////////////////////
-Ali3Vector Ali4Vector::Get3Vector()
+Ali3Vector Ali4Vector::Get3Vector() const
{
// Provide the 3-vector part
return fV;
Double_t a[3];
fV.GetErrors(a,f);
+ // Dummy invokation of GetScalar to obtain automatic proper error determination
+ e[0]=GetScalar();
+
e[0]=GetResultError();
+
for (Int_t i=0; i<3; i++)
{
e[i+1]=a[i];
}
}
///////////////////////////////////////////////////////////////////////////
-void Ali4Vector::Info(TString f)
+void Ali4Vector::Data(TString f)
{
// Print contravariant vector components and errors according to
// reference frame f and according to the current mode.
GetErrors(err,f);
Double_t inv=GetInvariant();
Double_t dinv=GetResultError();
- cout << " Contravariant vector in " << f << " coordinates : "
+ cout << " Contravariant vector in " << f.Data() << " coordinates : "
<< vec[0] << " " << vec[1] << " " << vec[2] << " " << vec[3] << endl;
- cout << " ------------- Errors in " << f << " coordinates : "
+ cout << " ------------- Errors in " << f.Data() << " coordinates : "
<< err[0] << " " << err[1] << " " << err[2] << " " << err[3] << endl;
cout << " --- Lorentz invariant (v^i*v_i) : " << inv << " error : " << dinv << endl;
}
else
{
- cout << " *Ali4Vector::Info* Unsupported frame : " << f << endl
+ cout << " *Ali4Vector::Data* Unsupported frame : " << f.Data() << endl
<< " Possible frames are 'car', 'sph' and 'cyl'." << endl;
}
}
}
}
///////////////////////////////////////////////////////////////////////////
-Int_t Ali4Vector::GetScalarFlag()
+Int_t Ali4Vector::GetScalarFlag() const
{
// Provide the value of the fScalar flag (for internal use only).
return fScalar;
}
///////////////////////////////////////////////////////////////////////////
+Ali3Vector Ali4Vector::GetVecTrans() const
+{
+// Provide the transverse vector part w.r.t. z-axis.
+// Error propagation is performed automatically
+
+ return fV.GetVecTrans();
+}
+///////////////////////////////////////////////////////////////////////////
+Ali3Vector Ali4Vector::GetVecLong() const
+{
+// Provide the longitudinal vector part w.r.t. z-axis.
+// Error propagation is performed automatically
+
+ return fV.GetVecLong();
+}
+///////////////////////////////////////////////////////////////////////////
+Double_t Ali4Vector::GetScaTrans()
+{
+// Provide the "transverse value" of the scalar part w.r.t. z-axis.
+// This provides a basis for e.g. E_trans calculation.
+// Note : the returned value is always positive or zero.
+// The error on the value is available via GetResultError()
+// after invokation of GetScaTrans().
+ Double_t a[3],ea[3];
+
+ fV.GetVector(a,"sph");
+ fV.GetErrors(ea,"sph");
+
+ Double_t s=GetScalar();
+ Double_t ds=GetResultError();
+
+ Double_t st,dst2;
+ st=s*sin(a[1]);
+ dst2=pow((sin(a[1])*ds),2)+pow((s*cos(a[1])*ea[1]),2);
+
+ fDresult=sqrt(dst2);
+ return fabs(st);
+}
+///////////////////////////////////////////////////////////////////////////
+Double_t Ali4Vector::GetScaLong()
+{
+// Provide the "longitudinal value" of the scalar part w.r.t. z-axis.
+// This provides a basis for e.g. E_long calculation.
+// Note : the returned value can also be negative.
+// The error on the value is available via GetResultError()
+// after invokation of GetScaLong().
+ Double_t a[3],ea[3];
+
+ fV.GetVector(a,"sph");
+ fV.GetErrors(ea,"sph");
+
+ Double_t s=GetScalar();
+ Double_t ds=GetResultError();
+
+ Double_t sl,dsl2;
+ sl=s*cos(a[1]);
+ dsl2=pow((cos(a[1])*ds),2)+pow((s*sin(a[1])*ea[1]),2);
+
+ fDresult=sqrt(dsl2);
+ return sl;
+}
+///////////////////////////////////////////////////////////////////////////
+Double_t Ali4Vector::GetPseudoRapidity()
+{
+// Provide the pseudorapidity value of the vector part w.r.t. z-axis.
+// The error on the value is available via GetResultError()
+// after invokation of GetPseudoRapidity().
+ Double_t eta=fV.GetPseudoRapidity();
+ fDresult=fV.GetResultError();
+ return eta;
+}
+///////////////////////////////////////////////////////////////////////////
+Ali3Vector Ali4Vector::GetBetaVector() const
+{
+// Provide the beta 3-vector corresponding to this 4-vector.
+ Ali3Vector beta;
+ if (fabs(fV0)>0.) beta=fV/fV0;
+ if (fabs(fDv0)>0.)
+ {
+ Double_t vecv[3],errv[3],errb[3];
+ Double_t sqerr=0;
+ fV.GetVector(vecv,"car");
+ fV.GetErrors(errv,"car");
+ for (Int_t i=0; i<3; i++)
+ {
+ sqerr=pow((errv[i]/fV0),2)+pow((vecv[i]*fDv0/(fV0*fV0)),2);
+ errb[i]=sqrt(sqerr);
+ }
+ beta.SetErrors(errb,"car");
+ }
+ return beta;
+}
+///////////////////////////////////////////////////////////////////////////
+Double_t Ali4Vector::GetBeta()
+{
+// Provide the beta value (i.e. v/c) corresponding to this 4-vector.
+ Ali3Vector beta=GetBetaVector();
+ Double_t val=beta.GetNorm();
+ fDresult=beta.GetResultError();
+ return val;
+}
+///////////////////////////////////////////////////////////////////////////
+Double_t Ali4Vector::GetGamma()
+{
+// Provide the Lorentz gamma factor corresponding to this 4-vector.
+// In case the gamma factor is infinite a value of -1 is returned.
+ Double_t gamma=-1;
+ fDresult=0;
+ Double_t inv=sqrt(fabs(fV2));
+ if (inv>0.)
+ {
+ Double_t dinv=fDv2/(2.*inv);
+ gamma=fV0/inv;
+ Double_t sqerr=pow((fDv0/inv),2)+pow((fV0*dinv/fV2),2);
+ fDresult=sqrt(sqerr);
+ }
+ return gamma;
+}
+///////////////////////////////////////////////////////////////////////////