ATLAS Offline Software
Trig_reco_tf.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2 
3 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4 
5 
8 
9 import sys
10 import time
11 
12 from PyJobTransforms.transform import transform
13 from PyJobTransforms.trfExe import athenaExecutor, DQMergeExecutor
14 from PyJobTransforms.trfArgs import addAthenaArguments, addDetectorArguments
15 from PyJobTransforms.trfDecorators import stdTrfExceptionHandler, sigUsrStackTrace
16 from RecJobTransforms.recTransformUtils import addCommonRecTrfArgs, addStandardRecoFiles
17 
18 import PyJobTransforms.trfArgClasses as trfArgClasses
19 
20 from TrigTransform.trigRecoExe import trigRecoExecutor
21 from TrigTransform.trigCostExe import trigCostExecutor
22 from TrigTransform.trigRateExe import trigRateExecutor
23 
24 # Setup core logging here
25 from PyJobTransforms.trfLogger import msg
26 msg.info('logging set in %s', sys.argv[0])
27 
28 @stdTrfExceptionHandler
29 @sigUsrStackTrace
30 def main():
31 
32  msg.info('This is %s', sys.argv[0])
33 
34  trf = getTransform()
35  trf.parseCmdLineArgs(sys.argv[1:])
36  trf.execute()
37  trf.generateReport()
38 
39  msg.info("%s stopped at %s, trf exit code %d", sys.argv[0], time.asctime(), trf.exitCode)
40  sys.exit(trf.exitCode)
41 
43  executorSet = set()
44 
45  # BSRDOtoRAW is the HLT step of the trigger transform
46  # runs primarily using athenaHLT
47  # literalRunargs used for when running with athena
48  executorSet.add(trigRecoExecutor(name = 'BSRDOtoRAW', skeletonFile = 'TriggerJobOpts/runHLT_standalone.py',
49  skeletonCA = 'TriggerJobOpts.runHLT',
50  exe = 'setsid athenaHLT.py',
51  # setsid is needed to fix the process-group id of child processes to be the same as mother process; discussed in https://its.cern.ch/jira/browse/ATR-20513
52  substep = 'b2r', tryDropAndReload = False,
53  inData = ['BS_RDO', 'RDO'], outData = ['BS', 'DRAW_TRIGCOST', 'HIST_HLTMON', 'HIST_DEBUGSTREAMMON'],
54  perfMonFile = 'ntuple_BSRDOtoRAW.pmon.gz',
55  literalRunargs = ['writeBS = runArgs.writeBS',
56  'from AthenaCommon.AthenaCommonFlags import jobproperties as jps',
57  'jps.AthenaCommonFlags.FilesInput.set_Value_and_Lock(runArgs.inputBS_RDOFile)',
58  'jps.AthenaCommonFlags.EvtMax.set_Value_and_Lock(runArgs.maxEvents)',
59  'if hasattr(runArgs,\'skipEvents\'):',
60  ' jps.AthenaCommonFlags.SkipEvents.set_Value_and_Lock(runArgs.skipEvents)',
61  'if hasattr(runArgs,\'outputBSFile\'):',
62  ' jps.AthenaCommonFlags.BSRDOOutput.set_Value_and_Lock( runArgs.outputBSFile )']))
63 
64  # RAWtoCOST is the COST step for trigger transform
65  # runs in athena and will succeed if input BS file has costmon enabled
66  executorSet.add(trigCostExecutor(name = 'DRAWCOSTtoNTUPCOST',
67  exe = 'RunTrigCostAnalysis.py',
68  inData = ['DRAW_TRIGCOST'], outData = ['NTUP_TRIGCOST']))
69 
70  # AODtoNTUPRATE is the RATE step for trigger transform
71  # runs in athena from an input AOD file
72  executorSet.add(trigRateExecutor(name = 'AODtoNTUPRATE',
73  exe = 'RatesAnalysisFullMenu.py',
74  inData = ['AOD'], outData = ['NTUP_TRIGRATE']))
75 
76  # RAWtoALL, DQHistogramMerge are the reconstruction substeps for trigger transform
77  # shortened list from addRecoSubsteps in RecJobTransforms.recTransformUtils
78  executorSet.add(athenaExecutor(name = 'RAWtoALL',
79  skeletonCA = 'RecJobTransforms.RAWtoALL_Skeleton',
80  substep = 'r2a', inData = ['BS', 'RDO'],
81  outData = ['ESD', 'AOD', 'HIST_R2A'],
82  perfMonFile = 'ntuple_RAWtoALL.pmon.gz'))
83  executorSet.add(DQMergeExecutor(name = 'DQHistogramMerge', inData = ['HIST_R2A'], outData = ['HIST']))
84 
85  # Other reco steps - not currently used in trigger reprocessings
86  # if remove can also remove outputNTUP_TRIGFile
87 
88  trf = transform(executor = executorSet, description = 'Trigger transform to run HLT, followed by'
89  ' general purpose ATLAS reconstruction transform. Input to HLT is inputBS_RDOFile'
90  ' with outputs of RDO, ESD or AOD. For more details see:'
91  ' https://twiki.cern.ch/twiki/bin/viewauth/Atlas/TriggerTransform or for reco_tf, see:'
92  ' https://twiki.cern.ch/twiki/bin/viewauth/Atlas/RecoTf')
93 
94  # Add arguments
95  # shortened list from RecJobTransforms.Reco_tf
96  addAthenaArguments(trf.parser)
97  addDetectorArguments(trf.parser)
98  # shortened list from addAllRecoArgs in RecJobTransforms.recTransformUtils
99  addCommonRecTrfArgs(trf.parser)
100  addStandardRecoFiles(trf.parser)
101 
102  # Now add specific trigger transform arguments
103  # Putting this last makes them appear last in the help so easier to find
104  addTriggerArgs(trf.parser)
105  addTrigCostRateArgs(trf.parser)
106  addTriggerDBArgs(trf.parser)
107  addDebugArgs(trf.parser)
108 
109  return trf
110 
111 
112 def addTriggerArgs(parser):
113  # Use arggroup to get these arguments in their own sub-section (of --help)
114  parser.defineArgGroup('Trigger', 'Specific options related to the trigger configuration used for reprocessing')
115 
116  # Arguments specific for trigger transform
117  # writeBS used in literal arguments when running HLT step in athena (not athenaHLT)
118  parser.add_argument('--writeBS', type=trfArgClasses.argFactory(trfArgClasses.argBool, runarg=True),
119  help='Needed if running BSRDO to BS step in athena (default: True)', group='Trigger', default=trfArgClasses.argBool(True, runarg=True))
120  # input BS file for the HLT step (name just to be unique identifier)
121  parser.add_argument('--inputBS_RDOFile', nargs='+',
122  type=trfArgClasses.argFactory(trfArgClasses.argBSFile, io='input', runarg=True, type='bs'),
123  help='Input bytestream file', group='Trigger')
124  # without an outputBSFile name specified then any further steps will know to use tmp.BS
125  parser.add_argument('--outputBSFile', nargs='+',
126  type=trfArgClasses.argFactory(trfArgClasses.argBSFile, io='output', runarg=True, type='bs'),
127  help='Output bytestream file', group='Trigger')
128  # select output stream in BS file
129 
131  parser.add_argument('--streamSelection', nargs='+', type=trfArgClasses.argFactory(trfArgClasses.argList, runarg=True),
132  help='select output streams in produced BS file (default: \"Main\"). Specify \"All\" to disable splitting (standard reco will fail on any events with only PEB data)', group='Trigger', default=trfArgClasses.argList("Main", runarg=True))
133  # HLT out histogram file, if defined renames expert-monitoring file that is produced automatically
134  parser.add_argument('--outputHIST_HLTMONFile', nargs='+',
135  type=trfArgClasses.argFactory(trfArgClasses.argHISTFile, io='output', runarg=True, countable=False),
136  help='Output HLTMON file', group='Trigger')
137  # Trigger Configuration String as used in reco Steps
138  parser.add_argument('--triggerConfig', nargs='+', metavar='substep=TRIGGERCONFIG',
139  type=trfArgClasses.argFactory(trfArgClasses.argSubstep, runarg=True, separator='='),
140  help='Trigger Configuration String. '
141  'N.B. This argument uses EQUALS (=) to separate the substep name from the value.', group='Trigger')
142  # precommand for athenaHLT aka -c
143  parser.add_argument('--precommand', nargs='+', type=trfArgClasses.argFactory(trfArgClasses.argList, runarg=True),
144  help='precommand for athenaHLT aka -c', group='Trigger')
145  # postcommand for athenaHLT aka -C
146  parser.add_argument('--postcommand', nargs='+', type=trfArgClasses.argFactory(trfArgClasses.argList, runarg=True),
147  help='postcommand for athenaHLT aka -C', group='Trigger')
148  # For prodsys to make sure uses inputBS_RDOFile rather than inputBSFile when running the b2r step
149  parser.add_argument('--prodSysBSRDO', type=trfArgClasses.argFactory(trfArgClasses.argBool, runarg=True),
150  help='For prodsys to make sure uses inputBS_RDOFile rather than inputBSFile when running the b2r step', group='Trigger')
151 
152 
154  # Use arggroup to get these arguments in their own sub-section (of --help)
155  parser.defineArgGroup('TrigCost', 'Specific options related to the trigger cost and rates steps in trigger reprocessings')
156 
157  # without a outputDRAW_TRIGCOSTFile name specified then it will not be possible to run any further COST analysis if the BS is slimmed to a specific stream
158  parser.add_argument('--outputDRAW_TRIGCOSTFile', nargs='+',
159  type=trfArgClasses.argFactory(trfArgClasses.argBSFile, io='output', runarg=True),
160  help='Output bytestream file of CostMonitoring stream', group='TrigCost')
161  # input BS file for the TRIGCOST step (name just to be unique identifier for prodSys)
162  parser.add_argument('--inputDRAW_TRIGCOSTFile', nargs='+',
163  type=trfArgClasses.argFactory(trfArgClasses.argBSFile, io='input', runarg=True),
164  help='Input bytestream file of CostMonitoring stream', group='TrigCost')
165  # NTUP_COST is used for COST monitoring - used in the reco release
166  parser.add_argument('--outputNTUP_TRIGCOSTFile', nargs='+',
167  type=trfArgClasses.argFactory(trfArgClasses.argHISTFile, io='output', runarg=True, countable=False),
168  help='D3PD output NTUP_TRIGCOST file', group='TrigCost')
169  # NTUP_RATE is used for COST monitoring - used in the reco release
170  parser.add_argument('--outputNTUP_TRIGRATEFile', nargs='+',
171  type=trfArgClasses.argFactory(trfArgClasses.argHISTFile, io='output', runarg=True, countable=False),
172  help='D3PD output NTUP_TRIGRATE file', group='TrigCost')
173 
174  # Additional cost arguments for cost processing step
175  parser.add_argument('--costopts', nargs='+',
176  type=trfArgClasses.argFactory(trfArgClasses.argSubstepList, splitter=' ', runarg=False),
177  help='Extra options to pass to cost processing.', group='TrigCost')
178 
179  # Additional rate arguments for rates analysis step
180  parser.add_argument('--rateopts', nargs='+',
181  type=trfArgClasses.argFactory(trfArgClasses.argSubstepList, splitter=' ', runarg=False),
182  help='Extra options to pass to rates analysis.', group='TrigCost')
183 
184 def addTriggerDBArgs(parser):
185  # Use arggroup to get these arguments in their own sub-section (of --help)
186  parser.defineArgGroup('TriggerDB', 'Specific options related to the trigger DB')
187 
188  parser.add_argument('--useDB', type=trfArgClasses.argFactory(trfArgClasses.argBool, runarg=True),
189  help='read from DB for athenaHLT aka use-database', group='TriggerDB')
190  parser.add_argument('--DBserver', type=trfArgClasses.argFactory(trfArgClasses.argString, runarg=True),
191  help='DB name: aka athenaHLT db-server', group='TriggerDB')
192  parser.add_argument('--DBsmkey', type=trfArgClasses.argFactory(trfArgClasses.argString, runarg=True),
193  help='DB SMK', group='TriggerDB')
194  parser.add_argument('--DBhltpskey', type=trfArgClasses.argFactory(trfArgClasses.argString, runarg=True),
195  help='DB hltpskey', group='TriggerDB')
196  parser.add_argument('--DBl1pskey', type=trfArgClasses.argFactory(trfArgClasses.argString, runarg=True),
197  help='DB l1pskey', group='TriggerDB')
198 
199 
200 def addDebugArgs(parser):
201  # Use arggroup to get these arguments in their own sub-section (of --help)
202  parser.defineArgGroup('Debug', 'Specific options related to the trigger debug recovery')
203 
204  parser.add_argument('--outputHIST_DEBUGSTREAMMONFile', nargs='+',
205  type=trfArgClasses.argFactory(trfArgClasses.argHISTFile, io='output', runarg=True, countable=False),
206  help='Output DEBUGSTREAMMON file', group='Debug')
207 
208 
209 if __name__ == '__main__':
210  main()
python.trfArgs.addDetectorArguments
def addDetectorArguments(parser)
Options related to the setup of the ATLAS detector (used in simulation and digitisation as well as re...
Definition: trfArgs.py:229
PyJobTransforms.trfArgClasses
Transform argument class definitions.
Trig_reco_tf.addTriggerDBArgs
def addTriggerDBArgs(parser)
Definition: Trig_reco_tf.py:184
python.recTransformUtils.addStandardRecoFiles
def addStandardRecoFiles(parser)
Definition: recTransformUtils.py:27
python.recTransformUtils.addCommonRecTrfArgs
def addCommonRecTrfArgs(parser)
Definition: recTransformUtils.py:14
Trig_reco_tf.addDebugArgs
def addDebugArgs(parser)
Definition: Trig_reco_tf.py:200
python.trfArgs.addAthenaArguments
def addAthenaArguments(parser, maxEventsDefaultSubstep='first', addValgrind=True, addPerfMon=True, addVTune=True)
Options related to running athena in general TODO: Some way to mask certain options (perExec,...
Definition: trfArgs.py:59
Trig_reco_tf.addTriggerArgs
def addTriggerArgs(parser)
Definition: Trig_reco_tf.py:112
Amg::transform
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Definition: GeoPrimitivesHelpers.h:156
Trig_reco_tf.addTrigCostRateArgs
def addTrigCostRateArgs(parser)
Definition: Trig_reco_tf.py:153
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
PyJobTransforms.trfExe
Transform execution functions.
PyJobTransforms.trfLogger
Logging configuration for ATLAS job transforms.
Trig_reco_tf.main
def main()
Definition: Trig_reco_tf.py:30
PyJobTransforms.transform
Main package for new style ATLAS job transforms.
Trig_reco_tf.getTransform
def getTransform()
Definition: Trig_reco_tf.py:42