ATLAS Offline Software
Loading...
Searching...
No Matches
CheckCPSGroups.py
Go to the documentation of this file.
1# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
2
3"""
4Validation of Coherent Prescale Groups
5- Python check that all Coherent Prescale group assignments are reasonable
6- Allows early failure in the case of invalid groups, such as:
7 - Only one chain in CPS group
8 - Multiple L1 inputs for same CPS group
9 - CPS group not matching L1 name
10
11Author: Teng Jian Khoo
12"""
13
14__doc__="Validation of coherent prescales set on the list of chains"
15
16from AthenaCommon.Logging import logging
17log = logging.getLogger(__name__)
18
19def checkCPSGroups(chainDicts):
20
21 cps_to_chain = {}
22 for hlt in chainDicts:
23 # Extract all CPS items
24 for group in hlt["groups"]:
25 if 'CPS' in group:
26 # Add if not existing
27 if group not in cps_to_chain:
28 cps_to_chain[group] = []
29 cps_to_chain[group].append(hlt)
30
31 CPS_OK = True
32 for CPS_group, HLT_list in cps_to_chain.items():
33 CPS_item = CPS_group.split('CPS_',1)[1]
34
35 if not CPS_group.startswith('RATE:CPS'):
36 log.error("Malformed CPS group %s", CPS_group)
37 CPS_OK = False
38
39 # Checks for each CPS item
40 if len(HLT_list)<2:
41 log.error("CPS group %s contains too few chains %s", CPS_group, [hlt['chainName'] for hlt in HLT_list])
42 CPS_OK = False
43
44 for grp in hlt['groups']:
45 if 'Primary' in grp:
46 log.error("Primary trigger '%s' in CPS %s", hlt['chainName'], CPS_group)
47 CPS_OK = False
48
49 # Verify L1 item matches CPS group
50 if ',' in hlt['L1item']:
51 if CPS_item != hlt['name'].rsplit('_L1')[1]:
52 log.error("CPS group %s for HLT chain %s does not match mult-seed L1 item %s", CPS_group, hlt['chainName'], hlt['name'].rsplit('_L1')[1])
53 CPS_OK = False
54 # Checks CPS for multi-seed items
55 else:
56 if CPS_item != hlt['L1item'][3:]:
57 log.error("CPS group %s for HLT chain %s does not match L1 item %s", CPS_group, hlt['chainName'], hlt['L1item'])
58 CPS_OK = False
59 # Passing this check also implies that there is exactly 1 L1 for the CPS group
60
61 if not CPS_OK:
62 raise Exception("Invalid CPS group assignments found")
checkCPSGroups(chainDicts)