ATLAS Offline Software
Loading...
Searching...
No Matches
testTrigR2ToR3NavDAOD.py
Go to the documentation of this file.
1#!/usr/bin/env python
2#
3# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
4#
5# Test script for NavigationDAODTesterAlgv2 - verifies R2 to R3 navigation conversion on DAOD level.
6
7if __name__ == "__main__":
8 import sys
9 # Set the Athena configuration flags
10 from AthenaConfiguration.AllConfigFlags import initConfigFlags
11 flags = initConfigFlags()
12 # flags.Exec.VerboseMessageComponents = ["*Trigger*"] # uncomment for debugging
13
14 # Input DAOD: the file must contain the R2 TrigMatch_<chain> branches AND
15 # the R2->R3 converted HLTNav_Summary_DAODSlimmed branch. No central file
16 # can serve as a default input: set the path here or on the command line
17 # (--filesInput=<file>, handled by flags.fillFromArgs()).
18 flags.Input.Files = [""]
19 flags.Exec.MaxEvents = -1
20 flags.Exec.SkipEvents = 0
21 flags.Common.MsgSuppression = False
22 flags.fillFromArgs()
23 flags.lock()
24
25 # Initialize main services and merge necessary configurations.
26 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
27 from AthenaConfiguration.ComponentFactory import CompFactory
28 # from AthenaCommon.Constants import DEBUG # for the optional debug OutputLevel below
29
30 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
31 cfg = MainServicesCfg(flags)
32 cfg.merge(PoolReadCfg(flags))
33
34 from EventBookkeeperTools.EventBookkeeperToolsConfig import CutFlowSvcCfg
35 cfg.merge(CutFlowSvcCfg(flags))
36
37 # MetaDataSvc is scheduled by TrigDecisionToolCfg, no need to add it explicitly.
38
39 # Obtain the default Trigger Decision Tool (configured from the file metadata).
40 # HLTSummary and NavigationFormat are auto-configured by TrigDecisionToolCfg.
41 from TrigDecisionTool.TrigDecisionToolConfig import TrigDecisionToolCfg
42 tdt = cfg.getPrimaryAndMerge(TrigDecisionToolCfg(flags))
43
44 # Create matching and composite tools
45 r3MatchingTool = CompFactory.Trig.R3MatchingTool("R3MatchingTool")
46 r3MatchingTool.TrigDecisionTool = tdt
47 # Subfeatures OFF while confirming R2 == R3 equivalence. The TrigMatch
48 # branches only contain the primary (highest-pT) feature, so the R3 side
49 # must use the primary feature only for a like-for-like comparison.
50 r3MatchingTool.IncludeSubfeatures = False
51
52 matchFromCompositeTool = CompFactory.Trig.MatchFromCompositeTool("MatchFromCompositeTool")
53 matchFromCompositeTool.InputPrefix = "TrigMatch_"
54 # Pointer/shallow equality for the R2 match (DRThreshold < 0 disables DR
55 # matching), following the physics-analysis usage of MatchFromCompositeTool.
56 matchFromCompositeTool.DRThreshold = -1
57 matchFromCompositeTool.MatchShallow = True
58
59
60 # Select triggers to test - the definitive list comes from the FILE itself:
61 # every TrigMatch_<chain> container in the DAOD is a chain with a pre-stored
62 # R2 matching reference to compare against.
63 # Do NOT select the list via TriggerListsHelper + flags.Trigger.EDMVersion:
64 # a converted DAOD reports EDMVersion 3 ("HLTNav_Summary.* found in POOL
65 # file"), so the helper returns the Run-3 menu names, none of which exist
66 # in a Run-2 file -> a full sweep would vacuously pass (found 2026-06-12).
67 list_triggers = sorted(c[len("TrigMatch_"):] for c in flags.Input.Collections
68 if c.startswith("TrigMatch_"))
69
70 print("########################### Testing triggers:", list_triggers)
71
72 # Note: a single R3-configured TDT is sufficient when running from a DAOD -
73 # the converted navigation is already in the file, there is no Run2 payload
74 # left, so no separate Run2/Run3 TDT pair is needed (unlike the AOD test).
75
76 # --- Create NavigationDAODTesterAlgv2 ---
77 # This algorithm compares R2 (from pre-stored composites) and R3 (from converted navigation)
78 # matching results for offline physics objects.
79
80 checker = CompFactory.Trig.NavigationDAODTesterAlgv2(
81 TrigDecisionTool = tdt,
82 R3MatchingTool = r3MatchingTool,
83 MatchFromCompositeTool = matchFromCompositeTool,
84 # Exception list: chains for which the R2/R3 comparison CANNOT succeed
85 # by construction (substring match against chain names).
86 # 1) Chains listed in the converter's SpecialCases.h excludedChains are
87 # deliberately NOT converted: isPassed (decision bits) stays true and
88 # the R2 TrigMatch reference exists, but the R3 navigation is
89 # intentionally absent -> a guaranteed, EXPECTED "R2 passes R3 fails".
90 # Keep this list in sync with SpecialCases.h.
91 # Note: "nomucomb" itself no longer needs excluding - its linearised
92 # TrigMatch layout is handled by the per-object path
93 # (ChainsWithLinearisedR2Matching, default ["nomucomb"]).
94 ChainsToExclude = [
95 # === SpecialCases.h excludedChains (not converted by design) ===
96 "HLT_mu20_msonly_mu6noL1_msonly_nscan05",
97 "HLT_mu6_dRl1_mu20_msonly_iloosems_mu6noL1_dRl1_msonly",
98 "HLT_g45_loose_6j45_0eta240",
99 "HLT_mu18_2mu4_JpsimumuL2",
100 "HLT_mu18_2mu0noL1_JpsimumuFS",
101 "HLT_mu20_2mu0noL1_JpsimumuFS",
102 "HLT_mu20_2mu2noL1_JpsimumuFS",
103 "HLT_mu20_2mu4_JpsimumuL2",
104 "HLT_mu20_2mu4noL1",
105 "HLT_2mu4_bJpsimumu",
106 "HLT_2mu4_bUpsimumu",
107 "HLT_2mu6_bJpsimumu", # also matches the _delayed variants
108 "HLT_2mu6_bUpsimumu", # also matches the _delayed variants
109 "HLT_mu11_nomucomb_2mu4noL1_nscan03_L1MU11_2MU6", # also matches _bTau
110 # === known open issues, deferred to a follow-up (substring match) ===
111 # 2) The muon noL1 family: the noL1 leg is a full-scan reconstruction
112 # with a joint MultiComb hypo deciding all thresholds at once, so
113 # Run 2 stores no per-leg structure to convert; in addition the R2
114 # TrigMatch reference is often empty for these chains. Note that
115 # the plain 2mu4noL1 chains (mu18_2mu4noL1, mu11_2mu4noL1_nscan03*)
116 # validate cleanly and stay in the test.
117 "mu8noL1", # mu18/mu20/mu22/mu20_ivarmedium + e24/e26 variants
118 "mu6noL1_nscan03", # l2idonly / nomucomb / mu11_bTau variants
119 "msonly_nscan05", # mu20_msonly_mu10noL1 / mu15noL1 variants
120 # 3) Individual chains with unresolved chain-level disagreements:
121 "HLT_e26_lhtight_nod0_e15_etcut_L1EM7_Zee", # etcut leg + Zee topological special case
122 "HLT_2mu6_10invm30_pt2_z10", # invariant-mass selection
123 ],
124
125 PrintSubfeatures = False) # set True (+ OutputLevel = DEBUG) to inspect subfeatures
126 checker.Chains = list_triggers
127
128 cfg.addEventAlgo(checker)
129
130
131 # Alter the MessageSvc output.
132 msg = cfg.getService('MessageSvc')
133 msg.Format = '% F%35W%C% F%9W%e%7W%R%T %0W%M'
134
135 cfg.printConfig(withDetails=True, summariseProps=False)
136 sc = cfg.run()
137 sys.exit(0 if sc.isSuccess() else 1)
void print(char *figname, TCanvas *c1)