SND@LHC Software
Loading...
Searching...
No Matches
runCharmHadProd Namespace Reference

Functions

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

Variables

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

Function Documentation

◆ compactifyCascade()

runCharmHadProd.compactifyCascade (   run)

Definition at line 98 of file runCharmHadProd.py.

98def compactifyCascade(run):
99 ncpus = 20
100 cmd = ''
101 Ntot = 0
102 NperJob = nev
103 for i in range(run,+ncpus):
104 fName = path+"run"+str(i)+"/Cascade-run"+str(i)+"-parp16-MSTP82-1-MSEL"+msel+".root"
105 f=open(path+"run"+str(i)+"/log"+str(i))
106 success = False
107 for l in f.readlines():
108 if not l.find('Macro finished succesfully')<0: success = True
109 if not success:
110 print("job not finished properly",fName)
111 continue
112 cmd += fName +" "
113 f.close()
114 Ntot+= NperJob
115 if cmd.find('root')<0:
116 print('no file found, exit')
117 else:
118 stat = str( int(Ntot/1E6))+'Mpot'
119 outFile = "Cascade-run"+str(run)+"-"+str(run+ncpus-1)+"-parp16-MSTP82-1-MSEL"+msel+"-"+stat+".root"
120 rc = os.system("hadd -O "+outFile + " " +cmd)
121 f = ROOT.TFile(outFile)
122 Npot = f.Get("2").GetBinContent(1)/2./chicc
123 f.Close()
124 stat = str( int(Npot/1E9))+'Bpot'
125 oldOutFile = outFile
126 outFile = "Cascade-run"+str(run)+"-"+str(run+ncpus-1)+"-parp16-MSTP82-1-MSEL"+msel+"-"+stat+".root"
127 os.system("mv "+oldOutFile+" "+outFile)
128 rc = os.system("xrdcp "+outFile+" $EOSSHIP/eos/experiment/ship/data/Mbias/background-prod-2018/"+outFile)
129 if rc != 0:
130 print("copy to EOS failed, stop",outFile)
131 else:
132 rc = os.system("rm "+outFile)
133

◆ makeBackground()

runCharmHadProd.makeBackground (   run,
  cycle = 0 
)

Definition at line 35 of file runCharmHadProd.py.

35def makeBackground(run,cycle=0):
36 for n in range(ncpus):
37 orun = run+cycle*1000
38 os.chdir('run'+str(run))
39 inputFile = path+"run"+str(run)+"/Cascade-run"+str(run)+"-parp16-MSTP82-1-MSEL"+msel+".root"
40 f=ROOT.TFile(inputFile)
41 nt = f.pythia6
42 N = nt.GetEntries()
43 f.Close()
44 if msel == "4":
45 cmd = "python $FAIRSHIP/muonShieldOptimization/run_fixedTarget.py --force --charm -V -e 10 -P -n "+str(N)+" -r "+str(orun)+" -b 100 -X 100 -I "+inputFile
46 else:
47 cmd = "python $FAIRSHIP/muonShieldOptimization/run_fixedTarget.py --force --beauty -V -e 10 -P -n "+str(N)+" -r "+str(orun)+" -b 100 -X 100 -I "+inputFile
48 os.system(cmd+ " >logFT"+str(orun)+" &")
49 os.chdir('../')
50 run+=1
51

◆ makeBackgroundX()

runCharmHadProd.makeBackgroundX (   runList,
  cycle = 0 
)

Definition at line 54 of file runCharmHadProd.py.

54def makeBackgroundX(runList,cycle=0):
55 for run in runList:
56 orun = run+cycle*1000
57 os.chdir('run'+str(run))
58 inputFile = path+"run"+str(run)+"/Cascade-run"+str(run)+"-parp16-MSTP82-1-MSEL"+msel+".root"
59 f=ROOT.TFile(inputFile)
60 nt = f.pythia6
61 N = nt.GetEntries()
62 f.Close()
63 cmd = "python $FAIRSHIP/muonShieldOptimization/run_fixedTarget.py --force --charm -V -e 10 -P -n "+str(N)+" -r "+str(orun)+" -b 100 -X 100 -I "+inputFile
64 if run in runList: os.system(cmd+ " >logFT"+str(orun)+" &")
65 os.chdir('../')
66

◆ makeHadrons()

runCharmHadProd.makeHadrons (   run)

Definition at line 24 of file runCharmHadProd.py.

