diff --git a/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_configFuntuple.qmt b/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_configFuntuple.qmt
index cc6fa248ada7ba3f753bc8ba632e6f8e096c70b6..c725086950d02418ca317e1ee1e6f2a3a9412833 100644
--- a/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_configFuntuple.qmt
+++ b/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_configFuntuple.qmt
@@ -1,7 +1,7 @@
 <?xml version="1.0" ?>
 <!--
 ###############################################################################
-# (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration           #
+# (c) Copyright 2021-2023 CERN for the benefit of the LHCb Collaboration      #
 #                                                                             #
 # This software is distributed under the terms of the GNU General Public      #
 # Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING".   #
diff --git a/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_All.qmt b/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_All.qmt
index 31897866c45cf8a2e73cbb2df54a674749d3e3c3..857403d5e3b8d29cc6c669bd1ad5079a0c464b8f 100755
--- a/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_All.qmt
+++ b/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_All.qmt
@@ -1,7 +1,7 @@
 <?xml version="1.0" ?>
 <!--
 ###############################################################################
-# (c) Copyright 2021-2022 CERN for the benefit of the LHCb Collaboration      #
+# (c) Copyright 2021-2023 CERN for the benefit of the LHCb Collaboration      #
 #                                                                             #
 # This software is distributed under the terms of the GNU General Public      #
 # Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING".   #
@@ -48,6 +48,8 @@
 findReferenceBlock("""B0DsK_Tuple                         SUCCESS Booked 1 N-Tuples and 0 Event Tag Collections"""
 , stdout, result, causes, signature_offset = 0)
 
+countErrorLines({"FATAL":0, "ERROR":0})
+
 import sys, os, glob
 from ROOT import TFile
 
@@ -69,15 +71,17 @@ B_excluded_1 = set(B_vars_stored) - set(b_names)
 B_excluded_2 = set(b_names) - set(B_vars_stored)
 if len(B_excluded_1) != 0: raise Exception('Number of stored variables is less than what is expected. The extra variables expected are: ' , B_excluded_1)
 if len(B_excluded_2) != 0: raise Exception('Number of stored variables is greater than what is expected. The extra variables stored are: ', B_excluded_2)
+f.Close()
 
-# Check there are no NaN values in the ntuple
-# from DaVinciTests.QMTest.check_helpers import has_nan
-# assert not has_nan("DV_example_allFunctors_ntp.root", "B0DsK_Tuple/DecayTree")
+# Check there are no NaN values in the ntuple except where expected.
+from DaVinciTests.QMTest.check_helpers import list_fields_with_nan
 
