Belle II Software  release-05-01-25
JacobianMatrixUtil.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2016 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Oliver Frost *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <tracking/trackFindingCDC/numerics/JacobianMatrix.h>
13 #include <tracking/trackFindingCDC/numerics/ParameterVector.h>
14 
15 #include <tracking/trackFindingCDC/geometry/Vector2D.h>
16 
17 #include <tracking/trackFindingCDC/numerics/EigenView.h>
18 
19 #include <Eigen/Core>
20 
21 namespace Belle2 {
26  namespace TrackFindingCDC {
27 
29  struct JacobianMatrixUtil {
30 
32  template <unsigned int M, unsigned int N = M>
33  static JacobianMatrix<M, N> zero()
34  {
36  }
37 
39  template <int M, int N = M>
41  {
43  }
44 
46  template <int N>
47  static JacobianMatrix<N, N> passiveRotation(int i, int j, double phi)
48  {
49  return passiveRotation<N>(i, j, Vector2D::Phi(phi));
50  }
51 
53  template <int N>
54  static JacobianMatrix<N, N> passiveRotation(int i, int j, const Vector2D& phiVec)
55  {
56  assert(i < N);
57  assert(j < N);
58  JacobianMatrix<N, N> result = identity<N>();
59  result(i, i) = phiVec.x();
60  result(i, j) = phiVec.y();
61  result(j, i) = -phiVec.y();
62  result(j, j) = phiVec.x();
63  return result;
64  }
65 
67  template <int N>
68  static JacobianMatrix<N> scale(const ParameterVector<N>& scales)
69  {
70  JacobianMatrix<N> result = zero<N>();
71  mapToEigen(result).diagonal() = mapToEigen(scales);
72  return result;
73  }
74 
77  template <int M1, int N1, int M2, int N2>
78  static JacobianMatrix < M1 + M2, N1 + N2 > stackBlocks(const JacobianMatrix<M1, N1>& block1,
79  const JacobianMatrix<M2, N2>& block2)
80  {
81  JacobianMatrix < M1 + M2, N1 + N2 > result;
82  mapToEigen(result) << mapToEigen(block1), Eigen::Matrix<double, M1, N2>::Zero(),
83  Eigen::Matrix<double, M2, N1>::Zero(), mapToEigen(block2);
84  return result;
85  }
86  };
87 
88  }
90 }
Belle2::TrackFindingCDC::JacobianMatrixUtil::scale
static JacobianMatrix< N > scale(const ParameterVector< N > &scales)
Calculates the jacobian matrix for a scaling in each parameter.
Definition: JacobianMatrixUtil.h:76
Belle2::TrackFindingCDC::Vector2D
A two dimensional vector which is equipped with functions for correct handeling of orientation relat...
Definition: Vector2D.h:37
Belle2::TrackFindingCDC::PlainMatrix::Zero
static PlainMatrix< T, M, N > Zero()
Construct a matrix initialized with zeros.
Definition: PlainMatrix.h:77
Belle2::TrackFindingCDC::Vector2D::y
double y() const
Getter for the y coordinate.
Definition: Vector2D.h:619
Belle2::TrackFindingCDC::JacobianMatrixUtil::zero
static JacobianMatrix< M, N > zero()
Construct a zero matrix.
Definition: JacobianMatrixUtil.h:41
Belle2::TrackFindingCDC::JacobianMatrixUtil::passiveRotation
static JacobianMatrix< N, N > passiveRotation(int i, int j, double phi)
Construct a passive rotation matrix around coordinates i and j.
Definition: JacobianMatrixUtil.h:55
Belle2::TrackFindingCDC::Vector2D::Phi
static Vector2D Phi(const double phi)
Constucts a unit vector with azimuth angle equal to phi.
Definition: Vector2D.h:73
Belle2::TrackFindingCDC::JacobianMatrixUtil::stackBlocks
static JacobianMatrix< M1+M2, N1+N2 > stackBlocks(const JacobianMatrix< M1, N1 > &block1, const JacobianMatrix< M2, N2 > &block2)
Combines two jacobian matrices by putting them in two blocks diagonal to each other in a larger matri...
Definition: JacobianMatrixUtil.h:86
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::Vector2D::x
double x() const
Getter for the x coordinate.
Definition: Vector2D.h:609
Belle2::TrackFindingCDC::PlainMatrix
A matrix implementation to be used as an interface typ through out the track finder.
Definition: PlainMatrix.h:50
Belle2::TrackFindingCDC::PlainMatrix::Identity
static PlainMatrix< T, M, N > Identity()
Construct an identity matrix.
Definition: PlainMatrix.h:84
Belle2::TrackFindingCDC::JacobianMatrixUtil::identity
static JacobianMatrix< M, N > identity()
Construct a unit matrix.
Definition: JacobianMatrixUtil.h:48