Commit 554ca592 authored by Atlas-Software Librarian's avatar Atlas-Software Librarian Committed by Graeme Stewart
Browse files

'CMakeLists.txt' (TrkVertexKinematicFitterUtils-01-00-00)

parent 8e4226a1
################################################################################
# Package: TrkVertexKinematicFitterUtils
################################################################################
# Declare the package name:
atlas_subdir( TrkVertexKinematicFitterUtils )
# Declare the package's dependencies:
atlas_depends_on_subdirs( PUBLIC
Tracking/TrkVertexFitter/TrkVertexFitterInterfaces )
# Component(s) in the package:
atlas_add_library( TrkVertexKinematicFitterUtils
src/*.cxx
PUBLIC_HEADERS TrkVertexKinematicFitterUtils
LINK_LIBRARIES TrkVertexFitterInterfaces )
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef TrkVertexKinematicFitterUtils_CollinearityConstraint_h
#define TrkVertexKinematicFitterUtils_CollinearityConstraint_h
// This object defines a Collinearity constraint to be used with the constrained kinematic vertex fitter
// It minimizes the angles between the tracks (phi in the x-y plane and theta in the z-plane) using scalar products
#include "TrkVertexFitterInterfaces/IKinematicConstraint.h"
namespace Trk
{
class CollinearityConstraint : public IKinematicConstraint
{
public:
CollinearityConstraint() ;
~CollinearityConstraint();
virtual const Amg::VectorX vectorOfValues(std::vector<Amg::VectorX> & cart_coordList, std::vector<int> &charges, Amg::Vector3D refPoint, double b_fieldTesla ) const;
virtual const Amg::MatrixX matrixOfDerivatives(std::vector<Amg::VectorX> & cart_coordList, std::vector<int> &charges, Amg::Vector3D refPoint, double b_fieldTesla ) const;
virtual int numberOfEquations() const { return m_eqno; }
private:
int m_eqno; // number of constraint-equations used
};
}
#endif //TrkVertexKinematicFitterUtils_CollinearityConstraint_h
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef TrkVertexKinematicFitterUtils_MassConstraint_h
#define TrkVertexKinematicFitterUtils_MassConstraint_h
// This object defines a MASS constraint to be used with the constrained vertex fitter
#include "TrkVertexFitterInterfaces/IKinematicConstraint.h"
namespace Trk
{
/** @class MassConstraint
@brief Concrete implementation of Trk::IKinematicConstraint to formulate
a mass constraint in kinematic vertex fits.
The constraint is constructed with a mass value (in MeV), to which the
invariant mass of the particles emerging from a vertex will be constrained.
It calculates the values and derivatives for a list of particles,
given by their parameters and charges.
@author Maaike Limper
*/
class MassConstraint : public IKinematicConstraint
{
public:
//! empty constructor
MassConstraint() ;
/** standard constructor
@param[in] mass Invariant mass in MeV to which particles shall be constrained
*/
MassConstraint( double mass ) ;
~MassConstraint();
/** method returning the vector of parameters values. Method defined through
the <nop>IKinematicConstraint base class
@param[in] cart_coordList vector of particles represented in cartesian frame,
that is through the parameters (px, py, pz, E, x, y, z).
@param[in] charges charge information for the vector of particles
@param[in] refPoint reference point for cartesian coordinates
@param[in] b_fieldTesla local solenoidal approximation of field
@param[out] vector of values to enter the constrained-fit equation
*/
const Amg::VectorX vectorOfValues(std::vector<Amg::VectorX> & cart_coordList, std::vector<int> &charges, Amg::Vector3D refPoint, double b_fieldTesla ) const;
/** method returning the matrix of derivatives. Method defined through the
<nop>IKinematicConstraint base class
@param[in] cart_coordList vector of particles represented in cartesian frame,
that is through the parameters (px, py, pz, E, x, y, z).
@param[in] charges charge information for the vector of particles
@param[in] refPoint reference point for cartesian coordinates
@param[in] b_fieldTesla local solenoidal approximation of field
@param[out] matrix of derivatives to enter the constrained-fit equation
*/
const Amg::MatrixX matrixOfDerivatives(std::vector<Amg::VectorX> & cart_coordList, std::vector<int> &charges, Amg::Vector3D refPoint, double b_fieldTesla ) const;
//! tells the number of equations needed for this type of constraint, that is 1
int numberOfEquations() const { return m_eqno; }
//! tells the mass value used for the constraint
double mass() { return m_mass; }
private:
//! value of mass to be constrained in MeV
double m_mass;
//! number of constraint-equations used by this type of constraint
int m_eqno;
};
}
#endif //TrkVertexKinematicFitterUtils_MassConstraint_h
package TrkVertexKinematicFitterUtils
author Maaike Limper <Maaike.Limper@cern.ch>
use AtlasPolicy AtlasPolicy-*
use TrkVertexFitterInterfaces TrkVertexFitterInterfaces-* Tracking/TrkVertexFitter
library TrkVertexKinematicFitterUtils *.cxx
apply_pattern installed_library
#apply_pattern component_library
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
/**
@mainpage The TrkKinematicVertexFitterUtils package
TrkKinematicVertexFitterUtils provides classes for constraints in vertex reconstruction.
&nbsp;
For the time being it is meant to host the concrete types of kinematic constraints
implemented under the Trk::IKinematicConstraint base class interface.
Each constraint class calculates a vector of values and a matrix of derivatives
of the corresponding constraint equation at the expansion point provided by
the user.
@section OverviewTrkKinUtils Class Overview
The TrkVertexKinematicFitterUtils package contains:
- Trk::MassConstraint - formulates the mass constraint in kinematic vertex fitting
The classes in this package (and any future additions) shall not extend any
of the athena components, therefore the package follows the installed_library pattern.
@author <a href="http://cern.ch/xwho">Maaike Limper</a>
@section ExtrasTrkKinUtils Extra Pages
- @ref UsedTrkKinUtils
- @ref requirementsTrkKinUtils
*/
/**
@page UsedTrkKinUtils Used Packages
@htmlinclude used_packages.html
*/
/**
@page requirementsTrkKinUtils Requirements
@include requirements
*/
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
/***************************************************************************
CollinearityConstraint.cxx
Veerle Heijne
***************************************************************************/
#include "TrkVertexKinematicFitterUtils/CollinearityConstraint.h"
Trk::CollinearityConstraint::CollinearityConstraint() :
m_eqno(2)
{}
Trk::CollinearityConstraint::~CollinearityConstraint(){}
const Amg::VectorX Trk::CollinearityConstraint::vectorOfValues(std::vector<Amg::VectorX> & cart_coordList, std::vector<int> &charges, Amg::Vector3D refPoint, double b_fieldTesla ) const {
unsigned int ntrack = cart_coordList.size();
Amg::VectorX vectorOfValues2(2,0);
if( ntrack != 2 ){
return vectorOfValues2; //returning vector with zero's
}
double bend_factor = -0.299792458*b_fieldTesla ;
double& px1 = cart_coordList[0][0];
double& py1 = cart_coordList[0][1];
double& pz1 = cart_coordList[0][2];
double pt1 = sqrt(px1*px1 + py1*py1);
double& px2 = cart_coordList[1][0];
double& py2 = cart_coordList[1][1];
double& pz2 = cart_coordList[1][2];
double pt2 = sqrt(px2*px2 + py2*py2);
double deltaX1 = refPoint[0] - cart_coordList[0][4];
double deltaY1 = refPoint[1] - cart_coordList[0][5];
double deltaX2 = refPoint[0] - cart_coordList[1][4];
double deltaY2 = refPoint[1] - cart_coordList[1][5];
double a1 = charges[0]*bend_factor;
double a2 = charges[1]*bend_factor;
//constraint equations, using scalar product:
vectorOfValues2[0] = 1 - ((px1-a1*deltaY1)*(px2-a2*deltaY2)+(py1+a1*deltaX1)*(py2+a2*deltaX2))/(pt1*pt2) ;
vectorOfValues2[1] = pz1*pt2 - pz2*pt1;
return vectorOfValues2;
}
const Amg::MatrixX Trk::CollinearityConstraint::matrixOfDerivatives(std::vector<Amg::VectorX> & cart_coordList, std::vector<int> &charges, Amg::Vector3D refPoint, double b_fieldTesla ) const {
unsigned int ntrack = cart_coordList.size();
Amg::MatrixX matrixDeriv2(2,ntrack*7);
if( ntrack != 2 ){
return matrixDeriv2; //returning matrix with zero's
}
double bend_factor = -0.299792458*b_fieldTesla ;
double& px1 = cart_coordList[0][0];
double& py1 = cart_coordList[0][1];
double& pz1 = cart_coordList[0][2];
double pt1 = sqrt(px1*px1 + py1*py1);
double& px2 = cart_coordList[1][0];
double& py2 = cart_coordList[1][1];
double& pz2 = cart_coordList[1][2];
double pt2 = sqrt(px2*px2 + py2*py2);
double deltaX1 = refPoint[0] - cart_coordList[0][4];
double deltaY1 = refPoint[1] - cart_coordList[0][5];
double deltaX2 = refPoint[0] - cart_coordList[1][4];
double deltaY2 = refPoint[1] - cart_coordList[1][5];
double a1 = charges[0]*bend_factor;
double a2 = charges[1]*bend_factor;
//derivatives to first constraint-equation:
matrixDeriv2(0,0) = -(px2-a2*deltaY2)/(pt1*pt2) + px1*((px1-a1*deltaY1)*(px2-a2*deltaY2)+(py1+a1*deltaX1)*(py2+a2*deltaX2))/(pt1*pt1*pt1*pt2); //vs px1
matrixDeriv2(0,1) = -(py2+a2*deltaX2)/(pt1*pt2) + py1*((px1-a1*deltaY1)*(px2-a2*deltaY2)+(py1+a1*deltaX1)*(py2+a2*deltaX2))/(pt1*pt1*pt1*pt2); //vs py1
matrixDeriv2(0,2) = 0.; //vs pz1
matrixDeriv2(0,3) = 0.; //vs E1
matrixDeriv2(0,4) = a1*(py2+a2*deltaX2)/(pt1*pt2); // vs x1
matrixDeriv2(0,5) = -a1*(px2-a2*deltaY2)/(pt1*pt2); // vs y1
matrixDeriv2(0,6) = 0.; // vs z1
matrixDeriv2(0,7) = -(px1-a1*deltaY1)/(pt1*pt2) + px2*((px1-a1*deltaY1)*(px2-a2*deltaY2)+(py1+a1*deltaX1)*(py2+a2*deltaX2))/(pt1*pt2*pt2*pt2); //vs px2
matrixDeriv2(0,8) = -(py1+a1*deltaX1)/(pt1*pt2) + py2*((px1-a1*deltaY1)*(px2-a2*deltaY2)+(py1+a1*deltaX1)*(py2+a2*deltaX2))/(pt1*pt2*pt2*pt2) ; //vs py2
matrixDeriv2(0,9) = 0.; //vs pz2
matrixDeriv2(0,10) = 0.; //vs E2
matrixDeriv2(0,11) = a2*(py1+a1*deltaX1)/(pt1*pt2); // vs x2
matrixDeriv2(0,12) = -a2*(px1-a1*deltaY1)/(pt1*pt2); // vs y2
matrixDeriv2(0,13) = 0.; // vs z2
//derivatives to second constraint-equation:
matrixDeriv2(1,0) = -(px1*pz2)/pt1; //vs px1
matrixDeriv2(1,1) = -(py1*pz2)/pt1; //vs py1
matrixDeriv2(1,2) = pt2; //vs pz1
matrixDeriv2(1,3) = 0.; //vs E1
matrixDeriv2(1,4) = 0.; // vs x1
matrixDeriv2(1,5) = 0.; // vs y1
matrixDeriv2(1,6) = 0.; // vs z1
matrixDeriv2(1,7) = (px2*pz1)/pt2; //vs px2
matrixDeriv2(1,8) = (py2*pz1)/pt2; //vs py2
matrixDeriv2(1,9) = -pt1; //vs pz2
matrixDeriv2(1,10) = 0; //vs E2
matrixDeriv2(1,11) = 0.; // vs x2
matrixDeriv2(1,12) = 0.; // vs y2
matrixDeriv2(1,13) = 0.; // vs z2
return matrixDeriv2;
}
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
/***************************************************************************
MassConstraint.cxx
maaike.limper@cern.ch
***************************************************************************/
#include "TrkVertexKinematicFitterUtils/MassConstraint.h"
Trk::MassConstraint::MassConstraint() :
m_mass( 0. ),
m_eqno(1)
{}
Trk::MassConstraint::MassConstraint( double mass ) :
m_mass(mass),
m_eqno(1)
{}
Trk::MassConstraint::~MassConstraint(){}
const Amg::VectorX Trk::MassConstraint::vectorOfValues(std::vector<Amg::VectorX> & cart_coordList, std::vector<int> &charges, Amg::Vector3D refPoint, double b_fieldTesla ) const {
unsigned int ntrack = cart_coordList.size();
Amg::VectorX vectorOfValues2(1,0);
double bend_factor = -0.299792458*b_fieldTesla ;
double Etot = 0.;
double Px = 0.;
double Py = 0.;
double Pz = 0.;
for( unsigned int i = 0 ; i < ntrack ; i++ ){
double& E = cart_coordList[i][3];
double& px = cart_coordList[i][0];
double& py = cart_coordList[i][1];
double& pz = cart_coordList[i][2];
double deltaX = refPoint[0] - cart_coordList[i][4];
double deltaY = refPoint[1] - cart_coordList[i][5];
double a = charges[i]*bend_factor;
// sum of values of cartesian coordinates at given reference-point
Etot += E;
Px += (px - a*deltaY);
Py += (py + a*deltaX);
Pz += pz;
}
vectorOfValues2[0] = Etot*Etot - Px*Px - Py*Py - Pz*Pz - m_mass*m_mass ; // fill vector using sums made in track-loop
return vectorOfValues2;
}
const Amg::MatrixX Trk::MassConstraint::matrixOfDerivatives(std::vector<Amg::VectorX> & cart_coordList, std::vector<int> &charges, Amg::Vector3D refPoint, double b_fieldTesla ) const {
unsigned int ntrack = cart_coordList.size();
Amg::MatrixX matrixDeriv2(1,ntrack*7);
double bend_factor = -0.299792458*b_fieldTesla ;
for( unsigned int i = 0 ; i < ntrack ; i++ ){
double& E = cart_coordList[i][3];
double& px = cart_coordList[i][0];
double& py = cart_coordList[i][1];
double& pz = cart_coordList[i][2];
double deltaX = refPoint[0] - cart_coordList[i][4];
double deltaY = refPoint[1] - cart_coordList[i][5];
double a = charges[i]*bend_factor;
for(unsigned int jtrack=0; jtrack < ntrack; jtrack++){
unsigned int joff = jtrack*7;
matrixDeriv2(0,joff+0) = matrixDeriv2(0,joff+0) - 2*(px - a*deltaY);
matrixDeriv2(0,joff+1) = matrixDeriv2(0,joff+1) - 2*(py + a*deltaX);
matrixDeriv2(0,joff+2) = matrixDeriv2(0,joff+2) - 2*pz;
matrixDeriv2(0,joff+3) = matrixDeriv2(0,joff+3) + 2*E;
// shouldn't this go to 0 when deltaX = 0 ?! no! when vertex moves px,py moves and vice-versa
// so derivative of vertex should depend on px,py
matrixDeriv2(0,joff+4) = matrixDeriv2(0,joff+4) + 2*a*(py + a*deltaX);
matrixDeriv2(0,joff+5) = matrixDeriv2(0,joff+5) - 2*a*(px - a*deltaY);
//(*p_matrixDeriv)[0][joff+6] = (*p_matrixDeriv)[0][joff+6] + 0.; // no dependence on z!
}
}
return matrixDeriv2;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment