ATLAS Offline Software
EndOfEvent.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 """Code to setup MET reconstruction during the end-of-event sequence"""
3 
4 from typing import List
5 
6 from AthenaCommon.CFElements import parOR
7 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
8 from .ConfigHelpers import AlgConfig, stringToMETRecoDict
9 from ..CommonSequences.FullScanDefs import caloFSRoI, trkFSRoI
10 
11 
12 _algs_by_purpose = {
13  "metcalo": ["cell", "tcpufit", "tcpufit_sig30"],
14  "mettrk": [
15  "pfopufit",
16  "pfsum",
17  "pfsum_vssk",
18  "pfsum_cssk",
19  "trkmht",
20  "mhtpufit_pf",
21  "mhtpufit_em",
22  "pfopufit_sig30",
23  "nn",
24  ],
25 }
26 
27 
28 def getMETRecoSequences(flags, purposes: List[str]):
29  """Create the full reconstruction sequences to run at the end of the event
30 
31  Parameters
32  ----------
33  purposes : List[str]
34  The purpose keys given in the associated acceptedevts chain
35 
36  Returns
37  -------
38  An OR containing the configured algorithms
39  A list of the required RoIs
40  A list of the required streams
41  """
42  ef_reco_algs = []
43  for purpose in purposes:
44  ef_reco_algs += [
45  alg for alg in _algs_by_purpose.get(purpose, []) if alg not in ef_reco_algs
46  ]
47  seqname = f"{''.join(purposes)}EndOfEventRecoSequence"
48 
49  merged_ca = ComponentAccumulator()
50  merged_ca.addSequence(parOR(seqname), primary=True)
51  max_step_idx = 0
52  for alg in ef_reco_algs:
53  cfg = AlgConfig.fromRecoDict(**stringToMETRecoDict(alg))
54  step_output = cfg.make_reco_algs(flags, **cfg.interpret_reco_dict())
55  max_step_idx = max(max_step_idx, step_output.max_step_idx)
56  for ca in step_output.steps:
57  merged_ca.merge(ca, seqname)
58 
59  rois = [caloFSRoI]
60  if max_step_idx > 1:
61  # If we have more than one step then we also need the FS tracking RoI
62  rois.append(trkFSRoI)
63 
64  streams = ["Main", "VBFDelayed"]
65  return merged_ca, rois, streams
max
#define max(a, b)
Definition: cfImp.cxx:41
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.HLT.MET.EndOfEvent.getMETRecoSequences
def getMETRecoSequences(flags, List[str] purposes)
Definition: EndOfEvent.py:28
python.JetAnalysisCommon.parOR
parOR
Definition: JetAnalysisCommon.py:271
python.HLT.MET.ConfigHelpers.stringToMETRecoDict
dict[str, Any] stringToMETRecoDict(str string, bool onlyRecoKeys=False)
Definition: ConfigHelpers.py:74