3 import sys, os, glob, subprocess, tarfile
4 from PyJobTransforms.CommonRunArgsToFlags
import commonRunArgsToFlags
5 from PyJobTransforms.TransformUtils
import processPreExec, processPreInclude, processPostExec, processPostInclude
6 from TRT_CalibAlgs.TRTCalibrationMgrConfig
import CalibConfig, TRT_CalibrationMgrCfg, TRT_StrawStatusCfg
7 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
13 print(
"# %s" % (text))
19 print(
" Running: %s\n" % (command))
20 stdout, stderr = subprocess.Popen(command, shell=
True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
21 print(
"OUTPUT: \n%s" % (stdout.decode(
'ascii')))
22 print(
"ERRORS: %s" % (
"NONE" if stderr.decode(
'ascii')==
'' else "\n"+stderr.decode(
'ascii')))
35 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
43 if "TRTCalibAccu_ART_Output" in runArgs.outputTARFile:
44 print(
"WARNING - Testing the TRTCalib_accu transform")
46 print(
"INFO - Running TRTCalib_accu transform")
48 flags.Input.Files=runArgs.inputRAWFile
49 flags.Output.HISTFileName=runArgs.outputTARFile
58 flags = flags.cloneAndReplace(
59 "Tracking.ActiveConfig",
60 f
"Tracking.{flags.Tracking.PrimaryPassConfig.value}Pass",
70 from ByteStreamCnvSvc.ByteStreamConfig
import ByteStreamReadCfg
73 from InDetConfig.TrackRecoConfig
import InDetTrackRecoCfg
82 with open(
"ConfigTRTCalib_accu.pkl",
"wb")
as f:
87 if not sc.isSuccess():
88 sys.exit(
not sc.isSuccess())
90 outputFile = runArgs.outputTARFile
92 nextstep(
"Generating the tracktuple and StrawStatus file")
95 os.rename(outputFile, outputFile+
'.basic.root')
96 command =
'TRTCalib_bhadd dumfile %s.basic.root' % (outputFile)
98 tryError(command,
"ERROR: Failed in process TRTCalib_bhadd\n")
101 nextstep(
"Renaming outputs from Athena and TRTCalib_bhadd")
104 command =
"mv -v tracktuple.root %s.tracktuple.root ; " % (outputFile)
105 command +=
"mv -v %s %s.straw.txt" % (glob.glob(
'TRT_StrawStatusOutput.*newFormat.txt')[0],outputFile)
107 tryError(command,
"ERROR: Failed in renaming\n")
115 files_list=glob.glob(outputFile+
".*")
117 tar = tarfile.open(outputFile,
"w:gz")
118 print(
"Compressing files in %s output file:" % outputFile)
119 for file
in files_list:
124 print(
"ERROR: Failed compressing the output files\n",e)
128 print(
"\nListing files:")
129 for file
in sorted(glob.glob(
"./*", recursive=
True)):