ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetValidation
InDetTrackPerfMon
scripts
makeDcubeConfig.py
Go to the documentation of this file.
1
#!/usr/bin/env python
2
# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
4
7
8
import
argparse, os, sys
9
import
subprocess
10
from
AthenaCommon.Logging
import
logging
11
log = logging.getLogger(
"makeDcubeConfig.py"
)
12
13
# Parsing arguments
14
parser = argparse.ArgumentParser( description =
"makeDcubeConfig.py options:"
)
15
parser.add_argument(
"-i"
,
"--inputFile"
, help=
"IDPVM input file"
, required=
True
)
16
parser.add_argument(
"-c"
,
"--configName"
, help=
"Name of the output dcube xml config file"
, default=
"dcube_config.xml"
)
17
parser.add_argument(
"-d"
,
"--debug"
, help=
'set debug level printout'
, action=
'store_true'
, default=
False
)
18
MyArgs = parser.parse_args()
19
if
MyArgs.debug : log.setLevel( logging.DEBUG )
20
21
22
dcubeExe = os.getenv(
"ATLAS_LOCAL_ROOT"
)+
"/dcube/current/DCubeClient/python/dcube.py"
23
log.debug( f
"Setting Dcube executable to {dcubeExe}"
)
24
if
not
os.path.exists( dcubeExe ):
25
log.error( f
"Dcube executable {dcubeExe} not found. Exiting."
)
26
sys.exit(1)
27
28
29
dcubeCmd = [ dcubeExe,
'-g'
,
30
'-c'
,
'tmp_'
+MyArgs.configName,
31
'-r'
, MyArgs.inputFile, MyArgs.inputFile ]
32
log.debug(
"Running: "
+(
' '
.join( dcubeCmd )) )
33
subprocess.run( dcubeCmd, check=
True
)
34
if
not
os.path.exists(
'tmp_'
+MyArgs.configName ):
35
log.error( f
"Temporary dcube config tmp_{MyArgs.configName} not found. Exiting."
)
36
sys.exit(1)
37
38
39
import
xml.etree.ElementTree
as
ET
40
treeXML = ET.parse(
'tmp_'
+MyArgs.configName )
41
rootXML = treeXML.getroot()
42
43
45
for
tdir
in
rootXML.iter(
"TDirectory"
):
46
histList = tdir.findall(
"hist1D"
)
47
histList += tdir.findall(
"hist2D"
)
48
histList += tdir.findall(
"graph"
)
49
50
for
hist
in
histList:
51
52
if
"TH1"
in
hist.get(
"type"
):
53
hist.set(
"plotopts"
,
"norm;ratio"
)
# for 1D plots
54
if
"TH2"
in
hist.get(
"type"
):
55
hist.set(
"plotopts"
,
"norm;box"
)
# for 1D plots
56
if
hist.get(
"type"
) ==
"TProfile"
or
hist.get(
"type"
) ==
"TEfficiency"
:
57
hist.set(
"plotopts"
,
"ratio"
)
# for 1D TProfiles and TEfficiencies
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"
)
# for 2D TProfile2Ds and TEff2Ds
61
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"
)
# just ratio for resol, no need for norm
71
if
"_vs_"
in
hist.get(
"name"
)
and
hist.get(
"name"
).endswith(
"pt"
):
72
hist.set(
"plotopts"
,
"logx;ratio"
)
# also logx for e.g. resol vs pt plots
73
log.info(
"Done editing Dcube XML config"
)
74
75
76
treeXML.write( MyArgs.configName, xml_declaration=
True
)
77
log.info( f
"New Dcube XML config written {MyArgs.configName}"
)
78
os.remove(
'tmp_'
+MyArgs.configName )
# remove tmp config
Generated on
for ATLAS Offline Software by
1.17.0