@@ -1836,17 +1836,18 @@ void StandaloneTrackMonitor::analyze(edm::Event const& iEvent, edm::EventSetup c
18361836 theMainVtx = *theClosestVertex;
18371837 }
18381838 if (theMainVtx.isValid ()) {
1839- const math::XYZPoint theMainVtxPos (
1840- theMainVtx.position ().x (), theMainVtx.position ().y (), theMainVtx.position ().z ());
1841- const math::XYZPoint myVertex (
1842- mumuTransientVtx.position ().x (), mumuTransientVtx.position ().y (), mumuTransientVtx.position ().z ());
1843- const math::XYZPoint deltaVtx (
1844- theMainVtxPos.x () - myVertex.x (), theMainVtxPos.y () - myVertex.y (), theMainVtxPos.z () - myVertex.z ());
1845- double cosphi3D =
1846- (Zp.Px () * deltaVtx.x () + Zp.Py () * deltaVtx.y () + Zp.Pz () * deltaVtx.z ()) /
1847- (sqrt (Zp.Px () * Zp.Px () + Zp.Py () * Zp.Py () + Zp.Pz () * Zp.Pz ()) *
1848- sqrt (deltaVtx.x () * deltaVtx.x () + deltaVtx.y () * deltaVtx.y () + deltaVtx.z () * deltaVtx.z ()));
1849- cosPhi3DdileptonH_->Fill (cosphi3D, wfac);
1839+ const auto & mainVertexPos = theMainVtx.position ();
1840+ const auto & myVertexPos = mumuTransientVtx.position ();
1841+
1842+ const double deltaX = myVertexPos.x () - mainVertexPos.x ();
1843+ const double deltaY = myVertexPos.y () - mainVertexPos.y ();
1844+ const double deltaZ = myVertexPos.z () - mainVertexPos.z ();
1845+
1846+ const double deltaNorm = sqrt (deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ);
1847+ const double zpNorm = sqrt (Zp.Px () * Zp.Px () + Zp.Py () * Zp.Py () + Zp.Pz () * Zp.Pz ());
1848+
1849+ const double cosPhi3D = (Zp.Px () * deltaX + Zp.Py () * deltaY + Zp.Pz () * deltaZ) / (zpNorm * deltaNorm);
1850+ cosPhi3DdileptonH_->Fill (cosPhi3D, wfac);
18501851 }
18511852 }
18521853 }
0 commit comments