CVertex.C
//-----------------------------------------------------------------------------
// $Header: /asis/offline/ceres/cool/project/RCS/CVertex.C,v 3.3 1997/08/19 10:15:43 messer Exp $
//
// COOL Program Library
// Copyright (C) CERES collaboration, 1996
//
// Implementation of class CVertex
//
//-----------------------------------------------------------------------------
#include <iostream.h>
#include <math.h>
#include "CVertex.h"
CVertex::CVertex()
{
position.setX(0);
position.setY(0);
position.setZ(0);
varX = 0;
varY = 0;
chi2 = 0;
nTracks = 0;
fittedZPosition = 0;
}
CVertex::CVertex(double x, double y, double z)
{
position.setX(x);
position.setY(y);
position.setZ(z);
varX = 0;
varY = 0;
chi2 = 0;
nTracks = 0;
fittedZPosition = z;
}
CVertex::CVertex(double x, double y, double z, double zFit)
{
position.setX(x);
position.setY(y);
position.setZ(z);
varX = 0;
varY = 0;
chi2 = 0;
nTracks = 0;
fittedZPosition = zFit;
}
CVertex::~CVertex() {}
void CVertex::print(ostream& ost)
{
ost << "position: " << position << endl;
ost << "variance-x: " << varX << endl;
ost << "variance-y: " << varY << endl;
ost << "chi2: " << chi2 << endl;
ost << "fit points: " << nTracks << endl;
}
void CVertex::transform(CEventCoord& gp, const CLabXYZCoord& xyz) const
{
CLabXYZCoord eventXYZ = xyz - position;
double radius = sqrt(eventXYZ.getX()*eventXYZ.getX() + eventXYZ.getY()*eventXYZ.getY());
gp.setTheta(atan2(radius, eventXYZ.getZ())*1000.); // rad -> mrad
gp.setPhi(atan2(eventXYZ.getY(), eventXYZ.getX()));
gp.setZ(eventXYZ.getZ());
}
void CVertex::transform(CEventCoord& gp, const CLabCylinderCoord& cyl) const
{
CLabXYZCoord xyz;
::transform(xyz, cyl);
transform(gp, xyz);
}
void CVertex::transform(CLabXYZCoord& xyz, const CEventCoord& gp) const
{
double r = gp.getZ() * tan(gp.getTheta()/1000.); // mrad -> rad
xyz.setX(r * cos(gp.getPhi()));
xyz.setY(r * sin(gp.getPhi()));
xyz.setZ(gp.getZ());
xyz += position;
}
void CVertex::transform(CLabCylinderCoord& cyl, const CEventCoord& gp) const
{
CLabXYZCoord xyz;
transform(xyz, gp);
::transform(cyl, xyz);
}
void CVertex::transform(CLabCylinderCoord& cyl, const CEventXYZCoord& xyz) const
{
CEventCoord polar;
::transform(polar, xyz);
transform(cyl, polar);
}
void CVertex::transform(CEventXYZCoord& xyz, const CLabCylinderCoord& cyl) const
{
CEventCoord polar;
transform(polar, cyl);
::transform(xyz, polar);
}
void CVertex::transform(CLabXYZCoord& labxyz, const CEventXYZCoord& evtxyz) const
{
labxyz.setX(evtxyz.getX() + position.getX());
labxyz.setY(evtxyz.getY() + position.getY());
labxyz.setZ(evtxyz.getZ() + position.getZ());
}
void CVertex::transform(CEventXYZCoord& evtxyz, const CLabXYZCoord& labxyz) const
{
evtxyz.setX(labxyz.getX() - position.getX());
evtxyz.setY(labxyz.getY() - position.getY());
evtxyz.setZ(labxyz.getZ() - position.getZ());
}