29def fromRunArgs(runArgs):
30
31 outputFile = runArgs.outputTAR_CALIBFile
32
33
34 nextstep("UNTAR input file")
35
36
37 print(
"Uncompressing files:")
38 try:
39 for file in runArgs.inputTARFile:
41 tarfile.open(file).extractall(".")
42 except OSError as e:
43 print(
"ERROR: Failed uncompressing TAR file\n",e)
44 sys.exit(e.errno)
45
46
47 nextstep("Renaming *straw.txt and *tracktuple.root files for the final output")
48
49
50 listOfStrawFiles = glob.glob("*.merged.straw.txt")
51 listOfTrackFiles = glob.glob("*.tracktuple.root")
52
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)))
55 exit(1)
56
57 command = "mv -v %s %s.merged.straw.txt; " % (listOfStrawFiles[0],outputFile)
58
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)
62 else:
63 print(
"INFO: piecetoken different than \"all\". Not need to rename *tracktuple.root file")
64
65 tryError(command, "Renaming *straw.txt and *tracktuple.root files\n")
66
67
68 nextstep("Calculating constants ATHENA")
69
70
71 myFile = []
72
73 if runArgs.rawfile:
74 myFile.append(runArgs.rawfile)
75
76 else:
77 if not runArgs.project and not runArgs.runnr and not runArgs.stream:
78 try:
79 splitInput = runArgs.inputTARFile[0].
split(
'.')
80 project="----"
81 runnr ="----"
82 stream ="----"
83 if splitInput:
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\"...")
88 else:
89 print(
"ERROR: not able to find project=\"%s\" or runNumber=\"%s\" or stream=\"%s\" from \"lsn\" " % (project, runnr, stream))
90 exit(1)
91
92 except OSError as e:
93 print(
"ERROR: Failed trying to build RAW file name for Athena.\n",e)
94 sys.exit(e.errno)
95
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!")
99 sys.exit(1)
100 else:
101
102
103
104
105 rawpath = "/eos/atlas/atlastier0/rucio/%s/%s/%s/%s.%s.%s.%s" % (runArgs.project,runArgs.stream,runArgs.runnr.zfill(8),runArgs.project,runArgs.runnr.zfill(8),runArgs.stream,runArgs.step)
106 if len(glob.glob(rawpath)) == 0:
107 print(
"ERROR: Any folder under \"%s\". Please check that the path is correct" % rawpath)
108 sys.exit(1)
109 elif len(glob.glob(rawpath)) > 1:
110 print(
"ERROR: More than one folder under '%s'. Please specify the correct one with \"step\" argument in the transform" % rawpath)
111 for f in glob.glob(rawpath):
113 sys.exit(1)
114
115 globedFiles = glob.glob(rawpath+"*")
116 if not globedFiles:
117 print(
"ERROR: Not able to find any file under %s. Please check that the files exists" % (rawpath))
118 sys.exit(1)
119
120 myFile.append(random.choice(globedFiles))
121 print(
"RAW file selected for testing:",myFile)
122 if not myFile:
123 print(
"ERROR: provide a valid project=\"%s\" or runNumber=\"%s\" or stream=\"%s\"" % (runArgs.project, runArgs.runnr, runArgs.stream))
124 sys.exit(1)
125
126 from AthenaConfiguration.AllConfigFlags import initConfigFlags
127 flags=initConfigFlags()
128
129 commonRunArgsToFlags(runArgs, flags)
130
131 processPreInclude(runArgs, flags)
132 processPreExec(runArgs, flags)
133
134
135 flags.Input.Files=myFile
136 flags.Output.HISTFileName="DontUse.remove"
137
138
139 flags.Exec.MaxEvents=1
140
141
142 CalibConfig(flags)
143
144
145 flags.fillFromArgs()
146
147
148 flags = flags.cloneAndReplace(
149 "Tracking.ActiveConfig",
150 f"Tracking.{flags.Tracking.PrimaryPassConfig.value}Pass",
151
152
153 keepOriginal=True)
154
155 flags.lock()
156 flags.dump()
157
158 cfg=MainServicesCfg(flags)
159
160 from ByteStreamCnvSvc.ByteStreamConfig import ByteStreamReadCfg
161 cfg.merge(ByteStreamReadCfg(flags))
162
163 from InDetConfig.TrackRecoConfig import InDetTrackRecoCfg
164 cfg.merge(InDetTrackRecoCfg(flags))
165
166 cfg.merge(TRT_CalibrationMgrCfg(flags,DoCalibrate=True, Hittuple=glob.glob("*.basic.root")[0], caltag=runArgs.piecetoken))
167 cfg.merge(TRT_StrawStatusCfg(flags))
168
169 processPostInclude(runArgs, flags, cfg)
170 processPostExec(runArgs, flags, cfg)
171
172 with open("ConfigTRTCalib_calib.pkl", "wb") as f:
173 cfg.store(f)
174
175 sc = cfg.run()
176 if not sc.isSuccess():
177 sys.exit(not sc.isSuccess())
178
179
180 nextstep("Renaming outputs from Calibrator")
181
182
183 command = "mv -v calibout.root %s.calibout.root ; " % (outputFile)
184 command += "mv -v calibout_rt.txt %s.calibout_rt.txt; " % (outputFile)
185 command += "mv -v calibout_t0.txt %s.calibout_t0.txt; " % (outputFile)
186 command += "mv -v calib_constants_out.txt %s.calib_constants_out.txt; " % (outputFile)
187
188 tryError(command, "ERROR: Failed renaming files in TRT calib step\n")
189
190
191 nextstep("TAR'ing files")
192
193 try:
194
195 files_list=glob.glob(outputFile+".*")
196
197 tar = tarfile.open(outputFile, "w:gz")
198 print(
"Compressing files in %s output file:" % outputFile)
199 for file in files_list:
201 tar.add(file)
202 tar.close()
203 except OSError as e:
204 print(
"ERROR: Failed compressing the output files\n",e)
205 sys.exit(e.errno)
206
207
208 print(
"\nListing files:")
209 for file in sorted(glob.glob("./*", recursive=True)):
void print(char *figname, TCanvas *c1)
std::vector< std::string > split(const std::string &s, const std::string &t=":")