31 outputFile = runArgs.outputTAR_CALIBFile
37 print(
"Uncompressing files:")
39 for file
in runArgs.inputTARFile:
41 tarfile.open(file).extractall(
".")
43 print(
"ERROR: Failed uncompressing TAR file\n",e)
47 nextstep(
"Renaming *straw.txt and *tracktuple.root files for the final output")
50 listOfStrawFiles = glob.glob(
"*.merged.straw.txt")
51 listOfTrackFiles = glob.glob(
"*.tracktuple.root")
53 if not listOfStrawFiles
or (
not listOfTrackFiles
and runArgs.piecetoken !=
"all"):
54 print(
"ERROR: Empty array of \"*.merged.straw.txt\" (size %d) or \"*.tracktuple.root\" (size %d) files" % (len(listOfStrawFiles), len(listOfTrackFiles)))
57 command =
"mv -v %s %s.merged.straw.txt; " % (listOfStrawFiles[0],outputFile)
59 if(runArgs.piecetoken ==
"all"):
60 print(
"INFO: piecetoken equal to \"all\". Saving *tracktuple.root file")
61 command +=
"mv -v %s %s.tracktuple.root; " % (listOfTrackFiles[0],outputFile)
63 print(
"INFO: piecetoken different than \"all\". Not need to rename *tracktuple.root file")
65 tryError(command,
"Renaming *straw.txt and *tracktuple.root files\n")
68 nextstep(
"Calculating constants ATHENA")
74 myFile.append(runArgs.rawfile)
77 if not runArgs.project
and not runArgs.runnr
and not runArgs.stream:
79 splitInput = runArgs.inputTARFile[0].
split(
'.')
84 runArgs.project = splitInput[0]
85 runArgs.runnr = splitInput[1]
86 runArgs.stream = splitInput[2]
87 print(
"INFO: No input arguments are given to name the RAW file. Obtained from \"lsn\"...")
89 print(
"ERROR: not able to find project=\"%s\" or runNumber=\"%s\" or stream=\"%s\" from \"lsn\" " % (project, runnr, stream))
93 print(
"ERROR: Failed trying to build RAW file name for Athena.\n",e)
96 if (
not runArgs.project
or not runArgs.runnr
or not runArgs.stream):
97 print(
"ERROR: Raw file not provided, project=\"%s\" or runNumber=\"%s\" or stream=\"%s\" missing..." % (runArgs.project, runArgs.runnr, runArgs.stream))
98 print(
"Provide them!")
101 rawpath =
"/eos/atlas/atlastier0/rucio/%s/%s/%s/%s.%s.%s.merge.RAW/" % (runArgs.project,runArgs.stream,runArgs.runnr.zfill(8),runArgs.project,runArgs.runnr.zfill(8),runArgs.stream)
102 globedFiles = glob.glob(rawpath+
"*")
104 print(
"ERROR: Not able to find any file under %s. Please check that the path is correct or files exists" % (rawpath))
107 myFile.append(random.choice(globedFiles))
108 print(
"RAW file selected for testing:",myFile)
110 print(
"ERROR: provide a valid project=\"%s\" or runNumber=\"%s\" or stream=\"%s\"" % (runArgs.project, runArgs.runnr, runArgs.stream))
113 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
122 flags.Input.Files=myFile
123 flags.Output.HISTFileName=
"DontUse.remove"
126 flags.Exec.MaxEvents=1
135 flags = flags.cloneAndReplace(
136 "Tracking.ActiveConfig",
137 f
"Tracking.{flags.Tracking.PrimaryPassConfig.value}Pass",
147 from ByteStreamCnvSvc.ByteStreamConfig
import ByteStreamReadCfg
150 from InDetConfig.TrackRecoConfig
import InDetTrackRecoCfg
153 cfg.merge(
TRT_CalibrationMgrCfg(flags,DoCalibrate=
True, Hittuple=glob.glob(
"*.basic.root")[0], caltag=runArgs.piecetoken))
159 with open(
"ConfigTRTCalib_calib.pkl",
"wb")
as f:
163 if not sc.isSuccess():
164 sys.exit(
not sc.isSuccess())
167 nextstep(
"Renaming outputs from Calibrator")
170 command =
"mv -v calibout.root %s.calibout.root ; " % (outputFile)
171 command +=
"mv -v calibout_rt.txt %s.calibout_rt.txt; " % (outputFile)
172 command +=
"mv -v calibout_t0.txt %s.calibout_t0.txt; " % (outputFile)
173 command +=
"mv -v calib_constants_out.txt %s.calib_constants_out.txt; " % (outputFile)
175 tryError(command,
"ERROR: Failed renaming files in TRT calib step\n")
182 files_list=glob.glob(outputFile+
".*")
184 tar = tarfile.open(outputFile,
"w:gz")
185 print(
"Compressing files in %s output file:" % outputFile)
186 for file
in files_list:
191 print(
"ERROR: Failed compressing the output files\n",e)
195 print(
"\nListing files:")
196 for file
in sorted(glob.glob(
"./*", recursive=
True)):