From df610b494a03dce182a26a5ad43690086e1cf1f1 Mon Sep 17 00:00:00 2001
From: Scott Snyder <scott.snyder@cern.ch>
Date: Wed, 7 Aug 2024 07:14:46 +0200
Subject: [PATCH] JetTagDQA: Fix test for missing aux variable.

JetTagDQA: Fix test for missing aux variable.

Don't use exceptions as a way of testing for missing aux variables.
---
 .../JetTagValidation/JetTagDQA/src/PhysValBTag.cxx           | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/PhysicsAnalysis/JetTagging/JetTagValidation/JetTagDQA/src/PhysValBTag.cxx b/PhysicsAnalysis/JetTagging/JetTagValidation/JetTagDQA/src/PhysValBTag.cxx
index 06e2da902ff0..d5246d09f0d3 100644
--- a/PhysicsAnalysis/JetTagging/JetTagValidation/JetTagDQA/src/PhysValBTag.cxx
+++ b/PhysicsAnalysis/JetTagging/JetTagValidation/JetTagDQA/src/PhysValBTag.cxx
@@ -365,11 +365,10 @@ namespace JetTagDQA {
 
     // also loop over the tracks associated to the MSV vertices -> can be missing in the other track list
     // get the MSV vertices
-    std::vector< ElementLink< xAOD::VertexContainer > > MSV_vertices;
     static const SG::ConstAccessor<std::vector< ElementLink< xAOD::VertexContainer > > >
       MSV_verticesAcc("MSV_vertices");
-    try { MSV_vertices = MSV_verticesAcc(*btag); }
-    catch(std::exception& exception) {  }
+    std::vector< ElementLink< xAOD::VertexContainer > > MSV_vertices =
+      MSV_verticesAcc.withDefault(*btag, std::vector< ElementLink< xAOD::VertexContainer > >());
 
     // loop over the MSV vertices
     for (unsigned int i = 0; i < MSV_vertices.size(); i++) {
-- 
GitLab