CMS 3D CMS Logo

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

#include <KinematicConstrainedVertexFitterT.h>

Public Member Functions

RefCountedKinematicTree fit (const std::vector< RefCountedKinematicParticle > &part)
 
RefCountedKinematicTree fit (const std::vector< RefCountedKinematicParticle > &part, MultiTrackKinematicConstraintT< nTrk, nConstraint > *cs)
 
RefCountedKinematicTree fit (const std::vector< RefCountedKinematicParticle > &part, MultiTrackKinematicConstraintT< nTrk, nConstraint > *cs, GlobalPoint *pt)
 
float getCSum () const
 
int getNit () const
 
 KinematicConstrainedVertexFitterT (const MagneticField *ifield)
 
 KinematicConstrainedVertexFitterT (const MagneticField *ifield, const LinearizationPointFinder &fnd)
 
void setParameters (const edm::ParameterSet &pSet)
 
 ~KinematicConstrainedVertexFitterT ()
 

Private Member Functions

void defaultParameters ()
 

Private Attributes

float csum
 
const MagneticFieldfield
 
LinearizationPointFinderfinder
 
int iterations
 
ConstrainedTreeBuilderTtBuilder
 
float theMaxDelta
 
float theMaxReducedChiSq
 
int theMaxStep
 
float theMinChiSqImprovement
 
KinematicConstrainedVertexUpdatorT< nTrk, nConstraint > * updator
 
VertexKinematicConstraintTvCons
 

Detailed Description

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

Class fitting the veretx out of set of tracks via usual LMS with Lagrange multipliers. Additional constraints can be applyed to the tracks during the vertex fit (solves non-factorizabele cases). Since the vertex constraint is included by default, do not add a separate VertexKinematicConstraint! Example: Vertex fit with collinear tracks..

Definition at line 25 of file KinematicConstrainedVertexFitterT.h.

Constructor & Destructor Documentation

◆ KinematicConstrainedVertexFitterT() [1/2]

template<int nTrk, int nConstraint>
KinematicConstrainedVertexFitterT< nTrk, nConstraint >::KinematicConstrainedVertexFitterT ( const MagneticField ifield)
explicit

◆ KinematicConstrainedVertexFitterT() [2/2]

template<int nTrk, int nConstraint>
KinematicConstrainedVertexFitterT< nTrk, nConstraint >::KinematicConstrainedVertexFitterT ( const MagneticField ifield,
const LinearizationPointFinder fnd 
)

◆ ~KinematicConstrainedVertexFitterT()

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

Definition at line 121 of file KinematicConstrainedVertexFitterT.h.

121  {
122  delete finder;
123  delete vCons;
124  delete updator;
125  delete tBuilder;
126 }

References HLT_FULL_cff::finder, and HLT_FULL_cff::updator.

Member Function Documentation

◆ defaultParameters()

template<int nTrk, int nConstraint>
void KinematicConstrainedVertexFitterT< nTrk, nConstraint >::defaultParameters ( )
private

◆ fit() [1/3]

template<int nTrk, int nConstraint>
RefCountedKinematicTree KinematicConstrainedVertexFitterT< nTrk, nConstraint >::fit ( const std::vector< RefCountedKinematicParticle > &  part)
inline

Without additional constraint, this will perform a simple vertex fit using LMS with Lagrange multipliers method (by definition valid only if nConstraint=0)

Definition at line 50 of file KinematicConstrainedVertexFitterT.h.

50 { return fit(part, 0, 0); }

References KinematicConstrainedVertexFitterT< nTrk, nConstraint >::fit().

Referenced by KinematicConstrainedVertexFitterT< nTrk, nConstraint >::fit(), trackingPlots.Iteration::modules(), and ConversionVertexFinder::run().

◆ fit() [2/3]

