48 return StatusCode::SUCCESS;
54 return StatusCode::SUCCESS;
60 m_Updator(
"Trk::KalmanVertexUpdator", this),
63 m_Smoother(
"Trk::DummyVertexSmoother",this),
64 m_LinTrkFactory(
"Trk::FullPerigeeLinearizedTrackFactory",this),
68 m_useLooseConvergence(false),
74 declareProperty(
"MaxIterations",
m_maxStep);
80 declareProperty(
"VertexUpdator",
m_Updator);
86 declareProperty(
"ID_maxR",
m_maxR);
87 declareProperty(
"ID_maxZ",
m_maxZ);
99 const std::vector<const Trk::NeutralParameters*> & neutralPerigeeList,
107 xAOD::Vertex * FittedVertex =
fit(perigeeList, neutralPerigeeList, constraint);
110 if(FittedVertex !=
nullptr )
116 for(
unsigned int i = 0;
i <perigeeList.size(); ++
i)
122 for(
unsigned int i = 0;
i <neutralPerigeeList.size(); ++
i) {
124 (FittedVertex->
vxTrackAtVertex())[perigeeList.size()+
i].setInitialPerigee(iPer);
136 const std::vector<const Trk::NeutralParameters*> & neutralPerigeeList)
const
142 return fit(perigeeList, neutralPerigeeList, start_point);
149 const std::vector<const Trk::NeutralParameters*> & neutralPerigeeList,
154 if(perigeeList.empty())
156 ATH_MSG_INFO(
"Empty vector of tracks passed, returning 0" );
163 const AmgSymMatrix(3)& initialVertexError = constraint.covariancePosition();
169 bool priorInfo=
false;
172 if(initialVertexError.trace() == 0.)
177 float diag = 1000000.0;
180 priorErrorMatrix = in_m * diag;
188 priorErrorMatrix = initialVertexError;
191 std::unique_ptr<xAOD::Vertex> returnVertex = std::make_unique<xAOD::Vertex>();
199 std::vector<Trk::VxTrackAtVertex> tracks_to_fit =
linearizeTracks(perigeeList, neutralPerigeeList, *returnVertex);
200 std::vector<Trk::VxTrackAtVertex> fittedTracks(0);
208 double previousChi2{};
209 unsigned int n_iter = 0;
215 auto deltaChi2 = [](
double chi1,
double chi0){
216 return std::abs((chi1-chi0)*2./(chi1+chi0+2.));
238 if (new_vertex != returnVertex.get()) {
239 returnVertex.reset( new_vertex );
244 previousPreviousPosition = previousPosition;
245 previousPosition = newPosition;
246 previousChi2 = newChi2;
247 newPosition = returnVertex->
position();
252 deltaR = (previousPosition - newPosition).
perp();
262 ATH_MSG_DEBUG(
" steps. Deltachi2: " << deltaChi2(newChi2, previousChi2) );
264 returnVertex.reset();
268 if(returnVertex !=
nullptr){
271 ATH_MSG_INFO(
"Sequential vertex fit fails:: zero pointer returned" );
275 return returnVertex.release();
281 const std::vector<const Trk::NeutralParameters*> & neutralPerigeeList,
286 std::vector<Trk::VxTrackAtVertex> out_tracks(0);
287 for(
const auto *
i : perigeeList)
293 if( loc_per !=
nullptr)
304 out_tracks.push_back(*vTrack);
309 ATH_MSG_WARNING(
"Cannot linearize tracks; treatment of neutrals not yet supported" );
314 for(
const auto *
i : neutralPerigeeList)
320 if( loc_per !=
nullptr)
330 out_tracks.push_back(*vTrack);
335 ATH_MSG_WARNING(
"Cannot linearize tracks; treatment of neutrals not yet supported" );
346 if ( linVertexPos.perp() >
m_maxR || std::abs(linVertexPos.z()) >
m_maxZ )
348 ATH_MSG_DEBUG(
" Linearization position outside ID. Setting back to (0,0,0) " );
354 std::vector<Trk::VxTrackAtVertex>& out_tracks = tracks;
372 return fit(vectorTrk, vectorNeut, constraint);
379 if(vectorTrk.empty())
385 if(vectorNeut.empty())
394 std::vector<const Trk::TrackParameters*> measuredPerigees;
395 std::vector<const xAOD::TrackParticle*> trkToFit;
397 for(std::vector<const xAOD::TrackParticle*>::const_iterator
i = vectorTrk.begin();
i!= vectorTrk.end();++
i)
400 bool foundDuplicate(
false);
401 for (std::vector<const xAOD::TrackParticle*>::const_iterator j = vectorTrk.begin(); j!=
i; ++j) {
403 ATH_MSG_WARNING(
"Duplicate track given as input to the fitter. Ignored." );
404 foundDuplicate =
true;
408 if (foundDuplicate)
continue;
412 if(tmpMeasPer!=
nullptr) {
413 trkToFit.push_back(*
i);
414 measuredPerigees.push_back(tmpMeasPer);
416 ATH_MSG_INFO(
"Failed to dynamic_cast this track parameters to perigee" );
421 std::vector<const Trk::NeutralParameters*> measuredNeutralPerigees;
422 std::vector<const xAOD::NeutralParticle*> neutToFit;
423 for(std::vector<const xAOD::NeutralParticle*>::const_iterator
i = vectorNeut.begin();
i!= vectorNeut.end();++
i)
426 bool foundDuplicate(
false);
427 for (std::vector<const xAOD::NeutralParticle*>::const_iterator j = vectorNeut.begin(); j!=
i; ++j) {
429 ATH_MSG_WARNING(
"Duplicate neutral given as input to the fitter. Ignored." );
430 foundDuplicate =
true;
434 if (foundDuplicate)
continue;
438 if(tmpMeasPer!=
nullptr) {
439 neutToFit.push_back(*
i);
440 measuredNeutralPerigees.push_back(tmpMeasPer);
442 ATH_MSG_INFO(
"Failed to dynamic_cast this neutral parameters to perigee" );
447 xAOD::Vertex* fittedVertex =
fit( measuredPerigees, measuredNeutralPerigees, constraint );
451 if(fittedVertex ==
nullptr)
460 for(
unsigned int i = 0;
i <trkToFit.size(); ++
i)
480 for(
unsigned int i = 0;
i <neutToFit.size(); ++
i)
495 ( fittedVertex->
vxTrackAtVertex() )[trkToFit.size()+
i].setOrigTrack(linkTT);
504 for (
unsigned int i = 0 ;
i < VTAVsize ; ++
i)
509 ATH_MSG_WARNING(
"Trying to set link to xAOD::TrackParticle. The VxTrackAtVertex is not found" );
527 if (!linkToXAODTPneutral) {
528 ATH_MSG_WARNING(
"Skipping track. Trying to set link to something else than xAOD::TrackParticle or xAOD::NeutralParticle." );