Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHActsSiliconSeeding.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHActsSiliconSeeding.cc
1 #include "PHActsSiliconSeeding.h"
2 
6 
9 #include <phool/PHDataNode.h>
10 #include <phool/PHNode.h>
11 #include <phool/PHNodeIterator.h>
12 #include <phool/PHObject.h>
13 #include <phool/PHTimer.h>
14 #include <phool/getClass.h>
15 #include <phool/phool.h>
16 
17 #include <intt/CylinderGeomIntt.h>
18 
21 
22 #include <trackbase/InttDefs.h>
23 #include <trackbase/MvtxDefs.h>
24 #include <trackbase/TrkrCluster.h>
27 #include <trackbase/TrkrDefs.h>
32 
33 #pragma GCC diagnostic push
34 #pragma GCC diagnostic ignored "-Wstringop-overread"
36 #pragma GCC diagnostic pop
39 #include <Acts/Seeding/Seed.hpp>
41 
42 namespace
43 {
44  template <class T>
45  inline constexpr T square(const T& x)
46  {
47  return x * x;
48  }
49 } // namespace
50 
52  : SubsysReco(name)
53 {
54 }
55 
57 {
59  sfCfg = sfCfg.toInternalUnits();
60 
61  m_seedFinderCfg.seedFilter = std::make_unique<Acts::SeedFilter<SpacePoint>>(
63 
66 
67  if (Verbosity() > 5)
68  {
69  printSeedConfigs(sfCfg);
70  }
71  // vector containing the map of z bins in the top and bottom layers
72  m_bottomBinFinder = std::make_shared<const Acts::BinFinder<SpacePoint>>(
74  m_topBinFinder = std::make_shared<const Acts::BinFinder<SpacePoint>>(
76 
77  if (m_seedAnalysis)
78  {
79  m_file = new TFile(std::string(Name() + ".root").c_str(), "recreate");
81  }
82 
84 }
86 {
87  if (getNodes(topNode) != Fun4AllReturnCodes::EVENT_OK)
88  {
90  }
91 
93  {
95  }
96 
97  auto beginend = m_geomContainerIntt->get_begin_end();
98  int i = 0;
99  for (auto iter = beginend.first; iter != beginend.second; ++iter)
100  {
101  m_nInttLayerRadii[i] = iter->second->get_radius();
102  i++;
103  }
104 
106 }
107 
109 {
110  if (m_nIteration > 0)
111  {
112  _iteration_map = findNode::getClass<TrkrClusterIterationMapv1>(topNode, "TrkrClusterIterationMap");
113  if (!_iteration_map)
114  {
115  std::cerr << PHWHERE << "Cluster Iteration Map missing, aborting." << std::endl;
117  }
118  }
119 
120  auto eventTimer = std::make_unique<PHTimer>("eventTimer");
121  eventTimer->stop();
122  eventTimer->restart();
123 
124  if (Verbosity() > 0)
125  std::cout << "Processing PHActsSiliconSeeding event "
126  << m_event << std::endl;
127 
128  std::vector<const SpacePoint*> spVec;
129  auto seedVector = runSeeder(spVec);
130 
131  eventTimer->stop();
132  auto seederTime = eventTimer->get_accumulated_time();
133  eventTimer->restart();
134 
135  makeSvtxTracks(seedVector);
136 
137  eventTimer->stop();
138  auto circleFitTime = eventTimer->get_accumulated_time();
139 
140  for (auto sp : spVec)
141  {
142  delete sp;
143  }
144  spVec.clear();
145 
146  if (Verbosity() > 0)
147  std::cout << "Finished PHActsSiliconSeeding process_event"
148  << std::endl;
149 
150  if (Verbosity() > 0)
151  {
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;
158  }
159 
160  m_event++;
161 
163 }
164 
166 {
167  if (m_seedAnalysis)
168  {
169  writeHistograms();
170  }
171 
172  if (Verbosity() > 1)
173  {
174  std::cout << "There were " << m_nBadInitialFits
175  << " bad initial circle fits" << std::endl;
176  std::cout << "There were " << m_nBadUpdates
177  << " bad second circle fits" << std::endl;
178  }
179 
181 }
182 
183 GridSeeds PHActsSiliconSeeding::runSeeder(std::vector<const SpacePoint*>& spVec)
184 {
186 
188  auto covConverter =
189  [=](const SpacePoint& sp, float zAlign, float rAlign, float sigmaError)
190  -> std::pair<Acts::Vector3, Acts::Vector2>
191  {
192  Acts::Vector3 position{sp.x(), sp.y(), sp.z()};
194  cov[0] = (sp.m_varianceR + rAlign * rAlign) * sigmaError;
195  cov[1] = (sp.m_varianceZ + zAlign * zAlign) * sigmaError;
196  return std::make_pair(position, cov);
197  };
198 
199  Acts::Extent rRangeSPExtent;
200 
201  spVec = getSiliconSpacePoints(rRangeSPExtent);
202 
203  if (m_seedAnalysis)
204  {
205  h_nInputMeas->Fill(spVec.size());
206  }
207 
208  auto grid =
209  Acts::SpacePointGridCreator::createGrid<SpacePoint>(m_gridCfg,
210  m_gridOptions);
211 
212  auto spGroup = Acts::BinnedSPGroup<SpacePoint>(spVec.begin(),
213  spVec.end(),
214  covConverter,
217  std::move(grid),
218  rRangeSPExtent,
221 
223  const Acts::Range1D<float> rMiddleSPRange(
224  std::floor(rRangeSPExtent.min(Acts::binR) / 2) * 2 + 1.5,
225  std::floor(rRangeSPExtent.max(Acts::binR) / 2) * 2 - 1.5);
226 
227  GridSeeds seedVector;
228  SeedContainer seeds;
229  seeds.clear();
230  decltype(seedFinder)::SeedingState state;
231  state.spacePointData.resize(spVec.size(),
232  m_seedFinderCfg.useDetailedDoubleMeasurementInfo);
233  for (const auto [bottom, middle, top] : spGroup)
234  {
236  state, spGroup.grid(),
237  std::back_inserter(seeds),
238  bottom,
239  middle,
240  top,
241  rMiddleSPRange);
242  }
243 
244  seedVector.push_back(seeds);
245 
246  return seedVector;
247 }
248 
250 {
251  int numSeeds = 0;
252  int numGoodSeeds = 0;
253 
255  for (auto& seeds : seedVector)
256  {
258  for (auto& seed : seeds)
259  {
260  if (Verbosity() > 1)
261  {
262  std::cout << "Seed " << numSeeds << " has "
263  << seed.sp().size() << " measurements "
264  << std::endl;
265  }
266 
267  numSeeds++;
268 
269  std::vector<TrkrDefs::cluskey> cluster_keys;
270 
271  std::vector<Acts::Vector3> globalPositions;
272 
273  std::map<TrkrDefs::cluskey, Acts::Vector3> positions;
274  auto trackSeed = std::make_unique<TrackSeed_v1>();
275 
276  for (auto& spacePoint : seed.sp())
277  {
278  const auto& cluskey = spacePoint->Id();
279  cluster_keys.push_back(cluskey);
280 
281  trackSeed->insert_cluster_key(cluskey);
282  auto globalPosition = m_tGeometry->getGlobalPosition(
283  cluskey,
285  globalPositions.push_back(globalPosition);
286 
287  positions.insert(std::make_pair(cluskey, globalPosition));
288  if (Verbosity() > 1)
289  {
290  std::cout << "Adding cluster with x,y "
291  << spacePoint->x() << ", " << spacePoint->y()
292  << " mm in detector "
293  << (unsigned int) TrkrDefs::getTrkrId(cluskey)
294  << " with cluskey " << cluskey
295  << std::endl;
296  }
297  }
298  if(m_searchInIntt)
299  {
300  int nintt = 0;
301  for (auto& key : cluster_keys)
302  {
304  {
305  nintt++;
306  }
307  }
309  if(nintt > 2)
310  {
311  continue;
312  }
313  }
314  double z = seed.z() / Acts::UnitConstants::cm;
315 
316  auto fitTimer = std::make_unique<PHTimer>("trackfitTimer");
317  fitTimer->stop();
318  fitTimer->restart();
319 
320  trackSeed->circleFitByTaubin(positions, 0, 8);
321  if (fabs(trackSeed->get_x()) > m_maxSeedPCA ||
322  fabs(trackSeed->get_y()) > m_maxSeedPCA)
323  {
324  if (Verbosity() > 1)
325  {
326  std::cout << "Large PCA seed " << std::endl;
327  trackSeed->identify();
328  }
330  continue;
331  }
332 
333  trackSeed->lineFit(positions, 0, 8);
334  z = trackSeed->get_Z0();
335 
336  fitTimer->stop();
337  auto circlefittime = fitTimer->get_accumulated_time();
338  fitTimer->restart();
339 
341  int mvtxsize = globalPositions.size();
342  auto additionalClusters = findInttMatches(globalPositions, *trackSeed);
343 
346  for (int newkey = 0; newkey < additionalClusters.size(); newkey++)
347  {
348  trackSeed->insert_cluster_key(additionalClusters[newkey]);
349  positions.insert(std::make_pair(additionalClusters[newkey], globalPositions[mvtxsize + newkey]));
350 
351  if (Verbosity() > 1)
352  {
353  std::cout << "adding additional intt key " << additionalClusters[newkey] << std::endl;
354  }
355  }
356 
357  fitTimer->stop();
358  auto addClusters = fitTimer->get_accumulated_time();
359  fitTimer->restart();
360 
362  trackSeed->circleFitByTaubin(positions, 0, 8);
363 
364  if (Verbosity() > 0)
365  {
366  std::cout << "find intt clusters time " << addClusters << std::endl;
367  }
368 
369  numGoodSeeds++;
370 
372  trackSeed->set_Z0(z);
373 
374  if (Verbosity() > 1)
375  {
376  std::cout << "Silicon seed id " << m_seedContainer->size() << std::endl;
377  std::cout << "seed phi, theta, eta : "
378  << trackSeed->get_phi(m_clusterMap, m_tGeometry) << ", " << trackSeed->get_theta()
379  << ", " << trackSeed->get_eta() << std::endl;
380  trackSeed->identify();
381  }
382 
383  m_seedContainer->insert(trackSeed.get());
384 
385  fitTimer->stop();
386  auto svtxtracktime = fitTimer->get_accumulated_time();
387  if (Verbosity() > 0)
388  {
389  std::cout << "Intt fit time " << circlefittime << " and svtx time "
390  << svtxtracktime << std::endl;
391  }
392  }
393  }
394 
395  if (m_seedAnalysis)
396  {
397  h_nSeeds->Fill(numGoodSeeds);
398  h_nActsSeeds->Fill(numSeeds);
399  }
400  if (Verbosity() > 1)
401  {
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;
407  for(auto& seed : *m_seedContainer)
408  {
409  if(!seed)
410  {
411  continue;
412  }
413  seed->identify();
414  }
415  }
416 
417  return;
418 }
419 
420 std::vector<TrkrDefs::cluskey> PHActsSiliconSeeding::findInttMatches(
421  std::vector<Acts::Vector3>& clusters,
422  TrackSeed& seed)
423 {
424  const float R = fabs(1. / seed.get_qOverR());
425  const float X0 = seed.get_X0();
426  const float Y0 = seed.get_Y0();
427  const float B = seed.get_Z0();
428  const float m = seed.get_slope();
429 
430  double xProj[m_nInttLayers];
431  double yProj[m_nInttLayers];
432  double zProj[m_nInttLayers];
433 
435  if (m_seedAnalysis)
436  {
437  for (const auto& glob : clusters)
438  {
439  h_hits->Fill(glob(0), glob(1));
440  h_zhits->Fill(glob(2),
441  std::sqrt(square(glob(0)) + square(glob(1))));
442  h_projHits->Fill(glob(0), glob(1));
443  h_zprojHits->Fill(glob(2),
444  sqrt(square(glob(0)) + square(glob(1))));
445  }
446  }
447 
449  for (int layer = 0; layer < m_nInttLayers; ++layer)
450  {
453  R, X0, Y0);
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);
458 
460  if (std::isnan(xplus))
461  {
462  if (Verbosity() > 2)
463  {
464  std::cout << "Circle intersection calc failed, skipping"
465  << std::endl;
466  std::cout << "layer radius " << m_nInttLayerRadii[layer]
467  << " and circ rad " << R << " with center " << X0
468  << ", " << Y0 << std::endl;
469  }
470  continue;
471  }
472 
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);
479 
480  if (fabs(lastClusPhi - plusPhi) < fabs(lastClusPhi - minusPhi))
481  {
482  xProj[layer] = xplus;
483  yProj[layer] = yplus;
484  }
485  else
486  {
487  xProj[layer] = xminus;
488  yProj[layer] = yminus;
489  }
490 
491  zProj[layer] = m * m_nInttLayerRadii[layer] + B;
492 
493  if (m_seedAnalysis)
494  {
495  h_projHits->Fill(xProj[layer], yProj[layer]);
496  h_zprojHits->Fill(zProj[layer], std::sqrt(square(xProj[layer]) +
497  square(yProj[layer])));
498  }
499 
500  if (Verbosity() > 2)
501  {
502  std::cout << "Projected point is : " << xProj[layer] << ", "
503  << yProj[layer] << ", " << zProj[layer] << std::endl;
504  }
505  }
506 
507  return matchInttClusters(clusters, seed, xProj, yProj, zProj);
508 }
509 
510 std::vector<TrkrDefs::cluskey> PHActsSiliconSeeding::matchInttClusters(
511  std::vector<Acts::Vector3>& clusters,
512  TrackSeed& seed,
513  const double xProj[],
514  const double yProj[],
515  const double zProj[])
516 {
517  std::vector<TrkrDefs::cluskey> matchedClusters;
518  TrkrDefs::cluskey matchedClusterLay0;
519  Acts::Vector3 matchedGlobPosLay0;
520  TrkrDefs::cluskey matchedClusterLay1;
521  Acts::Vector3 matchedGlobPosLay1;
522  float minResidLay0 = std::numeric_limits<float>::max();
523  float minResidLay1 = std::numeric_limits<float>::max();
524 
525  std::set<int> layersToSkip;
526  if (m_searchInIntt)
527  {
528  for(auto it = seed.begin_cluster_keys();
529  it != seed.end_cluster_keys();
530  ++it)
531  {
532  auto key = *it;
533  unsigned int layer = TrkrDefs::getLayer(key);
534  if(layer == 3 or layer == 4)
535  {
536  layersToSkip.insert(0);
537  layersToSkip.insert(1);
538  }
539  else if (layer == 5 or layer==6)
540  {
541  layersToSkip.insert(2);
542  layersToSkip.insert(3);
543  }
544  }
545  }
546 
547  for (int inttlayer = 0; inttlayer < m_nInttLayers; inttlayer++)
548  {
549  if(m_searchInIntt)
550  {
551  if(layersToSkip.find(inttlayer) != layersToSkip.end())
552  {
553  continue;
554  }
555  }
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;
559 
560  for (const auto& hitsetkey : m_clusterMap->getHitSetKeys(TrkrDefs::TrkrId::inttId, inttlayer + 3))
561  {
562  double ladderLocation[3] = {0., 0., 0.};
563 
564  // Add three to skip the mvtx layers for comparison
565  // to projections
566  auto layerGeom = dynamic_cast<CylinderGeomIntt*>(m_geomContainerIntt->GetLayerGeom(inttlayer + 3));
567 
569  layerGeom->find_segment_center(surf, m_tGeometry, ladderLocation);
570 
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;
574  if (dphi > M_PI)
575  {
576  dphi -= 2. * M_PI;
577  }
578  else if (dphi < -1 * M_PI)
579  {
580  dphi += 2. * M_PI;
581  }
582 
586  if (fabs(dphi) > 0.2)
587  {
588  continue;
589  }
590 
591  TVector3 projectionLocal(0, 0, 0);
592  TVector3 projectionGlobal(xProj[inttlayer], yProj[inttlayer], zProj[inttlayer]);
593 
594  projectionLocal = layerGeom->get_local_from_world_coords(surf,
595  m_tGeometry,
596  projectionGlobal);
597 
598  auto range = m_clusterMap->getClusters(hitsetkey);
599  for (auto clusIter = range.first; clusIter != range.second; ++clusIter)
600  {
601  const auto cluskey = clusIter->first;
602  if (_iteration_map != NULL && m_nIteration > 0)
603  {
605  {
606  continue; // skip clusters used in a previous iteration
607  }
608  }
609 
610  const auto cluster = clusIter->second;
612  if (m_seedAnalysis)
613  {
614  const auto globalP = m_tGeometry->getGlobalPosition(
615  cluskey, cluster);
616  h_nInttProj->Fill(projectionLocal[1] - cluster->getLocalX(),
617  projectionLocal[2] - cluster->getLocalY());
618  h_hits->Fill(globalP(0), globalP(1));
619  h_zhits->Fill(globalP(2),
620  std::sqrt(square(globalP(0)) + square(globalP(1))));
621 
622  h_resids->Fill(zProj[inttlayer] - cluster->getLocalY(),
623  projRphi - cluster->getLocalX());
624  }
625 
628  float rphiresid = fabs(projectionLocal[1] - cluster->getLocalX());
629  float zresid = fabs(projectionLocal[2] - cluster->getLocalY());
630  if (rphiresid < m_rPhiSearchWin and
631  zresid < stripZSpacing / 2.)
632  {
633  const auto globalPos = m_tGeometry->getGlobalPosition(
634  cluskey, cluster);
635 
636  if (inttlayer < 2 && rphiresid < minResidLay0)
637  {
638  matchedClusterLay0 = cluskey;
640  matchedGlobPosLay0 = globalPos;
641  minResidLay0 = rphiresid;
642  }
643  if (inttlayer > 1 && rphiresid < minResidLay1)
644  {
645  matchedClusterLay1 = cluskey;
646  matchedGlobPosLay1 = globalPos;
647  minResidLay1 = rphiresid;
648  }
649 
650  if (Verbosity() > 4)
651  {
652  std::cout << "Matched INTT cluster with cluskey " << cluskey
653  << " and position " << globalPos.transpose()
654  << std::endl
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
659  << " with search windows " << m_rPhiSearchWin
660  << " in rphi and strip z spacing " << stripZSpacing
661  << std::endl;
662  }
663  }
664  }
665  }
666  }
667 
668  if (minResidLay0 < std::numeric_limits<float>::max())
669  {
670  matchedClusters.push_back(matchedClusterLay0);
671  clusters.push_back(matchedGlobPosLay0);
672  }
673  if (minResidLay1 < std::numeric_limits<float>::max())
674  {
675  matchedClusters.push_back(matchedClusterLay1);
676  clusters.push_back(matchedGlobPosLay1);
677  }
678 
679  if (m_seedAnalysis)
680  {
681  h_nMatchedClusters->Fill(matchedClusters.size());
682  }
683 
684  return matchedClusters;
685 }
686 
688  const Surface& surf,
689  const TrkrDefs::cluskey key,
690  TrkrCluster* clus)
691 {
694  Acts::Vector3 globalPos(0, 0, 0);
695  Acts::Vector3 mom(1, 1, 1);
696  globalPos = surf->localToGlobal(m_tGeometry->geometry().getGeoContext(),
697  localPos, mom);
698 
699  Acts::SquareMatrix2 localCov = Acts::SquareMatrix2::Zero();
700  localCov(0, 0) = pow(clus->getRPhiError(), 2) * Acts::UnitConstants::cm2;
701  localCov(1, 1) = pow(clus->getZError(), 2) * Acts::UnitConstants::cm2;
702 
703  float x = globalPos.x();
704  float y = globalPos.y();
705  float z = globalPos.z();
706  float r = std::sqrt(x * x + y * y);
707 
718 
719  Acts::RotationMatrix3 rotLocalToGlobal =
720  surf->referenceFrame(m_tGeometry->geometry().getGeoContext(), globalPos, mom);
721  auto scale = 2 / std::hypot(x, y);
723  jacXyzToRhoZ(0, Acts::ePos0) = scale * x;
724  jacXyzToRhoZ(0, Acts::ePos1) = scale * y;
725  jacXyzToRhoZ(1, Acts::ePos2) = 1;
726  // compute Jacobian from local coordinates to rho/z
728  jacXyzToRhoZ *
729  rotLocalToGlobal.block<3, 2>(Acts::ePos0, Acts::ePos0);
730  // compute rho/z variance
731  Acts::ActsVector<2> var = (jac * localCov * jac.transpose()).diagonal();
732 
733  /*
734  * From Acts v17 to v19 the scattering uncertainty value allowed was changed.
735  * This led to a decrease in efficiency. To offset this, we scale the
736  * uncertainties by a tuned factor that gives the v17 performance
737  * Track reconstruction is an art as much as it is a science...
738  */
739  SpacePointPtr spPtr(new SpacePoint{key, x, y, z, r, surf->geometryId(), var[0] * m_uncfactor, var[1] * m_uncfactor});
740 
741  if (Verbosity() > 2)
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;
751 
752  return spPtr;
753 }
754 
755 std::vector<const SpacePoint*> PHActsSiliconSeeding::getSiliconSpacePoints(Acts::Extent& rRangeSPExtent)
756 {
757  std::vector<const SpacePoint*> spVec;
758  unsigned int numSiliconHits = 0;
759  unsigned int totNumSiliconHits = 0;
760  std::vector<TrkrDefs::TrkrId> dets = {TrkrDefs::TrkrId::mvtxId};
761  if(m_searchInIntt)
762  {
763  dets.push_back(TrkrDefs::TrkrId::inttId);
764  }
765  for(const auto& det : dets)
766  {
767  for (const auto& hitsetkey : m_clusterMap->getHitSetKeys(det))
768  {
769  auto range = m_clusterMap->getClusters(hitsetkey);
770  for (auto clusIter = range.first; clusIter != range.second; ++clusIter)
771  {
772  const auto cluskey = clusIter->first;
773  totNumSiliconHits++;
774  if (_iteration_map != NULL && m_nIteration > 0)
775  {
777  {
778  continue; // skip hits used in a previous iteration
779  }
780  }
781 
782  const auto cluster = clusIter->second;
785  if (!surface)
786  {
787  continue;
788  }
789 
790  auto sp = makeSpacePoint(surface, cluskey, cluster).release();
791  spVec.push_back(sp);
792  rRangeSPExtent.extend({sp->x(), sp->y(), sp->z()});
793  numSiliconHits++;
794  }
795  }
796  }
797  if (m_seedAnalysis)
798  {
799  h_nInputMvtxMeas->Fill(numSiliconHits);
800  }
801 
802  if (Verbosity() > 1)
803  {
804  std::cout << "Total number of silicon hits : " << totNumSiliconHits << std::endl;
805  std::cout << "Seed finding with "
806  << numSiliconHits << " hits " << std::endl;
807  }
808  return spVec;
809 }
810 
812 {
821 
825 }
826 
828 {
831  return config;
832 }
833 
835 {
837  m_seedFinderCfg.deltaRMinTopSP = 5 * Acts::UnitConstants::mm;
838  m_seedFinderCfg.deltaRMaxTopSP = 270 * Acts::UnitConstants::mm;
839  m_seedFinderCfg.deltaRMinBottomSP = 5 * Acts::UnitConstants::mm;
840  m_seedFinderCfg.deltaRMaxBottomSP = 270 * Acts::UnitConstants::mm;
841 
843  m_seedFinderCfg.rMax = m_rMax;
844  m_seedFinderCfg.rMin = m_rMin;
845  m_seedFinderCfg.zMin = m_zMin;
846  m_seedFinderCfg.zMax = m_zMax;
847 
849  m_seedFinderCfg.deltaRMin = m_deltaRMin;
850  m_seedFinderCfg.deltaRMax = m_deltaRMax;
851 
853  m_seedFinderCfg.collisionRegionMin = -300. * Acts::UnitConstants::mm;
854  m_seedFinderCfg.collisionRegionMax = 300. * Acts::UnitConstants::mm;
855  m_seedFinderCfg.sigmaScattering = m_sigmaScattering;
856  m_seedFinderCfg.maxSeedsPerSpM = m_maxSeedsPerSpM;
857  m_seedFinderCfg.cotThetaMax = m_cotThetaMax;
860 
862  m_seedFinderCfg.radLengthPerSeed = 0.05;
863 
865  m_seedFinderCfg.impactMax = m_impactMax;
866 
867  m_seedFinderCfg.rMinMiddle = 3. * Acts::UnitConstants::cm;
868  m_seedFinderCfg.rMaxMiddle = 3.7 * Acts::UnitConstants::cm;
869 
871  m_seedFinderCfg.zAlign = m_zalign;
872  m_seedFinderCfg.rAlign = m_ralign;
873  m_seedFinderCfg.toleranceParam = m_tolerance;
874  m_seedFinderCfg.maxPtScattering = m_maxPtScattering;
875  m_seedFinderCfg.sigmaError = m_sigmaError;
876  m_seedFinderCfg.helixCut = m_helixcut;
877 
879  m_seedFinderCfg.toInternalUnits().calculateDerivedQuantities();
881 }
882 
884 {
885  m_geomContainerIntt = findNode::getClass<PHG4CylinderGeomContainer>(topNode, "CYLINDERGEOM_INTT");
886  if (!m_geomContainerIntt)
887  {
888  std::cout << PHWHERE << "CYLINDERGEOM_INTT node not found on node tree"
889  << std::endl;
891  }
892 
893  m_tGeometry = findNode::getClass<ActsGeometry>(topNode, "ActsGeometry");
894  if (!m_tGeometry)
895  {
896  std::cout << PHWHERE << "No ActsGeometry on node tree. Bailing."
897  << std::endl;
899  }
900 
901  if (m_useTruthClusters)
902  m_clusterMap = findNode::getClass<TrkrClusterContainer>(topNode,
903  "TRKR_CLUSTER_TRUTH");
904  else
905  m_clusterMap = findNode::getClass<TrkrClusterContainer>(topNode,
906  "TRKR_CLUSTER");
907 
908  if (!m_clusterMap)
909  {
910  std::cout << PHWHERE << "No cluster container on the node tree. Bailing."
911  << std::endl;
913  }
914 
916 }
918 {
919  PHNodeIterator iter(topNode);
920 
921  PHCompositeNode* dstNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "DST"));
922 
923  if (!dstNode)
924  {
925  std::cerr << "DST node is missing, quitting" << std::endl;
926  throw std::runtime_error("Failed to find DST node in PHActsSiliconSeeding::createNodes");
927  }
928 
929  PHNodeIterator dstIter(dstNode);
930  PHCompositeNode* svtxNode = dynamic_cast<PHCompositeNode*>(dstIter.findFirst("PHCompositeNode", "SVTX"));
931 
932  if (!svtxNode)
933  {
934  svtxNode = new PHCompositeNode("SVTX");
935  dstNode->addNode(svtxNode);
936  }
937 
938  m_seedContainer = findNode::getClass<TrackSeedContainer>(topNode, _track_map_name);
939  if (!m_seedContainer)
940  {
942  PHIODataNode<PHObject>* trackNode =
944  svtxNode->addNode(trackNode);
945  }
946 
948 }
949 
951 {
952  m_file->cd();
953  h_nInttProj->Write();
954  h_nMatchedClusters->Write();
955  h_nMvtxHits->Write();
956  h_nSeeds->Write();
957  h_nActsSeeds->Write();
958  h_nTotSeeds->Write();
959  h_nInttHits->Write();
960  h_nInputMeas->Write();
961  h_nHits->Write();
962  h_nInputMvtxMeas->Write();
963  h_nInputInttMeas->Write();
964  h_hits->Write();
965  h_zhits->Write();
966  h_projHits->Write();
967  h_zprojHits->Write();
968  h_resids->Write();
969  m_file->Write();
970  m_file->Close();
971 }
972 
974 {
975  h_nMatchedClusters = new TH1F("nMatchedClusters", ";N_{matches}", 50, 0, 50);
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,
981  80, 0, 80);
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);
986  h_nInputMvtxMeas = new TH1I("nInputMvtxMeas", ";N_{meas}^{mvtx}",
987  150, 0, 150);
988  h_nInputInttMeas = new TH1I("nInputInttMeas", ";N_{meas}^{intt}",
989  150, 0, 150);
990  h_hits = new TH2F("hits", ";x [cm]; y [cm]", 1000, -20, 20,
991  1000, -20, 20);
992  h_zhits = new TH2F("zhits", ";z [cm]; r [cm]", 1000, -30, 30,
993  1000, -30, 30);
994  h_projHits = new TH2F("projhits", ";x [cm]; y [cm]", 1000, -20, 20,
995  1000, -20, 20);
996  h_zprojHits = new TH2F("zprojhits", ";z [cm]; r [cm]", 1000, -30, 30,
997  1000, -30, 30);
998  h_resids = new TH2F("resids", ";z_{resid} [cm]; rphi_{resid} [cm]",
999  100, -1, 1, 100, -1, 1);
1000 }
1001 
1003 {
1004  double returnPhi = phi;
1005  if (returnPhi < 0)
1006  returnPhi += 2 * M_PI;
1007  return returnPhi;
1008 }
1009 
1011 {
1012  if (!spacing)
1013  {
1014  m_gridFactor = 1.;
1015  m_rMax = 50.;
1016  m_cotThetaMax = 1.335647;
1017  m_maxSeedPCA = 0.1;
1018  }
1019 }
1020 
1022 {
1023  // helper function for when updating acts to ensure all seeding parameters
1024  // are actually the same as before
1025 
1026  std::cout << " --------------- SeedFilterConfig ------------------ " << std::endl;
1027  std::cout << "deltaInvHelixDiameter = "
1028  << sfconfig.deltaInvHelixDiameter << std::endl
1029  << "impactWeightFactor = " << sfconfig.impactWeightFactor
1030  << std::endl
1031  << "zOriginWeightFactor = "
1032  << sfconfig.zOriginWeightFactor << std::endl
1033  << "compatSeedWeight = " << sfconfig.compatSeedWeight
1034  << std::endl
1035  << "deltaRMin = " << sfconfig.deltaRMin
1036  << std::endl
1037  << "maxSeedsPerSpM = "
1038  << sfconfig.maxSeedsPerSpM << std::endl
1039  << "compatSeedLimit = " << sfconfig.compatSeedLimit
1040  << std::endl
1041  << "seedWeightIncrement = "
1042  << sfconfig.seedWeightIncrement << std::endl
1043  << "numSeedIncrement = " << sfconfig.numSeedIncrement
1044  << std::endl;
1045 
1046  std::cout << " --------------- SeedFinderConfig ------------------ " << std::endl;
1047 
1048  std::cout << "deltaRMinTopSp = " << m_seedFinderCfg.deltaRMinTopSP
1049  << std::endl
1050  << "deltaRMaxTopSP = " << m_seedFinderCfg.deltaRMaxTopSP
1051  << std::endl
1052  << "deltaRMinBottomSP = " << m_seedFinderCfg.deltaRMinBottomSP
1053  << std::endl
1054  << "deltaRMaxBottomSP = " << m_seedFinderCfg.deltaRMaxBottomSP
1055  << std::endl
1056  << "minpt = " << m_seedFinderCfg.minPt
1057  << std::endl
1058  << "cotThetaMax = " << m_seedFinderCfg.cotThetaMax
1059  << std::endl
1060  << "deltaRMin = " << m_seedFinderCfg.deltaRMin
1061  << std::endl
1062  << "deltaRMax = " << m_seedFinderCfg.deltaRMax
1063  << std::endl
1064  << "binSizeR = " << m_seedFinderCfg.binSizeR
1065  << std::endl
1066  << "deltaRMiddleMinSPRange = " << m_seedFinderCfg.deltaRMiddleMinSPRange
1067  << std::endl
1068  << "deltaRMiddleMaxSPRange = " << m_seedFinderCfg.deltaRMiddleMaxSPRange
1069  << std::endl
1070  << "rMinMiddle = " << m_seedFinderCfg.rMinMiddle
1071  << std::endl
1072  << "rMaxMiddle = " << m_seedFinderCfg.rMaxMiddle
1073  << std::endl
1074  << "deltaZMax = " << m_seedFinderCfg.deltaZMax
1075  << std::endl
1076  << "rMax = " << m_seedFinderCfg.rMax
1077  << std::endl
1078  << "rMin = " << m_seedFinderCfg.rMin
1079  << std::endl
1080  << "zMin = " << m_seedFinderCfg.zMin
1081  << std::endl
1082  << "zMax = " << m_seedFinderCfg.zMax
1083  << std::endl
1084  << "collisionRegionMin = " << m_seedFinderCfg.collisionRegionMin
1085  << std::endl
1086  << "collisionRegionMax = " << m_seedFinderCfg.collisionRegionMax
1087  << std::endl
1088  << "sigmaScattering = " << m_seedFinderCfg.sigmaScattering
1089  << std::endl
1090  << "maxSeedsPerSpM = " << m_seedFinderCfg.maxSeedsPerSpM
1091  << std::endl
1092  << "bFieldInZ = " << m_seedFinderOptions.bFieldInZ
1093  << std::endl
1094  << "radLengthPerSeed = " << m_seedFinderCfg.radLengthPerSeed
1095  << std::endl
1096  << "impactMax = " << m_seedFinderCfg.impactMax
1097  << std::endl
1098  << "zAlign = " << m_seedFinderCfg.zAlign
1099  << std::endl
1100  << "rAlign = " << m_seedFinderCfg.rAlign
1101  << std::endl
1102  << "toleranceParam = " << m_seedFinderCfg.toleranceParam
1103  << std::endl
1104  << "maxPtScattering = " << m_seedFinderCfg.maxPtScattering
1105  << std::endl
1106  << "sigmaError = " << m_seedFinderCfg.sigmaError
1107  << std::endl
1108  << "helixcut = " << m_seedFinderCfg.helixcut
1109  << std::endl;
1110 
1111  std::cout << " --------------- SeedFinderOptions ------------------ " << std::endl;
1112  std::cout << "beamPos = " << m_seedFinderOptions.beamPos.transpose()
1113  << std::endl
1114  << "bFieldInZ = " << m_seedFinderOptions.bFieldInZ
1115  << std::endl
1116  << "pTPerHelixRadius = " << m_seedFinderOptions.pTPerHelixRadius
1117  << std::endl
1118  << "minHelixDiameter2 = " << m_seedFinderOptions.minHelixDiameter2
1119  << std::endl
1120  << "pT2perRadius = " << m_seedFinderOptions.pT2perRadius
1121  << std::endl
1122  << "sigmapT2perRadius = " << m_seedFinderOptions.sigmapT2perRadius
1123  << std::endl;
1124 
1125  std::cout << " --------------- SpacePointGridConfig ------------------ " << std::endl;
1126 
1127  std::cout << "minpt = " << m_gridCfg.minPt << std::endl
1128  << "rMax = " << m_gridCfg.rMax << std::endl
1129  << "zMax = " << m_gridCfg.zMax << std::endl
1130  << "zMin = " << m_gridCfg.zMin << std::endl
1131  << "deltaRMax = " << m_gridCfg.deltaRMax << std::endl
1132  << "cotThetaMax = " << m_gridCfg.cotThetaMax << std::endl
1133  << "impactMax = " << m_gridCfg.impactMax << std::endl
1134  << "phiBinDeflectionCoverage = " << m_gridCfg.phiBinDeflectionCoverage << std::endl
1135  << "bFieldInZ = " << m_gridOptions.bFieldInZ << std::endl;
1136 }