CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
KinematicConstrainedVertexUpdatorT< nTrk, nConstraint > Class Template Reference

#include <KinematicConstrainedVertexUpdatorT.h>

Public Member Functions

 KinematicConstrainedVertexUpdatorT ()
 
RefCountedKinematicVertex update (const ROOT::Math::SVector< double, 3+7 *nTrk > &inState, ROOT::Math::SMatrix< double, 3+7 *nTrk, 3+7 *nTrk, ROOT::Math::MatRepSym< double, 3+7 *nTrk > > &inCov, std::vector< KinematicState > &lStates, const GlobalPoint &lPoint, GlobalVector const &fieldValue, MultiTrackKinematicConstraintT< nTrk, nConstraint > *cs)
 
 ~KinematicConstrainedVertexUpdatorT ()
 

Private Attributes

ROOT::Math::SVector< double, 3+7 *nTrk > delta_alpha
 
ROOT::Math::SVector< double, 3+7 *nTrk > finPar
 
ROOT::Math::SMatrix< double, nConstraint+4, 3+7 *nTrk > g
 
ROOT::Math::SVector< double, nConstraint+4 > lambda
 
ROOT::Math::SMatrix< double, 7, 7, ROOT::Math::MatRepSym< double, 7 > > nCovariance = ROOT::Math::SMatrixNoInit()
 
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > pCov = ROOT::Math::SMatrixNoInit()
 
ROOT::Math::SMatrix< double, nConstraint+4, nConstraint+4, ROOT::Math::MatRepSym< double, nConstraint+4 > > v_g_sym = ROOT::Math::SMatrixNoInit()
 
ROOT::Math::SVector< double, nConstraint+4 > val
 
VertexKinematicConstraintT vConstraint
 
KinematicVertexFactory vFactory
 

Detailed Description

template<int nTrk, int nConstraint>
class KinematicConstrainedVertexUpdatorT< nTrk, nConstraint >

Class caching the math part for KinematicConstrainedVertexFitter

Definition at line 34 of file KinematicConstrainedVertexUpdatorT.h.

Constructor & Destructor Documentation

◆ KinematicConstrainedVertexUpdatorT()

template<int nTrk, int nConstraint>
KinematicConstrainedVertexUpdatorT< nTrk, nConstraint >::KinematicConstrainedVertexUpdatorT ( )

Default constructor and destructor

Definition at line 76 of file KinematicConstrainedVertexUpdatorT.h.

76 {}

◆ ~KinematicConstrainedVertexUpdatorT()

template<int nTrk, int nConstraint>
KinematicConstrainedVertexUpdatorT< nTrk, nConstraint >::~KinematicConstrainedVertexUpdatorT ( )

Definition at line 79 of file KinematicConstrainedVertexUpdatorT.h.

79 {}

Member Function Documentation

◆ update()

template<int nTrk, int nConstraint>
RefCountedKinematicVertex KinematicConstrainedVertexUpdatorT< nTrk, nConstraint >::update ( const ROOT::Math::SVector< double, 3+7 *nTrk > &  inState,
ROOT::Math::SMatrix< double, 3+7 *nTrk, 3+7 *nTrk, ROOT::Math::MatRepSym< double, 3+7 *nTrk > > &  inCov,
std::vector< KinematicState > &  lStates,
const GlobalPoint lPoint,
GlobalVector const &  fieldValue,
MultiTrackKinematicConstraintT< nTrk, nConstraint > *  cs 
)

Method updating the states. Takes a vector of full parameters: (x,y,z,particle_1,...,particle_n), corresponding linearization point: vector of states and GlobalPoint, and constraint to be applied during the vertex fit. Returns refitted vector of 7n+3 parameters and corresponding covariance matrix, where n - number of tracks.

Definition at line 82 of file KinematicConstrainedVertexUpdatorT.h.

References cms::cuda::assert(), KineDebug3::count(), callgraph::cs, g, mps_fire::i, invertPosDefMatrix(), dqmiolumiharvest::j, LogDebug, copyEcalPFRecHitThresholds_cfg::prod, prod1Switch_cff::prod1, heppy_batch::val, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

