ATLAS Offline Software
Loading...
Searching...
No Matches
Trk::V0Tools Class Reference

#include <V0Tools.h>

Inheritance diagram for Trk::V0Tools:
Collaboration diagram for Trk::V0Tools:

Public Member Functions

 V0Tools (const std::string &t, const std::string &n, const IInterface *p)
 Default constructor due to Athena interface.
 ~V0Tools ()
 Virtual destructor.
StatusCode initialize ()
 Standard AlgTool methods.
double invariantMass (const xAOD::Vertex *vxCandidate, double posTrackMass, double negTrackMass) const
 Methods, returning the invariant mass, error on the invariant mass and Chi2 probability of the invariant mass of an xAOD::Vertex for a given hypothesis for the masses of the input tracks and the V0 mass.
double invariantMass (const xAOD::Vertex *vxCandidate, std::span< const double > masses) const
double invariantMassError (const xAOD::Vertex *vxCandidate, double posTrackMass, double negTrackMass) const
double invariantMassError (const xAOD::Vertex *vxCandidate, std::span< const double > masses) const
double invariantMassProbability (const xAOD::Vertex *vxCandidate, double V0Mass, double posTrackMass, double negTrackMass) const
double invariantMassProbability (const xAOD::Vertex *vxCandidate, double V0Mass, std::span< const double > masses) const
double massProbability (double V0Mass, double mass, double massErr) const
double vertexProbability (const xAOD::Vertex *vxCandidate) const
 Probability of the vertex fit.
double rxyError (const xAOD::Vertex *vxCandidate) const
 error on Rxy
double rxyError (const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex) const
 wrt an xAOD::Vertex vertex
double rxyError (const xAOD::Vertex *vxCandidate, const Amg::Vector3D &vertex) const
 wrt an Amg::Vector3D vertex
double pTError (const xAOD::Vertex *vxCandidate) const
 error on the transverse momentum of the V0
double separation (const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex) const
 statistical separation (Mahalanobis distance)
double separation (const xAOD::Vertex *vxCandidate, const Amg::Vector3D &vertex) const
double a0xyError (const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex) const
 errors on a0xy and a0z
double a0zError (const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex) const
double a0Error (const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex, bool in3D=true) const
 error on a0
double lxyError (const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex) const
 error on lxy
double lxyzError (const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex) const
 error on lxyz
double tau (const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex, double posTrackMass, double negTrackMass) const
 proper time wrt an xAOD::Vertex vertex assuming posTrackMass and negTrackMass tau = CONST*M*lxy/pT
double tau (const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex, std::span< const double > masses) const
 proper time wrt an xAOD::Vertex vertex assuming track masses
double tau (const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex, double posTrackMass, double negTrackMass, double massV0) const
 proper time wrt an xAOD::Vertex vertex assuming posTrackMass and negTrackMass (imposing massV0) making a correction to the proper time consistent with the imposed V0 mass
double tau (const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex, std::span< const double > masses, double massV0) const
 proper time wrt an xAOD::Vertex vertex assuming track masses (imposing massV0) making a correction to the proper time consistent with the imposed V0 mass
double tauError (const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex, double posTrackMass, double negTrackMass) const
 proper time error wrt an xAOD::Vertex vertex assuming posTrackMass and negTrackMass tau = CONST*M*lxy/pT
double tauError (const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex, std::span< const double > masses) const
 proper time error wrt an xAOD::Vertex vertex assuming track masses
double tauError (const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex, double posTrackMass, double negTrackMass, double massV0) const
 proper time error wrt an xAOD::Vertex vertex assuming posTrackMass and negTrackMass (imposing massV0) independent of massV0, variable included to match the corresponding proper time method
double tauError (const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex, std::span< const double > masses, double massV0) const
 proper time error wrt an xAOD::Vertex vertex assuming track masses (imposing massV0) independent of massV0, variable included to match the corresponding proper time method
double tauError (const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex, double massV0) const
 proper time error wrt an xAOD::Vertex vertex assuming massV0 imposing a V0 mass without making an adjustment
Amg::MatrixX tauMassCovariance (const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex, std::span< const double > masses) const
 mass-proper time covariance
double massTauCov (const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex, std::span< const double > masses) const
double tau3D (const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex, std::span< const double > masses) const
 proper time in 3D wrt an xAOD::Vertex vertex assuming track masses
double tau3DError (const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex, std::span< const double > masses) const
 proper time error in 3D wrt an xAOD::Vertex vertex assuming track masses
double tau3DError (const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex, double massV0) const
 proper time error in 3D wrt an xAOD::Vertex vertex assuming massV0 imposing a V0 mass without making an adjustment
double invariantMassBeforeFitIP (const xAOD::Vertex *vxCandidate, std::span< const double > masses) const
 create neutral TrackParticle from vxCandidate
double invariantMassBeforeFit (const xAOD::Vertex *vxCandidate, std::span< const double > masses, const EventContext &, const Trk::IExtrapolator *) const
double invariantMassBeforeFit (const xAOD::Vertex *vxCandidate, std::span< const double > masses, const Amg::Vector3D &vertex, const EventContext &, const Trk::IExtrapolator *) const
double invariantMassErrorBeforeFitIP (const xAOD::Vertex *vxCandidate, std::span< const double > masses) const
double invariantMassErrorBeforeFit (const xAOD::Vertex *vxCandidate, std::span< const double > masses, const EventContext &ctx, const Trk::IExtrapolator *) const
double invariantMassErrorBeforeFit (const xAOD::Vertex *vxCandidate, std::span< const double > masses, const Amg::Vector3D &vertex, const EventContext &ctx, const Trk::IExtrapolator *) const
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Static Public Member Functions

static const InterfaceID & interfaceID ()
 AlgTool interface methods.
static Amg::Vector3D trackMomentum (const xAOD::Vertex *vxCandidate, unsigned int trkIndex)
 Methods, returning the refitted 3-momenta of the positive and negative tracks and the V0 (for more than one track with the same charge, the first one is returned)
static Amg::Vector3D positiveTrackMomentum (const xAOD::Vertex *vxCandidate)
static Amg::Vector3D negativeTrackMomentum (const xAOD::Vertex *vxCandidate)
static Amg::Vector3D V0Momentum (const xAOD::Vertex *vxCandidate)
static xAOD::TrackParticle::FourMom_t track4Momentum (const xAOD::Vertex *vxCandidate, unsigned int trkIndex, double trackMass)
 Methods, returning the refitted 4-momenta of the positive and negative tracks and the V0 for a given hypothesis for the masses of the input tracks and the V0 mass.
static xAOD::TrackParticle::FourMom_t positiveTrack4Momentum (const xAOD::Vertex *vxCandidate, double posTrackMass)
static xAOD::TrackParticle::FourMom_t negativeTrack4Momentum (const xAOD::Vertex *vxCandidate, double negTrackMass)
static xAOD::TrackParticle::FourMom_t V04Momentum (const xAOD::Vertex *vxCandidate, double V0Mass)
static float ndof (const xAOD::Vertex *vxCandidate)
 NDoF of the vertex fit.
static float chisq (const xAOD::Vertex *vxCandidate)
 Chisq of the vertex fit.
static Amg::Vector3D vtx (const xAOD::Vertex *vxCandidate)
 vertex position
static double rxy (const xAOD::Vertex *vxCandidate)
 Rxy of the vertex.
static double rxy (const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex)
 wrt an xAOD::Vertex vertex
static double rxy (const xAOD::Vertex *vxCandidate, const Amg::Vector3D &vertex)
 wrt an Amg::Vector3D vertex
static double rxy_var (double dx, double dy, const Amg::MatrixX &cov)
 rxy_var
static double pT (const xAOD::Vertex *vxCandidate)
 transverse momentum of the V0
static double a0xy (const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex)
 closest distance in Z and the transverse plane of the momentum vector to an xAOD::Vertex a0xy using transverse measurements only a0z using the point of closest approach (3D)
static double a0z (const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex)
static double a0 (const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex)
 closest distance of the momentum vector to an xAOD::Vertex
static Amg::Vector3D pca (const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex)
 point of closest approach of the momentum vector to an xAOD::Vertex
static double lxy (const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex)
 projection of distance in xy of the vertex wrt an xAOD::Vertex vertex along the momentum direction (Px*dx+Py*dy)/pT
static double lxyz (const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex)
 projection of distance in 3D of the vertex wrt an xAOD::Vertex vertex along the momentum direction (Px*dx+Py*dy+Pz*dz)/p
static double tau (const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex, double massV0)
 proper time wrt an xAOD::Vertex vertex assuming massV0 imposing a V0 mass without making an adjustment
static double tau3D (const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex, double massV0)
 proper time in 3D wrt an xAOD::Vertex vertex assuming massV0 imposing a V0 mass without making an adjustment
static double thetaStar (const xAOD::Vertex *vxCandidate, double mass1, double mass2)
 Polarization angles in helicity frame (using positive track):
static double cosThetaStar (const xAOD::Vertex *vxCandidate, double posTrackMass, double negTrackMass)
 cosThetaStar
static double cosThetaStar (const CLHEP::HepLorentzVector &posTrack, const CLHEP::HepLorentzVector &negTrack)
static double phiStar (const xAOD::Vertex *vxCandidate, double posTrackMass, double negTrackMass)
 phiStar
static double phiStar (const CLHEP::HepLorentzVector &v0, const CLHEP::HepLorentzVector &track)
static double cosTheta (const xAOD::Vertex *vxCandidate, const Amg::Vector3D &vertex)
 cosTheta (pointing angle to an Amg::Vector3D or an xAOD::Vertex)
static double cosTheta (const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex)
static double cosTheta_xy (const xAOD::Vertex *vxCandidate, const Amg::Vector3D &vertex)
 cosTheta (pointing angle to an Amg::Vector3D or an xAOD::Vertex in transverse plane)
static double cosTheta_xy (const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex)
static float charge (const xAOD::Vertex *vxCandidate)
 sum of the charges of the tracks in the vertex
static const xAOD::TrackParticleorigTrack (const xAOD::Vertex *vxCandidate, int trkIndex)
 pointers to original tracks
static const xAOD::TrackParticlepositiveOrigTrack (const xAOD::Vertex *vxCandidate)
static const xAOD::TrackParticlenegativeOrigTrack (const xAOD::Vertex *vxCandidate)
static Amg::MatrixX convertCovMatrix (const xAOD::Vertex *vxCandidate)
static Amg::MatrixX makeV0Cov (const xAOD::Vertex *vxCandidate)

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

double massErrorV0Fitter (const xAOD::Vertex *vxCandidate, double posTrackMass, double negTrackMass) const
double massErrorV0Fitter (const xAOD::Vertex *vxCandidate, std::span< const double > masses) const
double massErrorVKalVrt (const xAOD::Vertex *vxCandidate, double posTrackMass, double negTrackMass) const
double massErrorVKalVrt (const xAOD::Vertex *vxCandidate, std::span< const double > masses) const
double massErrorVxCandidate (const xAOD::Vertex *vxCandidate, double posTrackMass, double negTrackMass) const
double massErrorVxCandidate (const xAOD::Vertex *vxCandidate, std::span< const double > masses) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 35 of file V0Tools.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ V0Tools()

V0Tools::V0Tools ( const std::string & t,
const std::string & n,
const IInterface * p )

Default constructor due to Athena interface.

Definition at line 26 of file V0Tools.cxx.

26 :
27 AthAlgTool(t,n,p)
28 {
29 declareInterface<V0Tools>(this);
30 }
AthAlgTool()
Default constructor:

◆ ~V0Tools()

V0Tools::~V0Tools ( )
default

Virtual destructor.

Member Function Documentation

◆ a0()

double V0Tools::a0 ( const xAOD::Vertex * vxCandidate,
const xAOD::Vertex * vertex )
static

closest distance of the momentum vector to an xAOD::Vertex

Definition at line 683 of file V0Tools.cxx.

684 {
685 double cosineTheta = cosTheta(vxCandidate,vertex);
686 double sinTheta = ((1.-cosineTheta*cosineTheta)>0.) ? sqrt((1.-cosineTheta*cosineTheta)) : 0.;
687 return (vtx(vxCandidate)-vertex->position()).mag() * sinTheta;
688 //return (vtx(vxCandidate)-vertex->position()).mag() * sqrt(1.-cosineTheta*cosineTheta);
689 }
static Amg::Vector3D vtx(const xAOD::Vertex *vxCandidate)
vertex position
Definition V0Tools.cxx:476
static double cosTheta(const xAOD::Vertex *vxCandidate, const Amg::Vector3D &vertex)
cosTheta (pointing angle to an Amg::Vector3D or an xAOD::Vertex)
Definition V0Tools.cxx:1850

◆ a0Error()

double V0Tools::a0Error ( const xAOD::Vertex * vxCandidate,
const xAOD::Vertex * vertex,
bool in3D = true ) const

error on a0

Definition at line 813 of file V0Tools.cxx.

814 {
815 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
816 auto vert = vxCandidate->position() - vertex->position();
817 double dx = vert.x();
818 double dy = vert.y();
819 double dz = vert.z();
820 double Px=0., Py=0., Pz=0.;
821 std::vector<double>dpxdqOverP(NTrk), dpxdtheta(NTrk), dpxdphi(NTrk);
822 std::vector<double>dpydqOverP(NTrk), dpydtheta(NTrk), dpydphi(NTrk);
823 std::vector<double>dpzdqOverP(NTrk), dpzdtheta(NTrk);
824 std::vector<double>da0dqOverP(NTrk), da0dtheta(NTrk), da0dphi(NTrk);
825
826 auto fullCov = convertCovMatrix(vxCandidate);
827 for( unsigned int it=0; it<NTrk; it++) {
828 const Trk::TrackParameters* bPer = vxCandidate->vxTrackAtVertex()[it].perigeeAtVertex();
829 double trkCharge = 1.;
830 if (bPer->parameters()[Trk::qOverP] < 0.) trkCharge = -1.;
831 double phi = bPer->parameters()[Trk::phi];
832 double theta = bPer->parameters()[Trk::theta];
833 double qOverP = bPer->parameters()[Trk::qOverP];
834 dpxdqOverP[it] = -(sin(theta)*cos(phi)*trkCharge)/(qOverP*qOverP);
835 dpxdtheta[it] = (cos(theta)*cos(phi)*trkCharge)/qOverP;
836 dpxdphi[it] = -(sin(theta)*sin(phi)*trkCharge)/qOverP;
837 dpydqOverP[it] = -(sin(theta)*sin(phi)*trkCharge)/(qOverP*qOverP);
838 dpydtheta[it] = (cos(theta)*sin(phi)*trkCharge)/qOverP;
839 dpydphi[it] = (sin(theta)*cos(phi)*trkCharge)/qOverP;
840 if ( in3D ) {
841 dpzdqOverP[it] = -(cos(theta)*trkCharge)/(qOverP*qOverP);
842 dpzdtheta[it] = -(sin(theta)*trkCharge)/qOverP;
843 }
844 Px += bPer->momentum()[Trk::px];
845 Py += bPer->momentum()[Trk::py];
846 Pz += bPer->momentum()[Trk::pz];
847 }
848 double cosineTheta;
849 double a0val;
850 if ( in3D ) {
851 cosineTheta = cosTheta(vxCandidate,vertex);
852 a0val = a0(vxCandidate,vertex);
853 } else { // transforms momentum and vertex separation to transverse plane and leads also to zero dXdz derivatives
854 cosineTheta = cosTheta_xy(vxCandidate,vertex);
855 a0val = a0xy(vxCandidate,vertex);
856 Pz = 0.;
857 dz = 0.;
858 }
859 double P = sqrt(Px*Px+Py*Py+Pz*Pz);
860 double r = sqrt(dx*dx+dy*dy+dz*dz);
861
862 double da0dx = (Px/P*r*cosineTheta - dx)/a0val;
863 double da0dy = (Py/P*r*cosineTheta - dy)/a0val;
864 double da0dz = (Pz/P*r*cosineTheta - dz)/a0val;
865 double da0dx0 = -da0dx;
866 double da0dy0 = -da0dy;
867 double da0dz0 = -da0dz;
868 for( unsigned int it=0; it<NTrk; it++) {
869 da0dqOverP[it] = -(r*cosineTheta/P)*(da0dx*dpxdqOverP[it]+da0dy*dpydqOverP[it]+da0dz*dpzdqOverP[it]);
870 da0dtheta[it] = -(r*cosineTheta/P)*(da0dx*dpxdtheta[it]+da0dy*dpydtheta[it]+da0dz*dpzdtheta[it]);
871 da0dphi[it] = -(r*cosineTheta/P)*(da0dx*dpxdphi[it]+da0dy*dpydphi[it]);
872 }
873
874 unsigned int ndim = 0;
875 if (fullCov.size() != 0) {
876 ndim = fullCov.rows();
877 } else {
878 ndim = 5*NTrk+3;
879 }
880
881 Amg::MatrixX V0_err;
882 if (ndim == 5*NTrk+3 || ndim == 5*NTrk+6) {
883 Amg::MatrixX D_vec(5*NTrk+6,1); D_vec.setZero();
884 for( unsigned int it=0; it<NTrk; it++) {
885 D_vec(5*it+0) = 0.;
886 D_vec(5*it+1) = 0.;
887 D_vec(5*it+2) = da0dphi[it];
888 D_vec(5*it+3) = da0dtheta[it];
889 D_vec(5*it+4) = da0dqOverP[it];
890 }
891 D_vec(5*NTrk+0) = da0dx;
892 D_vec(5*NTrk+1) = da0dy;
893 D_vec(5*NTrk+2) = da0dz;
894 D_vec(5*NTrk+3) = da0dx0;
895 D_vec(5*NTrk+4) = da0dy0;
896 D_vec(5*NTrk+5) = da0dz0;
897
898 Amg::MatrixX W_mat(5*NTrk+6,5*NTrk+6); W_mat.setZero();
899 if (fullCov.size() != 0) {
900 W_mat.block(0,0,ndim,ndim) = fullCov;
901 } else {
902 Amg::MatrixX V0_cov = makeV0Cov(vxCandidate);
903 W_mat.block(0,0,V0_cov.rows(),V0_cov.rows()) = V0_cov;
904 W_mat.block<3,3>(5*NTrk,5*NTrk) = vxCandidate->covariancePosition();
905 }
906 W_mat.block<3,3>(5*NTrk+3,5*NTrk+3) = vertex->covariancePosition();
907 V0_err = D_vec.transpose() * W_mat * D_vec;
908 } else if (ndim == 3*NTrk+3) {
909 Amg::MatrixX D_vec(3*NTrk+6,1); D_vec.setZero();
910 D_vec(0) = da0dx;
911 D_vec(1) = da0dy;
912 D_vec(2) = da0dz;
913 for( unsigned int it=0; it<NTrk; it++) {
914 D_vec(3*it+3) = da0dphi[it];
915 D_vec(3*it+4) = da0dtheta[it];
916 D_vec(3*it+5) = da0dqOverP[it];
917 }
918 D_vec(3*NTrk+3) = da0dx0;
919 D_vec(3*NTrk+4) = da0dy0;
920 D_vec(3*NTrk+5) = da0dz0;
921
922 Amg::MatrixX W_mat(3*NTrk+6,3*NTrk+6); W_mat.setZero();
923 W_mat.block(0,0,ndim,ndim) = fullCov;
924 W_mat.block<3,3>(3*NTrk+3,3*NTrk+3) = vertex->covariancePosition();
925 V0_err = D_vec.transpose() * W_mat * D_vec;
926 }else{
927 ATH_MSG_ERROR("This should not happen - returning zero.");
928 return 0;
929 }
930
931 double a0Errsq = V0_err(0,0);
932 if (a0Errsq <= 0.) ATH_MSG_DEBUG("a0Error: negative sqrt a0Errsq " << a0Errsq);
933 double a0Err = (a0Errsq>0.) ? sqrt(a0Errsq) : 0.;
934 return a0Err;
935 }
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
static Double_t P(Double_t *tt, Double_t *par)
const Amg::Vector3D & momentum() const
Access method for the momentum.
static Amg::MatrixX makeV0Cov(const xAOD::Vertex *vxCandidate)
Definition V0Tools.cxx:2293
static double a0xy(const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex)
closest distance in Z and the transverse plane of the momentum vector to an xAOD::Vertex a0xy using t...
Definition V0Tools.cxx:667
static double cosTheta_xy(const xAOD::Vertex *vxCandidate, const Amg::Vector3D &vertex)
cosTheta (pointing angle to an Amg::Vector3D or an xAOD::Vertex in transverse plane)
Definition V0Tools.cxx:1866
static Amg::MatrixX convertCovMatrix(const xAOD::Vertex *vxCandidate)
Definition V0Tools.cxx:2444
std::vector< Trk::VxTrackAtVertex > & vxTrackAtVertex()
Non-const access to the VxTrackAtVertex vector.
const Amg::Vector3D & position() const
Returns the 3-pos.
int r
Definition globals.cxx:22
double a0
Definition globals.cxx:27
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
@ pz
global momentum (cartesian)
Definition ParamDefs.h:61
@ theta
Definition ParamDefs.h:66
@ qOverP
perigee
Definition ParamDefs.h:67
@ phi
Definition ParamDefs.h:75
@ px
Definition ParamDefs.h:59
@ py
Definition ParamDefs.h:60
ParametersBase< TrackParametersDim, Charged > TrackParameters

◆ a0xy()

double V0Tools::a0xy ( const xAOD::Vertex * vxCandidate,
const xAOD::Vertex * vertex )
static

closest distance in Z and the transverse plane of the momentum vector to an xAOD::Vertex a0xy using transverse measurements only a0z using the point of closest approach (3D)

Definition at line 667 of file V0Tools.cxx.

