20 #include <phgenfit/Fitter.h>
22 #include <phfield/PHFieldUtility.h>
24 #include <phgeom/PHGeomUtility.h>
38 #include <GenFit/FitStatus.h>
39 #include <GenFit/GFRaveTrackParameters.h>
40 #include <GenFit/GFRaveVertex.h>
41 #include <GenFit/GFRaveVertexFactory.h>
42 #include <GenFit/KalmanFittedStateOnPlane.h>
43 #include <GenFit/KalmanFitterInfo.h>
44 #include <GenFit/MeasuredStateOnPlane.h>
45 #include <GenFit/RKTrackRep.h>
47 #include <GenFit/TrackPoint.h>
49 #include <TMatrixDSymfwd.h>
50 #include <TMatrixTSym.h>
51 #include <TMatrixTUtils.h>
62 namespace genfit {
class AbsTrackRep; }
64 #define LogDebug(exp) std::cout << "DEBUG: " << __FILE__ << ": " << __LINE__ << ": " << exp << std::endl
65 #define LogError(exp) std::cout << "ERROR: " << __FILE__ << ": " << __LINE__ << ": " << exp << std::endl
66 #define LogWarning(exp) std::cout << "WARNING: " << __FILE__ << ": " << __LINE__ << ": " << exp << std::endl
77 , _over_write_svtxvertexmap(
false)
78 , _svtxvertexmaprefit_node_name(
"SvtxVertexMapRefit")
80 , _primary_pid_guess(211)
82 , _vertex_finder(nullptr)
83 , _vertexing_method(
"avf-smoothing:1")
86 , _vertexmap_refit(nullptr)
87 , _t_translate(nullptr)
116 "RKTrackRep",
false);
154 std::cout <<
PHWHERE <<
"Events processed: " <<
_event << std::endl;
160 vector<genfit::Track*> gf_tracks;
175 unsigned int nmvtx = 0;
185 if(
Verbosity() > 1) std::cout <<
" track " << iter->first <<
" has nmvtx at least " << nmvtx << std::endl;
192 gf_track_map.insert({genfit_track, iter->first});
193 gf_tracks.push_back(const_cast<genfit::Track*>(genfit_track));
198 vector<genfit::GFRaveVertex*> rave_vertices;
199 if (gf_tracks.size() >= 2)
208 std::cout <<
PHWHERE <<
"GFRaveVertexFactory::findVertices failed!";
214 for (
auto iter : gf_track_map)
delete iter.first;
220 std::cout <<
"=============== Timers: ===============" << std::endl;
221 std::cout <<
"Event: " <<
_event << std::endl;
224 std::cout <<
"=======================================" << std::endl;
253 "PHCompositeNode",
"DST"));
256 cerr <<
PHWHERE <<
"DST Node missing, doing nothing." << endl;
263 "PHCompositeNode",
"SVTX"));
269 cout <<
"SVTX node added" << endl;
277 tb_node->
addNode(vertexes_node);
279 cout <<
"Svtx/SvtxVertexMapRefit node added" << endl;
281 else if (!findNode::getClass<SvtxVertexMap>(topNode,
"SvtxVertexMap"))
286 tb_node->
addNode(vertexes_node);
288 cout <<
"Svtx/SvtxVertexMap node added" << endl;
302 _trackmap = findNode::getClass<SvtxTrackMap>(topNode,
"SvtxTrackMap");
305 cout <<
PHWHERE <<
" SvtxTrackMap node not found on node tree"
311 _vertexmap = findNode::getClass<SvtxVertexMap>(topNode,
"SvtxVertexMap");
314 cout <<
PHWHERE <<
" SvtxVertexrMap node not found on node tree"
326 cout <<
PHWHERE <<
" SvtxVertexMapRefit node not found on node tree"
339 const std::vector<genfit::GFRaveVertex*>& rave_vertices,
350 for (genfit::GFRaveVertex* rave_vtx : rave_vertices)
360 svtx_vtx->set_chisq(rave_vtx->getChi2());
361 svtx_vtx->set_ndof(rave_vtx->getNdf());
362 svtx_vtx->set_position(0, rave_vtx->getPos().X());
363 svtx_vtx->set_position(1, rave_vtx->getPos().Y());
364 svtx_vtx->set_position(2, rave_vtx->getPos().Z());
366 for (
int i = 0; i < 3; i++)
367 for (
int j = 0; j < 3; j++)
368 svtx_vtx->set_error(i, j, rave_vtx->getCov()[i][j]);
370 for (
unsigned int i = 0; i < rave_vtx->getNTracks(); i++)
373 const genfit::Track* rave_track =
374 rave_vtx->getParameters(i)->getTrack();
379 auto iter = gf_track_map.find(rave_track);
380 if (iter != gf_track_map.end())
381 svtx_vtx->insert_track(iter->second);
408 cout << __LINE__ << endl;
409 svtx_vtx->identify();
427 LogDebug(
"TranslateSvtxToGenFitTrack no state in track!");
444 LogDebug(
"TranslateSvtxToGenFitTrack invalid state found on track!");
451 for (
int i = 0; i < 6; ++i)
453 for (
int j = 0; j < 6; ++j)
461 cout <<
"DEBUG" << __LINE__ << endl;
463 cout <<
"radius: " <<
pos.Perp() << endl;
464 cout <<
"DEBUG: " << __LINE__ << endl;
465 for (
int i = 0; i < 6; ++i)
467 for (
int j = 0; j < 6; ++j)
469 cout << svtx_state->
get_error(i, j) <<
"\t";
480 genfit::Track* genfit_track =
new genfit::Track(rep, TVector3(0, 0, 0), TVector3(0, 0, 0));
482 genfit::FitStatus*
fs =
new genfit::FitStatus();
485 fs->setNdf(svtx_track->
get_ndf());
486 fs->setIsFitted(
true);
487 fs->setIsFitConvergedFully(
true);
489 genfit_track->setFitStatus(fs, rep);
491 genfit::TrackPoint*
tp =
new genfit::TrackPoint(genfit_track);
493 genfit::KalmanFitterInfo* fi =
new genfit::KalmanFitterInfo(tp, rep);
494 tp->setFitterInfo(fi);
496 genfit::MeasuredStateOnPlane*
ms =
new genfit::MeasuredStateOnPlane(rep);
497 ms->setPosMomCov(
pos,
mom, cov);
500 cout <<
"DEBUG: " << __LINE__ << endl;
502 cout <<
"Orig: " << __LINE__ << endl;
504 cout <<
"Translate: " << __LINE__ << endl;
505 ms->get6DCov().Print();
508 genfit::KalmanFittedStateOnPlane* kfs =
new genfit::KalmanFittedStateOnPlane(*ms, 1., 1.);
511 fi->setForwardUpdate(kfs);
513 genfit_track->insertPoint(tp);
531 LogDebug(
"TranslateSvtxToGenFitTrack failed!");