template<int nTrk, int nConstraint>
RefCountedKinematicTree KinematicConstrainedVertexFitterT< nTrk, nConstraint >::fit ( const std::vector< RefCountedKinematicParticle > &  part,
MultiTrackKinematicConstraintT< nTrk, nConstraint > *  cs 
)
inline

LMS with Lagrange multipliers fit of vertex constraint and user-specified constraint.

Definition at line 55 of file KinematicConstrainedVertexFitterT.h.

56  {
57  return fit(part, cs, nullptr);
58  };

References fwrapper::cs, and KinematicConstrainedVertexFitterT< nTrk, nConstraint >::fit().

Referenced by trackingPlots.Iteration::modules().

◆ fit() [3/3]

template<int nTrk, int nConstraint>
RefCountedKinematicTree KinematicConstrainedVertexFitterT< nTrk, nConstraint >::fit ( const std::vector< RefCountedKinematicParticle > &  part,
MultiTrackKinematicConstraintT< nTrk, nConstraint > *  cs,
GlobalPoint pt 
)

LMS with Lagrange multipliers fit of vertex constraint, user-specified constraint and user-specified starting point.

Definition at line 145 of file KinematicConstrainedVertexFitterT.h.

148  {
149  assert(nConstraint == 0 || cs != nullptr);
150  if (part.size() != nTrk)
151  throw VertexException("KinematicConstrainedVertexFitterT::input states are not nTrk");
152 
153  //sorting out the input particles
154  InputSort iSort;
155  std::pair<std::vector<RefCountedKinematicParticle>, std::vector<FreeTrajectoryState> > input = iSort.sort(part);
156  const std::vector<RefCountedKinematicParticle>& particles = input.first;
157  const std::vector<FreeTrajectoryState>& fStates = input.second;
158 
159  // linearization point:
160  GlobalPoint linPoint = (pt != nullptr) ? *pt : finder->getLinearizationPoint(fStates);
161 
162  //initial parameters:
163  ROOT::Math::SVector<double, 3 + 7 * nTrk> inPar; //3+ 7*ntracks
164  ROOT::Math::SVector<double, 3 + 7 * nTrk> finPar; //3+ 7*ntracks
165 
166  ROOT::Math::SMatrix<double, 3 + 7 * nTrk, 3 + 7 * nTrk, ROOT::Math::MatRepSym<double, 3 + 7 * nTrk> > inCov;
167 
168  //making initial vector of parameters and initial particle-related covariance
169  int nSt = 0;
170  std::vector<KinematicState> lStates(nTrk);
171  for (std::vector<RefCountedKinematicParticle>::const_iterator i = particles.begin(); i != particles.end(); i++) {
172  lStates[nSt] = (*i)->stateAtPoint(linPoint);
173  KinematicState const& state = lStates[nSt];
174  if (!state.isValid()) {
175  LogDebug("KinematicConstrainedVertexFitter") << "State is invalid at point: " << linPoint << std::endl;
177  }
178  inPar.Place_at(state.kinematicParameters().vector(), 3 + 7 * nSt);
179  inCov.Place_at(state.kinematicParametersError().matrix(), 3 + 7 * nSt, 3 + 7 * nSt);
180  ++nSt;
181  }
182 
183  //initial vertex error matrix components (huge error method)
184  //and vertex related initial vector components
185  double in_er = 100.;
186  inCov(0, 0) = in_er;
187  inCov(1, 1) = in_er;
188  inCov(2, 2) = in_er;
189 
190  inPar(0) = linPoint.x();
191  inPar(1) = linPoint.y();
192  inPar(2) = linPoint.z();
193 
194  //constraint equations value and number of iterations
195  double eq;
196  int nit = 0;
197  iterations = 0;
198  csum = 0.0;
199 
200  GlobalPoint lPoint = linPoint;
202  ROOT::Math::SMatrix<double, 3 + 7 * nTrk, 3 + 7 * nTrk, ROOT::Math::MatRepSym<double, 3 + 7 * nTrk> > refCCov =
203  ROOT::Math::SMatrixNoInit();
204 
205  double chisq = 1e6;
206  bool convergence = false;
207 
208  //iterarions over the updator: each time updated parameters
209  //are taken as new linearization point
210  do {
211  eq = 0.;
212  refCCov = inCov;
213  std::vector<KinematicState> oldStates = lStates;
214  GlobalVector mf = field->inInverseGeV(lPoint);
215  rVtx = updator->update(inPar, refCCov, lStates, lPoint, mf, cs);
216  if (particles.size() != lStates.size() || rVtx == nullptr) {
217  LogDebug("KinematicConstrainedVertexFitter") << "updator failure\n";
219  }
220 
221  double newchisq = rVtx->chiSquared();
222  if (nit > 2 && newchisq > theMaxReducedChiSq * rVtx->degreesOfFreedom() &&
223  (newchisq - chisq) > (-theMinChiSqImprovement)) {
224  LogDebug("KinematicConstrainedVertexFitter") << "bad chisq and insufficient improvement, bailing\n";
226  }
227  chisq = newchisq;
228 
229  const GlobalPoint& newPoint = rVtx->position();
230 
231  double maxDelta = 0.0;
232 
233  double deltapos[3];
234  deltapos[0] = newPoint.x() - lPoint.x();
235  deltapos[1] = newPoint.y() - lPoint.y();
236  deltapos[2] = newPoint.z() - lPoint.z();
237  for (int i = 0; i < 3; ++i) {
238  double delta = deltapos[i] * deltapos[i] / rVtx->error().matrix()(i, i);
239  if (delta > maxDelta)
240  maxDelta = delta;
241  }
242 
243  for (std::vector<KinematicState>::const_iterator itold = oldStates.begin(), itnew = lStates.begin();
244  itnew != lStates.end();
245  ++itold, ++itnew) {
246  for (int i = 0; i < 7; ++i) {
247  double deltapar = itnew->kinematicParameters()(i) - itold->kinematicParameters()(i);
248  double delta = deltapar * deltapar / itnew->kinematicParametersError().matrix()(i, i);
249  if (delta > maxDelta)
250  maxDelta = delta;
251  }
252  }
253 
254  lPoint = newPoint;
255 
256  nit++;
257  convergence = maxDelta < theMaxDelta || (nit == theMaxStep && maxDelta < 4.0 * theMaxDelta);
258 
259  } while (nit < theMaxStep && !convergence);
260 
261  if (!convergence) {
263  }
264 
265  // std::cout << "new full cov matrix" << std::endl;
266  // std::cout << refCCov << std::endl;
267 
268  iterations = nit;
269  csum = eq;
270 
271  return tBuilder->buildTree<nTrk>(particles, lStates, rVtx, refCCov);
272 }