24def makeHadrons(run):
25 for n in range(ncpus):
26 s = x.Rndm()*1000000000.
27 os.system('mkdir run'+str(run))
28 os.chdir('run'+str(run))
29 cmd = "python $FAIRSHIP/macro/makeCascade.py -m "+msel+" -n " + str(nev) + " -t Cascade-run"+str(run)+"-parp16-MSTP82-1-MSEL"+msel+".root"
30 # if not run in runList:
31 os.system(cmd+ " >log"+str(run)+" &")
32 os.chdir('../')
33 run+=1
34

◆ merge()

runCharmHadProd.merge (   run,
  cycle = 0 
)

Definition at line 67 of file runCharmHadProd.py.

67def merge(run,cycle=0):
68 fname = "pythia8_Geant4_XX_10.0.root"
69 cmd = " "
70 for n in range(ncpus):
71 for x in os.listdir(path+'/run'+str(run+n)):
72 orun = run+cycle*1000
73 if not x.find('run_fixedTarget_'+str(orun+n)) < 0:
74 if cycle == 0 and run == 0 and not x.find('1001') < 0: continue
75 if cycle == 0 and run == 0 and not x.find('1010') < 0: continue
76 cmd += path+'/run'+str(run+n)+'/'+x+'/'+fname.replace('XX',str(orun+n))+' '
77 if msel == "4": outFile = fname.replace('XX', 'charm_'+str(orun)+'-'+str(orun+ncpus-1) )
78 else: outFile = fname.replace('XX', 'beauty_'+str(orun)+'-'+str(orun+ncpus-1) )
79 rc = os.system("hadd -O "+outFile + " " +cmd)
80 if rc != 0:
81 print("hadd failed, stop",outFile)
82 else:
83 rc = os.system("xrdcp "+outFile+" $EOSSHIP/eos/experiment/ship/data/Mbias/background-prod-2018/"+outFile)
84 if rc != 0:
85 print("copy to EOS failed, stop",outFile)
86 else:
87 rc = os.system("rm "+outFile)
88

◆ mergeAll()

runCharmHadProd.mergeAll ( )

Definition at line 89 of file runCharmHadProd.py.

89def mergeAll():
90 cmd = "hadd pythia8_Geant4_charm_153.3B_10.0_mu.root "
91 tmp = "/eos/experiment/ship/data/Mbias/background-prod-2018/pythia8_Geant4_charm_XX_10.0_mu.root"
92 for x in ["0-19","20-39","40-59","60-79","80-99",\
93 "1000-1019","1020-1039","1040-1059","1060-1079","1080-1099",\
94 "2000-2019","2020-2039","2040-2059","2060-2079","2080-2099"]:
95 cmd+=tmp.replace('XX',x)+" "
96 os.system(cmd)
97

◆ potFromFileHeader()

runCharmHadProd.potFromFileHeader ( )

Definition at line 148 of file runCharmHadProd.py.

148def potFromFileHeader():
149 pot = 0
150 for x in f.GetListOfKeys():
151 if x.GetName()=='FileHeader':
152 pot += float(x.GetTitle().split(' ')[3])
153 print("PoT = ",pot)
154

◆ statistics()

runCharmHadProd.statistics ( )

Definition at line 134 of file runCharmHadProd.py.

134def statistics():
135 chicc=1.7e-3
136 if msel=='5': chicc = 1.6e-7
137 path = os.environ['EOSSHIP']+"/eos/experiment/ship/data/Mbias/background-prod-2018/"
138 fname = "Cascade-runAA-BB-parp16-MSTP82-1-MSEL4-40Mpot.root"
139 nPot = 0
140 nhadrons = 0
141 for x in [0,20,40,60,80]:
142 fn = fname.replace('AA',str(x)).replace('BB',str(x+19))
143 f=ROOT.TFile.Open(path+fn)
144 nPot += f.Get("2").GetBinContent(1)/2.
145 nhadrons += f.Get('pythia6').GetEntries()
146 print("total nr of hadrons:",nhadrons,nPot/chicc/1.E9,'Billion')
147

Variable Documentation

◆ cycle

int runCharmHadProd.cycle = 2

Definition at line 52 of file runCharmHadProd.py.

◆ msel

str runCharmHadProd.msel = "4"

Definition at line 4 of file runCharmHadProd.py.

◆ ncpus

int runCharmHadProd.ncpus = 20

Definition at line 3 of file runCharmHadProd.py.

◆ nev

int runCharmHadProd.nev = 2000000

Definition at line 8 of file runCharmHadProd.py.

◆ path

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

Definition at line 9 of file runCharmHadProd.py.

◆ run

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

Definition at line 158 of file runCharmHadProd.py.

◆ runList

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

Definition at line 53 of file runCharmHadProd.py.

◆ x

runCharmHadProd.x = ROOT.TRandom3()

Definition at line 155 of file runCharmHadProd.py.