-f.Close()
-print('Test successfully completed!')
+l_branches_with_nans = ['B0_TRUEP', 'B0_TRUEPT', 'B0_TRUEPX', 'B0_TRUEPY', 'B0_TRUEPZ', 'B0_TRUEENERGY', 'B0_TRUEORIGINVERTEX_X', 'B0_TRUEORIGINVERTEX_Y', 'B0_TRUEORIGINVERTEX_Z', 'B0_TRUEENDVERTEX_X', 'B0_TRUEENDVERTEX_Y', 'B0_TRUEENDVERTEX_Z', 'B0_MASSWITHHYPOTHESES', 'Kaon_PROBNN_D', 'Kaon_PROBNN_MU', 'Kaon_TRUEP', 'Kaon_TRUEPT', 'Kaon_TRUEPX', 'Kaon_TRUEPY', 'Kaon_TRUEPZ', 'Kaon_TRUEENERGY', 'Kaon_BREMENERGY', 'Kaon_BREMBENDCORR', 'Kaon_BREMPIDE', 'Kaon_ECALPIDE', 'Kaon_ECALPIDMU', 'Kaon_HCALPIDE', 'Kaon_HCALPIDMU', 'Kaon_ELECTRONSHOWEREOP', 'Kaon_CLUSTERMATCH', 'Kaon_ELECTRONMATCH', 'Kaon_BREMHYPOMATCH', 'Kaon_ELECTRONENERGY', 'Kaon_BREMHYPOENERGY', 'Kaon_BREMHYPODELTAX', 'Kaon_ELECTRONID', 'Kaon_HCALEOP', 'Ds_TRUEP', 'Ds_TRUEPT', 'Ds_TRUEPX', 'Ds_TRUEPY', 'Ds_TRUEPZ', 'Ds_TRUEENERGY', 'Ds_TRUEORIGINVERTEX_X', 'Ds_TRUEORIGINVERTEX_Y', 'Ds_TRUEORIGINVERTEX_Z', 'Ds_TRUEENDVERTEX_X', 'Ds_TRUEENDVERTEX_Y', 'Ds_TRUEENDVERTEX_Z', 'Ds_BPVCORRMERR', 'Ds_BPVLTIME', 'Ds_MASSWITHHYPOTHESES', 'pip_PROBNN_D', 'pip_PROBNN_MU', 'pip_TRUEP', 'pip_TRUEPT', 'pip_TRUEPX', 'pip_TRUEPY', 'pip_TRUEPZ', 'pip_TRUEENERGY', 'pip_BREMENERGY', 'pip_BREMBENDCORR', 'pip_BREMPIDE', 'pip_ECALPIDE', 'pip_ECALPIDMU', 'pip_HCALPIDE', 'pip_HCALPIDMU', 'pip_ELECTRONSHOWEREOP', 'pip_CLUSTERMATCH', 'pip_ELECTRONMATCH', 'pip_BREMHYPOMATCH', 'pip_ELECTRONENERGY', 'pip_BREMHYPOENERGY', 'pip_BREMHYPODELTAX', 'pip_ELECTRONID', 'pip_HCALEOP']
+
+l_test = list_fields_with_nan("DV_example_allFunctors_ntp.root", "B0DsK_Tuple/DecayTree")
+assert sorted(l_test) == sorted(l_branches_with_nans)
 
+print('Test successfully completed!')
 os.system(f"rm {ntuple}")
-countErrorLines({"FATAL":0, "ERROR":0})
 </text></argument>
 </extension>
diff --git a/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_All_olddst.qmt b/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_All_olddst.qmt
index 2ac8ebd940b987cbb65e539704f31ca6cfa38da8..2bb6f8f9d953eafa5b89785fc70b13d90cfc6b50 100755
--- a/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_All_olddst.qmt
+++ b/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_All_olddst.qmt
@@ -1,7 +1,7 @@
 <?xml version="1.0" ?>
 <!--
 ###############################################################################
-# (c) Copyright 2021-2022 CERN for the benefit of the LHCb Collaboration      #
+# (c) Copyright 2021-2023 CERN for the benefit of the LHCb Collaboration      #
 #                                                                             #
 # This software is distributed under the terms of the GNU General Public      #
 # Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING".   #
@@ -48,6 +48,8 @@
 findReferenceBlock("""B0DsK_Tuple                         SUCCESS Booked 1 N-Tuples and 0 Event Tag Collections"""
 , stdout, result, causes, signature_offset = 0)
 
+countErrorLines({"FATAL":0, "ERROR":0})
+
 import sys, os, glob
 from ROOT import TFile
 
@@ -69,15 +71,17 @@ B_excluded_1 = set(B_vars_stored) - set(b_names)
 B_excluded_2 = set(b_names) - set(B_vars_stored)
 if len(B_excluded_1) != 0: raise Exception('Number of stored variables is less than what is expected. The extra variables expected are: ' , B_excluded_1)
 if len(B_excluded_2) != 0: raise Exception('Number of stored variables is greater than what is expected. The extra variables stored are: ', B_excluded_2)
+f.Close()
 
-# Check there are no NaN values in the ntuple
-# from DaVinciTests.QMTest.check_helpers import has_nan
-# assert not has_nan("DV_example_allFunctors_ntp.root", "B0DsK_Tuple/DecayTree")
+# Check there are no NaN values in the ntuple except where expected.
+from DaVinciTests.QMTest.check_helpers import list_fields_with_nan
 
