8import argparse, os, sys
10from AthenaCommon.Logging
import logging
11log = logging.getLogger(
"makeDcubeConfig.py" )
14parser = argparse.ArgumentParser( description =
"makeDcubeConfig.py options:" )
15parser.add_argument(
"-i",
"--inputFile", help=
"IDPVM input file", required=
True )
16parser.add_argument(
"-c",
"--configName", help=
"Name of the output dcube xml config file", default=
"dcube_config.xml" )
17parser.add_argument(
"-d",
"--debug", help=
'set debug level printout', action=
'store_true', default=
False )
18MyArgs = parser.parse_args()
19if MyArgs.debug : log.setLevel( logging.DEBUG )
22dcubeExe = os.getenv(
"ATLAS_LOCAL_ROOT" )+
"/dcube/current/DCubeClient/python/dcube.py"
23log.debug( f
"Setting Dcube executable to {dcubeExe}" )
24if not os.path.exists( dcubeExe ):
25 log.error( f
"Dcube executable {dcubeExe} not found. Exiting." )
29dcubeCmd = [ dcubeExe,
'-g',
30 '-c',
'tmp_'+MyArgs.configName,
31 '-r', MyArgs.inputFile, MyArgs.inputFile ]
32log.debug(
"Running: "+(
' '.join( dcubeCmd )) )
33subprocess.run( dcubeCmd, check=
True )
34if not os.path.exists(
'tmp_'+MyArgs.configName ):
35 log.error( f
"Temporary dcube config tmp_{MyArgs.configName} not found. Exiting." )
39import xml.etree.ElementTree
as ET
40treeXML = ET.parse(
'tmp_'+MyArgs.configName )
41rootXML = treeXML.getroot()
45for tdir
in rootXML.iter(
"TDirectory"):
46 histList = tdir.findall(
"hist1D")
47 histList += tdir.findall(
"hist2D")
48 histList += tdir.findall(
"graph")
52 if "TH1" in hist.get(
"type"):
53 hist.set(
"plotopts",
"norm;ratio")
54 if "TH2" in hist.get(
"type"):
55 hist.set(
"plotopts",
"norm;box")
56 if hist.get(
"type") ==
"TProfile" or hist.get(
"type") ==
"TEfficiency":
57 hist.set(
"plotopts",
"ratio")
58 if (
"2D" in hist.get(
"type")
or
59 (
"TEfficiency" in hist.get(
"type")
and "2D" in hist.get(
"name") ) ):
60 hist.set(
"plotopts",
"box")
62 if tdir.get(
"name") ==
"Multiplicities":
63 if "summary" in hist.get(
"name"):
64 hist.set(
"plotopts",
"logy")
65 if tdir.get(
"name") ==
"Resolutions":
66 if (
"resolution" in hist.get(
"name")
or
67 "resmean" in hist.get(
"name")
or
68 "pullwidth" in hist.get(
"name")
or
69 "pullmean" in hist.get(
"name") ):
70 hist.set(
"plotopts",
"ratio")
71 if "_vs_" in hist.get(
"name")
and hist.get(
"name").endswith(
"pt"):
72 hist.set(
"plotopts",
"logx;ratio")
73log.info(
"Done editing Dcube XML config" )
76treeXML.write( MyArgs.configName, xml_declaration=
True )
77log.info( f
"New Dcube XML config written {MyArgs.configName}" )
78os.remove(
'tmp_'+MyArgs.configName )