FairShip
Loading...
Searching...
No Matches
runCharmHadProd Namespace Reference

Functions

None makeHadrons (run)
 
None makeBackground (run, int cycle=0)
 
None makeBackgroundX (runList, int cycle=0)
 
None merge (run, int cycle=0)
 
None mergeAll ()
 
None compactifyCascade (run)
 
None statistics ()
 
None potFromFileHeader (f)
 

Variables

int ncpus = 20
 
str msel = "4"
 
int nev = 2000000
 
str path = "/afs/cern.ch/project/lbcern/vol1/truf/charm/"
 
float chicc = 1.7e-3
 
 else :
 
int cycle = 2
 
list runList = [20, 28, 30, 33]
 
ROOT x = ROOT.TRandom3()
 
int run = int(sys.argv[1])
 

Function Documentation

◆ compactifyCascade()

None runCharmHadProd.compactifyCascade (   run)

Definition at line 164 of file runCharmHadProd.py.

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.

◆ makeBackground()

None runCharmHadProd.makeBackground (   run,
int   cycle = 0 
)

Definition at line 55 of file runCharmHadProd.py.

55def makeBackground(run, cycle: int = 0) -> None:
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)
61 nt = f.pythia6
62 N = nt.GetEntries()
63 f.Close()
64 if msel == "4":
65 cmd = (
66 "python $FAIRSHIP/muonShieldOptimization/run_fixedTarget.py --force --charm -V -e 10 -P -n "
67 + str(N)
68 + " -r "
69 + str(orun)
70 + " -b 100 -X 100 -I "
71 + inputFile
72 )
73 else:
74 cmd = (
75 "python $FAIRSHIP/muonShieldOptimization/run_fixedTarget.py --force --beauty -V -e 10 -P -n "
76 + str(N)
77 + " -r "
78 + str(orun)
79 + " -b 100 -X 100 -I "
80 + inputFile
81 )
82 os.system(cmd + " >logFT" + str(orun) + " &")
83 os.chdir("../")
84 run += 1
85
86

◆ makeBackgroundX()

None runCharmHadProd.makeBackgroundX (   runList,
int   cycle = 0 
)

Definition at line 91 of file runCharmHadProd.py.

91def makeBackgroundX(runList, cycle: int = 0) -> None:
92 for run in runList:
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)
97 nt = f.pythia6
98 N = nt.GetEntries()
99 f.Close()
100 cmd = (
101 "python $FAIRSHIP/muonShieldOptimization/run_fixedTarget.py --force --charm -V -e 10 -P -n "
102 + str(N)
103 + " -r "
104 + str(orun)
105 + " -b 100 -X 100 -I "
106 + inputFile
107 )
108 if run in runList:
109 os.system(cmd + " >logFT" + str(orun) + " &")
110 os.chdir("../")
111
112

◆ makeHadrons()

None runCharmHadProd.makeHadrons (   run)

Definition at line 33 of file runCharmHadProd.py.

33def makeHadrons(run) -> None:
34 for n in range(ncpus):
35 x.Rndm() * 1000000000.0
36 os.system("mkdir run" + str(run))
37 os.chdir("run" + str(run))
38 cmd = (
39 "python $FAIRSHIP/macro/makeCascade.py -m "
40 + msel
41 + " -n "
42 + str(nev)
43 + " -t Cascade-run"
44 + str(run)
45 + "-parp16-MSTP82-1-MSEL"
46 + msel
47 + ".root"
48 )
49 # if not run in runList:
50 os.system(cmd + " >log" + str(run) + " &")
51 os.chdir("../")
52 run += 1
53
54

◆ merge()

None runCharmHadProd.merge (   run,
int   cycle = 0 
)

Definition at line 113 of file runCharmHadProd.py.

113def merge(run, cycle: int = 0) -> None:
114 fname = "pythia8_Geant4_XX_10.0.root"
115 cmd = " "
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:
121 continue
122 if cycle == 0 and run == 0 and not x.find("1010") < 0:
123 continue
124 cmd += path + "/run" + str(run + n) + "/" + x + "/" + fname.replace("XX", str(orun + n)) + " "
125 if msel == "4":
126 outFile = fname.replace("XX", "charm_" + str(orun) + "-" + str(orun + ncpus - 1))
127 else:
128 outFile = fname.replace("XX", "beauty_" + str(orun) + "-" + str(orun + ncpus - 1))
129 rc = os.system("hadd -O " + outFile + " " + cmd)
130 if rc != 0:
131 print("hadd failed, stop", outFile)
132 else:
133 rc = os.system("xrdcp " + outFile + " $EOSSHIP/eos/experiment/ship/data/Mbias/background-prod-2018/" + outFile)
134 if rc != 0:
135 print("copy to EOS failed, stop", outFile)
136 else:
137 rc = os.system("rm " + outFile)
138
139

◆ mergeAll()

None runCharmHadProd.mergeAll ( )

Definition at line 140 of file runCharmHadProd.py.

140def mergeAll() -> None:
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"
143 for x in [
144 "0-19",
145 "20-39",
146 "40-59",
147 "60-79",
148 "80-99",
149 "1000-1019",
150 "1020-1039",
151 "1040-1059",
152 "1060-1079",
153 "1080-1099",
154 "2000-2019",
155 "2020-2039",
156 "2040-2059",
157 "2060-2079",
158 "2080-2099",
159 ]:
160 cmd += tmp.replace("XX", x) + " "
161 os.system(cmd)
162
163

◆ potFromFileHeader()

None runCharmHadProd.potFromFileHeader (   f)

Definition at line 234 of file runCharmHadProd.py.

234def potFromFileHeader(f) -> None:
235 pot = 0
236 for x in f.GetListOfKeys():
237 if x.GetName() == "FileHeader":
238 pot += float(x.GetTitle().split(" ")[3])
239 print("PoT = ", pot)
240
241

◆ statistics()

None runCharmHadProd.statistics ( )

Definition at line 221 of file runCharmHadProd.py.

221def statistics() -> None:
222 path = os.environ["EOSSHIP"] + "/eos/experiment/ship/data/Mbias/background-prod-2018/"
223 fname = "Cascade-runAA-BB-parp16-MSTP82-1-MSEL4-40Mpot.root"
224 nPot = 0
225 nhadrons = 0
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")
232
233

Variable Documentation

◆ chicc

float runCharmHadProd.chicc = 1.7e-3

Definition at line 16 of file runCharmHadProd.py.

◆ cycle

int runCharmHadProd.cycle = 2

Definition at line 87 of file runCharmHadProd.py.

◆ else

runCharmHadProd.else :

Definition at line 17 of file runCharmHadProd.py.

◆ msel

str runCharmHadProd.msel = "4"

Definition at line 10 of file runCharmHadProd.py.

◆ ncpus

int runCharmHadProd.ncpus = 20

Definition at line 9 of file runCharmHadProd.py.

◆ nev

int runCharmHadProd.nev = 2000000

Definition at line 14 of file runCharmHadProd.py.

◆ path

str runCharmHadProd.path = "/afs/cern.ch/project/lbcern/vol1/truf/charm/"

Definition at line 15 of file runCharmHadProd.py.

◆ run

int runCharmHadProd.run = int(sys.argv[1])

Definition at line 245 of file runCharmHadProd.py.

◆ runList

list runCharmHadProd.runList = [20, 28, 30, 33]

Definition at line 88 of file runCharmHadProd.py.

◆ x

ROOT runCharmHadProd.x = ROOT.TRandom3()

Definition at line 242 of file runCharmHadProd.py.