33 #pragma GCC diagnostic push
34 #pragma GCC diagnostic ignored "-Wstringop-overread"
36 #pragma GCC diagnostic pop
61 m_seedFinderCfg.seedFilter = std::make_unique<Acts::SeedFilter<SpacePoint>>(
74 m_topBinFinder = std::make_shared<const Acts::BinFinder<SpacePoint>>(
99 for (
auto iter = beginend.first; iter != beginend.second; ++iter)
112 _iteration_map = findNode::getClass<TrkrClusterIterationMapv1>(topNode,
"TrkrClusterIterationMap");
115 std::cerr <<
PHWHERE <<
"Cluster Iteration Map missing, aborting." << std::endl;
120 auto eventTimer = std::make_unique<PHTimer>(
"eventTimer");
122 eventTimer->restart();
125 std::cout <<
"Processing PHActsSiliconSeeding event "
128 std::vector<const SpacePoint*> spVec;
132 auto seederTime = eventTimer->get_accumulated_time();
133 eventTimer->restart();
138 auto circleFitTime = eventTimer->get_accumulated_time();
140 for (
auto sp : spVec)
147 std::cout <<
"Finished PHActsSiliconSeeding process_event"
152 std::cout <<
"PHActsSiliconSeeding Acts seed time "
153 << seederTime << std::endl;
154 std::cout <<
"PHActsSiliconSeeding circle fit time "
155 << circleFitTime << std::endl;
156 std::cout <<
"PHActsSiliconSeeding total event time "
157 << circleFitTime + seederTime << std::endl;
175 <<
" bad initial circle fits" << std::endl;
177 <<
" bad second circle fits" << std::endl;
190 -> std::pair<Acts::Vector3, Acts::Vector2>
196 return std::make_pair(
position, cov);
209 Acts::SpacePointGridCreator::createGrid<SpacePoint>(
m_gridCfg,
224 std::floor(rRangeSPExtent.min(
Acts::binR) / 2) * 2 + 1.5,
225 std::floor(rRangeSPExtent.max(
Acts::binR) / 2) * 2 - 1.5);
230 decltype(seedFinder)::SeedingState
state;
231 state.spacePointData.resize(spVec.size(),
232 m_seedFinderCfg.useDetailedDoubleMeasurementInfo);
233 for (
const auto [bottom, middle, top] : spGroup)
236 state, spGroup.grid(),
237 std::back_inserter(seeds),
244 seedVector.push_back(seeds);
252 int numGoodSeeds = 0;
255 for (
auto& seeds : seedVector)
258 for (
auto&
seed : seeds)
262 std::cout <<
"Seed " << numSeeds <<
" has "
263 <<
seed.sp().size() <<
" measurements "
269 std::vector<TrkrDefs::cluskey> cluster_keys;
271 std::vector<Acts::Vector3> globalPositions;
273 std::map<TrkrDefs::cluskey, Acts::Vector3>
positions;
274 auto trackSeed = std::make_unique<TrackSeed_v1>();
276 for (
auto& spacePoint :
seed.sp())
278 const auto&
cluskey = spacePoint->Id();
279 cluster_keys.push_back(
cluskey);
281 trackSeed->insert_cluster_key(
cluskey);
285 globalPositions.push_back(globalPosition);
287 positions.insert(std::make_pair(
cluskey, globalPosition));
290 std::cout <<
"Adding cluster with x,y "
291 << spacePoint->x() <<
", " << spacePoint->y()
292 <<
" mm in detector "
301 for (
auto& key : cluster_keys)
316 auto fitTimer = std::make_unique<PHTimer>(
"trackfitTimer");
320 trackSeed->circleFitByTaubin(positions, 0, 8);
326 std::cout <<
"Large PCA seed " << std::endl;
327 trackSeed->identify();
333 trackSeed->lineFit(positions, 0, 8);
334 z = trackSeed->get_Z0();
337 auto circlefittime = fitTimer->get_accumulated_time();
341 int mvtxsize = globalPositions.size();
342 auto additionalClusters =
findInttMatches(globalPositions, *trackSeed);
346 for (
int newkey = 0; newkey < additionalClusters.size(); newkey++)
348 trackSeed->insert_cluster_key(additionalClusters[newkey]);
349 positions.insert(std::make_pair(additionalClusters[newkey], globalPositions[mvtxsize + newkey]));
353 std::cout <<
"adding additional intt key " << additionalClusters[newkey] << std::endl;
358 auto addClusters = fitTimer->get_accumulated_time();
362 trackSeed->circleFitByTaubin(positions, 0, 8);
366 std::cout <<
"find intt clusters time " << addClusters << std::endl;
372 trackSeed->set_Z0(z);
377 std::cout <<
"seed phi, theta, eta : "
379 <<
", " << trackSeed->get_eta() << std::endl;
380 trackSeed->identify();
386 auto svtxtracktime = fitTimer->get_accumulated_time();
389 std::cout <<
"Intt fit time " << circlefittime <<
" and svtx time "
390 << svtxtracktime << std::endl;
402 std::cout <<
"Total number of seeds found in "
403 << seedVector.size() <<
" volume regions gives "
404 << numSeeds <<
" Acts seeds " << std::endl
405 << std::endl << std::endl;
421 std::vector<Acts::Vector3>&
clusters,
427 const float B = seed.
get_Z0();
437 for (
const auto& glob : clusters)
439 h_hits->Fill(glob(0), glob(1));
454 double xplus = std::get<0>(cci);
455 double yplus = std::get<1>(cci);
456 double xminus = std::get<2>(cci);
457 double yminus = std::get<3>(cci);
460 if (std::isnan(xplus))
464 std::cout <<
"Circle intersection calc failed, skipping"
467 <<
" and circ rad " << R <<
" with center " << X0
468 <<
", " << Y0 << std::endl;
475 const auto lastclusglob = clusters.at(clusters.size() - 1);
476 const double lastClusPhi = atan2(lastclusglob(1), lastclusglob(0));
477 const double plusPhi = atan2(yplus, xplus);
478 const double minusPhi = atan2(yminus, xminus);
480 if (fabs(lastClusPhi - plusPhi) < fabs(lastClusPhi - minusPhi))
482 xProj[
layer] = xplus;
483 yProj[
layer] = yplus;
487 xProj[
layer] = xminus;
488 yProj[
layer] = yminus;
502 std::cout <<
"Projected point is : " << xProj[
layer] <<
", "
503 << yProj[
layer] <<
", " << zProj[
layer] << std::endl;
511 std::vector<Acts::Vector3>&
clusters,
513 const double xProj[],
514 const double yProj[],
515 const double zProj[])
517 std::vector<TrkrDefs::cluskey> matchedClusters;
522 float minResidLay0 = std::numeric_limits<float>::max();
523 float minResidLay1 = std::numeric_limits<float>::max();
525 std::set<int> layersToSkip;
534 if(layer == 3 or layer == 4)
536 layersToSkip.insert(0);
537 layersToSkip.insert(1);
539 else if (layer == 5 or layer==6)
541 layersToSkip.insert(2);
542 layersToSkip.insert(3);
547 for (
int inttlayer = 0; inttlayer <
m_nInttLayers; inttlayer++)
551 if(layersToSkip.find(inttlayer) != layersToSkip.end())
556 const double projR = std::sqrt(
square(xProj[inttlayer]) +
square(yProj[inttlayer]));
557 const double projPhi = std::atan2(yProj[inttlayer], xProj[inttlayer]);
558 const double projRphi = projR * projPhi;
562 double ladderLocation[3] = {0., 0., 0.};
571 const double ladderphi = atan2(ladderLocation[1], ladderLocation[0]) + layerGeom->get_strip_phi_tilt();
572 const auto stripZSpacing = layerGeom->get_strip_z_spacing();
573 float dphi = ladderphi - projPhi;
578 else if (dphi < -1 * M_PI)
586 if (fabs(dphi) > 0.2)
591 TVector3 projectionLocal(0, 0, 0);
592 TVector3 projectionGlobal(xProj[inttlayer], yProj[inttlayer], zProj[inttlayer]);
594 projectionLocal = layerGeom->get_local_from_world_coords(
surf,
599 for (
auto clusIter = range.first; clusIter != range.second; ++clusIter)
601 const auto cluskey = clusIter->first;
610 const auto cluster = clusIter->second;
616 h_nInttProj->Fill(projectionLocal[1] - cluster->getLocalX(),
617 projectionLocal[2] - cluster->getLocalY());
618 h_hits->Fill(globalP(0), globalP(1));
622 h_resids->Fill(zProj[inttlayer] - cluster->getLocalY(),
623 projRphi - cluster->getLocalX());
628 float rphiresid = fabs(projectionLocal[1] - cluster->getLocalX());
629 float zresid = fabs(projectionLocal[2] - cluster->getLocalY());
631 zresid < stripZSpacing / 2.)
636 if (inttlayer < 2 && rphiresid < minResidLay0)
640 matchedGlobPosLay0 = globalPos;
641 minResidLay0 = rphiresid;
643 if (inttlayer > 1 && rphiresid < minResidLay1)
646 matchedGlobPosLay1 = globalPos;
647 minResidLay1 = rphiresid;
652 std::cout <<
"Matched INTT cluster with cluskey " <<
cluskey
653 <<
" and position " << globalPos.transpose()
655 <<
" with projections rphi "
656 << projRphi <<
" and inttclus rphi " << cluster->getLocalX()
657 <<
" and proj z " << zProj[inttlayer] <<
" and inttclus z "
658 << cluster->getLocalY() <<
" in layer " << inttlayer
660 <<
" in rphi and strip z spacing " << stripZSpacing
668 if (minResidLay0 < std::numeric_limits<float>::max())
670 matchedClusters.push_back(matchedClusterLay0);
671 clusters.push_back(matchedGlobPosLay0);
673 if (minResidLay1 < std::numeric_limits<float>::max())
675 matchedClusters.push_back(matchedClusterLay1);
676 clusters.push_back(matchedGlobPosLay1);
684 return matchedClusters;
703 float x = globalPos.x();
704 float y = globalPos.y();
705 float z = globalPos.z();
706 float r = std::sqrt(x * x + y * y);
721 auto scale = 2 / std::hypot(x, y);
742 std::cout <<
"Space point has "
743 << x <<
", " << y <<
", " << z <<
" with local coords "
744 << localPos.transpose()
745 <<
" with rphi/z variances " << localCov(0, 0)
746 <<
", " << localCov(1, 1) <<
" and rotated variances "
747 << var[0] <<
", " << var[1]
748 <<
" and cluster key "
749 << key <<
" and geo id "
750 << surf->geometryId() << std::endl;
757 std::vector<const SpacePoint*> spVec;
758 unsigned int numSiliconHits = 0;
759 unsigned int totNumSiliconHits = 0;
765 for(
const auto& det : dets)
770 for (
auto clusIter = range.first; clusIter != range.second; ++clusIter)
772 const auto cluskey = clusIter->first;
782 const auto cluster = clusIter->second;
792 rRangeSPExtent.
extend({sp->x(), sp->y(), sp->z()});
804 std::cout <<
"Total number of silicon hits : " << totNumSiliconHits << std::endl;
805 std::cout <<
"Seed finding with "
806 << numSiliconHits <<
" hits " << std::endl;
885 m_geomContainerIntt = findNode::getClass<PHG4CylinderGeomContainer>(topNode,
"CYLINDERGEOM_INTT");
888 std::cout <<
PHWHERE <<
"CYLINDERGEOM_INTT node not found on node tree"
893 m_tGeometry = findNode::getClass<ActsGeometry>(topNode,
"ActsGeometry");
896 std::cout <<
PHWHERE <<
"No ActsGeometry on node tree. Bailing."
902 m_clusterMap = findNode::getClass<TrkrClusterContainer>(topNode,
903 "TRKR_CLUSTER_TRUTH");
905 m_clusterMap = findNode::getClass<TrkrClusterContainer>(topNode,
910 std::cout <<
PHWHERE <<
"No cluster container on the node tree. Bailing."
925 std::cerr <<
"DST node is missing, quitting" << std::endl;
926 throw std::runtime_error(
"Failed to find DST node in PHActsSiliconSeeding::createNodes");
976 h_nInttProj =
new TH2F(
"nInttProj",
";l_{0}^{proj}-l_{0}^{clus} [cm]; l_{1}^{proj}-l_{1}^{clus} [cm]",
977 10000, -10, 10, 10000, -50, 50);
978 h_nMvtxHits =
new TH1I(
"nMvtxHits",
";N_{MVTX}", 6, 0, 6);
979 h_nInttHits =
new TH1I(
"nInttHits",
";N_{INTT}", 80, 0, 80);
980 h_nHits =
new TH2I(
"nHits",
";N_{MVTX};N_{INTT}", 10, 0, 10,
982 h_nActsSeeds =
new TH1I(
"nActsSeeds",
";N_{Seeds}", 400, 0, 400);
983 h_nSeeds =
new TH1I(
"nActsGoodSeeds",
";N_{Seeds}", 400, 0, 400);
984 h_nTotSeeds =
new TH1I(
"nTotSeeds",
";N_{Seeds}", 500, 0, 500);
985 h_nInputMeas =
new TH1I(
"nInputMeas",
";N_{Meas}", 2000, 0, 2000);
990 h_hits =
new TH2F(
"hits",
";x [cm]; y [cm]", 1000, -20, 20,
992 h_zhits =
new TH2F(
"zhits",
";z [cm]; r [cm]", 1000, -30, 30,
994 h_projHits =
new TH2F(
"projhits",
";x [cm]; y [cm]", 1000, -20, 20,
996 h_zprojHits =
new TH2F(
"zprojhits",
";z [cm]; r [cm]", 1000, -30, 30,
998 h_resids =
new TH2F(
"resids",
";z_{resid} [cm]; rphi_{resid} [cm]",
999 100, -1, 1, 100, -1, 1);
1004 double returnPhi =
phi;
1006 returnPhi += 2 * M_PI;
1026 std::cout <<
" --------------- SeedFilterConfig ------------------ " << std::endl;
1027 std::cout <<
"deltaInvHelixDiameter = "
1031 <<
"zOriginWeightFactor = "
1037 <<
"maxSeedsPerSpM = "
1041 <<
"seedWeightIncrement = "
1046 std::cout <<
" --------------- SeedFinderConfig ------------------ " << std::endl;
1066 <<
"deltaRMiddleMinSPRange = " <<
m_seedFinderCfg.deltaRMiddleMinSPRange
1068 <<
"deltaRMiddleMaxSPRange = " <<
m_seedFinderCfg.deltaRMiddleMaxSPRange
1111 std::cout <<
" --------------- SeedFinderOptions ------------------ " << std::endl;
1125 std::cout <<
" --------------- SpacePointGridConfig ------------------ " << std::endl;