86 unsigned int trackid = 0;
98 unsigned int tpcindex = trackSeed->get_tpc_seed_index();
106 auto svtxtrack = std::make_unique<SvtxTrack_v4>();
110 std::cout <<
"iterating track seed " << trackid << std::endl;
113 svtxtrack->set_id(trackid);
122 std::cout <<
"si seed id " << trackSeed->get_silicon_seed_index() << std::endl;
125 unsigned int seedindex = trackSeed->get_tpc_seed_index();
129 if (trackSeed->get_silicon_seed_index() == std::numeric_limits<unsigned int>::max())
132 svtxtrack->set_x(tpcseed->
get_x());
133 svtxtrack->set_y(tpcseed->
get_y());
134 svtxtrack->set_z(tpcseed->
get_z());
139 svtxtrack->set_x(siseed->
get_x());
140 svtxtrack->set_y(siseed->
get_y());
141 svtxtrack->set_z(siseed->
get_z());
143 svtxtrack->set_silicon_seed(siseed);
146 svtxtrack->set_charge(tpcseed->
get_qOverR() > 0 ? 1 : -1);
147 if (
m_fieldMap.find(
".root") != std::string::npos)
151 svtxtrack->set_pz(tpcseed->
get_pz());
157 svtxtrack->set_px(pt * std::cos(phi));
158 svtxtrack->set_py(pt * std::sin(phi));
159 svtxtrack->set_pz(pt * std::cosh(tpcseed->
get_eta()) * std::cos(tpcseed->
get_theta()));
164 unsigned int silseedindex = trackSeed->get_silicon_seed_index();
169 float tpcR = fabs(1. / tpcseed->
get_qOverR());
170 float tpcx = tpcseed->
get_X0();
171 float tpcy = tpcseed->
get_Y0();
172 float vertexradius = 80;
190 float intz = vertexradius * slope + tpcseed->
get_Z0();
194 std::vector<float> tpcparams{tpcR, tpcx, tpcy, tpcseed->
get_slope(),
199 auto tan = tangent.second;
200 auto pca = tangent.first;
202 svtxtrack->set_x(pca.x());
203 svtxtrack->set_y(pca.y());
206 if (
m_fieldMap.find(
".root") != std::string::npos)
208 p = tpcseed->
get_p();
218 svtxtrack->set_px(
charge < 0 ? tan.x() : tan.x() * -1);
219 svtxtrack->set_py(
charge < 0 ? tan.y() : tan.y() * -1);
220 svtxtrack->set_pz(cosmicslope > 0 ? fabs(tan.z()) : -1 * fabs(tan.z()));
221 svtxtrack->set_z(svtxtrack->get_pz() > 0 ? (slope < 0 ? intz : vertexradius * slope * -1 + tpcseed->
get_Z0()) : (slope > 0 ? intz : vertexradius * slope * -1 + tpcseed->
get_Z0()));
222 svtxtrack->set_charge(
charge);
224 if (silseed)
addKeys(svtxtrack, silseed);
226 svtxtrack->set_tpc_seed(tpcseed);
227 svtxtrack->set_silicon_seed(silseed);
229 svtxtrack->identify();
232 svtxtrack->set_tpc_seed(tpcseed);
239 svtxtrack->set_x(trackSeed->get_x());
240 svtxtrack->set_y(trackSeed->get_y());
241 svtxtrack->set_z(trackSeed->get_z());
242 svtxtrack->set_charge(trackSeed->get_qOverR() > 0 ? 1 : -1);
243 if (
m_fieldMap.find(
".root") != std::string::npos)
247 svtxtrack->set_pz(trackSeed->get_pz());
251 float pt = fabs(1. / trackSeed->get_qOverR()) * (0.3 / 100) * std::stod(
m_fieldMap);
254 svtxtrack->set_px(pt * std::cos(phi));
255 svtxtrack->set_py(pt * std::sin(phi));
256 svtxtrack->set_pz(pt * std::cosh(trackSeed->get_eta()) * std::cos(trackSeed->get_theta()));
260 double R = 1. / std::fabs(trackSeed->get_qOverR());
261 double X0 = trackSeed->get_X0();
262 double Y0 = trackSeed->get_Y0();
263 double Z0 = trackSeed->get_Z0();
264 double slope = trackSeed->get_slope();
265 std::vector<double> xy_error2;
266 std::vector<double> rz_error2;
267 std::vector<double> xy_residuals;
268 std::vector<double> rz_residuals;
269 std::vector<double> x_circle;
270 std::vector<double> y_circle;
271 std::vector<double> z_line;
272 for (
auto c_iter = trackSeed->begin_cluster_keys();
273 c_iter != trackSeed->end_cluster_keys();
281 double r = sqrt(x * x + y * y);
284 double xy_centerdist = sqrt(dx * dx + dy * dy);
286 xy_residuals.push_back(xy_centerdist - R);
288 rz_residuals.push_back(fabs(-slope * r + z - Z0) / sqrt(slope * slope + 1));
293 double phi = atan2(dy, dx);
294 x_circle.push_back(R * cos(phi) + X0);
295 y_circle.push_back(R * sin(phi) + Y0);
296 z_line.push_back(R * slope + Z0);
299 for (
unsigned int i = 0;
i < xy_residuals.size();
i++)
301 if (std::isnan(xy_error2[
i]))
305 if (std::isnan(rz_error2[i]))
310 chi2 += xy_residuals[
i] * xy_residuals[
i] / xy_error2[
i] + rz_residuals[
i] * rz_residuals[
i] / rz_error2[
i];
312 svtxtrack->set_chisq(chi2);
314 svtxtrack->set_ndf(2 * xy_residuals.size() - 5);
319 svtxtrack->set_silicon_seed(trackSeed);
320 svtxtrack->set_tpc_seed(
nullptr);
324 svtxtrack->set_tpc_seed(trackSeed);
325 svtxtrack->set_silicon_seed(
nullptr);
331 std::cout <<
"Inserting svtxtrack into map " << std::endl;
332 svtxtrack->identify();
368 m_trackMap = findNode::getClass<SvtxTrackMap>(topNode,
"SvtxTrackMap");
375 "PHCompositeNode",
"DST"));
378 std::cerr <<
PHWHERE <<
"DST Node missing, doing nothing." << std::endl;
393 std::cout <<
PHWHERE <<
"SVTX node added" << std::endl;
406 std::cout <<
PHWHERE <<
"Svtx/" << m_trackMapName <<
" node added" << std::endl;
419 m_tpcContainer = findNode::getClass<TrackSeedContainer>(topNode,
"TpcTrackSeedContainer");
422 std::cout <<
PHWHERE <<
"WARNING, TrackSeedTrackMapConverter may seg fault depending on what seeding algorithm this is run after" << std::endl;
425 m_siContainer = findNode::getClass<TrackSeedContainer>(topNode,
"SiliconTrackSeedContainer");
428 std::cout <<
PHWHERE <<
"WARNING, TrackSeedTrackMapConverter may seg fault depending on what seeding algorithm this is run after" << std::endl;
431 m_clusters = findNode::getClass<TrkrClusterContainer>(topNode,
"TRKR_CLUSTER");
434 std::cout <<
PHWHERE <<
" Can't find cluster container, can't continue."
439 m_tGeometry = findNode::getClass<ActsGeometry>(topNode,
"ActsGeometry");
442 std::cout <<
PHWHERE <<
" Can't find ActsGeometry, can't continue."
450 float vertexradius)
const
454 std::vector<Acts::Vector3> globpos;
463 globpos.push_back(glob);
465 if (r > largestR && glob.y() < 0)
467 globalMostOuter = glob;
472 float maxdr = std::numeric_limits<float>::max();
473 for (
auto& glob : globpos)
475 if (glob.y() > 0)
continue;
476 float dr = std::sqrt(
square(globalMostOuter.x()) +
square(globalMostOuter.y())) - std::sqrt(
square(glob.x()) +
square(glob.y()));
477 if (dr < maxdr && dr > 10)
480 globalSecondMostOuter = glob;
485 globalMostOuter -= vertex;
486 globalSecondMostOuter -= vertex;
488 const auto firstphi = atan2(globalMostOuter.y(), globalMostOuter.x());
489 const auto secondphi = atan2(globalSecondMostOuter.y(),
490 globalSecondMostOuter.x());
491 auto dphi = secondphi - firstphi;
492 if (dphi > M_PI) dphi = 2. * M_PI -
dphi;
493 if (dphi < -M_PI) dphi = 2. * M_PI +
dphi;
495 float r1 = std::sqrt(
square(globalMostOuter.x()) +
square(globalMostOuter.y()));
496 float r2 = std::sqrt(
square(globalSecondMostOuter.x()) +
square(globalSecondMostOuter.y()));
497 float z1 = globalMostOuter.z();
498 float z2 = globalSecondMostOuter.z();
500 float slope = (r2 -
r1) / (z2 - z1);
508 return std::make_pair(charge, slope);