References cms::cuda::assert(), fwrapper::cs, dumpMFGeometry_cfg::delta, HLT_FULL_cff::finder, mps_fire::i, input, LogDebug, allConversions_cfi::maxDelta, ecalTrigSettings_cff::particles, DiDispStaMuonMonitor_cfi::pt, InputSort::sort(), HLT_FULL_cff::updator, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by trackingPlots.Iteration::modules().

◆ getCSum()

template<int nTrk, int nConstraint>
float KinematicConstrainedVertexFitterT< nTrk, nConstraint >::getCSum ( ) const

Definition at line 280 of file KinematicConstrainedVertexFitterT.h.

280  {
281  return csum;
282 }

◆ getNit()

template<int nTrk, int nConstraint>
int KinematicConstrainedVertexFitterT< nTrk, nConstraint >::getNit ( ) const

Definition at line 275 of file KinematicConstrainedVertexFitterT.h.

275  {
276  return iterations;
277 }

Referenced by ConversionVertexFinder::run().

◆ setParameters()

template<int nTrk, int nConstraint>
void KinematicConstrainedVertexFitterT< nTrk, nConstraint >::setParameters ( const edm::ParameterSet pSet)

Configuration through PSet: number of iterations(maxDistance) and stopping condition (maxNbrOfIterations)