668 {
669 double cosineTheta_xy = cosTheta_xy(vxCandidate,vertex);
670 double sinTheta_xy = ((1.-cosineTheta_xy*cosineTheta_xy)>0.) ? sqrt((1.-cosineTheta_xy*cosineTheta_xy)) : 0.;
671 return (vtx(vxCandidate)-vertex->position()).perp() * sinTheta_xy;
672 //return (vtx(vxCandidate)-vertex->position()).perp() * sqrt(1.-cosineTheta_xy*cosineTheta_xy);
673 }

◆ a0xyError()

double V0Tools::a0xyError ( const xAOD::Vertex * vxCandidate,
const xAOD::Vertex * vertex ) const

errors on a0xy and a0z

Definition at line 808 of file V0Tools.cxx.

809 {
810 return a0Error(vxCandidate, vertex, false);
811 }
double a0Error(const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex, bool in3D=true) const
error on a0
Definition V0Tools.cxx:813

◆ a0z()

double V0Tools::a0z ( const xAOD::Vertex * vxCandidate,
const xAOD::Vertex * vertex )
static

Definition at line 675 of file V0Tools.cxx.

676 {
677 Amg::Vector3D pv = vertex->position();
678 Amg::Vector3D ca_point = pca(vxCandidate,vertex);
679 Amg::Vector3D a0_vec = pv - ca_point;
680 return a0_vec.z();
681 }
static Amg::Vector3D pca(const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex)
point of closest approach of the momentum vector to an xAOD::Vertex
Definition V0Tools.cxx:622
Eigen::Matrix< double, 3, 1 > Vector3D

◆ a0zError()

double V0Tools::a0zError ( const xAOD::Vertex * vxCandidate,
const xAOD::Vertex * vertex ) const

Definition at line 691 of file V0Tools.cxx.

692 {
693 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
694 auto vert = vxCandidate->position() - vertex->position();
695 double dx = vert.x();
696 double dy = vert.y();
697 double dz = vert.z();
698 double Px=0., Py=0., Pz=0.;
699 std::vector<double>dpxdqOverP(NTrk), dpxdtheta(NTrk), dpxdphi(NTrk);
700 std::vector<double>dpydqOverP(NTrk), dpydtheta(NTrk), dpydphi(NTrk);
701 std::vector<double>dpzdqOverP(NTrk), dpzdtheta(NTrk);
702 std::vector<double>da0dqOverP(NTrk), da0dtheta(NTrk), da0dphi(NTrk);
703
704 auto fullCov = convertCovMatrix(vxCandidate);
705 for( unsigned int it=0; it<NTrk; it++) {
706 const Trk::TrackParameters* bPer = vxCandidate->vxTrackAtVertex()[it].perigeeAtVertex();
707 double trkCharge = 1.;
708 if (bPer->parameters()[Trk::qOverP] < 0.) trkCharge = -1.;
709 double phi = bPer->parameters()[Trk::phi];
710 double theta = bPer->parameters()[Trk::theta];
711 double qOverP = bPer->parameters()[Trk::qOverP];
712 dpxdqOverP[it] = -(sin(theta)*cos(phi)*trkCharge)/(qOverP*qOverP);
713 dpxdtheta[it] = (cos(theta)*cos(phi)*trkCharge)/qOverP;
714 dpxdphi[it] = -(sin(theta)*sin(phi)*trkCharge)/qOverP;
715 dpydqOverP[it] = -(sin(theta)*sin(phi)*trkCharge)/(qOverP*qOverP);
716 dpydtheta[it] = (cos(theta)*sin(phi)*trkCharge)/qOverP;
717 dpydphi[it] = (sin(theta)*cos(phi)*trkCharge)/qOverP;
718 dpzdqOverP[it] = -(cos(theta)*trkCharge)/(qOverP*qOverP);
719 dpzdtheta[it] = -(sin(theta)*trkCharge)/qOverP;
720 Px += bPer->momentum()[Trk::px];
721 Py += bPer->momentum()[Trk::py];
722 Pz += bPer->momentum()[Trk::pz];
723 }
724 double P2 = Px*Px+Py*Py+Pz*Pz;
725 double B = Px*dx+Py*dy+Pz*dz;
726
727 double da0dx = (Px*Pz)/P2;
728 double da0dy = (Py*Pz)/P2;
729 double da0dz = (Pz*Pz)/P2 - 1.;
730 double da0dx0 = -da0dx;
731 double da0dy0 = -da0dy;
732 double da0dz0 = -da0dz;
733 for( unsigned int it=0; it<NTrk; it++) {
734 double dP2dqOverP = 2.*(Px*dpxdqOverP[it]+Py*dpydqOverP[it]+Pz*dpzdqOverP[it]);
735 double dP2dtheta = 2.*(Px*dpxdtheta[it]+Py*dpydtheta[it]+Pz*dpzdtheta[it]);
736 double dP2dphi = 2.*(Px*dpxdphi[it]+Py*dpydphi[it]);
737 da0dqOverP[it] = (B*(P2*dpzdqOverP[it]-Pz*dP2dqOverP) +
738 Pz*P2*(dx*dpxdqOverP[it]+dy*dpydqOverP[it]+dz*dpzdqOverP[it]))/(P2*P2);
739 da0dtheta[it] = (B*(P2*dpzdtheta[it]-Pz*dP2dtheta) +
740 Pz*P2*(dx*dpxdtheta[it]+dy*dpydtheta[it]+dz*dpzdtheta[it]))/(P2*P2);
741 da0dphi[it] = -(B*Pz*dP2dphi -
742 Pz*P2*(dx*dpxdphi[it]+dy*dpydphi[it]))/(P2*P2);
743 }
744
745 unsigned int ndim = 0;
746 if (fullCov.size() != 0) {
747 ndim = fullCov.rows();
748 } else {
749 ndim = 5*NTrk+3;
750 }
751
752 Amg::MatrixX V0_err;
753 if (ndim == 5*NTrk+3 || ndim == 5*NTrk+6) {
754 Amg::MatrixX D_vec(5*NTrk+6,1); D_vec.setZero();
755 for( unsigned int it=0; it<NTrk; it++) {
756 D_vec(5*it+0) = 0.;
757 D_vec(5*it+1) = 0.;
758 D_vec(5*it+2) = da0dphi[it];
759 D_vec(5*it+3) = da0dtheta[it];
760 D_vec(5*it+4) = da0dqOverP[it];
761 }
762 D_vec(5*NTrk+0) = da0dx;
763 D_vec(5*NTrk+1) = da0dy;
764 D_vec(5*NTrk+2) = da0dz;
765 D_vec(5*NTrk+3) = da0dx0;
766 D_vec(5*NTrk+4) = da0dy0;
767 D_vec(5*NTrk+5) = da0dz0;
768
769 Amg::MatrixX W_mat(5*NTrk+6,5*NTrk+6); W_mat.setZero();
770 if (fullCov.size() != 0) {
771 W_mat.block(0,0,ndim,ndim) = fullCov;
772 } else {
773 Amg::MatrixX V0_cov = makeV0Cov(vxCandidate);
774 W_mat.block(0,0,V0_cov.rows(),V0_cov.rows()) = V0_cov;
775 W_mat.block<3,3>(5*NTrk,5*NTrk) = vxCandidate->covariancePosition();
776 }
777 W_mat.block<3,3>(5*NTrk+3,5*NTrk+3) = vertex->covariancePosition();
778 V0_err = D_vec.transpose() * W_mat * D_vec;
779 } else if (ndim == 3*NTrk+3) {
780 Amg::MatrixX D_vec(3*NTrk+6,1); D_vec.setZero();
781 D_vec(0) = da0dx;
782 D_vec(1) = da0dy;
783 D_vec(2) = da0dz;
784 for( unsigned int it=0; it<NTrk; it++) {
785 D_vec(3*it+3) = da0dphi[it];
786 D_vec(3*it+4) = da0dtheta[it];
787 D_vec(3*it+5) = da0dqOverP[it];
788 }
789 D_vec(3*NTrk+3) = da0dx0;
790 D_vec(3*NTrk+4) = da0dy0;
791 D_vec(3*NTrk+5) = da0dz0;
792
793 Amg::MatrixX W_mat(3*NTrk+6,3*NTrk+6); W_mat.setZero();
794 W_mat.block(0,0,ndim,ndim) = fullCov;
795 W_mat.block<3,3>(3*NTrk+3,3*NTrk+3) = vertex->covariancePosition();
796 V0_err = D_vec.transpose() * W_mat * D_vec;
797 }else{
798 ATH_MSG_ERROR("This should not happen - returning zero.");
799 return 0;
800 }
801
802 double a0Errsq = V0_err(0,0);
803 if (a0Errsq <= 0.) ATH_MSG_DEBUG("a0Error: negative sqrt a0Errsq " << a0Errsq);
804 double a0Err = (a0Errsq>0.) ? sqrt(a0Errsq) : 0.;
805 return a0Err;
806 }

◆ charge()

float V0Tools::charge ( const xAOD::Vertex * vxCandidate)
static

sum of the charges of the tracks in the vertex

Definition at line 1884 of file V0Tools.cxx.

1885 {
1886 float ch = 0.;
1887 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
1888 for( unsigned int it=0; it<NTrk; it++) {
1889 float trkCharge = vxCandidate->trackParticle(it)->charge();
1890 //const Trk::TrackParameters* bPer = vxCandidate->vxTrackAtVertex()[it].perigeeAtVertex();
1891 //float trkCharge = 1.;
1892 //if (bPer->parameters()[Trk::qOverP] < 0.) trkCharge = -1.;
1893 ch += trkCharge;
1894 }
1895 return ch;
1896 }
float charge() const
Returns the charge.
const TrackParticle * trackParticle(size_t i) const
Get the pointer to a given track that was used in vertex reco.

◆ chisq()

float V0Tools::chisq ( const xAOD::Vertex * vxCandidate)
static

Chisq of the vertex fit.

Definition at line 451 of file V0Tools.cxx.

452 {
453 return vxCandidate->chiSquared();
454 }
float chiSquared() const
Returns the of the vertex fit as float.

◆ convertCovMatrix()

Amg::MatrixX V0Tools::convertCovMatrix ( const xAOD::Vertex * vxCandidate)
static

Definition at line 2444 of file V0Tools.cxx.

2445 {
2446 unsigned int NTrk = vxCandidate->nTrackParticles();
2447 const std::vector<float> &matrix = vxCandidate->covariance();
2448
2449 int ndim = 0;
2450
2451 if ( matrix.size() == (3*NTrk+3)*(3*NTrk+3+1)/2) {
2452 ndim = 3*NTrk+3;
2453 } else if (matrix.size() == (5*NTrk+3)*(5*NTrk+3+1)/2) {
2454 ndim = 5*NTrk+3;
2455 } else {
2456 return Amg::MatrixX(0,0);
2457 }
2458
2459 Amg::MatrixX mtx(ndim,ndim);
2460
2461 Eigen::Index ij=0;
2462 for (int i=1; i<= ndim; i++) {
2463 for (int j=1; j<=i; j++){
2464 if (i==j) {
2465 mtx(i-1,j-1)=matrix[ij];
2466 } else {
2467 mtx.fillSymmetric(i-1,j-1,matrix[ij]);
2468 }
2469 ij++;
2470 }
2471 }
2472 // NOTE: mtx is a pointer! Take care of deleting it after you do not
2473 // need it anymore!!!!
2474 return mtx;
2475 }
size_t nTrackParticles() const
Get the number of tracks associated with this vertex.
const std::vector< float > & covariance() const
Returns the covariance matrix as a simple vector of values.

◆ cosTheta() [1/2]

double V0Tools::cosTheta ( const xAOD::Vertex * vxCandidate,
const Amg::Vector3D & vertex )
static

cosTheta (pointing angle to an Amg::Vector3D or an xAOD::Vertex)

Definition at line 1850 of file V0Tools.cxx.

1851 {
1852 auto mom = V0Momentum(vxCandidate);
1853 auto vtx1 = vtx(vxCandidate);
1854 vtx1 -= vertex;
1855 return (mom.dot(vtx1))/(mom.mag()*(vtx1).mag());
1856 }
Scalar mag() const
mag method
static Amg::Vector3D V0Momentum(const xAOD::Vertex *vxCandidate)
Definition V0Tools.cxx:396

◆ cosTheta() [2/2]

double V0Tools::cosTheta ( const xAOD::Vertex * vxCandidate,
const xAOD::Vertex * vertex )
static

Definition at line 1858 of file V0Tools.cxx.

1859 {
1860 auto mom = V0Momentum(vxCandidate);
1861 auto vtx1 = vtx(vxCandidate);
1862 vtx1 -= vertex->position();
1863 return (mom.dot((vtx1)))/(mom.mag()*(vtx1).mag());
1864 }

◆ cosTheta_xy() [1/2]

double V0Tools::cosTheta_xy ( const xAOD::Vertex * vxCandidate,
const Amg::Vector3D & vertex )
static

cosTheta (pointing angle to an Amg::Vector3D or an xAOD::Vertex in transverse plane)

Definition at line 1866 of file V0Tools.cxx.

1867 {
1868 auto mom = V0Momentum(vxCandidate);
1869 auto vtx1 = vtx(vxCandidate);
1870 vtx1 -= vertex;
1871 double pT = mom.perp();
1872 return (mom.x()*vtx1.x()+mom.y()*vtx1.y())/(pT*vtx1.perp());
1873 }
static double pT(const xAOD::Vertex *vxCandidate)
transverse momentum of the V0
Definition V0Tools.cxx:542

◆ cosTheta_xy() [2/2]

double V0Tools::cosTheta_xy ( const xAOD::Vertex * vxCandidate,
const xAOD::Vertex * vertex )
static

Definition at line 1875 of file V0Tools.cxx.

1876 {
1877 auto mom = V0Momentum(vxCandidate);
1878 auto vtx1 = vtx(vxCandidate);
1879 vtx1 -= vertex->position();
1880 double pT = mom.perp();
1881 return (mom.x()*vtx1.x()+mom.y()*vtx1.y())/(pT*vtx1.perp());
1882 }

◆ cosThetaStar() [1/2]

double V0Tools::cosThetaStar ( const CLHEP::HepLorentzVector & posTrack,
const CLHEP::HepLorentzVector & negTrack )
static

Definition at line 1808 of file V0Tools.cxx.

1809 {
1810 CLHEP::HepLorentzVector v0(posTrack + negTrack);
1811 double Mv0 = v0.m();
1812 double Mplus = posTrack.m();
1813 double Mminus= negTrack.m();
1814 double Pv0 = v0.rho();
1815 double pssq = (Mv0*Mv0-(Mplus+Mminus)*(Mplus+Mminus))*(Mv0*Mv0-(Mplus-Mminus)*(Mplus-Mminus));
1816 double ps = (pssq>0.) ? sqrt(pssq) : 0.;
1817 ps /= 2.*Mv0;
1818 double pp = v0.px()*posTrack.px() + v0.py()*posTrack.py() + v0.pz()*posTrack.pz();
1819 return ( v0.e()*pp - Pv0*Pv0*posTrack.e())/( Mv0*ps*Pv0);
1820 }

◆ cosThetaStar() [2/2]

double V0Tools::cosThetaStar ( const xAOD::Vertex * vxCandidate,
double posTrackMass,
double negTrackMass )
static

cosThetaStar

Definition at line 1799 of file V0Tools.cxx.

1800 {
1801 xAOD::TrackParticle::FourMom_t PosMom = positiveTrack4Momentum(vxCandidate, posTrackMass);
1802 xAOD::TrackParticle::FourMom_t NegMom = negativeTrack4Momentum(vxCandidate, negTrackMass);
1803 CLHEP::HepLorentzVector posMom(PosMom.Px(),PosMom.Py(),PosMom.Pz(),PosMom.E());
1804 CLHEP::HepLorentzVector negMom(NegMom.Px(),NegMom.Py(),NegMom.Pz(),NegMom.E());
1805 return cosThetaStar(posMom, negMom);
1806 }
static xAOD::TrackParticle::FourMom_t positiveTrack4Momentum(const xAOD::Vertex *vxCandidate, double posTrackMass)
Definition V0Tools.cxx:416
static xAOD::TrackParticle::FourMom_t negativeTrack4Momentum(const xAOD::Vertex *vxCandidate, double negTrackMass)
Definition V0Tools.cxx:426
static double cosThetaStar(const xAOD::Vertex *vxCandidate, double posTrackMass, double negTrackMass)
cosThetaStar
Definition V0Tools.cxx:1799
IParticle::FourMom_t FourMom_t
Definition of the 4-momentum type.

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ initialize()

StatusCode V0Tools::initialize ( )

Standard AlgTool methods.

Definition at line 34 of file V0Tools.cxx.

35 {
36 ATH_MSG_DEBUG( "Initialize successful" );
37 return StatusCode::SUCCESS;
38 }

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & Trk::V0Tools::interfaceID ( )
inlinestatic

AlgTool interface methods.

Definition at line 57 of file V0Tools.h.

58 {
59 return IID_V0Tools;
60 }
static const InterfaceID IID_V0Tools("V0Tools", 1, 1)

◆ invariantMass() [1/2]

double V0Tools::invariantMass ( const xAOD::Vertex * vxCandidate,
double posTrackMass,
double negTrackMass ) const

Methods, returning the invariant mass, error on the invariant mass and Chi2 probability of the invariant mass of an xAOD::Vertex for a given hypothesis for the masses of the input tracks and the V0 mass.

if a negative value for a track is provided, the invariantMass and invariantMassError are returned excluding that track

Definition at line 40 of file V0Tools.cxx.

41 {
42 std::array<double, 2> masses = {posTrackMass, negTrackMass};
43
44 return invariantMass(vxCandidate,masses);
45 }
double invariantMass(const xAOD::Vertex *vxCandidate, double posTrackMass, double negTrackMass) const
Methods, returning the invariant mass, error on the invariant mass and Chi2 probability of the invari...
Definition V0Tools.cxx:40

◆ invariantMass() [2/2]

double V0Tools::invariantMass ( const xAOD::Vertex * vxCandidate,
std::span< const double > masses ) const

Definition at line 49 of file V0Tools.cxx.

50 {
51 double px = 0., py = 0., pz = 0., e = 0.;
52 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
53 if (masses.size() != NTrk) {
54 ATH_MSG_ERROR("The provided number of masses does not match the number of tracks in the vertex");
55 return -999999.;
56 }
57 for( unsigned int it=0; it<NTrk; it++) {
58 if (masses[it] >= 0.) {
59 xAOD::TrackParticle::FourMom_t lorentz_trk = track4Momentum(vxCandidate,it,masses[it]);
60 px += lorentz_trk.Px();
61 py += lorentz_trk.Py();
62 pz += lorentz_trk.Pz();
63 e += lorentz_trk.E();
64 }
65 }
66 double msq = e*e - px*px - py*py - pz*pz;
67 return (msq>0.) ? sqrt(msq) : 0.;
68 }
static xAOD::TrackParticle::FourMom_t track4Momentum(const xAOD::Vertex *vxCandidate, unsigned int trkIndex, double trackMass)
Methods, returning the refitted 4-momenta of the positive and negative tracks and the V0 for a given ...
Definition V0Tools.cxx:406

◆ invariantMassBeforeFit() [1/2]

double V0Tools::invariantMassBeforeFit ( const xAOD::Vertex * vxCandidate,
std::span< const double > masses,
const Amg::Vector3D & vertex,
const EventContext & ctx,
const Trk::IExtrapolator * extrap ) const

Definition at line 1979 of file V0Tools.cxx.

1981 {
1982 Trk::PerigeeSurface perigeeSurface(vertex);
1983 double px = 0., py = 0., pz = 0., e = 0.;
1984 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
1985 if (masses.size() != NTrk) {
1986 ATH_MSG_ERROR("The provided number of masses does not match the number of tracks in the vertex");
1987 return -999999.;
1988 }
1989 for( unsigned int it=0; it<NTrk; it++) {
1990 if (masses[it] >= 0.) {
1991 const xAOD::TrackParticle* TP = origTrack(vxCandidate,it);
1992 if (TP == nullptr) return -999999.;
1993 std::unique_ptr<const Trk::TrackParameters> extrPer =
1994 extrap->extrapolate(ctx, TP->perigeeParameters(), perigeeSurface);
1995 if (extrPer == nullptr)
1996 return -999999.;
1997 px += extrPer->momentum().x();
1998 py += extrPer->momentum().y();
1999 pz += extrPer->momentum().z();
2000 double pesq = extrPer->momentum().mag2() + masses[it]*masses[it];
2001 double pe = (pesq>0.) ? sqrt(pesq) : 0.;
2002 e += pe;
2003 }
2004 }
2005 double msq = e*e - px*px - py*py - pz*pz;
2006 return (msq>0.) ? sqrt(msq) : 0.;
2007 }
virtual std::unique_ptr< NeutralParameters > extrapolate(const NeutralParameters &parameters, const Surface &sf, PropDirection dir=anyDirection, const BoundaryCheck &bcheck=true) const =0
Main extrapolation Interface starting from neutral parameters and aiming at surface.
static const xAOD::TrackParticle * origTrack(const xAOD::Vertex *vxCandidate, int trkIndex)
pointers to original tracks
Definition V0Tools.cxx:1898
const Trk::Perigee & perigeeParameters() const
Returns the Trk::MeasuredPerigee track parameters.
TrackParticle_v1 TrackParticle
Reference the current persistent version:

◆ invariantMassBeforeFit() [2/2]

double V0Tools::invariantMassBeforeFit ( const xAOD::Vertex * vxCandidate,
std::span< const double > masses,
const EventContext & ctx,
const Trk::IExtrapolator * extrapolator ) const

Definition at line 1950 of file V0Tools.cxx.

