From 0dca3ed3199d704b11ab0b1c0746185adb625d8e Mon Sep 17 00:00:00 2001
From: Chris Jones <jonesc@hep.phy.cam.ac.uk>
Date: Tue, 18 Oct 2022 14:50:03 +0100
Subject: [PATCH] Add RICH QM test for 2022 data decoding

---
 .../tests/options/2022-data.py                | 28 ++++++
 .../tests/options/rich-decode.py              | 91 +++++++++++++++++++
 .../tests/qmtest/decode.qms/2022-data.qmt     | 25 +++++
 .../tests/refs/decode-2022-data.ref           | 58 ++++++++++++
 .../tests/refs/decode-2022-data.ref.dd4hep    | 58 ++++++++++++
 5 files changed, 260 insertions(+)
 create mode 100644 Rich/RichFutureRecSys/tests/options/2022-data.py
 create mode 100644 Rich/RichFutureRecSys/tests/options/rich-decode.py
 create mode 100644 Rich/RichFutureRecSys/tests/qmtest/decode.qms/2022-data.qmt
 create mode 100644 Rich/RichFutureRecSys/tests/refs/decode-2022-data.ref
 create mode 100644 Rich/RichFutureRecSys/tests/refs/decode-2022-data.ref.dd4hep

diff --git a/Rich/RichFutureRecSys/tests/options/2022-data.py b/Rich/RichFutureRecSys/tests/options/2022-data.py
new file mode 100644
index 00000000000..f820a5b4165
--- /dev/null
+++ b/Rich/RichFutureRecSys/tests/options/2022-data.py
@@ -0,0 +1,28 @@
+from __future__ import print_function
+###############################################################################
+# (c) Copyright 2000-2018 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".   #
+#                                                                             #
+# In applying this licence, CERN does not waive the privileges and immunities #
+# granted to it by virtue of its status as an Intergovernmental Organization  #
+# or submit itself to any jurisdiction.                                       #
+###############################################################################
+
+from Gaudi.Configuration import *
+from GaudiConf import IOHelper
+from Configurables import CondDB, LHCbApp, DDDBConf
+
+data = [
+    "mdf:root://eoslhcb.cern.ch//eos/lhcb/hlt2/LHCb/0000248711/Run_0000248711_HLT20840_20221011-113809-426.mdf"
+]
+IOHelper('MDF').inputFiles(data, clear=True)
+
+LHCbApp().Simulation = True
+LHCbApp().DataType = "Upgrade"
+CondDB().setProp("Upgrade", True)
+from DDDB.CheckDD4Hep import UseDD4Hep
+if not UseDD4Hep:
+    LHCbApp().DDDBtag = "upgrade/master"
+    LHCbApp().CondDBtag = "upgrade/master"
diff --git a/Rich/RichFutureRecSys/tests/options/rich-decode.py b/Rich/RichFutureRecSys/tests/options/rich-decode.py
new file mode 100644
index 00000000000..fe5aa98ce04
--- /dev/null
+++ b/Rich/RichFutureRecSys/tests/options/rich-decode.py
@@ -0,0 +1,91 @@
+###############################################################################
+# (c) Copyright 2000-2018 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".   #
+#                                                                             #
+# In applying this licence, CERN does not waive the privileges and immunities #
+# granted to it by virtue of its status as an Intergovernmental Organization  #
+# or submit itself to any jurisdiction.                                       #
+###############################################################################
+
+# --------------------------------------------------------------------------------------
+
+from Gaudi.Configuration import *
+from Configurables import GaudiSequencer
+from Configurables import Gaudi__Hive__FetchDataFromFile as FetchDataFromFile
+from Configurables import LHCb__UnpackRawEvent as UnpackRawEvent
+from Configurables import createODIN
+from Configurables import Rich__Future__RawBankDecoder as RichDecoder
+from Configurables import Rich__Future__SmartIDClustering as RichClustering
+from Configurables import Rich__Future__Rec__SIMDSummaryPixels as RichSIMDPixels
+from Configurables import Rich__Future__Rec__Moni__DetectorHits as DetectorHits
+
+# Event numbers
+nEvents = 100
+EventSelector().PrintFreq = 10
+
+# Auditors
+AuditorSvc().Auditors += ["FPEAuditor"]
+from Configurables import FPEAuditor
+
+FPEAuditor().ActivateAt = ["Execute"]
+
+# The overall sequence. Filled below.
+all = GaudiSequencer("All", MeasureTime=True)
+
+# Finally set up the application
+app = ApplicationMgr(
+    TopAlg=[all],
+    EvtMax=nEvents,  # events to be processed
+    ExtSvc=['ToolSvc', 'AuditorSvc'],
+    AuditAlgorithms=True)
+
+# Are we using DD4Hep ?
+from DDDB.CheckDD4Hep import UseDD4Hep
+if UseDD4Hep:
+    from Configurables import LHCb__Det__LbDD4hep__DD4hepSvc as DD4hepSvc
+    dd4hep = DD4hepSvc(DetectorList=["/world", "Magnet", "Rich1", "Rich2"])
+    app.ExtSvc += [dd4hep]
+
+# --------------------------------------------------------------------------------------
+
+# Fetch required data from file
+fetcher = FetchDataFromFile('FetchDSTData')
+fetcher.DataKeys = ['Trigger/RawEvent', 'Rich/RawEvent']
+all.Members += [fetcher]
+
+# First various raw event decodings
+
+# Unpack the ODIN raw event
+all.Members += [
+    UnpackRawEvent(
+        'UnpackODIN',
+        BankTypes=['ODIN'],
+        RawEventLocation='DAQ/RawEvent',
+        RawBankLocations=['DAQ/RawBanks/ODIN'])
+]
+
+odinDecode = createODIN("ODINDecode")
+all.Members += [odinDecode]
+
+if UseDD4Hep:
+    from Configurables import LHCb__Det__LbDD4hep__IOVProducer as IOVProducer
+    all.Members += [
+        IOVProducer(
+            "ReserveIOVDD4hep",
+            ODIN=odinDecode.ODIN,
+            SliceLocation="IOVLockDD4hep")
+    ]
+
+richDecode = RichDecoder("RichDecode")
+all.Members += [richDecode]
+
+clusters = RichClustering("RichClustering")
+all.Members += [clusters]
+
+simdPixs = RichSIMDPixels("SIMDPixels")
+all.Members += [simdPixs]
+
+pixMon = DetectorHits("RichRecPixelQC")
+all.Members += [pixMon]
diff --git a/Rich/RichFutureRecSys/tests/qmtest/decode.qms/2022-data.qmt b/Rich/RichFutureRecSys/tests/qmtest/decode.qms/2022-data.qmt
new file mode 100644
index 00000000000..0dfb6ca3437
--- /dev/null
+++ b/Rich/RichFutureRecSys/tests/qmtest/decode.qms/2022-data.qmt
@@ -0,0 +1,25 @@
+<?xml version="1.0" ?><!DOCTYPE extension  PUBLIC '-//QM/2.3/Extension//EN'  'http://www.codesourcery.com/qm/dtds/2.3/-//qm/2.3/extension//en.dtd'>
+<!--
+    (c) Copyright 2000-2018 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".
+
+    In applying this licence, CERN does not waive the privileges and immunities
+    granted to it by virtue of its status as an Intergovernmental Organization
+    or submit itself to any jurisdiction.
+-->
+<extension class="GaudiTest.GaudiExeTest" kind="test">
+  <argument name="program"><text>gaudirun.py</text></argument>
+  <argument name="timeout"><integer>1200</integer></argument>
+  <argument name="args"><set>
+    <text>$RICHFUTURERECSYSROOT/tests/options/rich-decode.py</text>
+    <text>$RICHFUTURERECSYSROOT/tests/options/2022-data.py</text>
+  </set></argument>
+  <argument name="reference"><text>../refs/decode-2022-data.ref</text></argument>
+  <argument name="error_reference"><text>../refs/empty.ref</text></argument>
+  <argument name="validator"><text>
+from GaudiConf.QMTest.LHCbExclusions import preprocessor
+validateWithReference(preproc = preprocessor)
+</text></argument>
+</extension>
diff --git a/Rich/RichFutureRecSys/tests/refs/decode-2022-data.ref b/Rich/RichFutureRecSys/tests/refs/decode-2022-data.ref
new file mode 100644
index 00000000000..79de96a935f
--- /dev/null
+++ b/Rich/RichFutureRecSys/tests/refs/decode-2022-data.ref
@@ -0,0 +1,58 @@
+ApplicationMgr    SUCCESS
+====================================================================================================================================
+====================================================================================================================================
+ApplicationMgr       INFO Application Manager Configured successfully
+DetectorPersist...   INFO Added successfully Conversion service:XmlCnvSvc
+DetectorDataSvc   SUCCESS Detector description database: git:/lhcb.xml
+All                  INFO Member list: Gaudi::Hive::FetchDataFromFile/FetchDSTData, LHCb::UnpackRawEvent/UnpackODIN, createODIN/ODINDecode, Rich::Future::RawBankDecoder/RichDecode, Rich::Future::SmartIDClustering/RichClustering, Rich::Future::Rec::SIMDSummaryPixels/SIMDPixels, Rich::Future::Rec::Moni::DetectorHits/RichRecPixelQC
+RndmGenSvc.Engine    INFO Generator engine type:CLHEP::RanluxEngine
+RndmGenSvc.Engine    INFO Current Seed:1234567 Luxury:3
+RndmGenSvc           INFO Using Random engine:HepRndm::Engine<CLHEP::RanluxEngine>
+ToolSvc.RichPar...   INFO Particle types considered = [electron, muon, pion, kaon, proton, deuteron, below_threshold]
+IODataManager       ERROR Referring to existing dataset mdf:root://eoslhcb.cern.ch//eos/lhcb/hlt2/LHCb/0000248711/Run_0000248711_HLT20840_20221011-113809-426.mdf by its physical name.
+IODataManager       ERROR You may not be able to navigate back to the input file -- processing continues
+ApplicationMgr       INFO Application Manager Initialized successfully
+ApplicationMgr       INFO Application Manager Started successfully
+EventSelector.D...   INFO Compression:0 Checksum:0
+EventSelector     SUCCESS Reading Event record 1. Record number within stream 1: 1
+EventPersistenc...   INFO Added successfully Conversion service:RootCnvSvc
+EventPersistenc...   INFO Added successfully Conversion service:LHCb::RawDataCnvSvc
+EventSelector     SUCCESS Reading Event record 11. Record number within stream 1: 11
+EventSelector     SUCCESS Reading Event record 21. Record number within stream 1: 21
+EventSelector     SUCCESS Reading Event record 31. Record number within stream 1: 31
+EventSelector     SUCCESS Reading Event record 41. Record number within stream 1: 41
+EventSelector     SUCCESS Reading Event record 51. Record number within stream 1: 51
+EventSelector     SUCCESS Reading Event record 61. Record number within stream 1: 61
+EventSelector     SUCCESS Reading Event record 71. Record number within stream 1: 71
+EventSelector     SUCCESS Reading Event record 81. Record number within stream 1: 81
+EventSelector     SUCCESS Reading Event record 91. Record number within stream 1: 91
+ApplicationMgr       INFO Application Manager Stopped successfully
+EventLoopMgr         INFO Histograms converted successfully according to request.
+ToolSvc              INFO Removing all tools created by ToolSvc
+ApplicationMgr       INFO Application Manager Finalized successfully
+ApplicationMgr       INFO Application Manager Terminated successfully
+RichClustering       INFO Number of counters : 1
+ |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+ | "No DePD object found for decoded channel ID"   |         4 |
+RichRecPixelQC    SUCCESS 1D histograms in directory "RICH/RichRecPixelQC" : 20
+ | ID                        |   Title                                       |    #    |     Mean   |    RMS     |  Skewness  |  Kurtosis  |
+ | Rich1/bottom/pixXGlo      | "Rich1 bottom Global X hits"                  |  48590  |    -7.1318 | 237.48     |   0.070755 |     0.1685 |
+ | Rich1/bottom/pixYGlo      | "Rich1 bottom Global Y hits"                  |  48590  |    -1361.6 | 67.406     |   -0.90512 |    0.40719 |
+ | Rich1/nActiveModules      | "Rich1 # Active PD Modules (nHits>0)"         |   100   |      84.13 | 29.264     |   -0.58639 |    -0.6091 |
+ | Rich1/nActivePDs          | "Rich1 # Active PDs (nHits>0)"                |   100   |     365.71 | 270.07     |    0.74883 |   -0.20499 |
+ | Rich1/nTotalPixs          | "Rich1 Overall occupancy (nHits>0)"           |   100   |     971.85 | 998.75     |     1.4935 |     2.0285 |
+ | Rich1/nTotalPixsPerPD     | "Rich1 Average overall PD occupancy (nHits>0) |  36571  |     2.6574 | 2.8133     |     2.7988 |     11.427 |
+ | Rich1/pixXLoc             | "Rich1 Local X hits"                          |  97185  | -0.0027776 | 236.43     |  -0.020491 |    0.15322 |
+ | Rich1/pixYLoc             | "Rich1 Local Y hits"                          |  97185  |    0.10756 | 258.98     |  0.0059156 |   -0.75145 |
+ | Rich1/top/pixXGlo         | "Rich1 top Global X hits"                     |  48595  |     7.1255 | 235.16     |   -0.11368 |    0.20068 |
+ | Rich1/top/pixYGlo         | "Rich1 top Global Y hits"                     |  48595  |     1361.7 | 68.186     |     0.8437 |    0.35607 |
+ | Rich2/ASide-left/pixXGlo  | "Rich2 ASide-left Global X hits"              |  54761  |     3900.5 | 85.513     |   -0.10252 |   -0.97041 |
+ | Rich2/ASide-left/pixYGlo  | "Rich2 ASide-left Global Y hits"              |  54761  |      10.02 | 306.8      |   0.021311 |   -0.41272 |
+ | Rich2/CSide-right/pixXGlo | "Rich2 CSide-right Global X hits"             |  54309  |    -3902.2 | 85.525     |    0.10848 |   -0.94471 |
+ | Rich2/CSide-right/pixYGlo | "Rich2 CSide-right Global Y hits"             |  54309  |     12.315 | 313.16     |   0.002616 |   -0.52723 |
+ | Rich2/nActiveModules      | "Rich2 # Active PD Modules (nHits>0)"         |   100   |     118.55 | 34.643     |    -1.3935 |    0.85603 |
+ | Rich2/nActivePDs          | "Rich2 # Active PDs (nHits>0)"                |   100   |     486.51 | 301.65     |   0.062544 |    -1.2409 |
+ | Rich2/nTotalPixs          | "Rich2 Overall occupancy (nHits>0)"           |   100   |     1090.7 | 1016.8     |     1.5552 |     3.4898 |
+ | Rich2/nTotalPixsPerPD     | "Rich2 Average overall PD occupancy (nHits>0) |  48651  |     2.2419 | 1.8495     |     2.5593 |     10.805 |
+ | Rich2/pixXLoc             | "Rich2 Local X hits"                          |  109070 |     1.2668 | 403.46     |  -0.005567 |    -1.3704 |
+ | Rich2/pixYLoc             | "Rich2 Local Y hits"                          |  109070 |     11.101 | 309.99     |   0.020188 |   -0.47631 |
diff --git a/Rich/RichFutureRecSys/tests/refs/decode-2022-data.ref.dd4hep b/Rich/RichFutureRecSys/tests/refs/decode-2022-data.ref.dd4hep
new file mode 100644
index 00000000000..de26debf811
--- /dev/null
+++ b/Rich/RichFutureRecSys/tests/refs/decode-2022-data.ref.dd4hep
@@ -0,0 +1,58 @@
+ApplicationMgr    SUCCESS
+====================================================================================================================================
+====================================================================================================================================
+ApplicationMgr       INFO Application Manager Configured successfully
+LHCb::Det::LbDD...   INFO Field map location: DBASE/FieldMap/vXrYpZ/cdf
+All                  INFO Member list: Gaudi::Hive::FetchDataFromFile/FetchDSTData, LHCb::UnpackRawEvent/UnpackODIN, createODIN/ODINDecode, LHCb::Det::LbDD4hep::IOVProducer/ReserveIOVDD4hep, Rich::Future::RawBankDecoder/RichDecode, Rich::Future::SmartIDClustering/RichClustering, Rich::Future::Rec::SIMDSummaryPixels/SIMDPixels, Rich::Future::Rec::Moni::DetectorHits/RichRecPixelQC
+RndmGenSvc.Engine    INFO Generator engine type:CLHEP::RanluxEngine
+RndmGenSvc.Engine    INFO Current Seed:1234567 Luxury:3
+RndmGenSvc           INFO Using Random engine:HepRndm::Engine<CLHEP::RanluxEngine>
+ToolSvc.RichPar...   INFO Particle types considered = [electron, muon, pion, kaon, proton, deuteron, below_threshold]
+IODataManager       ERROR Referring to existing dataset mdf:root://eoslhcb.cern.ch//eos/lhcb/hlt2/LHCb/0000248711/Run_0000248711_HLT20840_20221011-113809-426.mdf by its physical name.
+IODataManager       ERROR You may not be able to navigate back to the input file -- processing continues
+ApplicationMgr       INFO Application Manager Initialized successfully
+ApplicationMgr       INFO Application Manager Started successfully
+EventSelector.D...   INFO Compression:0 Checksum:0
+EventSelector     SUCCESS Reading Event record 1. Record number within stream 1: 1
+EventPersistenc...   INFO Added successfully Conversion service:RootCnvSvc
+EventPersistenc...   INFO Added successfully Conversion service:LHCb::RawDataCnvSvc
+DeMagnetConditi...   INFO Loading mag field from DBASE/FieldMap/vXrYpZ/cdf
+MagneticFieldEx...   INFO Scale factor: 0.999983
+EventSelector     SUCCESS Reading Event record 11. Record number within stream 1: 11
+EventSelector     SUCCESS Reading Event record 21. Record number within stream 1: 21
+EventSelector     SUCCESS Reading Event record 31. Record number within stream 1: 31
+EventSelector     SUCCESS Reading Event record 41. Record number within stream 1: 41
+EventSelector     SUCCESS Reading Event record 51. Record number within stream 1: 51
+EventSelector     SUCCESS Reading Event record 61. Record number within stream 1: 61
+EventSelector     SUCCESS Reading Event record 71. Record number within stream 1: 71
+EventSelector     SUCCESS Reading Event record 81. Record number within stream 1: 81
+EventSelector     SUCCESS Reading Event record 91. Record number within stream 1: 91
+ApplicationMgr       INFO Application Manager Stopped successfully
+EventLoopMgr         INFO Histograms converted successfully according to request.
+ApplicationMgr       INFO Application Manager Finalized successfully
+ApplicationMgr       INFO Application Manager Terminated successfully
+RichClustering       INFO Number of counters : 1
+ |    Counter                                      |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |
+ | "No DePD object found for decoded channel ID"   |         4 |
+RichRecPixelQC    SUCCESS 1D histograms in directory "RICH/RichRecPixelQC" : 20
+ | ID                        |   Title                                       |    #    |     Mean   |    RMS     |  Skewness  |  Kurtosis  |
+ | Rich1/bottom/pixXGlo      | "Rich1 bottom Global X hits"                  |  48590  |    -7.1318 | 237.48     |   0.070755 |     0.1685 |
+ | Rich1/bottom/pixYGlo      | "Rich1 bottom Global Y hits"                  |  48590  |    -1361.6 | 67.406     |   -0.90512 |    0.40719 |
+ | Rich1/nActiveModules      | "Rich1 # Active PD Modules (nHits>0)"         |   100   |      84.13 | 29.264     |   -0.58639 |    -0.6091 |
+ | Rich1/nActivePDs          | "Rich1 # Active PDs (nHits>0)"                |   100   |     365.71 | 270.07     |    0.74883 |   -0.20499 |
+ | Rich1/nTotalPixs          | "Rich1 Overall occupancy (nHits>0)"           |   100   |     971.85 | 998.75     |     1.4935 |     2.0285 |
+ | Rich1/nTotalPixsPerPD     | "Rich1 Average overall PD occupancy (nHits>0) |  36571  |     2.6574 | 2.8133     |     2.7988 |     11.427 |
+ | Rich1/pixXLoc             | "Rich1 Local X hits"                          |  97185  | -0.0027776 | 236.43     |  -0.020491 |    0.15322 |
+ | Rich1/pixYLoc             | "Rich1 Local Y hits"                          |  97185  |    0.10756 | 258.98     |  0.0059156 |   -0.75145 |
+ | Rich1/top/pixXGlo         | "Rich1 top Global X hits"                     |  48595  |     7.1255 | 235.16     |   -0.11368 |    0.20068 |
+ | Rich1/top/pixYGlo         | "Rich1 top Global Y hits"                     |  48595  |     1361.7 | 68.186     |     0.8437 |    0.35607 |
+ | Rich2/ASide-left/pixXGlo  | "Rich2 ASide-left Global X hits"              |  54761  |     3900.5 | 85.513     |   -0.10252 |   -0.97041 |
+ | Rich2/ASide-left/pixYGlo  | "Rich2 ASide-left Global Y hits"              |  54761  |      10.02 | 306.8      |   0.021311 |   -0.41272 |
+ | Rich2/CSide-right/pixXGlo | "Rich2 CSide-right Global X hits"             |  54309  |    -3902.2 | 85.525     |    0.10848 |   -0.94471 |
+ | Rich2/CSide-right/pixYGlo | "Rich2 CSide-right Global Y hits"             |  54309  |     12.315 | 313.16     |   0.002616 |   -0.52723 |
+ | Rich2/nActiveModules      | "Rich2 # Active PD Modules (nHits>0)"         |   100   |     118.55 | 34.643     |    -1.3935 |    0.85603 |
+ | Rich2/nActivePDs          | "Rich2 # Active PDs (nHits>0)"                |   100   |     486.51 | 301.65     |   0.062544 |    -1.2409 |
+ | Rich2/nTotalPixs          | "Rich2 Overall occupancy (nHits>0)"           |   100   |     1090.7 | 1016.8     |     1.5552 |     3.4898 |
+ | Rich2/nTotalPixsPerPD     | "Rich2 Average overall PD occupancy (nHits>0) |  48651  |     2.2419 | 1.8495     |     2.5593 |     10.805 |
+ | Rich2/pixXLoc             | "Rich2 Local X hits"                          |  109070 |     1.5009 | 454.94     | -0.0062755 |    -1.4906 |
+ | Rich2/pixYLoc             | "Rich2 Local Y hits"                          |  109070 |     11.101 | 309.99     |   0.020188 |   -0.47631 |
-- 
GitLab