Definition at line 129 of file KinematicConstrainedVertexFitterT.h.

129  {
130  theMaxDelta = pSet.getParameter<double>("maxDelta");
131  theMaxStep = pSet.getParameter<int>("maxNbrOfIterations");
132  theMaxReducedChiSq = pSet.getParameter<double>("maxReducedChiSq");
133  theMinChiSqImprovement = pSet.getParameter<double>("minChiSqImprovement");
134 }

References edm::ParameterSet::getParameter().

Referenced by ConversionVertexFinder::run().

Member Data Documentation

◆ csum

template<int nTrk, int nConstraint>
float KinematicConstrainedVertexFitterT< nTrk, nConstraint >::csum
private

◆ field

template<int nTrk, int nConstraint>
const MagneticField* KinematicConstrainedVertexFitterT< nTrk, nConstraint >::field
private

Definition at line 75 of file KinematicConstrainedVertexFitterT.h.

◆ finder

template<int nTrk, int nConstraint>
LinearizationPointFinder* KinematicConstrainedVertexFitterT< nTrk, nConstraint >::finder
private

◆ iterations

template<int nTrk, int nConstraint>
int KinematicConstrainedVertexFitterT< nTrk, nConstraint >::iterations
private

◆ tBuilder

template<int nTrk, int nConstraint>
ConstrainedTreeBuilderT* KinematicConstrainedVertexFitterT< nTrk, nConstraint >::tBuilder
private

◆ theMaxDelta

template<int nTrk, int nConstraint>
float KinematicConstrainedVertexFitterT< nTrk, nConstraint >::theMaxDelta
private

Definition at line 81 of file KinematicConstrainedVertexFitterT.h.

◆ theMaxReducedChiSq

template<int nTrk, int nConstraint>
float KinematicConstrainedVertexFitterT< nTrk, nConstraint >::theMaxReducedChiSq
private

Definition at line 83 of file KinematicConstrainedVertexFitterT.h.

◆ theMaxStep

template<int nTrk, int nConstraint>
int KinematicConstrainedVertexFitterT< nTrk, nConstraint >::theMaxStep
private

Definition at line 82 of file KinematicConstrainedVertexFitterT.h.

◆ theMinChiSqImprovement

template<int nTrk, int nConstraint>
float KinematicConstrainedVertexFitterT< nTrk, nConstraint >::theMinChiSqImprovement
private

Definition at line 84 of file KinematicConstrainedVertexFitterT.h.

◆ updator

template<int nTrk, int nConstraint>
KinematicConstrainedVertexUpdatorT<nTrk, nConstraint>* KinematicConstrainedVertexFitterT< nTrk, nConstraint >::updator
private

◆ vCons

