164def compactifyCascade(run) -> None:
165 ncpus = 20
166 cmd = ""
167 Ntot = 0
168 NperJob = nev
169 for i in range(run, +ncpus):
170 fName = path + "run" + str(i) + "/Cascade-run" + str(i) + "-parp16-MSTP82-1-MSEL" + msel + ".root"
171 with open(path +
"run" + str(i) +
"/log" + str(i))
as f:
172 success = False
173 for line in f.readlines():
174 if not line.find("Macro finished successfully") < 0:
175 success = True
176 if not success:
177 print("job not finished properly", fName)
178 continue
179 cmd += fName + " "
180 Ntot += NperJob
181 if cmd.find("root") < 0:
182 print("no file found, exit")
183 else:
184 stat = str(int(Ntot / 1e6)) + "Mpot"
185 outFile = (
186 "Cascade-run"
187 + str(run)
188 + "-"
189 + str(run + ncpus - 1)
190 + "-parp16-MSTP82-1-MSEL"
191 + msel
192 + "-"
193 + stat
194 + ".root"
195 )
196 rc = os.system("hadd -O " + outFile + " " + cmd)
197 f = ROOT.TFile(outFile)
198 Npot = f.Get("2").GetBinContent(1) / 2.0 / chicc
199 f.Close()
200 stat = str(int(Npot / 1e9)) + "Bpot"
201 oldOutFile = outFile
202 outFile = (
203 "Cascade-run"
204 + str(run)
205 + "-"
206 + str(run + ncpus - 1)
207 + "-parp16-MSTP82-1-MSEL"
208 + msel
209 + "-"
210 + stat
211 + ".root"
212 )
213 os.system("mv " + oldOutFile + " " + outFile)
214 rc = os.system("xrdcp " + outFile + " $EOSSHIP/eos/experiment/ship/data/Mbias/background-prod-2018/" + outFile)
215 if rc != 0:
216 print("copy to EOS failed, stop", outFile)
217 else:
218 rc = os.system("rm " + outFile)
219
220
int open(const char *, int)
Opens a file descriptor.