1951 {
1952 Trk::PerigeeSurface perigeeSurface(vxCandidate->position());
1953 double px = 0., py = 0., pz = 0., e = 0.;
1954 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
1955 if (masses.size() != NTrk) {
1956 ATH_MSG_ERROR("The provided number of masses does not match the number of tracks in the vertex");
1957 return -999999.;
1958 }
1959 for( unsigned int it=0; it<NTrk; it++) {
1960 if (masses[it] >= 0.) {
1961 const xAOD::TrackParticle* TP = origTrack(vxCandidate,it);
1962 if (TP == nullptr) return -999999.;
1963 std::unique_ptr<const Trk::TrackParameters> extrPer =
1964 extrapolator->extrapolate(ctx, TP->perigeeParameters(), perigeeSurface);
1965 if (extrPer == nullptr)
1966 return -999999.;
1967 px += extrPer->momentum().x();
1968 py += extrPer->momentum().y();
1969 pz += extrPer->momentum().z();
1970 double pesq = extrPer->momentum().mag2() + masses[it]*masses[it];
1971 double pe = (pesq>0.) ? sqrt(pesq) : 0.;
1972 e += pe;
1973 }
1974 }
1975 double msq = e*e - px*px - py*py - pz*pz;
1976 return (msq>0.) ? sqrt(msq) : 0.;
1977 }

◆ invariantMassBeforeFitIP()

double V0Tools::invariantMassBeforeFitIP ( const xAOD::Vertex * vxCandidate,
std::span< const double > masses ) const

create neutral TrackParticle from vxCandidate

