44 cout <<
"======================= GlobalVertexReco::InitRun() =======================" << endl;
45 cout <<
"===========================================================================" << endl;
55 cout <<
"GlobalVertexReco::process_event -- entered" << endl;
61 GlobalVertexMap *globalmap = findNode::getClass<GlobalVertexMap>(topNode,
"GlobalVertexMap");
64 cout <<
PHWHERE <<
"::ERROR - cannot find GlobalVertexMap" << endl;
68 SvtxVertexMap *svtxmap = findNode::getClass<SvtxVertexMap>(topNode,
"SvtxVertexMap");
69 MbdVertexMap *mbdmap = findNode::getClass<MbdVertexMap>(topNode,
"MbdVertexMap");
70 SvtxTrackMap *trackmap = findNode::getClass<SvtxTrackMap>(topNode,
"SvtxTrackMap");
88 std::set<unsigned int> used_svtx_vtxids;
89 std::set<unsigned int> used_mbd_vtxids;
91 if (svtxmap && mbdmap)
95 cout <<
"GlobalVertexReco::process_event - svtxmap && mbdmap" << endl;
99 svtxiter != svtxmap->
end();
105 float min_sigma = FLT_MAX;
107 mbditer != mbdmap->end();
114 if (sigma < min_sigma)
121 if (min_sigma > 3.0 || !mbd_best)
132 used_svtx_vtxids.insert(svtx->
get_id());
133 used_mbd_vtxids.insert(mbd_best->
get_id());
136 globalmap->
insert(vertex);
144 auto track = trackmap->find(*iter)->second;
145 track->set_vertex_id(vertex->
get_id());
161 cout <<
"GlobalVertexReco::process_event - svtxmap " << endl;
165 svtxiter != svtxmap->
end();
170 if (used_svtx_vtxids.find(svtx->
get_id()) != used_svtx_vtxids.end())
174 if (isnan(svtx->
get_z()))
185 used_svtx_vtxids.insert(svtx->
get_id());
193 auto track = trackmap->find(*iter)->second;
194 track->set_vertex_id(vertex->
get_id());
197 globalmap->
insert(vertex);
211 cout <<
"GlobalVertexReco::process_event - mbdmap" << endl;
215 mbditer != mbdmap->end();
220 if (used_mbd_vtxids.find(mbd->
get_id()) != used_mbd_vtxids.end())
224 if (isnan(mbd->
get_z()))
233 used_mbd_vtxids.insert(mbd->
get_id());
235 globalmap->
insert(vertex);
247 for (
const auto &[tkey, track] : *trackmap)
250 auto trackvtxid = track->get_vertex_id();
251 if (globalmap->
find(trackvtxid) != globalmap->
end())
256 float maxdz = std::numeric_limits<float>::max();
257 unsigned int vtxid = std::numeric_limits<unsigned int>::max();
259 for (
const auto &[vkey,
vertex] : *globalmap)
261 float dz = track->get_z() -
vertex->get_z();
262 if (fabs(dz) < maxdz)
269 track->set_vertex_id(vtxid);
272 std::cout <<
"Associated track with z " << track->get_z() <<
" to GlobalVertex id " << track->get_vertex_id() << std::endl;
292 cout <<
PHWHERE <<
"DST Node missing, doing nothing." << endl;
305 GlobalVertexMap *vertexes = findNode::getClass<GlobalVertexMap>(topNode,
"GlobalVertexMap");
310 globalNode->
addNode(VertexMapNode);