12 #include <trackbase_historic/SvtxVertex.h>
13 #include <trackbase_historic/SvtxVertexMap.h>
14 #include <trackbase_historic/SvtxVertexMap_v1.h>
15 #include <trackbase_historic/SvtxVertex_v1.h>
20 #include <trackbase_historic/SvtxVertex.h>
21 #include <trackbase_historic/SvtxVertexMap.h>
23 #include <ActsExamples/Plugins/BField/BFieldOptions.hpp>
24 #include <ActsExamples/Plugins/BField/ScalableBField.hpp>
29 #include <Acts/MagneticField/SharedBField.hpp>
33 #include <Acts/Utilities/Definitions.hpp>
44 , m_actsFitResults(nullptr)
45 , m_tGeometry(nullptr)
52 std::cout <<
"PHActsVertexFitter::Init" << std::endl;
60 std::cout <<
"PHActsVertexFitter::End " << std::endl;
87 std::cout <<
"Beginning PHActsVertexFitter::process_event number "
95 for (
const auto &[vertexId, trackVec] : vertexTrackMap)
106 std::cout <<
"Finished PHActsVertexFitter::process_event"
118 std::cout <<
"Updating SvtxVertex id " << vertexId << std::endl;
124 for (
int i = 0;
i < 3; ++
i)
126 for (
int j = 0;
j < 3; ++
j)
128 svtxVertex->set_error(
i,
j,
133 const auto &[chi2, ndf] = vertex.
fitQuality();
134 svtxVertex->set_ndof(ndf);
135 svtxVertex->set_chisq(chi2);
136 svtxVertex->set_t0(vertex.
time());
142 #if __cplusplus < 201402L
143 auto svtxVertex = boost::make_unique<SvtxVertex_v1>();
145 auto svtxVertex = std::make_unique<SvtxVertex_v1>();
150 std::cout <<
"Creating vertex for id " << vertexId
158 for (
int i = 0;
i < 3; ++
i)
160 for (
int j = 0;
j < 3; ++
j)
162 svtxVertex->set_error(
i,
j,
167 const auto &[chi2, ndf] = vertex.
fitQuality();
168 svtxVertex->set_ndof(ndf);
169 svtxVertex->set_chisq(chi2);
170 svtxVertex->set_t0(vertex.
time());
171 svtxVertex->set_id(vertexId);
180 return std::visit([tracks, logLevel,
this](
auto &inputField) {
182 using InputMagneticField =
183 typename std::decay_t<decltype(inputField)>::element_type;
184 using MagneticField = Acts::SharedBField<InputMagneticField>;
199 auto propagator = std::make_shared<Propagator>(
Stepper(bField));
202 Acts::LoggerWrapper(*
logger));
205 VertexFitter fitter(vertexFitterCfg);
216 auto fitRes = fitter.fit(tracks, linearizer,
223 fittedVertex = *fitRes;
226 std::cout <<
"Fitted vertex position "
239 std::cout <<
"Acts vertex fit error: "
240 << fitRes.error().message()
256 const unsigned int vertexId = track->get_vertex_id();
258 auto trackVecPos = trackPtrs.find(vertexId);
260 if (trackVecPos == trackPtrs.end())
264 trackVec.push_back(trackParam);
265 auto pair = std::make_pair(vertexId, trackVec);
266 trackPtrs.insert(pair);
270 trackVecPos->second.push_back(trackParam);
276 for (
const auto &[vertexId, trackVec] : trackPtrs)
278 std::cout <<
"Fitting vertexId : " << vertexId
279 <<
" with the following number of tracks "
283 for (
const auto param : trackVec)
285 std::cout <<
"Track position: ("
299 const Acts::Vector4D trackPos(
305 const Acts::Vector3D trackMom(track->
get_px(),
310 const double p = track->
get_p();
311 Acts::BoundSymMatrix
cov;
313 for (
int i = 0;
i < 6; ++
i)
315 for (
int j = 0;
j < 6; ++
j)
321 auto perigee = Acts::Surface::makeShared<Acts::PerigeeSurface>(
328 trackPos, trackMom,
p, trackQ,
cov);
335 m_actsFitResults = findNode::getClass<std::map<const unsigned int, Trajectory>>(topNode,
"ActsFitResults");
338 std::cout <<
PHWHERE <<
"Acts Trajectories not found on node tree, exiting."
343 m_trackMap = findNode::getClass<SvtxTrackMap>(topNode,
347 std::cout <<
PHWHERE <<
"No SvtxTrackMap on node tree. Bailing."
352 m_vertexMap = findNode::getClass<SvtxVertexMap>(topNode,
356 std::cout <<
PHWHERE <<
"No SvtxVertexMap on node tree, bailing"
361 m_tGeometry = findNode::getClass<ActsTrackingGeometry>(topNode,
"ActsTrackingGeometry");
364 std::cout <<
PHWHERE <<
"ActsTrackingGeometry not on node tree. Exiting"
380 std::cerr <<
"DST node is missing, quitting" << std::endl;
381 throw std::runtime_error(
"Failed to find DST node in PHActsTracks::createNodes");
394 findNode::getClass<SvtxVertexMap>(topNode,
"SvtxVertexMapActs");
400 "SvtxVertexMapActs",
"PHObject");