126  cuts = {
'':
'',
'_onlyMuons':
'abs(id)==13',
'_onlyNeutrinos':
'abs(id)==12||abs(id)==14||abs(id)==16'}
 
  131   for i 
in range(len(stats[ecut])):
 
  132    h[fn] = ROOT.TFile(files[ecut][i])
 
  133    t = h[fn].FindObjectAny(
"pythia8-Geant4")
 
  137     for l 
in t.GetListOfLeaves(): tuples += l.GetName()+
':' 
  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)
 
  146      h[
'ntuple'] = ROOT.TNtuple(
"pythia8-Geant4",
"flux after 3m hadron absorber, position&momentum before",tuples)
 
  149    t.Draw(
">>temp",cuts[opt])
 
  150    temp = gROOT.FindObjectAny(
'temp')
 
  153    for iev 
in range(nev) :
 
  154     rc = t.GetEntry(temp.GetEntry(iev))
 
  155     leaves = t.GetListOfLeaves()
 
  157     for x 
in range(leaves.GetEntries()):
 
  158      vlist.append( leaves.At(x).GetValue() )
 
  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)
 
  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.])
 
  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])
 
  180     vlist.append( float(ecut) )
 
  181     h[
'ntuple'].Fill(vlist)
 
 
  186 import rootUtils 
as ut
 
  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)
 
  194 sTree.Draw(
'z>>originz') 
 
  195 sTree.Draw(
'1000*sqrt(x*x+y*y):z>>originzr') 
 
  196 sTree.Draw(
'1000*x:1000*y>>originxy')