Methods, returning the invariant mass and the error on the invariant mass calculated from the original track parameters (at the perigee (IP) or at a given vertex position if no vertex is specified, the reconstructed vertex position is used

if a negative value for a track is provided, the invariantMass and invariantMassError are returned excluding that track

Definition at line 1925 of file V0Tools.cxx.

1926 {
1927 double px = 0., py = 0., pz = 0., e = 0.;
1928 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
1929 if (masses.size() != NTrk) {
1930 ATH_MSG_ERROR("The provided number of masses does not match the number of tracks in the vertex");
1931 return -999999.;
1932 }
1933 for( unsigned int it=0; it<NTrk; it++) {
1934 if (masses[it] >= 0.) {
1935 const xAOD::TrackParticle* TP = origTrack(vxCandidate,it);
1936 if (TP == nullptr) return -999999.;
1937 TLorentzVector Tp4 = TP->p4();
1938 px += Tp4.Px();
1939 py += Tp4.Py();
1940 pz += Tp4.Pz();
1941 double pesq = 1./(TP->qOverP()*TP->qOverP()) + masses[it]*masses[it];
1942 double pe = (pesq>0.) ? sqrt(pesq) : 0.;
1943 e += pe;
1944 }
1945 }
1946 double msq = e*e - px*px - py*py - pz*pz;
1947 return (msq>0.) ? sqrt(msq) : 0.;
1948 }
static Double_t Tp4(Double_t t)
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
float qOverP() const
Returns the parameter.

◆ invariantMassError() [1/2]

double V0Tools::invariantMassError ( const xAOD::Vertex * vxCandidate,
double posTrackMass,
double negTrackMass ) const

Definition at line 70 of file V0Tools.cxx.

71 {
72 std::array<double, 2> masses = {posTrackMass, negTrackMass};
73
74 return invariantMassError(vxCandidate,masses);
75 }
double invariantMassError(const xAOD::Vertex *vxCandidate, double posTrackMass, double negTrackMass) const
Definition V0Tools.cxx:70

◆ invariantMassError() [2/2]

double V0Tools::invariantMassError ( const xAOD::Vertex * vxCandidate,
std::span< const double > masses ) const

Definition at line 77 of file V0Tools.cxx.

78 {
79 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
80 if (masses.size() != NTrk) {
81 ATH_MSG_ERROR("The provided number of masses does not match the number of tracks in the vertex");
82 return -999999.;
83 }
84 double error = -999999.;
85 auto fullCov = convertCovMatrix(vxCandidate);
86 if (fullCov.size() == 0) {
87 ATH_MSG_DEBUG("0 pointer for full covariance. Making-up one from the vertex and tracks covariances");
88 error = massErrorVxCandidate(vxCandidate,masses);
89 } else {
90 unsigned int ndim = fullCov.rows();
91 if (ndim != 0) {
92 if (ndim == 5*NTrk+3 || ndim == 5*NTrk+6) {
93 error = massErrorV0Fitter(vxCandidate,masses);
94 } else if (ndim == 3*NTrk+3) {
95 error = massErrorVKalVrt(vxCandidate,masses);
96 }
97 }
98 }
99 return error;
100 }
double massErrorVxCandidate(const xAOD::Vertex *vxCandidate, double posTrackMass, double negTrackMass) const
Definition V0Tools.cxx:242
double massErrorVKalVrt(const xAOD::Vertex *vxCandidate, double posTrackMass, double negTrackMass) const
Definition V0Tools.cxx:167
double massErrorV0Fitter(const xAOD::Vertex *vxCandidate, double posTrackMass, double negTrackMass) const
Definition V0Tools.cxx:102

◆ invariantMassErrorBeforeFit() [1/2]

double V0Tools::invariantMassErrorBeforeFit ( const xAOD::Vertex * vxCandidate,
std::span< const double > masses,
const Amg::Vector3D & vertex,
const EventContext & ctx,
const Trk::IExtrapolator * extrap ) const

Definition at line 2088 of file V0Tools.cxx.

2090 {
2091 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
2092 if (masses.size() != NTrk) {
2093 ATH_MSG_ERROR("The provided number of masses does not match the number of tracks in the vertex");
2094 return -999999.;
2095 }
2096 Trk::PerigeeSurface perigeeSurface(vertex);
2097 double E=0., Px=0., Py=0., Pz=0.;
2098 std::vector<double>phi(NTrk), theta(NTrk), qOverP(NTrk), charge(NTrk), e(NTrk);
2099 std::vector<double>dm2dphi(NTrk), dm2dtheta(NTrk), dm2dqOverP(NTrk);
2100 Amg::MatrixX V0_cor(5*NTrk,5*NTrk); V0_cor.setZero();
2101 for( unsigned int it=0; it<NTrk; it++) {
2102 if (masses[it] >= 0.) {
2103 const xAOD::TrackParticle* TP = origTrack(vxCandidate,it);
2104 if (TP == nullptr) return -999999.;
2105 std::unique_ptr<const Trk::TrackParameters> extrPer =
2106 extrap->extrapolate(ctx, TP->perigeeParameters(), perigeeSurface);
2107 if (extrPer == nullptr)
2108 return -999999.;
2109 const AmgSymMatrix(5)* cov_tmp = extrPer->covariance();
2110 V0_cor(5*it+2,5*it+2) = (*cov_tmp)(2,2);
2111 V0_cor(5*it+2,5*it+3) = (*cov_tmp)(2,3);
2112 V0_cor(5*it+2,5*it+4) = (*cov_tmp)(2,4);
2113 V0_cor(5*it+3,5*it+3) = (*cov_tmp)(3,3);
2114 V0_cor(5*it+3,5*it+4) = (*cov_tmp)(3,4);
2115 V0_cor(5*it+4,5*it+4) = (*cov_tmp)(4,4);
2116 V0_cor(5*it+3,5*it+2) = (*cov_tmp)(2,3);
2117 V0_cor(5*it+4,5*it+2) = (*cov_tmp)(2,4);
2118 V0_cor(5*it+4,5*it+3) = (*cov_tmp)(3,4);
2119 charge[it] = TP->charge();
2120 phi[it] = extrPer->parameters()[Trk::phi];
2121 theta[it] = extrPer->parameters()[Trk::theta];
2122 qOverP[it] = extrPer->parameters()[Trk::qOverP];
2123 double tmp = 1./(qOverP[it]*qOverP[it]) + masses[it]*masses[it];
2124 double pe = (tmp>0.) ? sqrt(tmp) : 0.;
2125 e[it] = pe;
2126 E += e[it];
2127 Px += extrPer->momentum().x();
2128 Py += extrPer->momentum().y();
2129 Pz += extrPer->momentum().z();
2130 }
2131 }
2132 double msq = E*E - Px*Px - Py*Py - Pz*Pz;
2133 double mass = (msq>0.) ? sqrt(msq) : 0.;
2134
2135 for( unsigned int it=0; it<NTrk; it++) {
2136 if (masses[it] >= 0.) {
2137 dm2dphi[it] = 2.*(Px*sin(phi[it])-Py*cos(phi[it]))*sin(theta[it])*charge[it]/qOverP[it];
2138 dm2dtheta[it] = 2.*(Pz*sin(theta[it])-(Px*cos(phi[it])+Py*sin(phi[it]))*cos(theta[it]))*charge[it]/qOverP[it];
2139 dm2dqOverP[it] = 2.*(Pz*cos(theta[it])+(Px*cos(phi[it])+Py*sin(phi[it]))*sin(theta[it])-E*charge[it]/(qOverP[it]*e[it]))*charge[it]/(qOverP[it]*qOverP[it]);
2140 }
2141 }
2142
2143 Amg::MatrixX D_vec(5*NTrk,1); D_vec.setZero();
2144 for( unsigned int it=0; it<NTrk; it++) {
2145 D_vec(5*it+0,0) = 0.;
2146 D_vec(5*it+1,0) = 0.;
2147 D_vec(5*it+2,0) = dm2dphi[it];
2148 D_vec(5*it+3,0) = dm2dtheta[it];
2149 D_vec(5*it+4,0) = dm2dqOverP[it];
2150 }
2151 Amg::MatrixX V0_merr = D_vec.transpose() * V0_cor * D_vec;
2152
2153 double massVarsq = V0_merr(0,0);
2154 if (massVarsq <= 0.) ATH_MSG_DEBUG("massError: negative sqrt massVarsq " << massVarsq);
2155 double massVar = (massVarsq>0.) ? sqrt(massVarsq) : 0.;
2156 double massErr = massVar/(2.*mass);
2157 return massErr;
2158 }
#define AmgSymMatrix(dim)
static float charge(const xAOD::Vertex *vxCandidate)
sum of the charges of the tracks in the vertex
Definition V0Tools.cxx:1884

◆ invariantMassErrorBeforeFit() [2/2]

double V0Tools::invariantMassErrorBeforeFit ( const xAOD::Vertex * vxCandidate,
std::span< const double > masses,
const EventContext & ctx,
const Trk::IExtrapolator * extrap ) const

Definition at line 2076 of file V0Tools.cxx.

2077 {
2078 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
2079 if (masses.size() != NTrk) {
2080 ATH_MSG_ERROR("The provided number of masses does not match the number of tracks in the vertex");
2081 return -999999.;
2082 }
2083 Amg::Vector3D vertex = vxCandidate->position();
2084 return invariantMassErrorBeforeFit(vxCandidate,masses,vertex, ctx, extrap);
2085 }
double invariantMassErrorBeforeFit(const xAOD::Vertex *vxCandidate, std::span< const double > masses, const EventContext &ctx, const Trk::IExtrapolator *) const
Definition V0Tools.cxx:2076

◆ invariantMassErrorBeforeFitIP()

double V0Tools::invariantMassErrorBeforeFitIP ( const xAOD::Vertex * vxCandidate,
std::span< const double > masses ) const

Definition at line 2009 of file V0Tools.cxx.

2010 {
2011 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
2012 if (masses.size() != NTrk) {
2013 ATH_MSG_ERROR("The provided number of masses does not match the number of tracks in the vertex");
2014 return -999999.;
2015 }
2016 double mass = invariantMassBeforeFitIP(vxCandidate, masses);
2017 double E=0., Px=0., Py=0., Pz=0.;
2018 std::vector<double>phi(NTrk), theta(NTrk), qOverP(NTrk), charge(NTrk), e(NTrk);
2019 std::vector<double>dm2dphi(NTrk), dm2dtheta(NTrk), dm2dqOverP(NTrk);
2020 Amg::MatrixX V0_cor(5*NTrk,5*NTrk); V0_cor.setZero();
2021 for( unsigned int it=0; it<NTrk; it++) {
2022 if (masses[it] >= 0.) {
2023 const xAOD::TrackParticle* TP = origTrack(vxCandidate,it);
2024 if (TP == nullptr) return -999999.;
2025 const xAOD::ParametersCovMatrix_t cov_tmp = TP->definingParametersCovMatrix();
2026 V0_cor(5*it+2,5*it+2) = cov_tmp(2,2);
2027 V0_cor(5*it+2,5*it+3) = cov_tmp(2,3);
2028 V0_cor(5*it+2,5*it+4) = cov_tmp(2,4);
2029 V0_cor(5*it+3,5*it+3) = cov_tmp(3,3);
2030 V0_cor(5*it+3,5*it+4) = cov_tmp(3,4);
2031 V0_cor(5*it+4,5*it+4) = cov_tmp(4,4);
2032 V0_cor(5*it+3,5*it+2) = cov_tmp(2,3);
2033 V0_cor(5*it+4,5*it+2) = cov_tmp(2,4);
2034 V0_cor(5*it+4,5*it+3) = cov_tmp(3,4);
2035 charge[it] = TP->charge();
2036 phi[it] = TP->phi();
2037 theta[it] = TP->theta();
2038 qOverP[it] = TP->qOverP();
2039 double tmp = 1./(qOverP[it]*qOverP[it]) + masses[it]*masses[it];
2040 double pe = (tmp>0.) ? sqrt(tmp) : 0.;
2041 e[it] = pe;
2042 E += e[it];
2043 TLorentzVector p4 = TP->p4();
2044 Px += p4.Px();
2045 Py += p4.Py();
2046 Pz += p4.Pz();
2047 }
2048 }
2049
2050 for( unsigned int it=0; it<NTrk; it++) {
2051 if (masses[it] >= 0.) {
2052 dm2dphi[it] = 2.*(Px*sin(phi[it])-Py*cos(phi[it]))*sin(theta[it])*charge[it]/qOverP[it];
2053 dm2dtheta[it] = 2.*(Pz*sin(theta[it])-(Px*cos(phi[it])+Py*sin(phi[it]))*cos(theta[it]))*charge[it]/qOverP[it];
2054 dm2dqOverP[it] = 2.*(Pz*cos(theta[it])+(Px*cos(phi[it])+Py*sin(phi[it]))*sin(theta[it])-E*charge[it]/(qOverP[it]*e[it]))*charge[it]/(qOverP[it]*qOverP[it]);
2055 }
2056 }
2057
2058 Amg::MatrixX D_vec(5*NTrk,1); D_vec.setZero();
2059 for( unsigned int it=0; it<NTrk; it++) {
2060 D_vec(5*it+0,0) = 0.;
2061 D_vec(5*it+1,0) = 0.;
2062 D_vec(5*it+2,0) = dm2dphi[it];
2063 D_vec(5*it+3,0) = dm2dtheta[it];
2064 D_vec(5*it+4,0) = dm2dqOverP[it];
2065 }
2066 Amg::MatrixX V0_merr = D_vec.transpose() * V0_cor * D_vec;
2067
2068 double massVarsq = V0_merr(0,0);
2069 if (massVarsq <= 0.) ATH_MSG_DEBUG("massError: negative sqrt massVarsq " << massVarsq);
2070 double massVar = (massVarsq>0.) ? sqrt(massVarsq) : 0.;
2071 double massErr = massVar/(2.*mass);
2072 return massErr;
2073 }
double invariantMassBeforeFitIP(const xAOD::Vertex *vxCandidate, std::span< const double > masses) const
create neutral TrackParticle from vxCandidate
Definition V0Tools.cxx:1925
float theta() const
Returns the parameter, which has range 0 to .
virtual double phi() const override final
The azimuthal angle ( ) of the particle (has range to .)
const ParametersCovMatrix_t definingParametersCovMatrix() const
Returns the 5x5 symmetric matrix containing the defining parameters covariance matrix.

◆ invariantMassProbability() [1/2]

double V0Tools::invariantMassProbability ( const xAOD::Vertex * vxCandidate,
double V0Mass,
double posTrackMass,
double negTrackMass ) const

Definition at line 317 of file V0Tools.cxx.

318 {
319 std::array<double, 2> masses = {posTrackMass , negTrackMass};
320
321 return invariantMassProbability(vxCandidate,V0Mass,masses);
322 }
double invariantMassProbability(const xAOD::Vertex *vxCandidate, double V0Mass, double posTrackMass, double negTrackMass) const
Definition V0Tools.cxx:317

◆ invariantMassProbability() [2/2]

double V0Tools::invariantMassProbability ( const xAOD::Vertex * vxCandidate,
double V0Mass,
std::span< const double > masses ) const

Definition at line 324 of file V0Tools.cxx.

325 {
326 double mass = invariantMass(vxCandidate, masses);
327 double massErr = invariantMassError(vxCandidate, masses);
328 if(massErr > 0.)
329 {
330 double chi2 = (V0Mass - mass)*(V0Mass - mass)/(massErr*massErr);
331 int ndf = 1;
332 Genfun::CumulativeChiSquare myCumulativeChiSquare(ndf);
333 if (chi2 > 0.) {
334 double achi2prob = 1.-myCumulativeChiSquare(chi2);
335 return achi2prob;
336 } else {
337 ATH_MSG_DEBUG("chi <= 0");
338 return -1.;
339 }
340 }
341 else {
342 return -1.;
343 }
344 }
double chi2(TH1 *h0, TH1 *h1)

◆ lxy()

double V0Tools::lxy ( const xAOD::Vertex * vxCandidate,
const xAOD::Vertex * vertex )
static

projection of distance in xy of the vertex wrt an xAOD::Vertex vertex along the momentum direction (Px*dx+Py*dy)/pT

Definition at line 937 of file V0Tools.cxx.

938 {
939 auto vert = vxCandidate->position() - vertex->position();
940 double dx = vert.x();
941 double dy = vert.y();
942 Amg::Vector3D mom = V0Momentum(vxCandidate);
943 double dxy = (mom.x()*dx + mom.y()*dy)/mom.perp();
944 return dxy;
945 }

◆ lxyError()

double V0Tools::lxyError ( const xAOD::Vertex * vxCandidate,
const xAOD::Vertex * vertex ) const

error on lxy

Definition at line 947 of file V0Tools.cxx.

948 {
949 auto vert = vxCandidate->position() - vertex->position();
950 double dx = vert.x();
951 double dy = vert.y();
952 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
953 double Px=0., Py=0.;
954 std::vector<double>dpxdqOverP(NTrk), dpxdtheta(NTrk), dpxdphi(NTrk);
955 std::vector<double>dpydqOverP(NTrk), dpydtheta(NTrk), dpydphi(NTrk);
956 std::vector<double>dLxydqOverP(NTrk), dLxydtheta(NTrk), dLxydphi(NTrk);
957
958 auto fullCov = convertCovMatrix(vxCandidate);
959 for( unsigned int it=0; it<NTrk; it++) {
960 const Trk::TrackParameters* bPer = vxCandidate->vxTrackAtVertex()[it].perigeeAtVertex();
961 double trkCharge = 1.;
962 if (bPer->parameters()[Trk::qOverP] < 0.) trkCharge = -1.;
963 double phi = bPer->parameters()[Trk::phi];
964 double theta = bPer->parameters()[Trk::theta];
965 double qOverP = bPer->parameters()[Trk::qOverP];
966 dpxdqOverP[it] = -(sin(theta)*cos(phi)*trkCharge)/(qOverP*qOverP);
967 dpxdtheta[it] = (cos(theta)*cos(phi)*trkCharge)/qOverP;
968 dpxdphi[it] = -(sin(theta)*sin(phi)*trkCharge)/qOverP;
969 dpydqOverP[it] = -(sin(theta)*sin(phi)*trkCharge)/(qOverP*qOverP);
970 dpydtheta[it] = (cos(theta)*sin(phi)*trkCharge)/qOverP;
971 dpydphi[it] = (sin(theta)*cos(phi)*trkCharge)/qOverP;
972 Px += bPer->momentum()[Trk::px];
973 Py += bPer->momentum()[Trk::py];
974 }
975 double PTsq = Px*Px+Py*Py;
976 double PT = (PTsq>0.) ? sqrt(PTsq) : 0.;
977 double LXYoverPT = (Px*dx+Py*dy)/PTsq;
978
979 for( unsigned int it=0; it<NTrk; it++) {
980 double dPTdqOverP = (Px*dpxdqOverP[it]+Py*dpydqOverP[it])/PT;
981 double dPTdtheta = (Px*dpxdtheta[it]+Py*dpydtheta[it])/PT;
982 double dPTdphi = (Px*dpxdphi[it]+Py*dpydphi[it])/PT;
983 dLxydqOverP[it] = (dx*dpxdqOverP[it]+dy*dpydqOverP[it])/PT-LXYoverPT*dPTdqOverP;
984 dLxydtheta[it] = (dx*dpxdtheta[it]+dy*dpydtheta[it])/PT-LXYoverPT*dPTdtheta;
985 dLxydphi[it] = (dx*dpxdphi[it]+dy*dpydphi[it])/PT-LXYoverPT*dPTdphi;
986 }
987 double dLxydx = Px/PT;
988 double dLxydy = Py/PT;
989 double dLxydx0 = -dLxydx;
990 double dLxydy0 = -dLxydy;
991
992 unsigned int ndim = 0;
993 if (fullCov.size() != 0) {
994 ndim = fullCov.rows();
995 } else {
996 ndim = 5*NTrk+3;
997 }
998
999 Amg::MatrixX V0_err;
1000 if (ndim == 5*NTrk+3 || ndim == 5*NTrk+6) {
1001 Amg::MatrixX D_vec(5*NTrk+6,1); D_vec.setZero();
1002 for( unsigned int it=0; it<NTrk; it++) {
1003 D_vec(5*it+0) = 0.;
1004 D_vec(5*it+1) = 0.;
1005 D_vec(5*it+2) = dLxydphi[it];
1006 D_vec(5*it+3) = dLxydtheta[it];
1007 D_vec(5*it+4) = dLxydqOverP[it];
1008 }
1009 D_vec(5*NTrk+0) = dLxydx;
1010 D_vec(5*NTrk+1) = dLxydy;
1011 D_vec(5*NTrk+2) = 0.;
1012 D_vec(5*NTrk+3) = dLxydx0;
1013 D_vec(5*NTrk+4) = dLxydy0;
1014 D_vec(5*NTrk+5) = 0.;
1015
1016 Amg::MatrixX W_mat(5*NTrk+6,5*NTrk+6); W_mat.setZero();
1017 if (fullCov.size() != 0) {
1018 W_mat.block(0,0,ndim,ndim) = fullCov;
1019 } else {
1020 Amg::MatrixX V0_cov = makeV0Cov(vxCandidate);
1021 W_mat.block(0,0,V0_cov.rows(),V0_cov.rows()) = V0_cov;
1022 W_mat.block<3,3>(5*NTrk,5*NTrk) = vxCandidate->covariancePosition();
1023 }
1024 W_mat.block<3,3>(5*NTrk+3,5*NTrk+3) = vertex->covariancePosition();
1025 V0_err = D_vec.transpose() * W_mat * D_vec;
1026 } else if (ndim == 3*NTrk+3) {
1027 Amg::MatrixX D_vec(3*NTrk+6,1); D_vec.setZero();
1028 D_vec(0) = dLxydx;
1029 D_vec(1) = dLxydy;
1030 D_vec(2) = 0.;
1031 for( unsigned int it=0; it<NTrk; it++) {
1032 D_vec(3*it+3) = dLxydphi[it];
1033 D_vec(3*it+4) = dLxydtheta[it];
1034 D_vec(3*it+5) = dLxydqOverP[it];
1035 }
1036 D_vec(3*NTrk+3) = dLxydx0;
1037 D_vec(3*NTrk+4) = dLxydy0;
1038 D_vec(3*NTrk+5) = 0.;
1039
1040 Amg::MatrixX W_mat(3*NTrk+6,3*NTrk+6); W_mat.setZero();
1041 W_mat.block(0,0,ndim,ndim) = fullCov;
1042 W_mat.block<3,3>(3*NTrk+3,3*NTrk+3) = vertex->covariancePosition();
1043 V0_err = D_vec.transpose() * W_mat * D_vec;
1044 }else{
1045 ATH_MSG_ERROR("This should not happen - returning zero.");
1046 return 0;
1047 }
1048
1049 double LxyErrsq = V0_err(0,0);
1050 if (LxyErrsq <= 0.) ATH_MSG_DEBUG("lxyError: negative sqrt LxyErrsq " << LxyErrsq);
1051 return (LxyErrsq>0.) ? sqrt(LxyErrsq) : 0.;
1052 }
H5::PredType PT
Definition H5Traits.cxx:15

◆ lxyz()

double V0Tools::lxyz ( const xAOD::Vertex * vxCandidate,
const xAOD::Vertex * vertex )
static

projection of distance in 3D of the vertex wrt an xAOD::Vertex vertex along the momentum direction (Px*dx+Py*dy+Pz*dz)/p

Definition at line 1054 of file V0Tools.cxx.

1055 {
1056 auto vert = vxCandidate->position() - vertex->position();
1057 double dx = vert.x();
1058 double dy = vert.y();
1059 double dz = vert.z();
1060 Amg::Vector3D mom = V0Momentum(vxCandidate);
1061 double dxyz= (mom.x()*dx + mom.y()*dy + mom.z()*dz)/mom.mag();
1062 return dxyz;
1063 }

◆ lxyzError()

double V0Tools::lxyzError ( const xAOD::Vertex * vxCandidate,
const xAOD::Vertex * vertex ) const

error on lxyz

Definition at line 1065 of file V0Tools.cxx.

1066 {
1067 auto vert = vxCandidate->position() - vertex->position();
1068 double dx = vert.x();
1069 double dy = vert.y();
1070 double dz = vert.z();
1071 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
1072 double Px=0., Py=0., Pz=0.;
1073 std::vector<double>dpxdqOverP(NTrk), dpxdtheta(NTrk), dpxdphi(NTrk);
1074 std::vector<double>dpydqOverP(NTrk), dpydtheta(NTrk), dpydphi(NTrk);
1075 std::vector<double>dpzdqOverP(NTrk), dpzdtheta(NTrk);
1076 std::vector<double>dLxyzdqOverP(NTrk), dLxyzdtheta(NTrk), dLxyzdphi(NTrk);
1077
1078 auto fullCov = convertCovMatrix(vxCandidate);
1079 for( unsigned int it=0; it<NTrk; it++) {
1080 const Trk::TrackParameters* bPer = vxCandidate->vxTrackAtVertex()[it].perigeeAtVertex();
1081 double trkCharge = 1.;
1082 if (bPer->parameters()[Trk::qOverP] < 0.) trkCharge = -1.;
1083 double phi = bPer->parameters()[Trk::phi];
1084 double theta = bPer->parameters()[Trk::theta];
1085 double qOverP = bPer->parameters()[Trk::qOverP];
1086 dpxdqOverP[it] = -(sin(theta)*cos(phi)*trkCharge)/(qOverP*qOverP);
1087 dpxdtheta[it] = (cos(theta)*cos(phi)*trkCharge)/qOverP;
1088 dpxdphi[it] = -(sin(theta)*sin(phi)*trkCharge)/qOverP;
1089 dpydqOverP[it] = -(sin(theta)*sin(phi)*trkCharge)/(qOverP*qOverP);
1090 dpydtheta[it] = (cos(theta)*sin(phi)*trkCharge)/qOverP;
1091 dpydphi[it] = (sin(theta)*cos(phi)*trkCharge)/qOverP;
1092 dpzdqOverP[it] = -(cos(theta)*trkCharge)/(qOverP*qOverP);
1093 dpzdtheta[it] = -(sin(theta)*trkCharge)/qOverP;
1094 Px += bPer->momentum()[Trk::px];
1095 Py += bPer->momentum()[Trk::py];
1096 Pz += bPer->momentum()[Trk::pz];
1097 }
1098 double Psq = Px*Px+Py*Py+Pz*Pz;
1099 double P = (Psq>0.) ? sqrt(Psq) : 0.;
1100 double LXYZoverP = (Px*dx+Py*dy+Pz*dz)/Psq;
1101
1102 for( unsigned int it=0; it<NTrk; it++) {
1103 double dPdqOverP = (Px*dpxdqOverP[it]+Py*dpydqOverP[it]+Pz*dpzdqOverP[it])/P;
1104 double dPdtheta = (Px*dpxdtheta[it]+Py*dpydtheta[it]+Pz*dpzdtheta[it])/P;
1105 double dPdphi = (Px*dpxdphi[it]+Py*dpydphi[it])/P;
1106 dLxyzdqOverP[it] = (dx*dpxdqOverP[it]+dy*dpydqOverP[it]+dz*dpzdqOverP[it])/P-LXYZoverP*dPdqOverP;
1107 dLxyzdtheta[it] = (dx*dpxdtheta[it]+dy*dpydtheta[it]+dz*dpzdtheta[it])/P-LXYZoverP*dPdtheta;
1108 dLxyzdphi[it] = (dx*dpxdphi[it]+dy*dpydphi[it])/P-LXYZoverP*dPdphi;
1109 }
1110 double dLxyzdx = Px/P;
1111 double dLxyzdy = Py/P;
1112 double dLxyzdz = Pz/P;
1113 double dLxyzdx0 = -dLxyzdx;
1114 double dLxyzdy0 = -dLxyzdy;
1115 double dLxyzdz0 = -dLxyzdz;
1116
1117 unsigned int ndim = 0;
1118 if (fullCov.size() != 0) {
1119 ndim = fullCov.rows();
1120 } else {
1121 ndim = 5*NTrk+3;
1122 }
1123
1124 Amg::MatrixX V0_err;
1125 if (ndim == 5*NTrk+3 || ndim == 5*NTrk+6) {
1126 Amg::MatrixX D_vec(5*NTrk+6,1); D_vec.setZero();
1127 for( unsigned int it=0; it<NTrk; it++) {
1128 D_vec(5*it+0) = 0.;
1129 D_vec(5*it+1) = 0.;
1130 D_vec(5*it+2) = dLxyzdphi[it];
1131 D_vec(5*it+3) = dLxyzdtheta[it];
1132 D_vec(5*it+4) = dLxyzdqOverP[it];
1133 }
1134 D_vec(5*NTrk+0) = dLxyzdx;
1135 D_vec(5*NTrk+1) = dLxyzdy;
1136 D_vec(5*NTrk+2) = dLxyzdz;
1137 D_vec(5*NTrk+3) = dLxyzdx0;
1138 D_vec(5*NTrk+4) = dLxyzdy0;
1139 D_vec(5*NTrk+5) = dLxyzdz0;
1140
1141 Amg::MatrixX W_mat(5*NTrk+6,5*NTrk+6); W_mat.setZero();
1142 if (fullCov.size() != 0) {
1143 W_mat.block(0,0,ndim,ndim) = fullCov;
1144 } else {
1145 Amg::MatrixX V0_cov = makeV0Cov(vxCandidate);
1146 W_mat.block(0,0,V0_cov.rows(),V0_cov.rows()) = V0_cov;
1147 W_mat.block<3,3>(5*NTrk,5*NTrk) = vxCandidate->covariancePosition();
1148 }
1149 W_mat.block<3,3>(5*NTrk+3,5*NTrk+3) = vertex->covariancePosition();
1150 V0_err = D_vec.transpose() * W_mat * D_vec;
1151 } else if (ndim == 3*NTrk+3) {
1152 Amg::MatrixX D_vec(3*NTrk+6,1); D_vec.setZero();
1153 D_vec(0) = dLxyzdx;
1154 D_vec(1) = dLxyzdy;
1155 D_vec(2) = dLxyzdz;
1156 for( unsigned int it=0; it<NTrk; it++) {
1157 D_vec(3*it+3) = dLxyzdphi[it];
1158 D_vec(3*it+4) = dLxyzdtheta[it];
1159 D_vec(3*it+5) = dLxyzdqOverP[it];
1160 }
1161 D_vec(3*NTrk+3) = dLxyzdx0;
1162 D_vec(3*NTrk+4) = dLxyzdy0;
1163 D_vec(3*NTrk+5) = dLxyzdz0;
1164
1165 Amg::MatrixX W_mat(3*NTrk+6,3*NTrk+6); W_mat.setZero();
1166 W_mat.block(0,0,ndim,ndim) = fullCov;
1167 W_mat.block<3,3>(3*NTrk+3,3*NTrk+3) = vertex->covariancePosition();
1168 V0_err = D_vec.transpose() * W_mat * D_vec;
1169 }else{
1170 ATH_MSG_ERROR("This should not happen - returning zero.");
1171 return 0;
1172 }
1173
1174 double LxyzErrsq = V0_err(0,0);
1175 if (LxyzErrsq <= 0.) ATH_MSG_DEBUG("lxyzError: negative sqrt LxyzErrsq " << LxyzErrsq);
1176 return (LxyzErrsq>0.) ? sqrt(LxyzErrsq) : 0.;
1177 }

◆ makeV0Cov()

Amg::MatrixX V0Tools::makeV0Cov ( const xAOD::Vertex * vxCandidate)
static

Definition at line 2293 of file V0Tools.cxx.

2293 {
2294 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
2295 Amg::MatrixX V0_cov(5*NTrk,5*NTrk); V0_cov.setZero();
2296 for( unsigned int it=0; it<NTrk; it++){
2297 const Trk::TrackParameters* bPer = vxCandidate->vxTrackAtVertex()[it].perigeeAtVertex();
2298 const AmgSymMatrix(5)* cov_tmp = bPer->covariance();
2299 V0_cov(5*it+2,5*it+2) = (*cov_tmp)(2,2);
2300 V0_cov(5*it+2,5*it+3) = (*cov_tmp)(2,3);
2301 V0_cov(5*it+2,5*it+4) = (*cov_tmp)(2,4);
2302 V0_cov(5*it+3,5*it+3) = (*cov_tmp)(3,3);
2303 V0_cov(5*it+3,5*it+4) = (*cov_tmp)(3,4);
2304 V0_cov(5*it+4,5*it+4) = (*cov_tmp)(4,4);
2305 V0_cov(5*it+3,5*it+2) = (*cov_tmp)(2,3);
2306 V0_cov(5*it+4,5*it+2) = (*cov_tmp)(2,4);
2307 V0_cov(5*it+4,5*it+3) = (*cov_tmp)(3,4);
2308 }
2309 return V0_cov;
2310 }

◆ massErrorV0Fitter() [1/2]

double V0Tools::massErrorV0Fitter ( const xAOD::Vertex * vxCandidate,
double posTrackMass,
double negTrackMass ) const
private

Definition at line 102 of file V0Tools.cxx.

103 {
104 std::array<double, 2> masses = {posTrackMass, negTrackMass};
105
106 return massErrorV0Fitter(vxCandidate,masses);
107 }

◆ massErrorV0Fitter() [2/2]

double V0Tools::massErrorV0Fitter ( const xAOD::Vertex * vxCandidate,
std::span< const double > masses ) const
private

Definition at line 109 of file V0Tools.cxx.

110 {
111 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
112 if (masses.size() != NTrk) {
113 ATH_MSG_ERROR("The provided number of masses does not match the number of tracks in the vertex");
114 return -999999.;
115 }
116 auto fullCov = convertCovMatrix(vxCandidate);
117 if (fullCov.size() == 0) return -999999.;
118 double E=0., Px=0., Py=0., Pz=0.;
119 std::vector<double>phi(NTrk), theta(NTrk), qOverP(NTrk), charge(NTrk), e(NTrk);
120 std::vector<double>dm2dphi(NTrk), dm2dtheta(NTrk), dm2dqOverP(NTrk);
121 for( unsigned int it=0; it<NTrk; it++) {
122 if (masses[it] >= 0.) {
123 const Trk::TrackParameters* bPer = vxCandidate->vxTrackAtVertex()[it].perigeeAtVertex();
124 double trkCharge = 1.;
125 if (bPer->parameters()[Trk::qOverP] < 0.) trkCharge = -1.;
126 charge[it] = trkCharge;
127 phi[it] = bPer->parameters()[Trk::phi];
128 theta[it] = bPer->parameters()[Trk::theta];
129 qOverP[it] = bPer->parameters()[Trk::qOverP];
130 double tmp = 1./(qOverP[it]*qOverP[it]) + masses[it]*masses[it];
131 double pe = (tmp>0.) ? sqrt(tmp) : 0.;
132 e[it] = pe;
133 E += e[it];
134 Px += bPer->momentum()[Trk::px];
135 Py += bPer->momentum()[Trk::py];
136 Pz += bPer->momentum()[Trk::pz];
137 }
138 }
139 double msq = E*E - Px*Px - Py*Py - Pz*Pz;
140 double mass = (msq>0.) ? sqrt(msq) : 0.;
141
142 for( unsigned int it=0; it<NTrk; it++) {
143 if (masses[it] >= 0.) {
144 dm2dphi[it] = 2.*(Px*sin(phi[it])-Py*cos(phi[it]))*sin(theta[it])*charge[it]/qOverP[it];
145 dm2dtheta[it] = 2.*(Pz*sin(theta[it])-(Px*cos(phi[it])+Py*sin(phi[it]))*cos(theta[it]))*charge[it]/qOverP[it];
146 dm2dqOverP[it] = 2.*(Pz*cos(theta[it])+(Px*cos(phi[it])+Py*sin(phi[it]))*sin(theta[it])-E*charge[it]/(qOverP[it]*e[it]))*charge[it]/(qOverP[it]*qOverP[it]);
147 }
148 }
149
150 Amg::MatrixX D_vec(5*NTrk,1); D_vec.setZero();
151 for( unsigned int it=0; it<NTrk; it++) {
152 D_vec(5*it+0,0) = 0.;
153 D_vec(5*it+1,0) = 0.;
154 D_vec(5*it+2,0) = dm2dphi[it];
155 D_vec(5*it+3,0) = dm2dtheta[it];
156 D_vec(5*it+4,0) = dm2dqOverP[it];
157 }
158 Amg::MatrixX V0_merr = D_vec.transpose() * fullCov.block(0,0,5*NTrk,5*NTrk) * D_vec;
159
160 double massVarsq = V0_merr(0,0);
161 if (massVarsq <= 0.) ATH_MSG_DEBUG("massError: negative sqrt massVarsq " << massVarsq);
162 double massVar = (massVarsq>0.) ? sqrt(massVarsq) : 0.;
163 double massErr = massVar/(2.*mass);
164 return massErr;
165 }

◆ massErrorVKalVrt() [1/2]

double V0Tools::massErrorVKalVrt ( const xAOD::Vertex * vxCandidate,
double posTrackMass,
double negTrackMass ) const
private

Definition at line 167 of file V0Tools.cxx.

168 {
169 std::array<double, 2> masses = {posTrackMass, negTrackMass};
170 return massErrorVKalVrt(vxCandidate,masses);
171 }

◆ massErrorVKalVrt() [2/2]

double V0Tools::massErrorVKalVrt ( const xAOD::Vertex * vxCandidate,
std::span< const double > masses ) const
private

Definition at line 173 of file V0Tools.cxx.

174 {
175 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
176 if (masses.size() != NTrk) {
177 ATH_MSG_ERROR("The provided number of masses does not match the number of tracks in the vertex");
178 return -999999.;
179 }
180 std::vector<xAOD::TrackParticle::FourMom_t> particleMom(NTrk);
181 std::vector<AmgMatrix(3,3)> particleDeriv(NTrk);
183 AmgMatrix(3,3) tmpDeriv; tmpDeriv.setZero();
184 auto fullCov = convertCovMatrix(vxCandidate);
185 if (fullCov.size() == 0) return -999999.;
186
187 for( unsigned int it=0; it<NTrk; it++){
188 if (masses[it] >= 0.) {
189 const Trk::TrackParameters* bPer = vxCandidate->vxTrackAtVertex()[it].perigeeAtVertex();
190 double phi = bPer->parameters()[Trk::phi];
191 double theta = bPer->parameters()[Trk::theta];
192 double invP = bPer->parameters()[Trk::qOverP];
193 double px = cos(phi)*sin(theta)/fabs(invP);
194 double py = sin(phi)*sin(theta)/fabs(invP);
195 double pz = cos(theta)/fabs(invP);
196 double esq = px*px + py*py + pz*pz + masses[it]*masses[it];
197 double e = (esq>0.) ? sqrt(esq) : 0.;
199 tmp.SetPxPyPzE(px,py,pz,e);
200 particleMom[it] = tmp;
201 totalMom += tmp;
202
203// d(Px,Py,Pz)/d(Phi,Theta,InvP)
204 tmpDeriv(0,0) = - tmp.Py();
205 tmpDeriv(1,0) = tmp.Px();
206 tmpDeriv(2,0) = 0.;
207 tmpDeriv(0,1) = cos(phi) * tmp.Pz();
208 tmpDeriv(1,1) = sin(phi) * tmp.Pz();
209 tmpDeriv(2,1) = - sin(theta)/fabs(invP);
210 tmpDeriv(0,2) = - tmp.Px()/invP;
211 tmpDeriv(1,2) = - tmp.Py()/invP;
212 tmpDeriv(2,2) = - tmp.Pz()/invP;
213 particleDeriv[it] = tmpDeriv;
214 }
215 }
216
217 std::vector<double> Deriv(3*NTrk+3, 0.);
218 for(unsigned int it=0; it<NTrk; it++){
219 if (masses[it] >= 0.) {
220 double dMdPx = ( totalMom.E() * particleMom[it].Px()/particleMom[it].E() - totalMom.Px() ) / totalMom.M();
221 double dMdPy = ( totalMom.E() * particleMom[it].Py()/particleMom[it].E() - totalMom.Py() ) / totalMom.M();
222 double dMdPz = ( totalMom.E() * particleMom[it].Pz()/particleMom[it].E() - totalMom.Pz() ) / totalMom.M();
223
224 double dMdPhi = dMdPx*particleDeriv[it](0,0) + dMdPy*particleDeriv[it](1,0) + dMdPz*particleDeriv[it](2,0);
225 double dMdTheta = dMdPx*particleDeriv[it](0,1) + dMdPy*particleDeriv[it](1,1) + dMdPz*particleDeriv[it](2,1);
226 double dMdInvP = dMdPx*particleDeriv[it](0,2) + dMdPy*particleDeriv[it](1,2) + dMdPz*particleDeriv[it](2,2);
227
228 Deriv[3*it + 3 + 0] = dMdPhi; Deriv[3*it + 3 + 1] = dMdTheta; Deriv[3*it + 3 + 2] = dMdInvP;
229 }
230 }
231
232 double err = 0;
233 for(unsigned int i=0; i<3*NTrk+3; i++){
234 for(unsigned int j=0; j<3*NTrk+3; j++){
235 err += Deriv[i]*( fullCov)(i,j)*Deriv[j];
236 }
237 }
238 if (err <= 0.) ATH_MSG_DEBUG("massError: negative sqrt err " << err);
239 return (err>0.) ? sqrt(err) : 0.;
240 }
#define AmgMatrix(rows, cols)
if(febId1==febId2)

◆ massErrorVxCandidate() [1/2]

double V0Tools::massErrorVxCandidate ( const xAOD::Vertex * vxCandidate,
double posTrackMass,
double negTrackMass ) const
private

Definition at line 242 of file V0Tools.cxx.

243 {
244 std::array<double, 2> masses = {posTrackMass, negTrackMass};
245
246 return massErrorVxCandidate(vxCandidate,masses);
247 }

◆ massErrorVxCandidate() [2/2]

double V0Tools::massErrorVxCandidate ( const xAOD::Vertex * vxCandidate,
std::span< const double > masses ) const
private

Definition at line 249 of file V0Tools.cxx.

250 {
251 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
252 if (masses.size() != NTrk) {
253 ATH_MSG_ERROR("The provided number of masses does not match the number of tracks in the vertex");
254 return -999999.;
255 }
256 double E=0., Px=0., Py=0., Pz=0.;
257 std::vector<double>phi(NTrk), theta(NTrk), qOverP(NTrk), charge(NTrk), e(NTrk);
258 std::vector<double>dm2dphi(NTrk), dm2dtheta(NTrk), dm2dqOverP(NTrk);
259 Amg::MatrixX V0_cor(5*NTrk,5*NTrk); V0_cor.setZero();
260 for( unsigned int it=0; it<NTrk; it++) {
261 if (masses[it] >= 0.) {
262 const Trk::TrackParameters* bPer = vxCandidate->vxTrackAtVertex()[it].perigeeAtVertex();
263 const AmgSymMatrix(5)* cov_tmp = bPer->covariance();
264 V0_cor(5*it+2,5*it+2) = (*cov_tmp)(2,2);
265 V0_cor(5*it+2,5*it+3) = (*cov_tmp)(2,3);
266 V0_cor(5*it+2,5*it+4) = (*cov_tmp)(2,4);
267 V0_cor(5*it+3,5*it+3) = (*cov_tmp)(3,3);
268 V0_cor(5*it+3,5*it+4) = (*cov_tmp)(3,4);
269 V0_cor(5*it+4,5*it+4) = (*cov_tmp)(4,4);
270 V0_cor(5*it+3,5*it+2) = (*cov_tmp)(2,3);
271 V0_cor(5*it+4,5*it+2) = (*cov_tmp)(2,4);
272 V0_cor(5*it+4,5*it+3) = (*cov_tmp)(3,4);
273 double trkCharge = 1.;
274 if (bPer->parameters()(Trk::qOverP) < 0.) trkCharge = -1.;
275 charge[it] = trkCharge;
276 phi[it] = bPer->parameters()(Trk::phi);
277 theta[it] = bPer->parameters()(Trk::theta);
278 qOverP[it] = bPer->parameters()(Trk::qOverP);
279 double tmp = 1./(qOverP[it]*qOverP[it]) + masses[it]*masses[it];
280 double pe = (tmp>0.) ? sqrt(tmp) : 0.;
281 e[it] = pe;
282 E += e[it];
283 Px += bPer->momentum()(Trk::px);
284 Py += bPer->momentum()(Trk::py);
285 Pz += bPer->momentum()(Trk::pz);
286 }
287 }
288 double msq = E*E - Px*Px - Py*Py - Pz*Pz;
289 double mass = (msq>0.) ? sqrt(msq) : 0.;
290
291 for( unsigned int it=0; it<NTrk; it++) {
292 if (masses[it] >= 0.) {
293 dm2dphi[it] = 2.*(Px*sin(phi[it])-Py*cos(phi[it]))*sin(theta[it])*charge[it]/qOverP[it];
294 dm2dtheta[it] = 2.*(Pz*sin(theta[it])-(Px*cos(phi[it])+Py*sin(phi[it]))*cos(theta[it]))*charge[it]/qOverP[it];
295 dm2dqOverP[it] = 2.*(Pz*cos(theta[it])+(Px*cos(phi[it])+Py*sin(phi[it]))*sin(theta[it])-E*charge[it]/(qOverP[it]*e[it]))*charge[it]/(qOverP[it]*qOverP[it]);
296 }
297 }
298
299 Amg::MatrixX D_vec(5*NTrk,1); D_vec.setZero();
300 for( unsigned int it=0; it<NTrk; it++) {
301 D_vec(5*it+0,0) = 0.;
302 D_vec(5*it+1,0) = 0.;
303 D_vec(5*it+2,0) = dm2dphi[it];
304 D_vec(5*it+3,0) = dm2dtheta[it];
305 D_vec(5*it+4,0) = dm2dqOverP[it];
306 }
307
308 Amg::MatrixX V0_merr = D_vec.transpose() * V0_cor * D_vec;
309
310 double massVarsq = V0_merr(0,0);
311 if (massVarsq <= 0.) ATH_MSG_DEBUG("massError: negative sqrt massVarsq " << massVarsq);
312 double massVar = (massVarsq>0.) ? sqrt(massVarsq) : 0.;
313 double massErr = massVar/(2.*mass);
314 return massErr;
315 }

◆ massProbability()

double V0Tools::massProbability ( double V0Mass,
double mass,
double massErr ) const

Definition at line 346 of file V0Tools.cxx.

347 {
348 if(massErr > 0.)
349 {
350 double chi2 = (V0Mass - mass)*(V0Mass - mass)/(massErr*massErr);
351 int ndf = 1;
352 Genfun::CumulativeChiSquare myCumulativeChiSquare(ndf);
353 if (chi2 > 0.) {
354 double achi2prob = 1.-myCumulativeChiSquare(chi2);
355 return achi2prob;
356 } else {
357 ATH_MSG_DEBUG("chi <= 0");
358 return -1.;
359 }
360 }
361 else {
362 return -1.;
363 }
364 }

◆ massTauCov()

double V0Tools::massTauCov ( const xAOD::Vertex * vxCandidate,
const xAOD::Vertex * vertex,
std::span< const double > masses ) const

Definition at line 2161 of file V0Tools.cxx.

2162 {
2163 // Tau = CONST*M*(Px*dx+Py*dy)/(PT*PT)
2164 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
2165 if (masses.size() != NTrk) {
2166 ATH_MSG_DEBUG("The provided number of masses does not match the number of tracks in the vertex");
2167 return -999999.;
2168 }
2169 //double CONST = 1000./CLHEP::c_light;
2170 double CONST = 1000./299.792;
2171 double PT = V0Momentum(vxCandidate).perp();
2172 auto vert = vxCandidate->position() - vertex->position();
2173 double dx = vert.x();
2174 double dy = vert.y();
2175 double M = invariantMass(vxCandidate, masses);
2176 double E=0., Px=0., Py=0., Pz=0.;
2177 std::vector<double>dpxdqOverP(NTrk), dpxdtheta(NTrk), dpxdphi(NTrk);
2178 std::vector<double>dpydqOverP(NTrk), dpydtheta(NTrk), dpydphi(NTrk);
2179 std::vector<double>dpzdqOverP(NTrk), dpzdtheta(NTrk), dedqOverP(NTrk);
2180 std::vector<double>dMdqOverP(NTrk), dMdtheta(NTrk), dMdphi(NTrk);
2181 std::vector<double>dTaudqOverP(NTrk), dTaudtheta(NTrk), dTaudphi(NTrk);
2182
2183 auto fullCov = convertCovMatrix(vxCandidate);
2184 for( unsigned int it=0; it<NTrk; it++) {
2185 const Trk::TrackParameters* bPer = vxCandidate->vxTrackAtVertex()[it].perigeeAtVertex();
2186 double trkCharge = 1.;
2187 if (bPer->parameters()[Trk::qOverP] < 0.) trkCharge = -1.;
2188 double phi = bPer->parameters()[Trk::phi];
2189 double theta = bPer->parameters()[Trk::theta];
2190 double qOverP = bPer->parameters()[Trk::qOverP];
2191 double tmp = 1./(qOverP*qOverP) + masses[it]*masses[it];
2192 double pe = (tmp>0.) ? sqrt(tmp) : 0.;
2193 dedqOverP[it] = -1./(qOverP*qOverP*qOverP*pe);
2194 dpxdqOverP[it] = -(sin(theta)*cos(phi)*trkCharge)/(qOverP*qOverP);
2195 dpxdtheta[it] = (cos(theta)*cos(phi)*trkCharge)/qOverP;
2196 dpxdphi[it] = -(sin(theta)*sin(phi)*trkCharge)/qOverP;
2197 dpydqOverP[it] = -(sin(theta)*sin(phi)*trkCharge)/(qOverP*qOverP);
2198 dpydtheta[it] = (cos(theta)*sin(phi)*trkCharge)/qOverP;
2199 dpydphi[it] = (sin(theta)*cos(phi)*trkCharge)/qOverP;
2200 dpzdqOverP[it] = -(cos(theta)*trkCharge)/(qOverP*qOverP);
2201 dpzdtheta[it] = -(sin(theta)*trkCharge)/qOverP;
2202 E += pe;
2203 Px += bPer->momentum()[Trk::px];
2204 Py += bPer->momentum()[Trk::py];
2205 Pz += bPer->momentum()[Trk::pz];
2206 }
2207 double LXY = Px*dx+Py*dy;
2208
2209 for( unsigned int it=0; it<NTrk; it++) {
2210 dMdqOverP[it] = -(Px*dpxdqOverP[it]+Py*dpydqOverP[it]+Pz*dpzdqOverP[it]-E*dedqOverP[it])/M;
2211 dMdtheta[it] = -(Px*dpxdtheta[it]+Py*dpydtheta[it]+Pz*dpzdtheta[it])/M;
2212 dMdphi[it] = -(Px*dpxdphi[it]+Py*dpydphi[it])/M;
2213 double dPTdqOverP = (Px*dpxdqOverP[it]+Py*dpydqOverP[it])/PT;
2214 double dPTdtheta = (Px*dpxdtheta[it]+Py*dpydtheta[it])/PT;
2215 double dPTdphi = (Px*dpxdphi[it]+Py*dpydphi[it])/PT;
2216 double dLXYdqOverP = dx*dpxdqOverP[it]+dy*dpydqOverP[it];
2217 double dLXYdtheta = dx*dpxdtheta[it]+dy*dpydtheta[it];
2218 double dLXYdphi = dx*dpxdphi[it]+dy*dpydphi[it];
2219 dTaudqOverP[it] = (LXY*dMdqOverP[it]+M*dLXYdqOverP)/(PT*PT)-(2.*LXY*M*dPTdqOverP)/(PT*PT*PT);
2220 dTaudtheta[it] = (LXY*dMdtheta[it]+M*dLXYdtheta)/(PT*PT)-(2.*LXY*M*dPTdtheta)/(PT*PT*PT);
2221 dTaudphi[it] = (LXY*dMdphi[it]+M*dLXYdphi)/(PT*PT)-(2.*LXY*M*dPTdphi)/(PT*PT*PT);
2222 }
2223 double dTaudx = (M*Px)/(PT*PT);
2224 double dTaudy = (M*Py)/(PT*PT);
2225 double dTaudx0 = -dTaudx;
2226 double dTaudy0 = -dTaudy;
2227
2228 unsigned int ndim = 0;
2229 if (fullCov.size() != 0) {
2230 ndim = fullCov.rows();
2231 } else {
2232 ndim = 5*NTrk+3;
2233 }
2234
2235 Amg::MatrixX V0_err;
2236 if (ndim == 5*NTrk+3 || ndim == 5*NTrk+6) {
2237 Amg::MatrixX D_mat(5*NTrk+6,2); D_mat.setZero();
2238 for( unsigned int it=0; it<NTrk; it++) {
2239 D_mat(5*it+0,0) = 0.;
2240 D_mat(5*it+1,0) = 0.;
2241 D_mat(5*it+2,0) = CONST*dTaudphi[it];
2242 D_mat(5*it+3,0) = CONST*dTaudtheta[it];
2243 D_mat(5*it+4,0) = CONST*dTaudqOverP[it];
2244 D_mat(5*it+0,1) = 0.;
2245 D_mat(5*it+1,1) = 0.;
2246 D_mat(5*it+2,1) = dMdphi[it];
2247 D_mat(5*it+3,1) = dMdtheta[it];
2248 D_mat(5*it+4,1) = dMdqOverP[it];
2249 }
2250 D_mat(5*NTrk+0,0) = CONST*dTaudx;
2251 D_mat(5*NTrk+1,0) = CONST*dTaudy;
2252 D_mat(5*NTrk+2,0) = 0.;
2253 D_mat(5*NTrk+3,0) = CONST*dTaudx0;
2254 D_mat(5*NTrk+4,0) = CONST*dTaudy0;
2255 D_mat(5*NTrk+5,0) = 0.;
2256 Amg::MatrixX W_mat(5*NTrk+6,5*NTrk+6); W_mat.setZero();
2257 if (fullCov.size() != 0) {
2258 W_mat.block(0,0,ndim,ndim) = fullCov;
2259 } else {
2260 Amg::MatrixX V0_cov = makeV0Cov(vxCandidate);
2261 W_mat.block(0,0,V0_cov.rows(),V0_cov.rows()) = V0_cov;
2262 W_mat.block<3,3>(5*NTrk,5*NTrk) = vxCandidate->covariancePosition();
2263 }
2264 W_mat.block<3,3>(5*NTrk+3,5*NTrk+3) = vertex->covariancePosition();
2265 V0_err = D_mat.transpose() * W_mat * D_mat;
2266 } else if (ndim == 3*NTrk+3) {
2267 Amg::MatrixX D_mat(3*NTrk+6,2); D_mat.setZero();
2268 D_mat(0,0) = CONST*dTaudx;
2269 D_mat(1,0) = CONST*dTaudy;
2270 D_mat(2,0) = 0.;
2271 for( unsigned int it=0; it<NTrk; it++) {
2272 D_mat(3*it+3,0) = CONST*dTaudphi[it];
2273 D_mat(3*it+4,0) = CONST*dTaudtheta[it];
2274 D_mat(3*it+5,0) = CONST*dTaudqOverP[it];
2275 D_mat(3*it+3,1) = dMdphi[it];
2276 D_mat(3*it+4,1) = dMdtheta[it];
2277 D_mat(3*it+5,1) = dMdqOverP[it];
2278 }
2279 D_mat(3*NTrk+3,0) = CONST*dTaudx0;
2280 D_mat(3*NTrk+4,0) = CONST*dTaudy0;
2281 D_mat(3*NTrk+5,0) = 0.;
2282 Amg::MatrixX W_mat(3*NTrk+6,3*NTrk+6); W_mat.setZero();
2283 W_mat.block(0,0,ndim,ndim) = fullCov;
2284 W_mat.block<3,3>(3*NTrk+3,3*NTrk+3) = vertex->covariancePosition();
2285 V0_err = D_mat.transpose() * W_mat * D_mat;
2286 }else{
2287 ATH_MSG_ERROR("This should not happen - returning zero.");
2288 return 0;
2289 }
2290 return V0_err(0,1);
2291 }

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ ndof()

float V0Tools::ndof ( const xAOD::Vertex * vxCandidate)
static

NDoF of the vertex fit.

Definition at line 446 of file V0Tools.cxx.

447 {
448 return vxCandidate->numberDoF();
449 }
float numberDoF() const
Returns the number of degrees of freedom of the vertex fit as float.

◆ negativeOrigTrack()

const xAOD::TrackParticle * V0Tools::negativeOrigTrack ( const xAOD::Vertex * vxCandidate)
static

Definition at line 1914 of file V0Tools.cxx.

1915 {
1916 const xAOD::TrackParticle* origTrk(nullptr);
1917 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
1918 if (NTrk != 2) return origTrk;
1919 for( unsigned int it=0; it<NTrk; it++) {
1920 if(vxCandidate->trackParticle(it)->charge() < 0) origTrk = vxCandidate->trackParticle(it);
1921 }
1922 return origTrk;
1923 }

◆ negativeTrack4Momentum()

xAOD::TrackParticle::FourMom_t V0Tools::negativeTrack4Momentum ( const xAOD::Vertex * vxCandidate,
double negTrackMass )
static

Definition at line 426 of file V0Tools.cxx.

427 {
429 xAOD::TrackParticle::FourMom_t lorentz(0,0,0,0);
430 double tmp = mass*mass + mom.x()*mom.x() + mom.y()*mom.y() + mom.z()*mom.z();
431 double e = (tmp>0.) ? sqrt(tmp) : 0.;
432 lorentz.SetPxPyPzE(mom.x(), mom.y(), mom.z(), e);
433 return lorentz;
434 }
static Amg::Vector3D negativeTrackMomentum(const xAOD::Vertex *vxCandidate)
Definition V0Tools.cxx:384

◆ negativeTrackMomentum()

Amg::Vector3D V0Tools::negativeTrackMomentum ( const xAOD::Vertex * vxCandidate)
static

Definition at line 384 of file V0Tools.cxx.

385 {
386 Amg::Vector3D mom; mom.setZero();
387 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
388 if (NTrk != 2) return mom;
389 for( unsigned int it=0; it<NTrk; it++) {
390 float trkCharge = vxCandidate->trackParticle(it)->charge();
391 if (trkCharge < 0) mom = trackMomentum(vxCandidate,it);
392 }
393 return mom;
394 }
static Amg::Vector3D trackMomentum(const xAOD::Vertex *vxCandidate, unsigned int trkIndex)
Methods, returning the refitted 3-momenta of the positive and negative tracks and the V0 (for more th...
Definition V0Tools.cxx:366

◆ origTrack()

const xAOD::TrackParticle * V0Tools::origTrack ( const xAOD::Vertex * vxCandidate,
int trkIndex )
static

pointers to original tracks

Definition at line 1898 of file V0Tools.cxx.

1899 {
1900 return vxCandidate->trackParticle(trkIndex);
1901 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ pca()

Amg::Vector3D V0Tools::pca ( const xAOD::Vertex * vxCandidate,
const xAOD::Vertex * vertex )
static

point of closest approach of the momentum vector to an xAOD::Vertex

Definition at line 622 of file V0Tools.cxx.

623 {
624 assert(vxCandidate!=0);
625 if(nullptr == vxCandidate) {
626 Amg::Vector3D p; p.setZero();
627 return p;
628 }
629 const Amg::Vector3D& pv = vertex->position();
630 Amg::Vector3D sv = vtx(vxCandidate);
631 Amg::Vector3D P = V0Momentum(vxCandidate);
632 double p2 = P.mag2();
633 double pdr = P.dot((sv - pv));
634 return sv - P*pdr/p2;
635 }

◆ phiStar() [1/2]

double V0Tools::phiStar ( const CLHEP::HepLorentzVector & v0,
const CLHEP::HepLorentzVector & track )
static

Definition at line 1832 of file V0Tools.cxx.

1833 {
1834 double phiStar = -999999.;
1835 CLHEP::Hep3Vector V0 = v0.getV();
1836 CLHEP::Hep3Vector trk = track.getV();
1837 //double v0_rapidity = v0.rapidity();
1838 trk.rotateZ(-V0.phi());
1839 trk.rotateY(-V0.theta());
1840 //if (v0_rapidity < 0.) {
1841 // trk.rotateZ(-M_PI);
1842 // phiStar = -atan2(trk.y(),trk.x());
1843 //} else {
1844 // phiStar = atan2(trk.y(),trk.x());
1845 //}
1846 phiStar = atan2(trk.y(),trk.x());
1847 return phiStar;
1848 }
static double phiStar(const xAOD::Vertex *vxCandidate, double posTrackMass, double negTrackMass)
phiStar
Definition V0Tools.cxx:1823

◆ phiStar() [2/2]

double V0Tools::phiStar ( const xAOD::Vertex * vxCandidate,
double posTrackMass,
double negTrackMass )
static

phiStar

Definition at line 1823 of file V0Tools.cxx.

1824 {
1825 xAOD::TrackParticle::FourMom_t V_pos = positiveTrack4Momentum(vxCandidate,posTrackMass);
1826 xAOD::TrackParticle::FourMom_t V_neg = negativeTrack4Momentum(vxCandidate,negTrackMass);
1827 CLHEP::HepLorentzVector v_pos(V_pos.Px(),V_pos.Py(),V_pos.Pz(),V_pos.E());
1828 CLHEP::HepLorentzVector v_neg(V_neg.Px(),V_neg.Py(),V_neg.Pz(),V_neg.E());
1829 return phiStar(v_pos+v_neg,v_pos);
1830 }

◆ positiveOrigTrack()

const xAOD::TrackParticle * V0Tools::positiveOrigTrack ( const xAOD::Vertex * vxCandidate)
static

Definition at line 1903 of file V0Tools.cxx.

1904 {
1905 const xAOD::TrackParticle* origTrk(nullptr);
1906 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
1907 if (NTrk != 2) return origTrk;
1908 for( unsigned int it=0; it<NTrk; it++) {
1909 if(vxCandidate->trackParticle(it)->charge() > 0) origTrk = vxCandidate->trackParticle(it);
1910 }
1911 return origTrk;
1912 }

◆ positiveTrack4Momentum()

xAOD::TrackParticle::FourMom_t V0Tools::positiveTrack4Momentum ( const xAOD::Vertex * vxCandidate,
double posTrackMass )
static

Definition at line 416 of file V0Tools.cxx.

417 {
419 xAOD::TrackParticle::FourMom_t lorentz(0,0,0,0);
420 double tmp = mass*mass + mom.x()*mom.x() + mom.y()*mom.y() + mom.z()*mom.z();
421 double e = (tmp>0.) ? sqrt(tmp) : 0.;
422 lorentz.SetPxPyPzE(mom.x(), mom.y(), mom.z(), e);
423 return lorentz;
424 }
static Amg::Vector3D positiveTrackMomentum(const xAOD::Vertex *vxCandidate)
Definition V0Tools.cxx:372

◆ positiveTrackMomentum()

Amg::Vector3D V0Tools::positiveTrackMomentum ( const xAOD::Vertex * vxCandidate)
static

Definition at line 372 of file V0Tools.cxx.

373 {
374 Amg::Vector3D mom; mom.setZero();
375 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
376 if (NTrk != 2) return mom;
377 for( unsigned int it=0; it<NTrk; it++) {
378 float trkCharge = vxCandidate->trackParticle(it)->charge();
379 if (trkCharge > 0) mom = trackMomentum(vxCandidate,it);
380 }
381 return mom;
382 }

◆ pT()

double V0Tools::pT ( const xAOD::Vertex * vxCandidate)
static

transverse momentum of the V0

Definition at line 542 of file V0Tools.cxx.

543 {
544 return V0Momentum(vxCandidate).perp();
545 }

◆ pTError()

double V0Tools::pTError ( const xAOD::Vertex * vxCandidate) const

error on the transverse momentum of the V0

Definition at line 547 of file V0Tools.cxx.

548 {
549 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
550 double Px=0., Py=0.;
551 std::vector<double>dpxdqOverP(NTrk), dpxdtheta(NTrk), dpxdphi(NTrk);
552 std::vector<double>dpydqOverP(NTrk), dpydtheta(NTrk), dpydphi(NTrk);
553 std::vector<double>dPTdqOverP(NTrk), dPTdtheta(NTrk), dPTdphi(NTrk);
554
555 auto fullCov = convertCovMatrix(vxCandidate);
556 for( unsigned int it=0; it<NTrk; it++) {
557 const Trk::TrackParameters* bPer = vxCandidate->vxTrackAtVertex()[it].perigeeAtVertex();
558 double trkCharge = 1.;
559 if (bPer->parameters()[Trk::qOverP] < 0.) trkCharge = -1.;
560 double phi = bPer->parameters()[Trk::phi];
561 double theta = bPer->parameters()[Trk::theta];
562 double qOverP = bPer->parameters()[Trk::qOverP];
563 dpxdqOverP[it] = -(sin(theta)*cos(phi)*trkCharge)/(qOverP*qOverP);
564 dpxdtheta[it] = (cos(theta)*cos(phi)*trkCharge)/qOverP;
565 dpxdphi[it] = -(sin(theta)*sin(phi)*trkCharge)/qOverP;
566 dpydqOverP[it] = -(sin(theta)*sin(phi)*trkCharge)/(qOverP*qOverP);
567 dpydtheta[it] = (cos(theta)*sin(phi)*trkCharge)/qOverP;
568 dpydphi[it] = (sin(theta)*cos(phi)*trkCharge)/qOverP;
569 Px += bPer->momentum()[Trk::px];
570 Py += bPer->momentum()[Trk::py];
571 }
572 double PTsq = Px*Px+Py*Py;
573 double PT = (PTsq>0.) ? sqrt(PTsq) : 0.;
574
575 for( unsigned int it=0; it<NTrk; it++) {
576 dPTdqOverP[it] = (Px*dpxdqOverP[it]+Py*dpydqOverP[it])/PT;
577 dPTdtheta[it] = (Px*dpxdtheta[it]+Py*dpydtheta[it])/PT;
578 dPTdphi[it] = (Px*dpxdphi[it]+Py*dpydphi[it])/PT;
579 }
580
581 unsigned int ndim = 0;
582 if (fullCov.size() == 0) {
583 ndim = 5*NTrk+3;
584 } else {
585 ndim = fullCov.rows();
586 }
587
588 Amg::MatrixX PtErrSq;
589 if (ndim == 5*NTrk+3 || ndim == 5*NTrk+6) {
590 Amg::MatrixX D_vec(5*NTrk,1); D_vec.setZero();
591 for( unsigned int it=0; it<NTrk; it++) {
592 D_vec(5*it+0,0) = 0.;
593 D_vec(5*it+1,0) = 0.;
594 D_vec(5*it+2,0) = dPTdphi[it];
595 D_vec(5*it+3,0) = dPTdtheta[it];
596 D_vec(5*it+4,0) = dPTdqOverP[it];
597 }
598 if (fullCov.size() == 0) {
599 Amg::MatrixX V0_cov = makeV0Cov(vxCandidate);
600 PtErrSq = D_vec.transpose() * V0_cov * D_vec;
601 } else {
602 PtErrSq = D_vec.transpose() * fullCov.block(0,0,5*NTrk, 5*NTrk) * D_vec;
603 }
604 } else if (ndim == 3*NTrk+3) {
605 Amg::MatrixX D_vec(3*NTrk,1); D_vec.setZero();
606 for( unsigned int it=0; it<NTrk; it++) {
607 D_vec(3*it+0,0) = dPTdphi[it];
608 D_vec(3*it+1,0) = dPTdtheta[it];
609 D_vec(3*it+2,0) = dPTdqOverP[it];
610 }
611 PtErrSq = D_vec.transpose() * fullCov.block(3,3,3*NTrk,3*NTrk) * D_vec;
612 }else{
613 ATH_MSG_ERROR("This should not happen - returning zero.");
614 return 0;
615 }
616
617 double PtErrsq = PtErrSq(0,0);
618 if (PtErrsq <= 0.) ATH_MSG_DEBUG("ptError: negative sqrt PtErrsq " << PtErrsq);
619 return (PtErrsq>0.) ? sqrt(PtErrsq) : 0.;
620 }

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ rxy() [1/3]

double V0Tools::rxy ( const xAOD::Vertex * vxCandidate)
static

Rxy of the vertex.

Definition at line 481 of file V0Tools.cxx.

482 {
483 return vxCandidate->position().perp();
484 }

◆ rxy() [2/3]

double V0Tools::rxy ( const xAOD::Vertex * vxCandidate,
const Amg::Vector3D & vertex )
static

wrt an Amg::Vector3D vertex

Definition at line 491 of file V0Tools.cxx.

492 {
493 return (vxCandidate->position() - vertex).perp();
494 }

◆ rxy() [3/3]

double V0Tools::rxy ( const xAOD::Vertex * vxCandidate,
const xAOD::Vertex * vertex )
static

wrt an xAOD::Vertex vertex

Definition at line 486 of file V0Tools.cxx.

487 {
488 return (vxCandidate->position() - vertex->position()).perp();
489 }

◆ rxy_var()

double V0Tools::rxy_var ( double dx,
double dy,
const Amg::MatrixX & cov )
static

rxy_var

Definition at line 496 of file V0Tools.cxx.

497 {
498 double rxysq = dx*dx + dy*dy;
499 double rxy = (rxysq>0.) ? sqrt(rxysq) : 0.;
500 double drdx = dx/rxy;
501 double drdy = dy/rxy;
502 AmgMatrix(2, 1) D_vec; D_vec.setZero();
503 D_vec(0,0) = drdx;
504 D_vec(1,0) = drdy;
505 Amg::MatrixX rxy_err = D_vec.transpose() * cov.block<2,2>(0,0) * D_vec;
506 double rxyVar = rxy_err(0,0);
507 return rxyVar;
508 }
static double rxy(const xAOD::Vertex *vxCandidate)
Rxy of the vertex.
Definition V0Tools.cxx:481

◆ rxyError() [1/3]

double V0Tools::rxyError ( const xAOD::Vertex * vxCandidate) const

error on Rxy

Definition at line 510 of file V0Tools.cxx.

511 {
512 const Amg::MatrixX& cov = vxCandidate->covariancePosition();
513 double dx = vxCandidate->position().x();
514 double dy = vxCandidate->position().y();
515 double rxyVar = rxy_var(dx,dy,cov);
516 if (rxyVar <= 0.) ATH_MSG_DEBUG("rxyError: negative sqrt rxyVar " << rxyVar);
517 return (rxyVar>0.) ? sqrt(rxyVar) : 0.;
518 }
static double rxy_var(double dx, double dy, const Amg::MatrixX &cov)
rxy_var
Definition V0Tools.cxx:496

◆ rxyError() [2/3]

double V0Tools::rxyError ( const xAOD::Vertex * vxCandidate,
const Amg::Vector3D & vertex ) const

wrt an Amg::Vector3D vertex

Definition at line 531 of file V0Tools.cxx.

532 {
533 const Amg::MatrixX& cov = vxCandidate->covariancePosition();
534 auto vert = vxCandidate->position() - vertex;
535 double dx = vert.x();
536 double dy = vert.y();
537 double rxyVar = rxy_var(dx,dy,cov);
538 if (rxyVar <= 0.) ATH_MSG_DEBUG("rxyError: negative sqrt rxyVar " << rxyVar);
539 return (rxyVar>0.) ? sqrt(rxyVar) : 0.;
540 }

◆ rxyError() [3/3]

double V0Tools::rxyError ( const xAOD::Vertex * vxCandidate,
const xAOD::Vertex * vertex ) const

wrt an xAOD::Vertex vertex

Definition at line 520 of file V0Tools.cxx.

521 {
522 const Amg::MatrixX cov = vxCandidate->covariancePosition() + vertex->covariancePosition();
523 auto vert = vxCandidate->position() - vertex->position();
524 double dx = vert.x();
525 double dy = vert.y();
526 double rxyVar = rxy_var(dx,dy,cov);
527 if (rxyVar <= 0.) ATH_MSG_DEBUG("rxyError: negative sqrt rxyVar " << rxyVar);
528 return (rxyVar>0.) ? sqrt(rxyVar) : 0.;
529 }

◆ separation() [1/2]

double V0Tools::separation ( const xAOD::Vertex * vxCandidate,
const Amg::Vector3D & vertex ) const

Definition at line 652 of file V0Tools.cxx.

653 {
654 const Amg::SymMatrixX& cov = vxCandidate->covariancePosition().inverse().eval();
655 Amg::Vector3D D_vec; D_vec.setZero();
656 auto vert = vxCandidate->position() - vertex;
657 D_vec(0) = vert.x();
658 D_vec(1) = vert.y();
659 D_vec(2) = vert.z();
660 Amg::MatrixX sepVarsqMat = D_vec.transpose() * cov * D_vec;
661 double sepVarsq = sepVarsqMat(0,0);
662 if (sepVarsq <= 0.) ATH_MSG_DEBUG("separation: negative sqrt sepVarsq " << sepVarsq);
663 double sepVar = (sepVarsq>0.) ? sqrt(sepVarsq) : 0.;
664 return sepVar;
665 }
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > SymMatrixX

◆ separation() [2/2]

double V0Tools::separation ( const xAOD::Vertex * vxCandidate,
const xAOD::Vertex * vertex ) const

statistical separation (Mahalanobis distance)

Definition at line 637 of file V0Tools.cxx.

638 {
639 const Amg::MatrixX& cov = (vxCandidate->covariancePosition() + vertex->covariancePosition()).inverse().eval();
640 Amg::Vector3D D_vec; D_vec.setZero();
641 auto vert = vxCandidate->position() - vertex->position();
642 D_vec(0) = vert.x();
643 D_vec(1) = vert.y();
644 D_vec(2) = vert.z();
645 Amg::MatrixX sepVarsqMat = D_vec.transpose() * cov * D_vec;
646 double sepVarsq = sepVarsqMat(0,0);
647 if (sepVarsq <= 0.) ATH_MSG_DEBUG("separation: negative sqrt sepVarsq " << sepVarsq);
648 double sepVar = (sepVarsq>0.) ? sqrt(sepVarsq) : 0.;
649 return sepVar;
650 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ tau() [1/5]

double V0Tools::tau ( const xAOD::Vertex * vxCandidate,
const xAOD::Vertex * vertex,
double massV0 )
static

proper time wrt an xAOD::Vertex vertex assuming massV0 imposing a V0 mass without making an adjustment

Definition at line 1225 of file V0Tools.cxx.

1226 {
1227 //double CONST = 1000./CLHEP::c_light;
1228 double CONST = 1000./299.792;
1229 double LXY = lxy(vxCandidate,vertex);
1230 double PT = V0Momentum(vxCandidate).perp();
1231 return CONST*M*LXY/PT;
1232 }
static double lxy(const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex)
projection of distance in xy of the vertex wrt an xAOD::Vertex vertex along the momentum direction (P...
Definition V0Tools.cxx:937

◆ tau() [2/5]

double V0Tools::tau ( const xAOD::Vertex * vxCandidate,
const xAOD::Vertex * vertex,
double posTrackMass,
double negTrackMass ) const

proper time wrt an xAOD::Vertex vertex assuming posTrackMass and negTrackMass tau = CONST*M*lxy/pT

Definition at line 1179 of file V0Tools.cxx.

1180 {
1181 std::array<double, 2> masses = {posTrackMass, negTrackMass};
1182
1183 return tau(vxCandidate,vertex,masses);
1184 }
double tau(const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex, double posTrackMass, double negTrackMass) const
proper time wrt an xAOD::Vertex vertex assuming posTrackMass and negTrackMass tau = CONST*M*lxy/pT
Definition V0Tools.cxx:1179

◆ tau() [3/5]

double V0Tools::tau ( const xAOD::Vertex * vxCandidate,
const xAOD::Vertex * vertex,
double posTrackMass,
double negTrackMass,
double massV0 ) const

proper time wrt an xAOD::Vertex vertex assuming posTrackMass and negTrackMass (imposing massV0) making a correction to the proper time consistent with the imposed V0 mass

Definition at line 1201 of file V0Tools.cxx.

1202 {
1203 std::array<double, 2> masses = {posTrackMass, negTrackMass};
1204
1205 return tau(vxCandidate,vertex,masses,massV0);
1206 }

◆ tau() [4/5]

double V0Tools::tau ( const xAOD::Vertex * vxCandidate,
const xAOD::Vertex * vertex,
std::span< const double > masses ) const

proper time wrt an xAOD::Vertex vertex assuming track masses

Definition at line 1186 of file V0Tools.cxx.

1187 {
1188 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
1189 if (masses.size() != NTrk) {
1190 ATH_MSG_ERROR("The provided number of masses does not match the number of tracks in the vertex");
1191 return -999999.;
1192 }
1193 //double CONST = 1000./CLHEP::c_light;
1194 double CONST = 1000./299.792;
1195 double M = invariantMass(vxCandidate, masses);
1196 double LXY = lxy(vxCandidate,vertex);
1197 double PT = V0Momentum(vxCandidate).perp();
1198 return CONST*M*LXY/PT;
1199 }

◆ tau() [5/5]

double V0Tools::tau ( const xAOD::Vertex * vxCandidate,
const xAOD::Vertex * vertex,
std::span< const double > masses,
double massV0 ) const

proper time wrt an xAOD::Vertex vertex assuming track masses (imposing massV0) making a correction to the proper time consistent with the imposed V0 mass

Definition at line 1208 of file V0Tools.cxx.

1209 {
1210 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
1211 if (masses.size() != NTrk) {
1212 ATH_MSG_ERROR("The provided number of masses does not match the number of tracks in the vertex");
1213 return -999999.;
1214 }
1215 Amg::MatrixX cov = tauMassCovariance(vxCandidate,vertex,masses);
1216 double Tau = tau(vxCandidate,vertex,masses);
1217 double mass = invariantMass(vxCandidate,masses);
1218 double descr = cov(0,0)*cov(1,1)-cov(0,1)*cov(0,1);
1219 double cov_i11 = cov(1,1)/descr;
1220 double cov_i12 = -cov(0,1)/descr;
1221 double deltaTau = -(massV0-mass)*cov_i12/cov_i11;
1222 return Tau + deltaTau;
1223 }
Amg::MatrixX tauMassCovariance(const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex, std::span< const double > masses) const
mass-proper time covariance
Definition V0Tools.cxx:2312
list descr
print "%s.properties()" % self.__name__
@ Tau
The object is a tau (jet)
Definition ObjectType.h:49

◆ tau3D() [1/2]

double V0Tools::tau3D ( const xAOD::Vertex * vxCandidate,
const xAOD::Vertex * vertex,
double massV0 )
static

proper time in 3D wrt an xAOD::Vertex vertex assuming massV0 imposing a V0 mass without making an adjustment

Definition at line 1522 of file V0Tools.cxx.

1523 {
1524 //double CONST = 1000./CLHEP::c_light;
1525 double CONST = 1000./299.792;
1526 double LXYZ = lxyz(vxCandidate,vertex);
1527 double P = V0Momentum(vxCandidate).mag();
1528 return CONST*M*LXYZ/P;
1529 }
static double lxyz(const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex)
projection of distance in 3D of the vertex wrt an xAOD::Vertex vertex along the momentum direction (P...
Definition V0Tools.cxx:1054

◆ tau3D() [2/2]

double V0Tools::tau3D ( const xAOD::Vertex * vxCandidate,
const xAOD::Vertex * vertex,
std::span< const double > masses ) const

proper time in 3D wrt an xAOD::Vertex vertex assuming track masses

Definition at line 1507 of file V0Tools.cxx.

1508 {
1509 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
1510 if (masses.size() != NTrk) {
1511 ATH_MSG_DEBUG("The provided number of masses does not match the number of tracks in the vertex");
1512 return -999999.;
1513 }
1514 //double CONST = 1000./CLHEP::c_light;
1515 double CONST = 1000./299.792;
1516 double M = invariantMass(vxCandidate, masses);
1517 double LXYZ = lxyz(vxCandidate,vertex);
1518 double P = V0Momentum(vxCandidate).mag();
1519 return CONST*M*LXYZ/P;
1520 }

◆ tau3DError() [1/2]

double V0Tools::tau3DError ( const xAOD::Vertex * vxCandidate,
const xAOD::Vertex * vertex,
double massV0 ) const

proper time error in 3D wrt an xAOD::Vertex vertex assuming massV0 imposing a V0 mass without making an adjustment

Definition at line 1663 of file V0Tools.cxx.

1664 {
1665 // Tau = CONST*M*(Px*dx+Py*dy+Pz*dz)/(P*P)
1666 //double CONST = 1000./CLHEP::c_light;
1667 double CONST = 1000./299.792;
1668 double P = V0Momentum(vxCandidate).mag();
1669 auto vecsub = vxCandidate->position() - vertex->position();
1670 double dx = vecsub.x();
1671 double dy = vecsub.y();
1672 double dz = vecsub.z();
1673 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
1674 double Px=0., Py=0., Pz=0.;
1675 std::vector<double>dpxdqOverP(NTrk), dpxdtheta(NTrk), dpxdphi(NTrk);
1676 std::vector<double>dpydqOverP(NTrk), dpydtheta(NTrk), dpydphi(NTrk);
1677 std::vector<double>dpzdqOverP(NTrk), dpzdtheta(NTrk);
1678 std::vector<double>dTaudqOverP(NTrk), dTaudtheta(NTrk), dTaudphi(NTrk);
1679
1680 auto fullCov = convertCovMatrix(vxCandidate);
1681 for( unsigned int it=0; it<NTrk; it++) {
1682 const Trk::TrackParameters* bPer = vxCandidate->vxTrackAtVertex()[it].perigeeAtVertex();
1683 double trkCharge = 1.;
1684 if (bPer->parameters()[Trk::qOverP] < 0.) trkCharge = -1.;
1685 double phi = bPer->parameters()[Trk::phi];
1686 double theta = bPer->parameters()[Trk::theta];
1687 double qOverP = bPer->parameters()[Trk::qOverP];
1688 dpxdqOverP[it] = -(sin(theta)*cos(phi)*trkCharge)/(qOverP*qOverP);
1689 dpxdtheta[it] = (cos(theta)*cos(phi)*trkCharge)/qOverP;
1690 dpxdphi[it] = -(sin(theta)*sin(phi)*trkCharge)/qOverP;
1691 dpydqOverP[it] = -(sin(theta)*sin(phi)*trkCharge)/(qOverP*qOverP);
1692 dpydtheta[it] = (cos(theta)*sin(phi)*trkCharge)/qOverP;
1693 dpydphi[it] = (sin(theta)*cos(phi)*trkCharge)/qOverP;
1694 dpzdqOverP[it] = -(cos(theta)*trkCharge)/(qOverP*qOverP);
1695 dpzdtheta[it] = -(sin(theta)*trkCharge)/qOverP;
1696 Px += bPer->momentum()[Trk::px];
1697 Py += bPer->momentum()[Trk::py];
1698 Pz += bPer->momentum()[Trk::pz];
1699 }
1700 double LXYZ = Px*dx+Py*dy+Pz*dz;
1701
1702 for( unsigned int it=0; it<NTrk; it++) {
1703 double dPdqOverP = (Px*dpxdqOverP[it]+Py*dpydqOverP[it]+Pz*dpzdqOverP[it])/P;
1704 double dPdtheta = (Px*dpxdtheta[it]+Py*dpydtheta[it]+Pz*dpzdtheta[it])/P;
1705 double dPdphi = (Px*dpxdphi[it]+Py*dpydphi[it])/P;
1706 double dLXYZdqOverP = dx*dpxdqOverP[it]+dy*dpydqOverP[it]+dz*dpzdqOverP[it];
1707 double dLXYZdtheta = dx*dpxdtheta[it]+dy*dpydtheta[it]+dz*dpzdtheta[it];
1708 double dLXYZdphi = dx*dpxdphi[it]+dy*dpydphi[it];
1709 dTaudqOverP[it] = M*dLXYZdqOverP/(P*P)-(2.*LXYZ*M*dPdqOverP)/(P*P*P);
1710 dTaudtheta[it] = M*dLXYZdtheta/(P*P)-(2.*LXYZ*M*dPdtheta)/(P*P*P);
1711 dTaudphi[it] = M*dLXYZdphi/(P*P)-(2.*LXYZ*M*dPdphi)/(P*P*P);
1712 }
1713 double dTaudx = (M*Px)/(P*P);
1714 double dTaudy = (M*Py)/(P*P);
1715 double dTaudz = (M*Pz)/(P*P);
1716 double dTaudx0 = -dTaudx;
1717 double dTaudy0 = -dTaudy;
1718 double dTaudz0 = -dTaudz;
1719
1720 unsigned int ndim = 0;
1721 if (fullCov.size() != 0) {
1722 ndim = fullCov.rows();
1723 } else {
1724 ndim = 5*NTrk+3;
1725 }
1726
1727 Amg::MatrixX V0_err;
1728 if (ndim == 5*NTrk+3 || ndim == 5*NTrk+6) {
1729 Amg::MatrixX D_vec(5*NTrk+6,1); D_vec.setZero();
1730 for( unsigned int it=0; it<NTrk; it++) {
1731 D_vec(5*it+0) = 0.;
1732 D_vec(5*it+1) = 0.;
1733 D_vec(5*it+2) = dTaudphi[it];
1734 D_vec(5*it+3) = dTaudtheta[it];
1735 D_vec(5*it+4) = dTaudqOverP[it];
1736 }
1737 D_vec(5*NTrk+0) = dTaudx;
1738 D_vec(5*NTrk+1) = dTaudy;
1739 D_vec(5*NTrk+2) = dTaudz;
1740 D_vec(5*NTrk+3) = dTaudx0;
1741 D_vec(5*NTrk+4) = dTaudy0;
1742 D_vec(5*NTrk+5) = dTaudz0;
1743
1744 Amg::MatrixX W_mat(5*NTrk+6,5*NTrk+6); W_mat.setZero();
1745 if (fullCov.size() != 0) {
1746 W_mat.block(0,0,ndim,ndim) = fullCov;
1747 } else {
1748 Amg::MatrixX V0_cov = makeV0Cov(vxCandidate);
1749 W_mat.block(0,0,V0_cov.rows(),V0_cov.rows()) = V0_cov;
1750 W_mat.block<3,3>(5*NTrk,5*NTrk) = vxCandidate->covariancePosition();
1751 }
1752 W_mat.block<3,3>(5*NTrk+3,5*NTrk+3) = vertex->covariancePosition();
1753 V0_err = D_vec.transpose() * W_mat * D_vec;
1754 } else if (ndim == 3*NTrk+3) {
1755 Amg::MatrixX D_vec(3*NTrk+6,1); D_vec.setZero();
1756 D_vec(0) = dTaudx;
1757 D_vec(1) = dTaudy;
1758 D_vec(2) = dTaudz;
1759 for( unsigned int it=0; it<NTrk; it++) {
1760 D_vec(3*it+3) = dTaudphi[it];
1761 D_vec(3*it+4) = dTaudtheta[it];
1762 D_vec(3*it+5) = dTaudqOverP[it];
1763 }
1764 D_vec(3*NTrk+3) = dTaudx0;
1765 D_vec(3*NTrk+4) = dTaudy0;
1766 D_vec(3*NTrk+5) = dTaudz0;
1767
1768 Amg::MatrixX W_mat(3*NTrk+6,3*NTrk+6); W_mat.setZero();
1769 W_mat.block(0,0,ndim,ndim) = fullCov;
1770 W_mat.block<3,3>(3*NTrk+3,3*NTrk+3) = vertex->covariancePosition();
1771 V0_err = D_vec.transpose() * W_mat * D_vec;
1772 }else{
1773 ATH_MSG_ERROR("This should not happen - returning zero.");
1774 return 0;
1775 }
1776
1777 double tauErrsq = V0_err(0,0);
1778 if (tauErrsq <= 0.) ATH_MSG_DEBUG("tauError: negative sqrt tauErrsq " << tauErrsq);
1779 double tauErr = (tauErrsq>0.) ? sqrt(tauErrsq) : 0.;
1780 return CONST*tauErr;
1781 }

◆ tau3DError() [2/2]

double V0Tools::tau3DError ( const xAOD::Vertex * vxCandidate,
const xAOD::Vertex * vertex,
std::span< const double > masses ) const

proper time error in 3D wrt an xAOD::Vertex vertex assuming track masses

Definition at line 1531 of file V0Tools.cxx.

1532 {
1533 // Tau = CONST*M*(Px*dx+Py*dy+Pz*dz)/(P*P)
1534 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
1535 if (masses.size() != NTrk) {
1536 ATH_MSG_ERROR("The provided number of masses does not match the number of tracks in the vertex");
1537 return -999999.;
1538 }
1539 //double CONST = 1000./CLHEP::c_light;
1540 double CONST = 1000./299.792;
1541 double P = V0Momentum(vxCandidate).mag();
1542 auto vert = vxCandidate->position() - vertex->position();
1543 double dx = vert.x();
1544 double dy = vert.y();
1545 double dz = vert.z();
1546 double M = invariantMass(vxCandidate, masses);
1547 double E=0., Px=0., Py=0., Pz=0.;
1548 std::vector<double>dpxdqOverP(NTrk), dpxdtheta(NTrk), dpxdphi(NTrk);
1549 std::vector<double>dpydqOverP(NTrk), dpydtheta(NTrk), dpydphi(NTrk);
1550 std::vector<double>dpzdqOverP(NTrk), dpzdtheta(NTrk), dedqOverP(NTrk);
1551 std::vector<double>dTaudqOverP(NTrk), dTaudtheta(NTrk), dTaudphi(NTrk);
1552
1553 auto fullCov = convertCovMatrix(vxCandidate);
1554 for( unsigned int it=0; it<NTrk; it++) {
1555 const Trk::TrackParameters* bPer = vxCandidate->vxTrackAtVertex()[it].perigeeAtVertex();
1556 double trkCharge = 1.;
1557 if (bPer->parameters()[Trk::qOverP] < 0.) trkCharge = -1.;
1558 double phi = bPer->parameters()[Trk::phi];
1559 double theta = bPer->parameters()[Trk::theta];
1560 double qOverP = bPer->parameters()[Trk::qOverP];
1561 double tmp = 1./(qOverP*qOverP) + masses[it]*masses[it];
1562 double pe = (tmp>0.) ? sqrt(tmp) : 0.;
1563 dedqOverP[it] = -1./(qOverP*qOverP*qOverP*pe);
1564 dpxdqOverP[it] = -(sin(theta)*cos(phi)*trkCharge)/(qOverP*qOverP);
1565 dpxdtheta[it] = (cos(theta)*cos(phi)*trkCharge)/qOverP;
1566 dpxdphi[it] = -(sin(theta)*sin(phi)*trkCharge)/qOverP;
1567 dpydqOverP[it] = -(sin(theta)*sin(phi)*trkCharge)/(qOverP*qOverP);
1568 dpydtheta[it] = (cos(theta)*sin(phi)*trkCharge)/qOverP;
1569 dpydphi[it] = (sin(theta)*cos(phi)*trkCharge)/qOverP;
1570 dpzdqOverP[it] = -(cos(theta)*trkCharge)/(qOverP*qOverP);
1571 dpzdtheta[it] = -(sin(theta)*trkCharge)/qOverP;
1572 E += pe;
1573 Px += bPer->momentum()[Trk::px];
1574 Py += bPer->momentum()[Trk::py];
1575 Pz += bPer->momentum()[Trk::pz];
1576 }
1577 double LXYZ = Px*dx+Py*dy+Pz*dz;
1578
1579 for( unsigned int it=0; it<NTrk; it++) {
1580 double dMdqOverP = -(Px*dpxdqOverP[it]+Py*dpydqOverP[it]+Pz*dpzdqOverP[it]-E*dedqOverP[it])/M;
1581 double dMdtheta = -(Px*dpxdtheta[it]+Py*dpydtheta[it]+Pz*dpzdtheta[it])/M;
1582 double dMdphi = -(Px*dpxdphi[it]+Py*dpydphi[it])/M;
1583 double dPdqOverP = (Px*dpxdqOverP[it]+Py*dpydqOverP[it]+Pz*dpzdqOverP[it])/P;
1584 double dPdtheta = (Px*dpxdtheta[it]+Py*dpydtheta[it]+Pz*dpzdtheta[it])/P;
1585 double dPdphi = (Px*dpxdphi[it]+Py*dpydphi[it])/P;
1586 double dLXYZdqOverP = dx*dpxdqOverP[it]+dy*dpydqOverP[it]+dz*dpzdqOverP[it];
1587 double dLXYZdtheta = dx*dpxdtheta[it]+dy*dpydtheta[it]+dz*dpzdtheta[it];
1588 double dLXYZdphi = dx*dpxdphi[it]+dy*dpydphi[it];
1589 dTaudqOverP[it] = (LXYZ*dMdqOverP+M*dLXYZdqOverP)/(P*P)-(2.*LXYZ*M*dPdqOverP)/(P*P*P);
1590 dTaudtheta[it] = (LXYZ*dMdtheta+M*dLXYZdtheta)/(P*P)-(2.*LXYZ*M*dPdtheta)/(P*P*P);
1591 dTaudphi[it] = (LXYZ*dMdphi+M*dLXYZdphi)/(P*P)-(2.*LXYZ*M*dPdphi)/(P*P*P);
1592 }
1593 double dTaudx = (M*Px)/(P*P);
1594 double dTaudy = (M*Py)/(P*P);
1595 double dTaudz = (M*Pz)/(P*P);
1596 double dTaudx0 = -dTaudx;
1597 double dTaudy0 = -dTaudy;
1598 double dTaudz0 = -dTaudz;
1599
1600 unsigned int ndim = 0;
1601 if (fullCov.size() != 0) {
1602 ndim = fullCov.rows();
1603 } else {
1604 ndim = 5*NTrk+3;
1605 }
1606
1607 Amg::MatrixX V0_err;
1608 if (ndim == 5*NTrk+3 || ndim == 5*NTrk+6) {
1609 Amg::MatrixX D_vec(5*NTrk+6,1); D_vec.setZero();
1610 for( unsigned int it=0; it<NTrk; it++) {
1611 D_vec(5*it+0) = 0.;
1612 D_vec(5*it+1) = 0.;
1613 D_vec(5*it+2) = dTaudphi[it];
1614 D_vec(5*it+3) = dTaudtheta[it];
1615 D_vec(5*it+4) = dTaudqOverP[it];
1616 }
1617 D_vec(5*NTrk+0) = dTaudx;
1618 D_vec(5*NTrk+1) = dTaudy;
1619 D_vec(5*NTrk+2) = dTaudz;
1620 D_vec(5*NTrk+3) = dTaudx0;
1621 D_vec(5*NTrk+4) = dTaudy0;
1622 D_vec(5*NTrk+5) = dTaudz0;
1623
1624 Amg::MatrixX W_mat(5*NTrk+6,5*NTrk+6); W_mat.setZero();
1625 if (fullCov.size() != 0) {
1626 W_mat.block(0,0,ndim,ndim) = fullCov;
1627 } else {
1628 Amg::MatrixX V0_cov = makeV0Cov(vxCandidate);
1629 W_mat.block(0,0,V0_cov.rows(),V0_cov.rows()) = V0_cov;
1630 W_mat.block<3,3>(5*NTrk,5*NTrk) = vxCandidate->covariancePosition();
1631 }
1632 W_mat.block<3,3>(5*NTrk+3,5*NTrk+3) = vertex->covariancePosition();
1633 V0_err = D_vec.transpose() * W_mat * D_vec;
1634 } else if (ndim == 3*NTrk+3) {
1635 Amg::MatrixX D_vec(3*NTrk+6,1); D_vec.setZero();
1636 D_vec(0) = dTaudx;
1637 D_vec(1) = dTaudy;
1638 D_vec(2) = dTaudz;
1639 for( unsigned int it=0; it<NTrk; it++) {
1640 D_vec(3*it+3) = dTaudphi[it];
1641 D_vec(3*it+4) = dTaudtheta[it];
1642 D_vec(3*it+5) = dTaudqOverP[it];
1643 }
1644 D_vec(3*NTrk+3) = dTaudx0;
1645 D_vec(3*NTrk+4) = dTaudy0;
1646 D_vec(3*NTrk+5) = dTaudz0;
1647
1648 Amg::MatrixX W_mat(3*NTrk+6,3*NTrk+6); W_mat.setZero();
1649 W_mat.block(0,0,ndim,ndim) = fullCov;
1650 W_mat.block<3,3>(3*NTrk+3,3*NTrk+3) = vertex->covariancePosition();
1651 V0_err = D_vec.transpose() * W_mat * D_vec;
1652 }else{
1653 ATH_MSG_ERROR("This should not happen - returning zero.");
1654 return 0;
1655 }
1656
1657 double tauErrsq = V0_err(0,0);
1658 if (tauErrsq <= 0.) ATH_MSG_DEBUG("tauError: negative sqrt tauErrsq " << tauErrsq);
1659 double tauErr = (tauErrsq>0.) ? sqrt(tauErrsq) : 0.;
1660 return CONST*tauErr;
1661 }

◆ tauError() [1/5]

double V0Tools::tauError ( const xAOD::Vertex * vxCandidate,
const xAOD::Vertex * vertex,
double massV0 ) const

proper time error wrt an xAOD::Vertex vertex assuming massV0 imposing a V0 mass without making an adjustment

Definition at line 1393 of file V0Tools.cxx.

1394 {
1395 // Tau = CONST*M*(Px*dx+Py*dy)/(PT*PT)
1396 //double CONST = 1000./CLHEP::c_light;
1397 double CONST = 1000./299.792;
1398 double PT = V0Momentum(vxCandidate).perp();
1399 auto vecsub = vxCandidate->position() - vertex->position();
1400 double dx = vecsub.x();
1401 double dy = vecsub.y();
1402 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
1403 double Px=0., Py=0.;
1404 std::vector<double>dpxdqOverP(NTrk), dpxdtheta(NTrk), dpxdphi(NTrk);
1405 std::vector<double>dpydqOverP(NTrk), dpydtheta(NTrk), dpydphi(NTrk);
1406 std::vector<double>dPTdtheta(NTrk), dPTdphi(NTrk);
1407 std::vector<double>dTaudqOverP(NTrk), dTaudtheta(NTrk), dTaudphi(NTrk);
1408
1409 auto fullCov = convertCovMatrix(vxCandidate);
1410 for( unsigned int it=0; it<NTrk; it++) {
1411 const Trk::TrackParameters* bPer = vxCandidate->vxTrackAtVertex()[it].perigeeAtVertex();
1412 double trkCharge = 1.;
1413 if (bPer->parameters()[Trk::qOverP] < 0.) trkCharge = -1.;
1414 double phi = bPer->parameters()[Trk::phi];
1415 double theta = bPer->parameters()[Trk::theta];
1416 double qOverP = bPer->parameters()[Trk::qOverP];
1417 dpxdqOverP[it] = -(sin(theta)*cos(phi)*trkCharge)/(qOverP*qOverP);
1418 dpxdtheta[it] = (cos(theta)*cos(phi)*trkCharge)/qOverP;
1419 dpxdphi[it] = -(sin(theta)*sin(phi)*trkCharge)/qOverP;
1420 dpydqOverP[it] = -(sin(theta)*sin(phi)*trkCharge)/(qOverP*qOverP);
1421 dpydtheta[it] = (cos(theta)*sin(phi)*trkCharge)/qOverP;
1422 dpydphi[it] = (sin(theta)*cos(phi)*trkCharge)/qOverP;
1423 Px += bPer->momentum()[Trk::px];
1424 Py += bPer->momentum()[Trk::py];
1425 }
1426 double LXY = Px*dx+Py*dy;
1427
1428 for( unsigned int it=0; it<NTrk; it++) {
1429 double dPTdqOverP = (Px*dpxdqOverP[it]+Py*dpydqOverP[it])/PT;
1430 double dPTdtheta = (Px*dpxdtheta[it]+Py*dpydtheta[it])/PT;
1431 double dPTdphi = (Px*dpxdphi[it]+Py*dpydphi[it])/PT;
1432 double dLXYdqOverP = dx*dpxdqOverP[it]+dy*dpydqOverP[it];
1433 double dLXYdtheta = dx*dpxdtheta[it]+dy*dpydtheta[it];
1434 double dLXYdphi = dx*dpxdphi[it]+dy*dpydphi[it];
1435 dTaudqOverP[it] = M*dLXYdqOverP/(PT*PT)-(2.*LXY*M*dPTdqOverP)/(PT*PT*PT);
1436 dTaudtheta[it] = M*dLXYdtheta/(PT*PT)-(2.*LXY*M*dPTdtheta)/(PT*PT*PT);
1437 dTaudphi[it] = M*dLXYdphi/(PT*PT)-(2.*LXY*M*dPTdphi)/(PT*PT*PT);
1438 }
1439 double dTaudx = (M*Px)/(PT*PT);
1440 double dTaudy = (M*Py)/(PT*PT);
1441 double dTaudx0 = -dTaudx;
1442 double dTaudy0 = -dTaudy;
1443
1444 unsigned int ndim = 0;
1445 if (fullCov.size() != 0) {
1446 ndim = fullCov.rows();
1447 } else {
1448 ndim = 5*NTrk+3;
1449 }
1450
1451 Amg::MatrixX V0_err;
1452 if (ndim == 5*NTrk+3 || ndim == 5*NTrk+6) {
1453 Amg::MatrixX D_vec(5*NTrk+6,1); D_vec.setZero();
1454 for( unsigned int it=0; it<NTrk; it++) {
1455 D_vec(5*it+0) = 0.;
1456 D_vec(5*it+1) = 0.;
1457 D_vec(5*it+2) = dTaudphi[it];
1458 D_vec(5*it+3) = dTaudtheta[it];
1459 D_vec(5*it+4) = dTaudqOverP[it];
1460 }
1461 D_vec(5*NTrk+0) = dTaudx;
1462 D_vec(5*NTrk+1) = dTaudy;
1463 D_vec(5*NTrk+2) = 0.;
1464 D_vec(5*NTrk+3) = dTaudx0;
1465 D_vec(5*NTrk+4) = dTaudy0;
1466 D_vec(5*NTrk+5) = 0.;
1467
1468 Amg::MatrixX W_mat(5*NTrk+6,5*NTrk+6); W_mat.setZero();
1469 if (fullCov.size() != 0) {
1470 W_mat.block(0,0,ndim,ndim) = fullCov;
1471 } else {
1472 Amg::MatrixX V0_cov = makeV0Cov(vxCandidate);
1473 W_mat.block(0,0,V0_cov.rows(),V0_cov.rows()) = V0_cov;
1474 W_mat.block<3,3>(5*NTrk,5*NTrk) = vxCandidate->covariancePosition();
1475 }
1476 W_mat.block<3,3>(5*NTrk+3,5*NTrk+3) = vertex->covariancePosition();
1477 V0_err = D_vec.transpose() * W_mat * D_vec;
1478 } else if (ndim == 3*NTrk+3) {
1479 Amg::MatrixX D_vec(3*NTrk+6,1); D_vec.setZero();
1480 D_vec(0) = dTaudx;
1481 D_vec(1) = dTaudy;
1482 D_vec(2) = 0.;
1483 for( unsigned int it=0; it<NTrk; it++) {
1484 D_vec(3*it+3) = dTaudphi[it];
1485 D_vec(3*it+4) = dTaudtheta[it];
1486 D_vec(3*it+5) = dTaudqOverP[it];
1487 }
1488 D_vec(3*NTrk+3) = dTaudx0;
1489 D_vec(3*NTrk+4) = dTaudy0;
1490 D_vec(3*NTrk+5) = 0.;
1491
1492 Amg::MatrixX W_mat(3*NTrk+6,3*NTrk+6); W_mat.setZero();
1493 W_mat.block(0,0,ndim,ndim) = fullCov;
1494 W_mat.block<3,3>(3*NTrk+3,3*NTrk+3) = vertex->covariancePosition();
1495 V0_err = D_vec.transpose() * W_mat * D_vec;
1496 }else{
1497 ATH_MSG_ERROR("This should not happen - returning zero.");
1498 return 0;
1499 }
1500
1501 double tauErrsq = V0_err(0,0);
1502 if (tauErrsq <= 0.) ATH_MSG_DEBUG("tauError: negative sqrt tauErrsq " << tauErrsq);
1503 double tauErr = (tauErrsq>0.) ? sqrt(tauErrsq) : 0.;
1504 return CONST*tauErr;
1505 }

◆ tauError() [2/5]

double V0Tools::tauError ( const xAOD::Vertex * vxCandidate,
const xAOD::Vertex * vertex,
double posTrackMass,
double negTrackMass ) const

proper time error wrt an xAOD::Vertex vertex assuming posTrackMass and negTrackMass tau = CONST*M*lxy/pT

Definition at line 1234 of file V0Tools.cxx.

1235 {
1236 // Tau = CONST*M*(Px*dx+Py*dy)/(PT*PT)
1237 std::array<double, 2> masses = {posTrackMass, negTrackMass};
1238
1239 return tauError(vxCandidate,vertex,masses);
1240 }
double tauError(const xAOD::Vertex *vxCandidate, const xAOD::Vertex *vertex, double posTrackMass, double negTrackMass) const
proper time error wrt an xAOD::Vertex vertex assuming posTrackMass and negTrackMass tau = CONST*M*lxy...
Definition V0Tools.cxx:1234

◆ tauError() [3/5]

double V0Tools::tauError ( const xAOD::Vertex * vxCandidate,
const xAOD::Vertex * vertex,
double posTrackMass,
double negTrackMass,
double massV0 ) const

proper time error wrt an xAOD::Vertex vertex assuming posTrackMass and negTrackMass (imposing massV0) independent of massV0, variable included to match the corresponding proper time method

Definition at line 1371 of file V0Tools.cxx.

1372 {
1373 std::array<double, 2> masses = {posTrackMass, negTrackMass};
1374
1375 return tauError(vxCandidate,vertex,masses,massV0);
1376 }

◆ tauError() [4/5]

double V0Tools::tauError ( const xAOD::Vertex * vxCandidate,
const xAOD::Vertex * vertex,
std::span< const double > masses ) const

proper time error wrt an xAOD::Vertex vertex assuming track masses

Definition at line 1242 of file V0Tools.cxx.

1243 {
1244 // Tau = CONST*M*(Px*dx+Py*dy)/(PT*PT)
1245 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
1246 if (masses.size() != NTrk) {
1247 ATH_MSG_ERROR("The provided number of masses does not match the number of tracks in the vertex");
1248 return -999999.;
1249 }
1250 //double CONST = 1000./CLHEP::c_light;
1251 double CONST = 1000./299.792;
1252 double PT = V0Momentum(vxCandidate).perp();
1253 auto vert = vxCandidate->position() - vertex->position();
1254 double dx = vert.x();
1255 double dy = vert.y();
1256 double M = invariantMass(vxCandidate, masses);
1257 double E=0., Px=0., Py=0., Pz=0.;
1258 std::vector<double>dpxdqOverP(NTrk), dpxdtheta(NTrk), dpxdphi(NTrk);
1259 std::vector<double>dpydqOverP(NTrk), dpydtheta(NTrk), dpydphi(NTrk);
1260 std::vector<double>dpzdqOverP(NTrk), dpzdtheta(NTrk), dedqOverP(NTrk);
1261 std::vector<double>dTaudqOverP(NTrk), dTaudtheta(NTrk), dTaudphi(NTrk);
1262
1263 auto fullCov = convertCovMatrix(vxCandidate);
1264 for( unsigned int it=0; it<NTrk; it++) {
1265 const Trk::TrackParameters* bPer = vxCandidate->vxTrackAtVertex()[it].perigeeAtVertex();
1266 double trkCharge = 1.;
1267 if (bPer->parameters()[Trk::qOverP] < 0.) trkCharge = -1.;
1268 double phi = bPer->parameters()[Trk::phi];
1269 double theta = bPer->parameters()[Trk::theta];
1270 double qOverP = bPer->parameters()[Trk::qOverP];
1271 double tmp = 1./(qOverP*qOverP) + masses[it]*masses[it];
1272 double pe = (tmp>0.) ? sqrt(tmp) : 0.;
1273 dedqOverP[it] = -1./(qOverP*qOverP*qOverP*pe);
1274 dpxdqOverP[it] = -(sin(theta)*cos(phi)*trkCharge)/(qOverP*qOverP);
1275 dpxdtheta[it] = (cos(theta)*cos(phi)*trkCharge)/qOverP;
1276 dpxdphi[it] = -(sin(theta)*sin(phi)*trkCharge)/qOverP;
1277 dpydqOverP[it] = -(sin(theta)*sin(phi)*trkCharge)/(qOverP*qOverP);
1278 dpydtheta[it] = (cos(theta)*sin(phi)*trkCharge)/qOverP;
1279 dpydphi[it] = (sin(theta)*cos(phi)*trkCharge)/qOverP;
1280 dpzdqOverP[it] = -(cos(theta)*trkCharge)/(qOverP*qOverP);
1281 dpzdtheta[it] = -(sin(theta)*trkCharge)/qOverP;
1282 E += pe;
1283 Px += bPer->momentum()[Trk::px];
1284 Py += bPer->momentum()[Trk::py];
1285 Pz += bPer->momentum()[Trk::pz];
1286 }
1287 double LXY = Px*dx+Py*dy;
1288
1289 for( unsigned int it=0; it<NTrk; it++) {
1290 double dMdqOverP = -(Px*dpxdqOverP[it]+Py*dpydqOverP[it]+Pz*dpzdqOverP[it]-E*dedqOverP[it])/M;
1291 double dMdtheta = -(Px*dpxdtheta[it]+Py*dpydtheta[it]+Pz*dpzdtheta[it])/M;
1292 double dMdphi = -(Px*dpxdphi[it]+Py*dpydphi[it])/M;
1293 double dPTdqOverP = (Px*dpxdqOverP[it]+Py*dpydqOverP[it])/PT;
1294 double dPTdtheta = (Px*dpxdtheta[it]+Py*dpydtheta[it])/PT;
1295 double dPTdphi = (Px*dpxdphi[it]+Py*dpydphi[it])/PT;
1296 double dLXYdqOverP = dx*dpxdqOverP[it]+dy*dpydqOverP[it];
1297 double dLXYdtheta = dx*dpxdtheta[it]+dy*dpydtheta[it];
1298 double dLXYdphi = dx*dpxdphi[it]+dy*dpydphi[it];
1299 dTaudqOverP[it] = (LXY*dMdqOverP+M*dLXYdqOverP)/(PT*PT)-(2.*LXY*M*dPTdqOverP)/(PT*PT*PT);
1300 dTaudtheta[it] = (LXY*dMdtheta+M*dLXYdtheta)/(PT*PT)-(2.*LXY*M*dPTdtheta)/(PT*PT*PT);
1301 dTaudphi[it] = (LXY*dMdphi+M*dLXYdphi)/(PT*PT)-(2.*LXY*M*dPTdphi)/(PT*PT*PT);
1302 }
1303 double dTaudx = (M*Px)/(PT*PT);
1304 double dTaudy = (M*Py)/(PT*PT);
1305 double dTaudx0 = -dTaudx;
1306 double dTaudy0 = -dTaudy;
1307
1308 unsigned int ndim = 0;
1309 if (fullCov.size() != 0) {
1310 ndim = fullCov.rows();
1311 } else {
1312 ndim = 5*NTrk+3;
1313 }
1314
1315 Amg::MatrixX V0_err;
1316 if (ndim == 5*NTrk+3 || ndim == 5*NTrk+6) {
1317 Amg::MatrixX D_vec(5*NTrk+6,1); D_vec.setZero();
1318 for( unsigned int it=0; it<NTrk; it++) {
1319 D_vec(5*it+0) = 0.;
1320 D_vec(5*it+1) = 0.;
1321 D_vec(5*it+2) = dTaudphi[it];
1322 D_vec(5*it+3) = dTaudtheta[it];
1323 D_vec(5*it+4) = dTaudqOverP[it];
1324 }
1325 D_vec(5*NTrk+0) = dTaudx;
1326 D_vec(5*NTrk+1) = dTaudy;
1327 D_vec(5*NTrk+2) = 0.;
1328 D_vec(5*NTrk+3) = dTaudx0;
1329 D_vec(5*NTrk+4) = dTaudy0;
1330 D_vec(5*NTrk+5) = 0.;
1331
1332 Amg::MatrixX W_mat(5*NTrk+6,5*NTrk+6); W_mat.setZero();
1333 if (fullCov.size() != 0) {
1334 W_mat.block(0,0,ndim,ndim) = fullCov;
1335 } else {
1336 Amg::MatrixX V0_cov = makeV0Cov(vxCandidate);
1337 W_mat.block(0,0,V0_cov.rows(),V0_cov.rows()) = V0_cov;
1338 W_mat.block<3,3>(5*NTrk,5*NTrk) = vxCandidate->covariancePosition();
1339 }
1340 W_mat.block<3,3>(5*NTrk+3,5*NTrk+3) = vertex->covariancePosition();
1341 V0_err = D_vec.transpose() * W_mat * D_vec;
1342 } else if (ndim == 3*NTrk+3) {
1343 Amg::MatrixX D_vec(3*NTrk+6,1); D_vec.setZero();
1344 D_vec(0) = dTaudx;
1345 D_vec(1) = dTaudy;
1346 D_vec(2) = 0.;
1347 for( unsigned int it=0; it<NTrk; it++) {
1348 D_vec(3*it+3) = dTaudphi[it];
1349 D_vec(3*it+4) = dTaudtheta[it];
1350 D_vec(3*it+5) = dTaudqOverP[it];
1351 }
1352 D_vec(3*NTrk+3) = dTaudx0;
1353 D_vec(3*NTrk+4) = dTaudy0;
1354 D_vec(3*NTrk+5) = 0.;
1355
1356 Amg::MatrixX W_mat(3*NTrk+6,3*NTrk+6); W_mat.setZero();
1357 W_mat.block(0,0,ndim,ndim) = fullCov;
1358 W_mat.block<3,3>(3*NTrk+3,3*NTrk+3) = vertex->covariancePosition();
1359 V0_err = D_vec.transpose() * W_mat * D_vec;
1360 }else{
1361 ATH_MSG_ERROR("This should not happen - returning zero.");
1362 return 0;
1363 }
1364
1365 double tauErrsq = V0_err(0,0);
1366 if (tauErrsq <= 0.) ATH_MSG_DEBUG("tauError: negative sqrt tauErrsq " << tauErrsq);
1367 double tauErr = (tauErrsq>0.) ? sqrt(tauErrsq) : 0.;
1368 return CONST*tauErr;
1369 }

◆ tauError() [5/5]

double V0Tools::tauError ( const xAOD::Vertex * vxCandidate,
const xAOD::Vertex * vertex,
std::span< const double > masses,
double massV0 ) const

proper time error wrt an xAOD::Vertex vertex assuming track masses (imposing massV0) independent of massV0, variable included to match the corresponding proper time method

Definition at line 1378 of file V0Tools.cxx.

1379 {
1380 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
1381 if (masses.size() != NTrk) {
1382 ATH_MSG_ERROR("The provided number of masses does not match the number of tracks in the vertex");
1383 return -999999.;
1384 }
1385 double error = -999999.;
1386 Amg::MatrixX cov = tauMassCovariance(vxCandidate,vertex,masses);
1387 double descr = cov(0,0)*cov(1,1)-cov(0,1)*cov(0,1);
1388 double cov_i11 = cov(1,1)/descr;
1389 if (cov_i11 > 0.) error = 1./sqrt(cov_i11);
1390 return error;
1391 }

◆ tauMassCovariance()

Amg::MatrixX V0Tools::tauMassCovariance ( const xAOD::Vertex * vxCandidate,
const xAOD::Vertex * vertex,
std::span< const double > masses ) const

mass-proper time covariance

Definition at line 2312 of file V0Tools.cxx.

2313 {
2314 // Tau = CONST*M*(Px*dx+Py*dy)/(PT*PT)
2315 Amg::MatrixX V0_err;
2316 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
2317 if (masses.size() != NTrk) {
2318 ATH_MSG_ERROR("The provided number of masses does not match the number of tracks in the vertex");
2319 return V0_err;
2320 }
2321 //double CONST = 1000./CLHEP::c_light;
2322 double CONST = 1000./299.792;
2323 double PT = V0Momentum(vxCandidate).perp();
2324 auto vert = vxCandidate->position() - vertex->position();
2325 double dx = vert.x();
2326 double dy = vert.y();
2327 double M = invariantMass(vxCandidate, masses);
2328 double E=0., Px=0., Py=0., Pz=0.;
2329 std::vector<double>dpxdqOverP(NTrk), dpxdtheta(NTrk), dpxdphi(NTrk);
2330 std::vector<double>dpydqOverP(NTrk), dpydtheta(NTrk), dpydphi(NTrk);
2331 std::vector<double>dpzdqOverP(NTrk), dpzdtheta(NTrk), dedqOverP(NTrk);
2332 std::vector<double>dMdqOverP(NTrk), dMdtheta(NTrk), dMdphi(NTrk);
2333 std::vector<double>dTaudqOverP(NTrk), dTaudtheta(NTrk), dTaudphi(NTrk);
2334
2335 auto fullCov = convertCovMatrix(vxCandidate);
2336 for( unsigned int it=0; it<NTrk; it++) {
2337 const Trk::TrackParameters* bPer = vxCandidate->vxTrackAtVertex()[it].perigeeAtVertex();
2338 double trkCharge = 1.;
2339 if (bPer->parameters()[Trk::qOverP] < 0.) trkCharge = -1.;
2340 double phi = bPer->parameters()[Trk::phi];
2341 double theta = bPer->parameters()[Trk::theta];
2342 double qOverP = bPer->parameters()[Trk::qOverP];
2343 double tmp = 1./(qOverP*qOverP) + masses[it]*masses[it];
2344 double pe = (tmp>0.) ? sqrt(tmp) : 0.;
2345 dedqOverP[it] = -1./(qOverP*qOverP*qOverP*pe);
2346 dpxdqOverP[it] = -(sin(theta)*cos(phi)*trkCharge)/(qOverP*qOverP);
2347 dpxdtheta[it] = (cos(theta)*cos(phi)*trkCharge)/qOverP;
2348 dpxdphi[it] = -(sin(theta)*sin(phi)*trkCharge)/qOverP;
2349 dpydqOverP[it] = -(sin(theta)*sin(phi)*trkCharge)/(qOverP*qOverP);
2350 dpydtheta[it] = (cos(theta)*sin(phi)*trkCharge)/qOverP;
2351 dpydphi[it] = (sin(theta)*cos(phi)*trkCharge)/qOverP;
2352 dpzdqOverP[it] = -(cos(theta)*trkCharge)/(qOverP*qOverP);
2353 dpzdtheta[it] = -(sin(theta)*trkCharge)/qOverP;
2354 E += pe;
2355 Px += bPer->momentum()[Trk::px];
2356 Py += bPer->momentum()[Trk::py];
2357 Pz += bPer->momentum()[Trk::pz];
2358 }
2359 double LXY = Px*dx+Py*dy;
2360
2361 for( unsigned int it=0; it<NTrk; it++) {
2362 dMdqOverP[it] = -(Px*dpxdqOverP[it]+Py*dpydqOverP[it]+Pz*dpzdqOverP[it]-E*dedqOverP[it])/M;
2363 dMdtheta[it] = -(Px*dpxdtheta[it]+Py*dpydtheta[it]+Pz*dpzdtheta[it])/M;
2364 dMdphi[it] = -(Px*dpxdphi[it]+Py*dpydphi[it])/M;
2365 double dPTdqOverP = (Px*dpxdqOverP[it]+Py*dpydqOverP[it])/PT;
2366 double dPTdtheta = (Px*dpxdtheta[it]+Py*dpydtheta[it])/PT;
2367 double dPTdphi = (Px*dpxdphi[it]+Py*dpydphi[it])/PT;
2368 double dLXYdqOverP = dx*dpxdqOverP[it]+dy*dpydqOverP[it];
2369 double dLXYdtheta = dx*dpxdtheta[it]+dy*dpydtheta[it];
2370 double dLXYdphi = dx*dpxdphi[it]+dy*dpydphi[it];
2371 dTaudqOverP[it] = (LXY*dMdqOverP[it]+M*dLXYdqOverP)/(PT*PT)-(2.*LXY*M*dPTdqOverP)/(PT*PT*PT);
2372 dTaudtheta[it] = (LXY*dMdtheta[it]+M*dLXYdtheta)/(PT*PT)-(2.*LXY*M*dPTdtheta)/(PT*PT*PT);
2373 dTaudphi[it] = (LXY*dMdphi[it]+M*dLXYdphi)/(PT*PT)-(2.*LXY*M*dPTdphi)/(PT*PT*PT);
2374 }
2375 double dTaudx = (M*Px)/(PT*PT);
2376 double dTaudy = (M*Py)/(PT*PT);
2377 double dTaudx0 = -dTaudx;
2378 double dTaudy0 = -dTaudy;
2379
2380 unsigned int ndim = 0;
2381 if (fullCov.size() != 0) {
2382 ndim = fullCov.rows();
2383 } else {
2384 ndim = 5*NTrk+3;
2385 }
2386
2387 if (ndim == 5*NTrk+3 || ndim == 5*NTrk+6) {
2388 Amg::MatrixX D_mat(5*NTrk+6,2); D_mat.setZero();
2389 for( unsigned int it=0; it<NTrk; it++) {
2390 D_mat(5*it+0,0) = 0.;
2391 D_mat(5*it+1,0) = 0.;
2392 D_mat(5*it+2,0) = CONST*dTaudphi[it];
2393 D_mat(5*it+3,0) = CONST*dTaudtheta[it];
2394 D_mat(5*it+4,0) = CONST*dTaudqOverP[it];
2395 D_mat(5*it+0,1) = 0.;
2396 D_mat(5*it+1,1) = 0.;
2397 D_mat(5*it+2,1) = dMdphi[it];
2398 D_mat(5*it+3,1) = dMdtheta[it];
2399 D_mat(5*it+4,1) = dMdqOverP[it];
2400 }
2401 D_mat(5*NTrk+0,0) = CONST*dTaudx;
2402 D_mat(5*NTrk+1,0) = CONST*dTaudy;
2403 D_mat(5*NTrk+2,0) = 0.;
2404 D_mat(5*NTrk+3,0) = CONST*dTaudx0;
2405 D_mat(5*NTrk+4,0) = CONST*dTaudy0;
2406 D_mat(5*NTrk+5,0) = 0.;
2407 Amg::MatrixX W_mat(5*NTrk+6,5*NTrk+6); W_mat.setZero();
2408 if (fullCov.size() != 0) {
2409 W_mat.block(0,0,ndim,ndim) = fullCov;
2410 } else {
2411 Amg::MatrixX V0_cov = makeV0Cov(vxCandidate);
2412 W_mat.block(0,0,V0_cov.rows(),V0_cov.rows()) = V0_cov;
2413 W_mat.block<3,3>(5*NTrk,5*NTrk) = vxCandidate->covariancePosition();
2414 }
2415 W_mat.block<3,3>(5*NTrk+3,5*NTrk) = vertex->covariancePosition();
2416 V0_err = D_mat.transpose() * W_mat * D_mat;
2417 } else if (ndim == 3*NTrk+3) {
2418 Amg::MatrixX D_mat(3*NTrk+6,2); D_mat.setZero();
2419 D_mat(0,0) = CONST*dTaudx;
2420 D_mat(1,0) = CONST*dTaudy;
2421 D_mat(2,0) = 0.;
2422 for( unsigned int it=0; it<NTrk; it++) {
2423 D_mat(3*it+3,0) = CONST*dTaudphi[it];
2424 D_mat(3*it+4,0) = CONST*dTaudtheta[it];
2425 D_mat(3*it+5,0) = CONST*dTaudqOverP[it];
2426 D_mat(3*it+3,1) = dMdphi[it];
2427 D_mat(3*it+4,1) = dMdtheta[it];
2428 D_mat(3*it+5,1) = dMdqOverP[it];
2429 }
2430 D_mat(3*NTrk+3,0) = CONST*dTaudx0;
2431 D_mat(3*NTrk+4,0) = CONST*dTaudy0;
2432 D_mat(3*NTrk+5,0) = 0.;
2433 Amg::MatrixX W_mat(3*NTrk+6,3*NTrk+6); W_mat.setZero();
2434 W_mat.block(0,0,ndim,ndim) = fullCov;
2435 W_mat.block<3,3>(3*NTrk+3,3*NTrk+3) = vertex->covariancePosition();
2436 V0_err = D_mat.transpose() * W_mat * D_mat;
2437 }else{
2438 ATH_MSG_ERROR("This should not happen - returning zero.");
2439 return V0_err;
2440 }
2441 return V0_err;
2442 }

◆ thetaStar()

double V0Tools::thetaStar ( const xAOD::Vertex * vxCandidate,
double mass1,
double mass2 )
static

Polarization angles in helicity frame (using positive track):

thetaStar (in rad)

Definition at line 1783 of file V0Tools.cxx.

1784 {
1785 double theta = 0.;
1788 CLHEP::HepLorentzVector v1(V1.Px(),V1.Py(),V1.Pz(),V1.E());
1789 CLHEP::HepLorentzVector v2(V2.Px(),V2.Py(),V2.Pz(),V2.E());
1790 CLHEP::HepLorentzVector v0 = v1 + v2;
1791 CLHEP::Hep3Vector boost_v0 = v0.boostVector();
1792 boost_v0 *= -1.0;
1793 v1.boost( boost_v0 );
1794 v2.boost( boost_v0 );
1795 theta = v0.angle( v1.vect() );
1796 return theta;
1797 }

◆ track4Momentum()

xAOD::TrackParticle::FourMom_t V0Tools::track4Momentum ( const xAOD::Vertex * vxCandidate,
unsigned int trkIndex,
double trackMass )
static

Methods, returning the refitted 4-momenta of the positive and negative tracks and the V0 for a given hypothesis for the masses of the input tracks and the V0 mass.

Definition at line 406 of file V0Tools.cxx.

407 {
408 Amg::Vector3D mom = trackMomentum(vxCandidate, trkIndex);
409 xAOD::TrackParticle::FourMom_t lorentz(0,0,0,0);
410 double tmp = mass*mass + mom.x()*mom.x() + mom.y()*mom.y() + mom.z()*mom.z();
411 double e = (tmp>0.) ? sqrt(tmp) : 0.;
412 lorentz.SetPxPyPzE(mom.x(), mom.y(), mom.z(), e);
413 return lorentz;
414 }

◆ trackMomentum()

Amg::Vector3D V0Tools::trackMomentum ( const xAOD::Vertex * vxCandidate,
unsigned int trkIndex )
static

Methods, returning the refitted 3-momenta of the positive and negative tracks and the V0 (for more than one track with the same charge, the first one is returned)

Definition at line 366 of file V0Tools.cxx.

367 {
368 const Trk::TrackParameters* aPerigee = vxCandidate->vxTrackAtVertex()[trkIndex].perigeeAtVertex();
369 return aPerigee->momentum();
370 }

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

◆ V04Momentum()

xAOD::TrackParticle::FourMom_t V0Tools::V04Momentum ( const xAOD::Vertex * vxCandidate,
double V0Mass )
static

Definition at line 436 of file V0Tools.cxx.

437 {
438 Amg::Vector3D mom = V0Momentum(vxCandidate);
439 double tmp = V0Mass*V0Mass + mom.x()*mom.x() + mom.y()*mom.y() + mom.z()*mom.z();
440 double e = (tmp>0.) ? sqrt(tmp) : 0.;
441 xAOD::TrackParticle::FourMom_t lorentz(0,0,0,0);
442 lorentz.SetPxPyPzE(mom.x(), mom.y(), mom.z(), e);
443 return lorentz;
444 }

◆ V0Momentum()

Amg::Vector3D V0Tools::V0Momentum ( const xAOD::Vertex * vxCandidate)
static

Definition at line 396 of file V0Tools.cxx.

397 {
398 Amg::Vector3D mom; mom.setZero();
399 unsigned int NTrk = vxCandidate->vxTrackAtVertex().size();
400 for( unsigned int it=0; it<NTrk; it++) {
401 mom += trackMomentum(vxCandidate,it);
402 }
403 return mom;
404 }

◆ vertexProbability()

double V0Tools::vertexProbability ( const xAOD::Vertex * vxCandidate) const

Probability of the vertex fit.

Definition at line 456 of file V0Tools.cxx.

457 {
458 float dof = ndof(vxCandidate);
459 if (dof > 0.) {
460 Genfun::CumulativeChiSquare myCumulativeChiSquare(dof);
461 float chi = chisq(vxCandidate);
462 if (chi > 0.) {
463 double chi2prob = 1.-myCumulativeChiSquare(chi);
464 return chi2prob;
465 } else {
466 ATH_MSG_DEBUG("chi <= 0");
467 return -1.;
468 }
469 } else {
470 ATH_MSG_DEBUG("dof <= 0");
471 return -1.;
472 }
473
474 }
static float ndof(const xAOD::Vertex *vxCandidate)
NDoF of the vertex fit.
Definition V0Tools.cxx:446
static float chisq(const xAOD::Vertex *vxCandidate)
Chisq of the vertex fit.
Definition V0Tools.cxx:451

◆ vtx()

Amg::Vector3D V0Tools::vtx ( const xAOD::Vertex * vxCandidate)
static

vertex position

Definition at line 476 of file V0Tools.cxx.

477 {
478 return vxCandidate->position();
479 }

Member Data Documentation

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: