1 #ifndef KinematicConstrainedVertexFitterT_H
2 #define KinematicConstrainedVertexFitterT_H
24 template <
int nTrk,
int nConstra
int>
95 template <
int nTrk,
int nConstra
int>
107 template <
int nTrk,
int nConstra
int>
120 template <
int nTrk,
int nConstra
int>
128 template <
int nTrk,
int nConstra
int>
131 theMaxStep = pSet.
getParameter<
int>(
"maxNbrOfIterations");
132 theMaxReducedChiSq = pSet.
getParameter<
double>(
"maxReducedChiSq");
133 theMinChiSqImprovement = pSet.
getParameter<
double>(
"minChiSqImprovement");
136 template <
int nTrk,
int nConstra
int>
140 theMaxReducedChiSq = 225.;
141 theMinChiSqImprovement = 50.;
144 template <
int nTrk,
int nConstra
int>
146 const std::vector<RefCountedKinematicParticle>&
part,
149 assert(nConstraint == 0 ||
cs !=
nullptr);
150 if (
part.size() != nTrk)
151 throw VertexException(
"KinematicConstrainedVertexFitterT::input states are not nTrk");
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;
163 ROOT::Math::SVector<double, 3 + 7 * nTrk> inPar;
164 ROOT::Math::SVector<double, 3 + 7 * nTrk> finPar;
166 ROOT::Math::SMatrix<double, 3 + 7 * nTrk, 3 + 7 * nTrk, ROOT::Math::MatRepSym<double, 3 + 7 * nTrk> > inCov;
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);
175 LogDebug(
"KinematicConstrainedVertexFitter") <<
"State is invalid at point: " << linPoint << std::endl;
190 inPar(0) = linPoint.
x();
191 inPar(1) = linPoint.
y();
192 inPar(2) = linPoint.
z();
202 ROOT::Math::SMatrix<double, 3 + 7 * nTrk, 3 + 7 * nTrk, ROOT::Math::MatRepSym<double, 3 + 7 * nTrk> > refCCov =
203 ROOT::Math::SMatrixNoInit();
206 bool convergence =
false;
213 std::vector<KinematicState> oldStates = lStates;
215 rVtx =
updator->update(inPar, refCCov, lStates, lPoint, mf,
cs);
216 if (
particles.size() != lStates.size() || rVtx ==
nullptr) {
217 LogDebug(
"KinematicConstrainedVertexFitter") <<
"updator failure\n";
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";
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);
243 for (std::vector<KinematicState>::const_iterator itold = oldStates.begin(), itnew = lStates.begin();
244 itnew != lStates.end();
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);
257 convergence =
maxDelta < theMaxDelta || (nit == theMaxStep &&
maxDelta < 4.0 * theMaxDelta);
259 }
while (nit < theMaxStep && !convergence);
271 return tBuilder->buildTree<nTrk>(
particles, lStates, rVtx, refCCov);
274 template <
int nTrk,
int nConstra
int>
279 template <
int nTrk,
int nConstra
int>