15 path =
"/afs/cern.ch/project/lbcern/vol1/truf/charm/"
19 path =
"/afs/cern.ch/project/lbcern/vol1/truf/beauty/"
34 for n
in range(ncpus):
35 x.Rndm() * 1000000000.0
36 os.system(
"mkdir run" + str(run))
37 os.chdir(
"run" + str(run))
39 "python $FAIRSHIP/macro/makeCascade.py -m "
45 +
"-parp16-MSTP82-1-MSEL"
50 os.system(cmd +
" >log" + str(run) +
" &")
56 for n
in range(ncpus):
57 orun = run + cycle * 1000
58 os.chdir(
"run" + str(run))
59 inputFile = path +
"run" + str(run) +
"/Cascade-run" + str(run) +
"-parp16-MSTP82-1-MSEL" + msel +
".root"
60 f = ROOT.TFile(inputFile)
66 "python $FAIRSHIP/muonShieldOptimization/run_fixedTarget.py --force --charm -V -e 10 -P -n "
70 +
" -b 100 -X 100 -I "
75 "python $FAIRSHIP/muonShieldOptimization/run_fixedTarget.py --force --beauty -V -e 10 -P -n "
79 +
" -b 100 -X 100 -I "
82 os.system(cmd +
" >logFT" + str(orun) +
" &")
88runList = [20, 28, 30, 33]
93 orun = run + cycle * 1000
94 os.chdir(
"run" + str(run))
95 inputFile = path +
"run" + str(run) +
"/Cascade-run" + str(run) +
"-parp16-MSTP82-1-MSEL" + msel +
".root"
96 f = ROOT.TFile(inputFile)
101 "python $FAIRSHIP/muonShieldOptimization/run_fixedTarget.py --force --charm -V -e 10 -P -n "
105 +
" -b 100 -X 100 -I "
109 os.system(cmd +
" >logFT" + str(orun) +
" &")
113def merge(run, cycle: int = 0) ->
None:
114 fname =
"pythia8_Geant4_XX_10.0.root"
116 for n
in range(ncpus):
117 for x
in os.listdir(path +
"/run" + str(run + n)):
118 orun = run + cycle * 1000
119 if not x.find(
"run_fixedTarget_" + str(orun + n)) < 0:
120 if cycle == 0
and run == 0
and not x.find(
"1001") < 0:
122 if cycle == 0
and run == 0
and not x.find(
"1010") < 0:
124 cmd += path +
"/run" + str(run + n) +
"/" + x +
"/" + fname.replace(
"XX", str(orun + n)) +
" "
126 outFile = fname.replace(
"XX",
"charm_" + str(orun) +
"-" + str(orun + ncpus - 1))
128 outFile = fname.replace(
"XX",
"beauty_" + str(orun) +
"-" + str(orun + ncpus - 1))
129 rc = os.system(
"hadd -O " + outFile +
" " + cmd)
131 print(
"hadd failed, stop", outFile)
133 rc = os.system(
"xrdcp " + outFile +
" $EOSSHIP/eos/experiment/ship/data/Mbias/background-prod-2018/" + outFile)
135 print(
"copy to EOS failed, stop", outFile)
137 rc = os.system(
"rm " + outFile)
141 cmd =
"hadd pythia8_Geant4_charm_153.3B_10.0_mu.root "
142 tmp =
"/eos/experiment/ship/data/Mbias/background-prod-2018/pythia8_Geant4_charm_XX_10.0_mu.root"
160 cmd += tmp.replace(
"XX", x) +
" "
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:
173 for line
in f.readlines():
174 if not line.find(
"Macro finished successfully") < 0:
177 print(
"job not finished properly", fName)
181 if cmd.find(
"root") < 0:
182 print(
"no file found, exit")
184 stat = str(int(Ntot / 1e6)) +
"Mpot"
189 + str(run + ncpus - 1)
190 +
"-parp16-MSTP82-1-MSEL"
196 rc = os.system(
"hadd -O " + outFile +
" " + cmd)
197 f = ROOT.TFile(outFile)
198 Npot = f.Get(
"2").GetBinContent(1) / 2.0 / chicc
200 stat = str(int(Npot / 1e9)) +
"Bpot"
206 + str(run + ncpus - 1)
207 +
"-parp16-MSTP82-1-MSEL"
213 os.system(
"mv " + oldOutFile +
" " + outFile)
214 rc = os.system(
"xrdcp " + outFile +
" $EOSSHIP/eos/experiment/ship/data/Mbias/background-prod-2018/" + outFile)
216 print(
"copy to EOS failed, stop", outFile)
218 rc = os.system(
"rm " + outFile)
222 path = os.environ[
"EOSSHIP"] +
"/eos/experiment/ship/data/Mbias/background-prod-2018/"
223 fname =
"Cascade-runAA-BB-parp16-MSTP82-1-MSEL4-40Mpot.root"
226 for x
in [0, 20, 40, 60, 80]:
227 fn = fname.replace(
"AA", str(x)).replace(
"BB", str(x + 19))
228 f = ROOT.TFile.Open(path + fn)
229 nPot += f.Get(
"2").GetBinContent(1) / 2.0
230 nhadrons += f.Get(
"pythia6").GetEntries()
231 print(
"total nr of hadrons:", nhadrons, nPot / chicc / 1.0e9,
"Billion")
236 for x
in f.GetListOfKeys():
237 if x.GetName() ==
"FileHeader":
238 pot += float(x.GetTitle().split(
" ")[3])
245run = int(sys.argv[1])
247print(
"following functions exist")
248print(
" - makeHadrons(run): will run makeCascade")
249print(
" - makeBackground(run): will run fixedTarget generator")
None makeBackgroundX(runList, int cycle=0)
None merge(run, int cycle=0)
None potFromFileHeader(f)
None makeBackground(run, int cycle=0)
None compactifyCascade(run)
int open(const char *, int)
Opens a file descriptor.