Skip to content

Commit

Permalink
minor optimization: square once vs. sqrt N times
Browse files Browse the repository at this point in the history
  • Loading branch information
genevb committed Dec 10, 2024
1 parent c4bfd80 commit aedef64
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions StRoot/StGenericVertexMaker/Minuit/StMinuitVertexFinder.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ int StMinuitVertexFinder::fit(StEvent* event)
// potentially be a database table (PrimaryVertexCuts) parameter,
// but the bias is approximate and highly unlikely to change/finetune.
StThreeVectorD beamAxis(0.0, mFXT ? -2.0 : 0.0, 0.0);
double RImpactMax2 = mRImpactMax*mRImpactMax;

for (const StTrackNode* stTrack : event->trackNodes())
{
Expand All @@ -422,8 +423,8 @@ int StMinuitVertexFinder::fit(StEvent* event)
if (! gDCA) continue;
StPhysicalHelixD gHelix = gDCA->helix();
StThreeVectorD DCAPosition = gHelix.at(gHelix.pathLength(beamAxis.x(),beamAxis.y())) - beamAxis;
double RImpact = DCAPosition.perp();
if (RImpact > mRImpactMax) continue;
double RImpact2 = DCAPosition.perp2();
if (RImpact2 > RImpactMax2) continue; // calculate square once instead of sqrt N times
mDCAs.push_back(gDCA);
// StPhysicalHelixD helix = gDCA->helix();
// mHelices.push_back(helix);
Expand Down

0 comments on commit aedef64

Please sign in to comment.