template<int nTrk, int nConstraint>
VertexKinematicConstraintT* KinematicConstrainedVertexFitterT< nTrk, nConstraint >::vCons
private
Vector3DBase
Definition: Vector3DBase.h:8
mps_fire.i
i
Definition: mps_fire.py:428
input
static const std::string input
Definition: EdmProvDump.cc:48
InputSort
Definition: InputSort.h:14
KinematicConstrainedVertexFitterT::theMaxReducedChiSq
float theMaxReducedChiSq
Definition: KinematicConstrainedVertexFitterT.h:83
VertexException
Common base class.
Definition: VertexException.h:12
KinematicConstrainedVertexFitterT::theMaxStep
int theMaxStep
Definition: KinematicConstrainedVertexFitterT.h:82
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
fwrapper::cs
unique_ptr< ClusterSequence > cs
Definition: fastjetfortran_madfks.cc:47
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
KinematicConstrainedVertexFitterT::csum
float csum
Definition: KinematicConstrainedVertexFitterT.h:87
KinematicState
Definition: KinematicState.h:17
KinematicConstrainedVertexFitterT::fit
RefCountedKinematicTree fit(const std::vector< RefCountedKinematicParticle > &part)
Definition: KinematicConstrainedVertexFitterT.h:50
KinematicTree
Definition: KinematicTree.h:36
cms::cuda::assert
assert(be >=bs)
ReferenceCountingPointer< KinematicTree >
KinematicConstrainedVertexFitterT::vCons
VertexKinematicConstraintT * vCons
Definition: KinematicConstrainedVertexFitterT.h:78
allConversions_cfi.maxDelta
maxDelta
Definition: allConversions_cfi.py:44
ecalTrigSettings_cff.particles
particles
Definition: ecalTrigSettings_cff.py:11
KinematicConstrainedVertexFitterT::defaultParameters
void defaultParameters()
Definition: KinematicConstrainedVertexFitterT.h:137
KinematicConstrainedVertexFitterT::finder
LinearizationPointFinder * finder
Definition: KinematicConstrainedVertexFitterT.h:76
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
part
part
Definition: HCALResponse.h:20
Point3DBase< float, GlobalTag >
MagneticField::inInverseGeV
GlobalVector inInverseGeV(const GlobalPoint &gp) const
Field value ad specified global point, in 1/Gev.
Definition: MagneticField.h:36
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
dumpMFGeometry_cfg.delta
delta
Definition: dumpMFGeometry_cfg.py:25
ConstrainedTreeBuilderT
Definition: ConstrainedTreeBuilderT.h:15
KinematicConstrainedVertexFitterT::updator
KinematicConstrainedVertexUpdatorT< nTrk, nConstraint > * updator
Definition: KinematicConstrainedVertexFitterT.h:77
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
KinematicConstrainedVertexFitterT::theMaxDelta
float theMaxDelta
Definition: KinematicConstrainedVertexFitterT.h:81
DefaultLinearizationPointFinder
Definition: DefaultLinearizationPointFinder.h:13
KinematicConstrainedVertexUpdatorT
Definition: KinematicConstrainedVertexUpdatorT.h:34
LinearizationPointFinder::clone
virtual LinearizationPointFinder * clone() const =0
ConstrainedTreeBuilderT::buildTree
RefCountedKinematicTree buildTree(const std::vector< RefCountedKinematicParticle > &initialParticles, const std::vector< KinematicState > &finalStates, const RefCountedKinematicVertex vtx, const ROOT::Math::SMatrix< double, 3+7 *nTrk, 3+7 *nTrk, ROOT::Math::MatRepSym< double, 3+7 *nTrk > > &fCov) const
Definition: ConstrainedTreeBuilderT.h:57
VertexKinematicConstraintT
Definition: VertexKinematicConstraintT.h:14
KinematicConstrainedVertexFitterT::tBuilder
ConstrainedTreeBuilderT * tBuilder
Definition: KinematicConstrainedVertexFitterT.h:79
InputSort::sort
std::pair< std::vector< RefCountedKinematicParticle >, std::vector< FreeTrajectoryState > > sort(const std::vector< RefCountedKinematicParticle > &particles) const
Definition: InputSort.cc:5
RunInfoPI::state
state
Definition: RunInfoPayloadInspectoHelper.h:16
KinematicConstrainedVertexFitterT::iterations
int iterations
Definition: KinematicConstrainedVertexFitterT.h:86
KinematicConstrainedVertexFitterT::theMinChiSqImprovement
float theMinChiSqImprovement
Definition: KinematicConstrainedVertexFitterT.h:84
LinearizationPointFinder::getLinearizationPoint
virtual GlobalPoint getLinearizationPoint(const std::vector< reco::TransientTrack > &) const =0
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
KinematicConstrainedVertexFitterT::field
const MagneticField * field
Definition: KinematicConstrainedVertexFitterT.h:75