88  {
90 
91  int vSize = lStates.size();
92 
93  assert(nConstraint == 0 || cs != nullptr);
94  assert(vSize == nConstraint);
95 
96  const MagneticField* field = lStates.front().magneticField();
97 
98  delta_alpha = inPar;
99  delta_alpha(0) -= lPoint.x();
100  delta_alpha(1) -= lPoint.y();
101  delta_alpha(2) -= lPoint.z();
102  int cst = 3;
103  for (std::vector<KinematicState>::const_iterator i = lStates.begin(); i != lStates.end(); i++)
104  for (int j = 0; j < 7; j++) {
105  delta_alpha(cst) -= i->kinematicParameters()(j);
106  cst++;
107  }
108 
109  // cout<<"delta_alpha"<<delta_alpha<<endl;
110  //resulting matrix of derivatives and vector of values.
111  //their size depends of number of tracks to analyze and number of
112  //additional constraints to apply
113 
114  if (nConstraint != 0) {
115  cs->init(lStates, lPoint, fieldValue);
116  val.Place_at(cs->value(), 0);
117  g.Place_at(cs->positionDerivative(), 0, 0);
118  g.Place_at(cs->parametersDerivative(), 0, 3);
119  }
120 
121  vConstraint.init(lStates, lPoint, fieldValue);
122  val.Place_at(vConstraint.value(), nConstraint);
123  g.Place_at(vConstraint.positionDerivative(), nConstraint, 0);
124  g.Place_at(vConstraint.parametersDerivative(), nConstraint, 3);
125 
126  //debug code
127  v_g_sym = ROOT::Math::Similarity(g, inCov);
128 
129  // bool ifl1 = v_g_sym.Invert();
130  bool ifl1 = invertPosDefMatrix(v_g_sym);
131  if (!ifl1) {
132  edm::LogWarning("KinematicConstrainedVertexUpdatorFailed") << "invert failed\n" << v_g_sym;
133  LogDebug("KinematicConstrainedVertexFitter3") << "Fit failed: unable to invert SYM gain matrix\n";
134  return RefCountedKinematicVertex();
135  }
136 
137  // delta alpha is now valid!
138  //full math case now!
139  val += g * delta_alpha;
140  lambda = v_g_sym * val;
141 
142  //final parameters
143  finPar = inPar - inCov * (ROOT::Math::Transpose(g) * lambda);
144 
145  //refitted covariance
146  ROOT::Math::SMatrix<double, 3 + 7 * nTrk, 3 + 7 * nTrk, ROOT::Math::MatRepSym<double, 3 + 7 * nTrk> > prod =
147  ROOT::Math::SimilarityT(g, v_g_sym);
148  ROOT::Math::SMatrix<double, 3 + 7 * nTrk, 3 + 7 * nTrk, ROOT::Math::MatRepSym<double, 3 + 7 * nTrk> > prod1;
149  ROOT::Math::AssignSym::Evaluate(prod1, inCov * prod * inCov);
150  // ROOT::Math::AssignSym::Evaluate(prod, prod1 * inCov);
151  inCov -= prod1;
152 
153  pCov = inCov.template Sub<ROOT::Math::SMatrix<double, 3, 3, ROOT::Math::MatRepSym<double, 3> > >(0, 0);
154 
155  // chi2
156  double chi = ROOT::Math::Dot(lambda, val); //??
157 
158  //this is ndf without significant prior
159  //vertex so -3 factor exists here
160  float ndf = 2 * vSize - 3;
161  ndf += nConstraint;
162 
163  //making resulting vertex
164  GlobalPoint vPos(finPar(0), finPar(1), finPar(2));
165  VertexState st(vPos, GlobalError(pCov));
166  RefCountedKinematicVertex rVtx = vFactory.vertex(st, chi, ndf);
167 
168  //making refitted states of Kinematic Particles
169  AlgebraicVector7 newPar;
170  int i_int = 0;
171  for (std::vector<KinematicState>::iterator i_st = lStates.begin(); i_st != lStates.end(); i_st++) {
172  for (int i = 0; i < 7; i++) {
173  newPar(i) = finPar(3 + i_int * 7 + i);
174  }
175 
176  nCovariance = inCov.template Sub<ROOT::Math::SMatrix<double, 7, 7, ROOT::Math::MatRepSym<double, 7> > >(
177  3 + i_int * 7, 3 + i_int * 7);
178  TrackCharge chl = i_st->particleCharge();
179  KinematicParameters nrPar(newPar);
181  KinematicState newState(nrPar, nrEr, chl, field);
182  (*i_st) = newState;
183  i_int++;
184  }
185  return rVtx;
186 }
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > pCov
void init(const std::vector< KinematicState > &states, const GlobalPoint &point, const GlobalVector &mf) override
ROOT::Math::SMatrix< double, nConstraint+4, nConstraint+4, ROOT::Math::MatRepSym< double, nConstraint+4 > > v_g_sym
T z() const
Definition: PV3DBase.h:61
ROOT::Math::SVector< double, 7 > AlgebraicVector7
Definition: Matrices.h:8
GlobalErrorBase< double, ErrorMatrixTag > GlobalError
Definition: GlobalError.h:13
ROOT::Math::SVector< double, nConstraint+4 > val
assert(be >=bs)
positionDerivativeType const & positionDerivative() const
int TrackCharge
Definition: TrackCharge.h:4
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
parametersDerivativeType const & parametersDerivative() const
bool invertPosDefMatrix(ROOT::Math::SMatrix< T, N, N, ROOT::Math::MatRepSym< T, N > > &m)
ROOT::Math::SVector< double, 3+7 *nTrk > finPar
ROOT::Math::SMatrix< double, 7, 7, ROOT::Math::MatRepSym< double, 7 > > nCovariance
ReferenceCountingPointer< KinematicVertex > RefCountedKinematicVertex
ROOT::Math::SVector< double, nConstraint+4 > lambda
static RefCountedKinematicVertex vertex(const VertexState &state, float totalChiSq, float degreesOfFr)
Log< level::Warning, false > LogWarning
ROOT::Math::SMatrix< double, nConstraint+4, 3+7 *nTrk > g
#define LogDebug(id)
ROOT::Math::SVector< double, 3+7 *nTrk > delta_alpha

