Skip to content
Snippets Groups Projects

Added Allen SelReports writer to allen control flow. Added a test of same.

Merged Patrick Spradlin requested to merge spradlin-202110Oct11-allen_sel_reps into master
6 files
+ 173
11
Compare changes
  • Side-by-side
  • Inline
Files
6
###############################################################################
# (c) Copyright 2000-2021 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. #
###############################################################################
"""Check the consistency of the line decisions and presence of SelReport
Takes two outputs from previously-run jobs:
1. The MDF
2. The TCK in TCKData/config.cdb
For each line with a decision in the DecReport, the presence of a
corresponding SelReport is checked.
Two error conditions are recognized and considered failures of the test:
- A positive line decision without a corresponding SelReport
- A SelReport for a line with a negative decision
"""
from __future__ import print_function
import argparse
from collections import defaultdict
from Configurables import (ApplicationMgr, HistogramPersistencySvc,
IODataManager, LHCbApp, ConfigCDBAccessSvc)
from DAQSys.Decoders import DecoderDB
from GaudiConf import IOHelper
import GaudiPython
from Moore.config import setup_ann_service, get_allen_hlt1_decision_ids
parser = argparse.ArgumentParser()
parser.add_argument("--input-mdf", help="Input MDF file")
args = parser.parse_args()
# Setup ANNsvc defaults (for TCK 0)
hlt1_decision_ids = get_allen_hlt1_decision_ids()
setup_ann_service(hlt1_decision_ids, {}, {})
# Configure basic application with inputs
LHCbApp(DataType="Upgrade", Simulation=True)
IOHelper("MDF").inputFiles([args.input_mdf])
# Disable warning about not being able to navigate ancestors
IODataManager(DisablePFNWarning=True)
# Disable warning about histogram saving not being required
HistogramPersistencySvc(OutputLevel=5)
# Decode Hlt DecReports
ApplicationMgr(TopAlg=[
DecoderDB["HltDecReportsDecoder/Hlt1DecReportsDecoder"].setup(),
DecoderDB["HltSelReportsDecoder/Hlt1SelReportsDecoder"].setup()
])
ConfigCDBAccessSvc().File = "TCKData/config.cdb"
# Set up counters for recording decisions and selreport existence from MDF
counts_from_mdf = defaultdict(lambda: defaultdict(int))
gaudi = GaudiPython.AppMgr()
TES = gaudi.evtSvc()
gaudi.run(1)
error = False
while TES["/Event"]:
decs = TES["/Event/Hlt1/DecReports"]
if not decs:
print("DecReports TES location not found")
error = True
break
sels = TES["/Event/Hlt1/SelReports"]
if not sels:
print("SelReports TES location not found")
error = True
break
for key in decs.decisionNames():
report = decs.decReport(key)
decision = report.decision()
hassel = sels.hasSelectionName(key)
counts_from_mdf[key][(decision, hassel)] += 1
gaudi.run(1)
# Check for any inconsistent instances:
missing_sel = (1, False) # Event accepted by line without a SelReport
extra_sel = (0, True) # SelReport for a line that did not accept the event
for key in counts_from_mdf.keys():
counters = counts_from_mdf[key]
line_name = key
if missing_sel in counters.keys():
error = True
print("Test ERROR: Missing SelReport for {}".format(line_name))
if extra_sel in counters.keys():
error = True
print("Test ERROR: Spurious SelReport for {}".format(line_name))
print("Coincidence counts for {}: {}".format(line_name, counters))
if error:
exit("Test failed") # exit with a non-zero code
Loading