-f.Close()
-print('Test successfully completed!')
+l_branches_with_nans =  ['B0_TRUEP', 'B0_TRUEPT', 'B0_TRUEPX', 'B0_TRUEPY', 'B0_TRUEPZ', 'B0_TRUEENERGY', 'B0_TRUEORIGINVERTEX_X', 'B0_TRUEORIGINVERTEX_Y', 'B0_TRUEORIGINVERTEX_Z', 'B0_TRUEENDVERTEX_X', 'B0_TRUEENDVERTEX_Y', 'B0_TRUEENDVERTEX_Z', 'Kaon_PROBNN_D', 'Kaon_PROBNN_MU', 'Kaon_TRUEP', 'Kaon_TRUEPT', 'Kaon_TRUEPX', 'Kaon_TRUEPY', 'Kaon_TRUEPZ', 'Kaon_TRUEENERGY', 'Kaon_BREMENERGY', 'Kaon_BREMBENDCORR', 'Kaon_BREMPIDE', 'Kaon_ECALPIDE', 'Kaon_ECALPIDMU', 'Kaon_HCALPIDE', 'Kaon_HCALPIDMU', 'Kaon_ELECTRONSHOWEREOP', 'Kaon_CLUSTERMATCH', 'Kaon_ELECTRONMATCH', 'Kaon_BREMHYPOMATCH', 'Kaon_ELECTRONENERGY', 'Kaon_BREMHYPOENERGY', 'Kaon_BREMHYPODELTAX', 'Kaon_ELECTRONID', 'Kaon_HCALEOP', 'Ds_TRUEP', 'Ds_TRUEPT', 'Ds_TRUEPX', 'Ds_TRUEPY', 'Ds_TRUEPZ', 'Ds_TRUEENERGY', 'Ds_TRUEORIGINVERTEX_X', 'Ds_TRUEORIGINVERTEX_Y', 'Ds_TRUEORIGINVERTEX_Z', 'Ds_TRUEENDVERTEX_X', 'Ds_TRUEENDVERTEX_Y', 'Ds_TRUEENDVERTEX_Z', 'Ds_BPVCORRMERR', 'Ds_BPVLTIME', 'Ds_MASSWITHHYPOTHESES', 'pip_PROBNN_D', 'pip_PROBNN_MU', 'pip_TRUEP', 'pip_TRUEPT', 'pip_TRUEPX', 'pip_TRUEPY', 'pip_TRUEPZ', 'pip_TRUEENERGY', 'pip_BREMENERGY', 'pip_BREMBENDCORR', 'pip_BREMPIDE', 'pip_ECALPIDE', 'pip_ECALPIDMU', 'pip_HCALPIDE', 'pip_HCALPIDMU', 'pip_ELECTRONSHOWEREOP', 'pip_CLUSTERMATCH', 'pip_ELECTRONMATCH', 'pip_BREMHYPOMATCH', 'pip_ELECTRONENERGY', 'pip_BREMHYPOENERGY', 'pip_BREMHYPODELTAX', 'pip_ELECTRONID', 'pip_HCALEOP']
+
+l_test = list_fields_with_nan("DV_example_allFunctors_ntp_old.root", "B0DsK_Tuple/DecayTree")
+assert sorted(l_test) == sorted(l_branches_with_nans)
 
+print('Test successfully completed!')
 os.system(f"rm {ntuple}")
-countErrorLines({"FATAL":0, "ERROR":0})
 </text></argument>
 </extension>
diff --git a/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_DTF.qmt b/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_DTF.qmt
index 3c875bf9f3f5f5b80108337e932a3f26f38e6927..79cb56730bacf2a3d9ca7049d140b4fe7f1b2e79 100755
--- a/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_DTF.qmt
+++ b/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_DTF.qmt
@@ -1,7 +1,7 @@
 <?xml version="1.0" ?>
 <!--
 ###############################################################################
-# (c) Copyright 2020-2021 CERN for the benefit of the LHCb Collaboration      #
+# (c) Copyright 2020-2023 CERN for the benefit of the LHCb Collaboration      #
 #                                                                             #
 # This software is distributed under the terms of the GNU General Public      #
 # Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING".   #