Member Data Documentation

◆ delta_alpha

template<int nTrk, int nConstraint>
ROOT::Math::SVector<double, 3 + 7 * nTrk> KinematicConstrainedVertexUpdatorT< nTrk, nConstraint >::delta_alpha
private

Definition at line 62 of file KinematicConstrainedVertexUpdatorT.h.

◆ finPar

template<int nTrk, int nConstraint>
ROOT::Math::SVector<double, 3 + 7 * nTrk> KinematicConstrainedVertexUpdatorT< nTrk, nConstraint >::finPar
private

Definition at line 65 of file KinematicConstrainedVertexUpdatorT.h.

◆ g

template<int nTrk, int nConstraint>
ROOT::Math::SMatrix<double, nConstraint + 4, 3 + 7 * nTrk> KinematicConstrainedVertexUpdatorT< nTrk, nConstraint >::g
private

Definition at line 63 of file KinematicConstrainedVertexUpdatorT.h.

◆ lambda

template<int nTrk, int nConstraint>
ROOT::Math::SVector<double, nConstraint + 4> KinematicConstrainedVertexUpdatorT< nTrk, nConstraint >::lambda
private

Definition at line 66 of file KinematicConstrainedVertexUpdatorT.h.

◆ nCovariance

template<int nTrk, int nConstraint>
ROOT::Math::SMatrix<double, 7, 7, ROOT::Math::MatRepSym<double, 7> > KinematicConstrainedVertexUpdatorT< nTrk, nConstraint >::nCovariance = ROOT::Math::SMatrixNoInit()
private

Definition at line 68 of file KinematicConstrainedVertexUpdatorT.h.

◆ pCov

template<int nTrk, int nConstraint>
ROOT::Math::SMatrix<double, 3, 3, ROOT::Math::MatRepSym<double, 3> > KinematicConstrainedVertexUpdatorT< nTrk, nConstraint >::pCov = ROOT::Math::SMatrixNoInit()
private

Definition at line 67 of file KinematicConstrainedVertexUpdatorT.h.

◆ v_g_sym

template<int nTrk, int nConstraint>
ROOT::Math::SMatrix<double, nConstraint + 4, nConstraint + 4, ROOT::Math::MatRepSym<double, nConstraint + 4> > KinematicConstrainedVertexUpdatorT< nTrk, nConstraint >::v_g_sym = ROOT::Math::SMatrixNoInit()
private

Definition at line 70 of file KinematicConstrainedVertexUpdatorT.h.

◆ val

template<int nTrk, int nConstraint>
ROOT::Math::SVector<double, nConstraint + 4> KinematicConstrainedVertexUpdatorT< nTrk, nConstraint >::val
private

Definition at line 64 of file KinematicConstrainedVertexUpdatorT.h.

◆ vConstraint

template<int nTrk, int nConstraint>
VertexKinematicConstraintT KinematicConstrainedVertexUpdatorT< nTrk, nConstraint >::vConstraint
private

Definition at line 61 of file KinematicConstrainedVertexUpdatorT.h.

◆ vFactory

template<int nTrk, int nConstraint>
KinematicVertexFactory KinematicConstrainedVertexUpdatorT< nTrk, nConstraint >::vFactory
private

Definition at line 60 of file KinematicConstrainedVertexUpdatorT.h.