From 69a5846a1461b14c9259a2ddd21fa619964a5890 Mon Sep 17 00:00:00 2001 From: mmusich Date: Wed, 17 Apr 2024 12:36:58 +0200 Subject: [PATCH] fix sign of cosPhi3D, make code more readable --- .../plugins/StandaloneTrackMonitor.cc | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/DQM/TrackingMonitorSource/plugins/StandaloneTrackMonitor.cc b/DQM/TrackingMonitorSource/plugins/StandaloneTrackMonitor.cc index e1dc903f3443a..0f7e80a9d568e 100644 --- a/DQM/TrackingMonitorSource/plugins/StandaloneTrackMonitor.cc +++ b/DQM/TrackingMonitorSource/plugins/StandaloneTrackMonitor.cc @@ -1836,17 +1836,18 @@ void StandaloneTrackMonitor::analyze(edm::Event const& iEvent, edm::EventSetup c theMainVtx = *theClosestVertex; } if (theMainVtx.isValid()) { - const math::XYZPoint theMainVtxPos( - theMainVtx.position().x(), theMainVtx.position().y(), theMainVtx.position().z()); - const math::XYZPoint myVertex( - mumuTransientVtx.position().x(), mumuTransientVtx.position().y(), mumuTransientVtx.position().z()); - const math::XYZPoint deltaVtx( - theMainVtxPos.x() - myVertex.x(), theMainVtxPos.y() - myVertex.y(), theMainVtxPos.z() - myVertex.z()); - double cosphi3D = - (Zp.Px() * deltaVtx.x() + Zp.Py() * deltaVtx.y() + Zp.Pz() * deltaVtx.z()) / - (sqrt(Zp.Px() * Zp.Px() + Zp.Py() * Zp.Py() + Zp.Pz() * Zp.Pz()) * - sqrt(deltaVtx.x() * deltaVtx.x() + deltaVtx.y() * deltaVtx.y() + deltaVtx.z() * deltaVtx.z())); - cosPhi3DdileptonH_->Fill(cosphi3D, wfac); + const auto& mainVertexPos = theMainVtx.position(); + const auto& myVertexPos = mumuTransientVtx.position(); + + const double deltaX = myVertexPos.x() - mainVertexPos.x(); + const double deltaY = myVertexPos.y() - mainVertexPos.y(); + const double deltaZ = myVertexPos.z() - mainVertexPos.z(); + + const double deltaNorm = sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ); + const double zpNorm = sqrt(Zp.Px() * Zp.Px() + Zp.Py() * Zp.Py() + Zp.Pz() * Zp.Pz()); + + const double cosPhi3D = (Zp.Px() * deltaX + Zp.Py() * deltaY + Zp.Pz() * deltaZ) / (zpNorm * deltaNorm); + cosPhi3DdileptonH_->Fill(cosPhi3D, wfac); } } }