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

Functions

 makeFinalNtuples (norm=5.E13, opt='')
 
 interactionRegion ()
 

Variables

bool Yandex = False
 
bool Yandex2 = False
 
bool Yandex3 = True
 
bool afterHadronAbsorber = False
 
bool JPsi = False
 
bool MoTarget = False
 
bool Tau = False
 
 pdg = TDatabasePDG()
 
 mu = pdg.GetParticle(13)
 
 Mmu = mu.Mass()
 
 Mmu2 = Mmu * Mmu
 
dict stats = {5.:[1E9,1E9],0.5:[1E8]}
 
dict files = {5.:['$SHIPSOFT/data/result_1Bn_ecut_5.root','$SHIPSOFT/data/result_1Bn_ecut_5-v02.root'],0.5:['$SHIPSOFT/data/result_0.1Bn_ecut_0.5.root']}
 
str fnew = 'pythia8_Geant4_total_Yandex.root'
 
float BR = 0.05961
 
dict jobs = {'b6276c506a_g4Ex_gap_':['53','54','55','56'],'b602f257b0_g4Ex_gap_':['52']}
 
int nevts = 0
 
int ntot = 0
 
str tag = '#events='
 
str path = job+run+str(i)+'/'
 
 fl = open(path+'log'+run+str(i))
 
 k = l.find(tag)
 
 ecut = float(r.split('.root')[0].split('_')[3])
 
dict h = {}
 
 norm
 
 E13
 
 opt
 

Function Documentation

◆ interactionRegion()

g4Ex_gap_mergeFiles.interactionRegion ( )

Definition at line 185 of file g4Ex_gap_mergeFiles.py.

185def interactionRegion():
186 import rootUtils as ut
187 import shipunit as u
188 f = ROOT.TFile('pythia8_Geant4_13_350.0.root')
189 sTree=f.FindObjectAny('pythia8-Geant4')
190 ut.bookHist(h,'originz','z',100,-50.5,-49.)
191 ut.bookHist(h,'originzr','r vs z',100,-50.5,-49.,100,0.,0.5)
192 ut.bookHist(h,'originxy','x vs y',100,-0.5,0.5,100,-0.5,0.5)
193 ROOT.gROOT.cd()
194 sTree.Draw('z>>originz')
195 sTree.Draw('1000*sqrt(x*x+y*y):z>>originzr')
196 sTree.Draw('1000*x:1000*y>>originxy')
197
198

◆ makeFinalNtuples()

g4Ex_gap_mergeFiles.makeFinalNtuples (   norm = 5.E13,
  opt = '' 
)

Definition at line 125 of file g4Ex_gap_mergeFiles.py.

125def makeFinalNtuples(norm=5.E13,opt=''):
126 cuts = {'':'','_onlyMuons':'abs(id)==13','_onlyNeutrinos':'abs(id)==12||abs(id)==14||abs(id)==16'}
127 first = True
128 tuples = ''
129 fn = 1
130 for ecut in stats:
131 for i in range(len(stats[ecut])):
132 h[fn] = ROOT.TFile(files[ecut][i])
133 t = h[fn].FindObjectAny("pythia8-Geant4")
134 fn+=1
135 if first:
136 first = False
137 for l in t.GetListOfLeaves(): tuples += l.GetName()+':'
138 tuples+='w:ecut'
139 fxx = fnew.replace('.root',opt+'.root')
140 if opt!='': fxx = fxx.replace('_total','')
141 h['N'] = ROOT.TFile(fxx, 'RECREATE')
142 print('new file created',fxx)
143 if afterHadronAbsorber:
144 h['ntuple'] = ROOT.TNtuple("pythia8-Geant4","flux after 3m hadron absorber",tuples)
145 else:
146 h['ntuple'] = ROOT.TNtuple("pythia8-Geant4","flux after 3m hadron absorber, position&momentum before",tuples)
147 gROOT.cd()
148 t.SetEventList(0)
149 t.Draw(">>temp",cuts[opt])
150 temp = gROOT.FindObjectAny('temp')
151 t.SetEventList(temp)
152 nev = temp.GetN()
153 for iev in range(nev) :
154 rc = t.GetEntry(temp.GetEntry(iev))
155 leaves = t.GetListOfLeaves()
156 vlist = array('f')
157 for x in range(leaves.GetEntries()):
158 vlist.append( leaves.At(x).GetValue() )
159 # get kinetic energy "id:px:py:pz:x:y:z:ox:oy:oz:pythiaid:parentid"
160 # since 2016 "id:px:py:pz:x:y:z:opx:opy:opz:ox:oy:oz:pythiaid:parentid"
161 Psq = vlist[1]**2+vlist[2]**2+vlist[3]**2
162 if abs(vlist[0])==13: Ekin = ROOT.TMath.Sqrt(Mmu2+Psq)-Mmu
163 else: Ekin = ROOT.TMath.Sqrt(Psq)
164 if Yandex:
165 if Ekin < ecut : continue
166 if Ekin > 5. : weight = norm/(ntot[5.] + ntot[0.5])
167 else : weight = norm/(ntot[0.5])
168 if Yandex2 or Yandex3:
169 if Ekin < ecut : continue
170 weight = norm/(ntot[10.])
171 if JPsi : weight = norm/(ntot[10.])
172 if Tau : weight = norm/(ntot[0.])
173 if MoTarget:
174 if Ekin < ecut : continue
175 if Ekin > 50. : weight = norm/(ntot[0.5] + ntot[10.] + ntot[20.]+ ntot[50.])
176 elif Ekin > 20. : weight = norm/(ntot[0.5] + ntot[10.] + ntot[20.])
177 elif Ekin > 10. : weight = norm/(ntot[0.5] + ntot[10.])
178 else : weight = norm/(ntot[0.5])
179 vlist.append(weight)
180 vlist.append( float(ecut) )
181 h['ntuple'].Fill(vlist)
182 h['N'].cd()
183 h['ntuple'].Write()
184