@@ -26,6 +26,15 @@
   </text></argument>
 <argument name="validator"><text>
 findReferenceBlock("""DimuonsTuple                        SUCCESS  ID=DecayTree     Title="DecayTree"                               #items=18 {EVENTNUMBER,RUNNUMBER,Jpsi_LOKI_P,Jpsi_LOKI_PT,Jpsi_LOKI_Muonp_PT,Jpsi_LOKI_Muonm}""")
+
 countErrorLines({"FATAL":0, "ERROR":0})
+
+# Check there are no NaN values in the ntuple except where expected.
+from DaVinciTests.QMTest.check_helpers import list_fields_with_nan
+
+l_branches_with_nans = ['Jpsi_DTF_PV_MASS']
+
+l_test = list_fields_with_nan("DV-example-tupling-DTF-ntp.root", "DimuonsTuple/DecayTree")
+assert sorted(l_test) == sorted(l_branches_with_nans)
 </text></argument>
 </extension>
diff --git a/DaVinciTests/python/DaVinciTests/QMTest/check_helpers.py b/DaVinciTests/python/DaVinciTests/QMTest/check_helpers.py
index 698a2c0e6288611c4ef3effbb80402354b737745..b72afdfc677814f07cba2caf04e3b3fb5ab4008a 100644
--- a/DaVinciTests/python/DaVinciTests/QMTest/check_helpers.py
+++ b/DaVinciTests/python/DaVinciTests/QMTest/check_helpers.py
@@ -25,6 +25,53 @@ def has_nan(filename: str,
     with the `columns` and `exclude` arguments, respectively,
     as detailed in the documentation of `RDataFrame.AsNumpy`.
     
+    Args:
+        filename (str): The full path to the ROOT file.
+        ntuple_name (str): The full path to the ntuple, e.g. My/Dir/MyNtuple.
+        columns (iterable[str], optional): If None, return all fields (branches) as columns,
+            otherwise specify names in iterable.
+        exclude (iterable[str], optional): Exclude fields (branches) from selection.
+    """
+    df = _get_pandas_dataframe(filename, ntuple_name, columns, exclude)
+
+    return df.isna().any().any()
+
+
+def count_nan_in_fields(filename: str, ntuple_name: str,
+                        fields: Iterable[str]):
+    """
+    Count the number of NaN values for a give list of fields (branches).
+
+    Args:
+        filename (str): The full path to the ROOT file.
+        ntuple_name (str): The full path to the ntuple, e.g. My/Dir/MyNtuple.
+        fields (iterable[str]): The list of fields to inspect.
+    """
+    df = _get_pandas_dataframe(filename, ntuple_name, fields)
+
+    return {f: df[f].isna().sum() for f in fields}
+
+
+def list_fields_with_nan(filename: str, ntuple_name: str):
+    """
+    List the fields (branches) that contain NaN values.
+
+    Args:
+        filename (str): The full path to the ROOT file.
+        ntuple_name (str): The full path to the ntuple, e.g. My/Dir/MyNtuple.
+    """
+    df = _get_pandas_dataframe(filename, ntuple_name)
+
+    return df.columns[df.isna().any()].tolist()
+
+
+def _get_pandas_dataframe(filename: str,
+                          ntuple_name: str,
+                          columns: Iterable[str] = None,
+                          exclude: Iterable[str] = None):
+    """
+    Helper to produce a Pandas DataFrame from a ROOT RDataFrame.
+
     Args:
         filename (str): The full path to the ROOT file.
         ntuple_name (str): The full path to the ntuple, e.g. My/Dir/MyNtuple.
@@ -35,6 +82,4 @@ def has_nan(filename: str,
     rdf = RDataFrame(ntuple_name, filename)
     ar = rdf.AsNumpy(columns, exclude)
 
-    df = pd.DataFrame(ar)
-
-    return df.isna().any().any()
+    return pd.DataFrame(ar)
diff --git a/DaVinciTutorials/tests/qmtest/test_tutorial1_functors_specialfield.qmt b/DaVinciTutorials/tests/qmtest/test_tutorial1_functors_specialfield.qmt
index a9268de8f29c018817096ed5e5477940e38e6a81..2b52870e4bfe0d3565dcb5922965773e3986683f 100644
--- a/DaVinciTutorials/tests/qmtest/test_tutorial1_functors_specialfield.qmt
+++ b/DaVinciTutorials/tests/qmtest/test_tutorial1_functors_specialfield.qmt
@@ -1,7 +1,7 @@
 <?xml version="1.0" ?>
 <!--
 ###############################################################################
-# (c) Copyright 2021-2022 CERN for the benefit of the LHCb Collaboration      #
+# (c) Copyright 2021-2023 CERN for the benefit of the LHCb Collaboration      #
 #                                                                             #
 # This software is distributed under the terms of the GNU General Public      #
 # Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING".   #
@@ -25,10 +25,14 @@
   <argument name="error_reference"><text>../refs/empty.ref</text></argument>
   <argument name="validator"><text>
 from DaVinciTests.QMTest.DaVinciExclusions import preprocessor, counter_preprocessor
+
 validateWithReference(preproc = preprocessor, counter_preproc = counter_preprocessor)
 
+countErrorLines({"FATAL":0, "ERROR":0})
+
 import os
 from ROOT import TFile
+
 ntuple  = './tutorial1_functors_specialfield.root'
 #this file should be disabled
 ntuple_new  = './tutorial1_Functors_specialfield_new.root'
@@ -38,10 +42,13 @@ t_B    = f.Get('TDirectoryName/TTreeName')
 b_names= [b.GetName() for b in t_B.GetListOfLeaves()]
 if not b_names: raise Exception(f"File: {ntuple} does not contain any branches. Please check.")
 f.Close()
+
+# Check there are no NaN values in the ntuple
+from DaVinciTests.QMTest.check_helpers import has_nan
+assert not has_nan(ntuple, 'TDirectoryName/TTreeName')
+
 print('Test successfully completed!')
 os.system(f"rm {ntuple}")
 os.system(f"rm {ntuple_new}")
-
-countErrorLines({"FATAL":0, "ERROR":0})
   </text></argument>
 </extension>
diff --git a/DaVinciTutorials/tests/qmtest/test_tutorial2_LoKi.qmt b/DaVinciTutorials/tests/qmtest/test_tutorial2_LoKi.qmt
index ed030ea3a1911ce78f9dcc0497e8dba36b01dbe8..a7011f331c702daf82675492d824b6846e277f09 100644
--- a/DaVinciTutorials/tests/qmtest/test_tutorial2_LoKi.qmt
+++ b/DaVinciTutorials/tests/qmtest/test_tutorial2_LoKi.qmt
@@ -1,7 +1,7 @@
 <?xml version="1.0" ?>
 <!--
 ###############################################################################
-# (c) Copyright 2021-2022 CERN for the benefit of the LHCb Collaboration      #
+# (c) Copyright 2021-2023 CERN for the benefit of the LHCb Collaboration      #
 #                                                                             #
 # This software is distributed under the terms of the GNU General Public      #
 # Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING".   #
@@ -25,10 +25,14 @@
   <argument name="error_reference"><text>../refs/empty.ref</text></argument>
   <argument name="validator"><text>
 from DaVinciTests.QMTest.DaVinciExclusions import preprocessor, counter_preprocessor
+
 validateWithReference(preproc = preprocessor, counter_preproc = counter_preprocessor)
 
+countErrorLines({"FATAL":0, "ERROR":0})
+
 import os
 from ROOT import TFile
+
 ntuple  = './tutorial2_LoKi.root'
 #this file should be disabled
 ntuple_new  = './tutorial2_LoKi_new.root'
@@ -38,10 +42,13 @@ t_B    = f.Get('TDirectoryName/TTreeName')
 b_names= [b.GetName() for b in t_B.GetListOfLeaves()]
 if not b_names: raise Exception(f"File: {ntuple} does not contain any branches. Please check.")
 f.Close()
+
+# Check there are no NaN values in the ntuple
+from DaVinciTests.QMTest.check_helpers import has_nan
+assert not has_nan(ntuple, 'TDirectoryName/TTreeName')
+
 print('Test successfully completed!')
 os.system(f"rm {ntuple}")
 os.system(f"rm {ntuple_new}")
-
-countErrorLines({"FATAL":0, "ERROR":0})
   </text></argument>
 </extension>
diff --git a/DaVinciTutorials/tests/qmtest/test_tutorial3_ThOrfunctors.qmt b/DaVinciTutorials/tests/qmtest/test_tutorial3_ThOrfunctors.qmt
index 834793932a1445f9766cea54ba3af51d5a295a49..62d10beeabca2bb6bd7eb663d226d6d8a434fe18 100644
--- a/DaVinciTutorials/tests/qmtest/test_tutorial3_ThOrfunctors.qmt
+++ b/DaVinciTutorials/tests/qmtest/test_tutorial3_ThOrfunctors.qmt
@@ -1,7 +1,7 @@
 <?xml version="1.0" ?>
 <!--
 ###############################################################################
-# (c) Copyright 2021-2022 CERN for the benefit of the LHCb Collaboration      #
+# (c) Copyright 2021-2023 CERN for the benefit of the LHCb Collaboration      #
 #                                                                             #
 # This software is distributed under the terms of the GNU General Public      #
 # Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING".   #
@@ -25,10 +25,14 @@
   <argument name="error_reference"><text>../refs/empty.ref</text></argument>
   <argument name="validator"><text>
 from DaVinciTests.QMTest.DaVinciExclusions import preprocessor, counter_preprocessor
+
 validateWithReference(preproc = preprocessor, counter_preproc = counter_preprocessor)
 
+countErrorLines({"FATAL":0, "ERROR":0})
+
 import os
 from ROOT import TFile
+
 ntuple  = './tutorial3_ThOrfunctors.root'
 #this file should be disabled
 ntuple_new  = './tutorial3_ThOrfunctors_new.root'
@@ -38,10 +42,13 @@ t_B    = f.Get('TDirectoryName/TTreeName')
 b_names= [b.GetName() for b in t_B.GetListOfLeaves()]
 if not b_names: raise Exception(f"File: {ntuple} does not contain any branches. Please check.")
 f.Close()
+
+# Check there are no NaN values in the ntuple
+from DaVinciTests.QMTest.check_helpers import has_nan
+assert not has_nan(ntuple, 'TDirectoryName/TTreeName')
+
 print('Test successfully completed!')
 os.system(f"rm {ntuple}")
 os.system(f"rm {ntuple_new}")
-
-countErrorLines({"FATAL":0, "ERROR":0})
   </text></argument>
 </extension>
diff --git a/DaVinciTutorials/tests/qmtest/test_tutorial4_trigger_eventinfo.qmt b/DaVinciTutorials/tests/qmtest/test_tutorial4_trigger_eventinfo.qmt
index af4192bcb261293508e6d6bc8aa055de7946fbf7..aab87eb37be6574c17627fb70febc2ecb8d07fb2 100644
--- a/DaVinciTutorials/tests/qmtest/test_tutorial4_trigger_eventinfo.qmt
+++ b/DaVinciTutorials/tests/qmtest/test_tutorial4_trigger_eventinfo.qmt
@@ -1,7 +1,7 @@
 <?xml version="1.0" ?>
 <!--
 ###############################################################################
-# (c) Copyright 2021-2022 CERN for the benefit of the LHCb Collaboration      #
+# (c) Copyright 2021-2023 CERN for the benefit of the LHCb Collaboration      #
 #                                                                             #
 # This software is distributed under the terms of the GNU General Public      #
 # Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING".   #
@@ -28,8 +28,11 @@ from DaVinciTests.QMTest.DaVinciExclusions import preprocessor, counter_preproce
 ##validator complains about long TTreeNames so comment out(see https://gitlab.cern.ch/lhcb/DaVinci/-/issues/46)
 #validateWithReference(preproc = preprocessor, counter_preproc = counter_preprocessor)
 
+countErrorLines({"FATAL":0, "ERROR":0})
+
 import os
 from ROOT import TFile
+
 ntuple  = './tutorial4_trigger_eventinfo.root'
 #this file should be disabled
 ntuple_new  = './tutorial4_trigger_eventinfo_new.root'
@@ -39,10 +42,13 @@ t_B    = f.Get('TDirectoryName/TTreeName')
 b_names= [b.GetName() for b in t_B.GetListOfLeaves()]
 if not b_names: raise Exception(f"File: {ntuple} does not contain any branches. Please check.")
 f.Close()
+
+# Check there are no NaN values in the ntuple
+from DaVinciTests.QMTest.check_helpers import has_nan
+assert not has_nan(ntuple, 'TDirectoryName/TTreeName')
+
 print('Test successfully completed!')
 os.system(f"rm {ntuple}")
 os.system(f"rm {ntuple_new}")
-
-countErrorLines({"FATAL":0, "ERROR":0})
   </text></argument>
 </extension>
diff --git a/DaVinciTutorials/tests/qmtest/test_tutorial5_MCTruth.qmt b/DaVinciTutorials/tests/qmtest/test_tutorial5_MCTruth.qmt
index 66978324c03918348c60fa643f63d3faacc0fe63..9b560b0ab4a127a970ccc61e67b9b7c6de27d3cc 100644
--- a/DaVinciTutorials/tests/qmtest/test_tutorial5_MCTruth.qmt
+++ b/DaVinciTutorials/tests/qmtest/test_tutorial5_MCTruth.qmt
@@ -1,7 +1,7 @@
 <?xml version="1.0" ?>
 <!--
 ###############################################################################
-# (c) Copyright 2021-2022 CERN for the benefit of the LHCb Collaboration      #
+# (c) Copyright 2021-2023 CERN for the benefit of the LHCb Collaboration      #
 #                                                                             #
 # This software is distributed under the terms of the GNU General Public      #
 # Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING".   #
@@ -25,10 +25,14 @@
   <argument name="error_reference"><text>../refs/empty.ref</text></argument>
   <argument name="validator"><text>
 from DaVinciTests.QMTest.DaVinciExclusions import preprocessor, counter_preprocessor
+
 validateWithReference(preproc = preprocessor, counter_preproc = counter_preprocessor)
 
+countErrorLines({"FATAL":0, "ERROR":0})
+
 import os
 from ROOT import TFile
+
 ntuple  = './tutorial5_MCTruth.root'
 #this file should be disabled
 ntuple_new  = './tutorial5_MCTruth_new.root'
@@ -38,10 +42,15 @@ t_B    = f.Get('TDirectoryName/TTreeName')
 b_names= [b.GetName() for b in t_B.GetListOfLeaves()]
 if not b_names: raise Exception(f"File: {ntuple} does not contain any branches. Please check.")
 f.Close()
+
+# Check there are no NaN values in the ntuple except where expected.
+from DaVinciTests.QMTest.check_helpers import list_fields_with_nan
+l_branches_with_nans = ['Bs_TRUEP', 'Jpsi_TRUEP', 'Phi_TRUEP', 'Mup_TRUEP', 'Mum_TRUEP', 'Kp_TRUEEPHI', 'Kp_TRUEP', 'Km_TRUEP']
+l_test = list_fields_with_nan(ntuple, 'TDirectoryName/TTreeName')
+assert sorted(l_test) == sorted(l_branches_with_nans)
+
 print('Test successfully completed!')
 os.system(f"rm {ntuple}")
 os.system(f"rm {ntuple_new}")
-
-countErrorLines({"FATAL":0, "ERROR":0})
   </text></argument>
 </extension>
diff --git a/DaVinciTutorials/tests/qmtest/test_tutorial6_DecayTreeFit.qmt b/DaVinciTutorials/tests/qmtest/test_tutorial6_DecayTreeFit.qmt
index 9ce5e4cae2ca2fa385afac4e61bdbdbdb60e1b70..d305ede6a547b308fc384dcff5182e399f111170 100644
--- a/DaVinciTutorials/tests/qmtest/test_tutorial6_DecayTreeFit.qmt
+++ b/DaVinciTutorials/tests/qmtest/test_tutorial6_DecayTreeFit.qmt
@@ -1,7 +1,7 @@
 <?xml version="1.0" ?>
 <!--
 ###############################################################################
-# (c) Copyright 2021-2022 CERN for the benefit of the LHCb Collaboration      #
+# (c) Copyright 2021-2023 CERN for the benefit of the LHCb Collaboration      #
 #                                                                             #
 # This software is distributed under the terms of the GNU General Public      #
 # Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING".   #
@@ -25,11 +25,14 @@
   <argument name="error_reference"><text>../refs/empty.ref</text></argument>
   <argument name="validator"><text>
 from DaVinciTests.QMTest.DaVinciExclusions import preprocessor, counter_preprocessor
+
 validateWithReference(preproc = preprocessor, counter_preproc = counter_preprocessor)
 
+countErrorLines({"FATAL":0, "ERROR":0})
 
 import os
 from ROOT import TFile
+
 ntuple  = './tutorial6_DecayTreeFit.root'
 #this file should be disabled
 ntuple_new  = './tutorial6_DecayTreeFit_new.root'
@@ -39,10 +42,13 @@ t_B    = f.Get('TDirectoryName/TTreeName')
 b_names= [b.GetName() for b in t_B.GetListOfLeaves()]
 if not b_names: raise Exception(f"File: {ntuple} does not contain any branches. Please check.")
 f.Close()
+
+# Check there are no NaN values in the ntuple
+from DaVinciTests.QMTest.check_helpers import has_nan
+assert not has_nan(ntuple, 'TDirectoryName/TTreeName')
+
 print('Test successfully completed!')
 os.system(f"rm {ntuple}")
 os.system(f"rm {ntuple_new}")
-
-countErrorLines({"FATAL":0, "ERROR":0})
   </text></argument>
 </extension>
diff --git a/DaVinciTutorials/tests/qmtest/test_tutorial7_multiple_sel_lines.qmt b/DaVinciTutorials/tests/qmtest/test_tutorial7_multiple_sel_lines.qmt
index 0477d41b042729b21dd1bb4a79327b8c57541b85..2652e12ee367f79c7596e9563feddb709e815493 100644
--- a/DaVinciTutorials/tests/qmtest/test_tutorial7_multiple_sel_lines.qmt
+++ b/DaVinciTutorials/tests/qmtest/test_tutorial7_multiple_sel_lines.qmt
@@ -1,7 +1,7 @@
 <?xml version="1.0" ?>
 <!--
 ###############################################################################
-# (c) Copyright 2021-2022 CERN for the benefit of the LHCb Collaboration      #
+# (c) Copyright 2021-2023 CERN for the benefit of the LHCb Collaboration      #
 #                                                                             #
 # This software is distributed under the terms of the GNU General Public      #
 # Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING".   #
@@ -25,10 +25,14 @@
   <argument name="error_reference"><text>../refs/empty.ref</text></argument>
   <argument name="validator"><text>
 from DaVinciTests.QMTest.DaVinciExclusions import preprocessor, counter_preprocessor
+
 validateWithReference(preproc = preprocessor, counter_preproc = counter_preprocessor)
 
+countErrorLines({"FATAL":0, "ERROR":0})
+
 import os
 from ROOT import TFile
+
 ntuple  = './tutorial7_multiple_sel_lines.root'
 #this file should be disabled
 ntuple_new  = './tutorial7_multiple_sel_lines_new.root'
@@ -41,10 +45,14 @@ b_names_2= [b.GetName() for b in t_B_2.GetListOfLeaves()]
 if not b_names_1: raise Exception(f"File: {ntuple} does not contain any branches. Please check.")
 if not b_names_2: raise Exception(f"File: {ntuple} does not contain any branches. Please check.")
 f.Close()
+
+# Check there are no NaN values in the ntuples
+from DaVinciTests.QMTest.check_helpers import has_nan
+assert not has_nan(ntuple, 'TDirectoryName1/TTreeName1')
+assert not has_nan(ntuple, 'TDirectoryName2/TTreeName2')
+
 print('Test successfully completed!')
 os.system(f"rm {ntuple}")
 os.system(f"rm {ntuple_new}")
-
-countErrorLines({"FATAL":0, "ERROR":0})
   </text></argument>
 </extension>