17from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
18from TrigInDetAnalysisExample.chainString
import chainString
20from TrigIDR4Monitoring.TrigIDR4MonFlags
import TrigIDR4MonFlags
21from TrigIDR4Monitoring.NodeUtils
import decodeFlags
22from TrigIDR4Monitoring.NodeUtils
import updateFlags
28def TrigIDR4MonConfig( flags, monlevels=None ):
38 flags = decodeFlags( iflags )
40 from AthenaMonitoring
import AthMonitorCfgHelper
41 monConfig = AthMonitorCfgHelper( flags,
"TrigIDR4Mon" )
43 ca = ComponentAccumulator()
49 if flags.IDTPM2.useDecorations:
50 from TrigIDR4Monitoring.TruthSelectBase
import TruthPerigeeDecoratorCfg
51 ca.merge( TruthPerigeeDecoratorCfg( flags ) )
55 algs =
TrigIDR4Monitoring( flags.IDTPM2,
"Tier0", monlevel=
"idMon:t0:shifter", kak=ca )
61 for a
in algs : monConfig.addAlgorithm(a)
63 ca.merge(monConfig.result())
75 from AthenaCommon.Logging
import logging
76 log = logging.getLogger(
"TrigIDR4Monitoring")
78 log.info( f
"Creating monitoring: {name}" )
85 if monlevel
is not None:
86 log.info(
"TIDA monitoring not None: monlevel: " + monlevel )
90 elif "shifter" in monlevel:
94 for node
in flags.nodes(): log.info( f
"Configuring analysis : {node.name()}" )
96 for node
in flags.nodes():
107 tida.SliceTag = flags.SliceTag
109 from TrigInDetMonitoring.TIDAChains
import getchains
113 for pattern
in flags.Chains :
114 if chainString(pattern).head:
118 if hltchains : chains = getchains( flags, flags.Chains, monlevel )
119 else: chains = flags.Chains
121 if len(chains)==0 :
raise RuntimeError(f
"No matched chains for Signature: {flags.name()}")
125 tida.MonTools =
createTATools( flags, flags.SliceTag, chains )
136 from AthenaConfiguration.ComponentFactory
import CompFactory
137 alg = CompFactory.TrigIDR4Mon( name=name )
148 from TrigIDR4Monitoring.TrackAnalysisConfig
import createTrackAnalysis
150 for chain
in chains :
151 cs = chainString(chain)
152 if excludeTagChains
and "tag" in cs.extra:
continue
156 tatool = createTrackAnalysis( flags, chain, tpchains, label, kak )
162 if s.endswith(suffix) :
return s[:-len(suffix)]
168 if cs_probe
is None: cs_probe = chainString(probe)
170 if "probe" not in cs_probe.extra :
return [ probe ]
172 prefix_probe =
chomp( cs_probe.extra,
"_probe" )
182 if tag==probe :
continue
184 cstag = chainString(tag)
191 if cs_probe.head!=cstag.head :
continue
200 if "tag" not in cstag.extra :
continue
202 prefix_tag =
chomp( cstag.extra,
"_tag" )
204 if prefix_probe != prefix_tag :
continue
209 return [ probe, tag ]
218 from AthenaCommon.Logging
import log
220 if flags.Output.HISTFileName:
221 log.info(
"histsvc: Create THistSvc with file name: "+flags.Output.HISTFileName )
223 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
224 ca = ComponentAccumulator()
226 from AthenaConfiguration.ComponentFactory
import CompFactory
227 THistSvc = CompFactory.THistSvc
230 if flags.Output.HISTFileName:
231 histsvc.Output += [
"%s DATAFILE='%s' OPT='RECREATE'" % (flags.DQ.FileKey, flags.Output.HISTFileName)]
232 log.info(
"histsvc: "+histsvc.Output[-1] )
234 ca.addService(histsvc)
241 if isinstance( files, str ): files = [ files ]
243 print( f
"check file: {f}" )
245 if f.startswith((
"root://",
"http://")):
continue
246 if not os.path.isfile(f):
247 print(f
"ERROR: Input file '{f}' does not exist, cwd: "+os.getcwd())
252 from PyUtils.MetaReader
import read_metadata
253 if filename.startswith((
"root://",
"http://")):
return None
254 metadata = read_metadata(filename)
255 return 'IS_SIMULATION' in metadata[filename].
get(
'eventTypes', [])
261 if arg.startswith(cmdoption) :
262 idx = args.index(arg)
267 idx = args.index(arg)
272 if not signatures:
return None
274 for sig
in signatures:
275 if sig.endswith(
".py")
or "=" in sig:
continue
278 if args:
clean_args( sigs, args,
"--signatures" )
286 print(
"no input files" )
289 if isinstance(files,str): files = [ files ]
294 if file.endswith(
".py")
or "=" in file:
continue
295 _out += file.split(
",")
300 if f.startswith((
"root://",
"http://")): out.append(f)
301 else: out += glob.glob(f)
304 print(
"no matching files", _out )
306 if args:
clean_args( _out, args,
"--filesInput" )
312if __name__==
'__main__':
315 from AthenaCommon.Logging
import log
316 log.info(
"test running" )
319 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
321 flags = initConfigFlags()
325 file =
'AOD.pool.root'
327 flags.Input.Files = [file]
331 flags.Input.isMC =
is_mc( flags.Input.Files[0] )
333 flags.Output.HISTFileName =
'duff.root'
336 flags.Common.doExpressProcessing=
True
348 flags.Input.AODFixesDone = {
"egammaAODFixesCfg"}
350 tflags = decodeFlags( flags )
352 TrigIDR4MonFlags( tflags )
354 updateFlags(flags,tflags)
361 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
362 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
363 cfg = MainServicesCfg(tflags)
365 cfg.merge( PoolReadCfg(tflags) )
369 cfg.merge( TrigIDR4MonConfig( tflags ) )
372 cfg.printConfig(withDetails=
False)
void print(char *figname, TCanvas *c1)
void name(const std::string &n)
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
TrigIDR4Mon_builder(flags=None, name="NoName")
parse_signatures(signatures, args=None)
TrigIDR4MonSignature(flags, key, toolkey, tools, monlevel, kak)
parse_files(files, args=None)
clean_args(values, args, cmdoption)
createTATools(flags, label, chains, excludeTagChains=True, kak=None)
getTagnProbe(probe, chains, cs_probe=None)
TrigIDR4Monitoring(flags, name=None, monlevel=None, kak=None)
TrigIDR4MonitoringCA(iflags, monlevels=None)