Variable Documentation

◆ afterHadronAbsorber

bool g4Ex_gap_mergeFiles.afterHadronAbsorber = False

Definition at line 7 of file g4Ex_gap_mergeFiles.py.

◆ BR

float g4Ex_gap_mergeFiles.BR = 0.05961

Definition at line 34 of file g4Ex_gap_mergeFiles.py.

◆ E13

g4Ex_gap_mergeFiles.E13

Definition at line 199 of file g4Ex_gap_mergeFiles.py.

◆ ecut

g4Ex_gap_mergeFiles.ecut = float(r.split('.root')[0].split('_')[3])

Definition at line 107 of file g4Ex_gap_mergeFiles.py.

◆ files

dict g4Ex_gap_mergeFiles.files = {5.:['$SHIPSOFT/data/result_1Bn_ecut_5.root','$SHIPSOFT/data/result_1Bn_ecut_5-v02.root'],0.5:['$SHIPSOFT/data/result_0.1Bn_ecut_0.5.root']}

Definition at line 23 of file g4Ex_gap_mergeFiles.py.

◆ fl

g4Ex_gap_mergeFiles.fl = open(path+'log'+run+str(i))

Definition at line 45 of file g4Ex_gap_mergeFiles.py.

◆ fnew

str g4Ex_gap_mergeFiles.fnew = 'pythia8_Geant4_total_Yandex.root'

Definition at line 24 of file g4Ex_gap_mergeFiles.py.

◆ h

dict g4Ex_gap_mergeFiles.h = {}

Definition at line 124 of file g4Ex_gap_mergeFiles.py.

◆ jobs

dict g4Ex_gap_mergeFiles.jobs = {'b6276c506a_g4Ex_gap_':['53','54','55','56'],'b602f257b0_g4Ex_gap_':['52']}

Definition at line 37 of file g4Ex_gap_mergeFiles.py.

◆ JPsi

bool g4Ex_gap_mergeFiles.JPsi = False

Definition at line 8 of file g4Ex_gap_mergeFiles.py.

◆ k

g4Ex_gap_mergeFiles.k = l.find(tag)

Definition at line 47 of file g4Ex_gap_mergeFiles.py.

◆ Mmu

g4Ex_gap_mergeFiles.Mmu = mu.Mass()

Definition at line 18 of file g4Ex_gap_mergeFiles.py.

◆ Mmu2

g4Ex_gap_mergeFiles.Mmu2 = Mmu * Mmu

Definition at line 19 of file g4Ex_gap_mergeFiles.py.

◆ MoTarget

bool g4Ex_gap_mergeFiles.MoTarget = False

Definition at line 9 of file g4Ex_gap_mergeFiles.py.

◆ mu

g4Ex_gap_mergeFiles.mu = pdg.GetParticle(13)

Definition at line 17 of file g4Ex_gap_mergeFiles.py.

◆ nevts

int g4Ex_gap_mergeFiles.nevts = 0

Definition at line 38 of file g4Ex_gap_mergeFiles.py.

◆ norm

g4Ex_gap_mergeFiles.norm

Definition at line 199 of file g4Ex_gap_mergeFiles.py.

◆ ntot

dict g4Ex_gap_mergeFiles.ntot = 0

Definition at line 39 of file g4Ex_gap_mergeFiles.py.

◆ opt

g4Ex_gap_mergeFiles.opt

Definition at line 199 of file g4Ex_gap_mergeFiles.py.

◆ path

str g4Ex_gap_mergeFiles.path = job+run+str(i)+'/'

Definition at line 44 of file g4Ex_gap_mergeFiles.py.

◆ pdg

g4Ex_gap_mergeFiles.pdg = TDatabasePDG()

Definition at line 16 of file g4Ex_gap_mergeFiles.py.

◆ stats

dict g4Ex_gap_mergeFiles.stats = {5.:[1E9,1E9],0.5:[1E8]}

Definition at line 22 of file g4Ex_gap_mergeFiles.py.

◆ tag

str g4Ex_gap_mergeFiles.tag = '#events='

Definition at line 40 of file g4Ex_gap_mergeFiles.py.

◆ Tau

bool g4Ex_gap_mergeFiles.Tau = False

Definition at line 10 of file g4Ex_gap_mergeFiles.py.

◆ Yandex

bool g4Ex_gap_mergeFiles.Yandex = False

Definition at line 4 of file g4Ex_gap_mergeFiles.py.

◆ Yandex2

bool g4Ex_gap_mergeFiles.Yandex2 = False

Definition at line 5 of file g4Ex_gap_mergeFiles.py.

◆ Yandex3

bool g4Ex_gap_mergeFiles.Yandex3 = True

Definition at line 6 of file g4Ex_gap_mergeFiles.py.