1from __future__
import print_function
5muonIn =
'$SHIPSOFT/data/muConcrete.root'
8if len(sys.argv)>1: nJob = int(sys.argv[1])
9if len(sys.argv)>2: nMult = int(sys.argv[2])
10if len(sys.argv)>3: muonIn = sys.argv[3]
11if len(sys.argv)>4: nPerJob = int(sys.argv[4])
14from array
import array
15PDG = ROOT.TDatabasePDG.Instance()
16myPythia = ROOT.TPythia6()
19for kf
in [211,321,130,310,3112,3122,3222,3312,3322,3334]:
20 kc = myPythia.Pycomp(kf)
21 myPythia.SetMDCY(kc,1,0)
27 if not apid
in masssq:
28 masssq[apid] = PDG.GetParticle(apid).Mass()**2
31R = int(time.time()%900000000)
33mutype = {-13:
'gamma/mu+',13:
'gamma/mu-'}
38fout = ROOT.TFile(
'muonDis_'+str(nJob)+
'.root',
'recreate')
39dTree = ROOT.TTree(
'DIS',
'muon DIS')
40iMuon = ROOT.TClonesArray(
"TVectorD")
41iMuonBranch = dTree.Branch(
"InMuon",iMuon,32000,-1)
42dPart = ROOT.TClonesArray(
"TVectorD")
43dPartBranch = dTree.Branch(
"Particles",dPart,32000,-1)
46fin = ROOT.TFile(muonIn)
49def rotate(ctheta,stheta,cphi,sphi,px,py,pz):
51 px1=ctheta*px+stheta*pz
52 pzr=-stheta*px+ctheta*pz
58nTOT = sTree.GetEntries()
61nEnd = min(nTOT,nStart + nPerJob)
62if muonIn.find(
'Concrete')<0:
67myPythia.SetMSTU(11, 11)
68print(
"start production ",nStart,nEnd)
70for k
in range(nStart,nEnd):
71 rc = sTree.GetEvent(k)
73 px,py,pz = sTree.px,sTree.py,sTree.pz
74 x,y,z = sTree.x,sTree.y,sTree.z
75 pid,w = sTree.id,sTree.w
76 p = ROOT.TMath.Sqrt(px*px+py*py+pz*pz)
79 theta = ROOT.TMath.ACos(pz/p)
80 phi = ROOT.TMath.ATan2(py,px)
81 ctheta,stheta = ROOT.TMath.Cos(theta),ROOT.TMath.Sin(theta)
82 cphi,sphi = ROOT.TMath.Cos(phi),ROOT.TMath.Sin(phi)
83 mu = array(
'd',[pid,px,py,pz,E,x,y,z,w])
84 muPart = ROOT.TVectorD(9,mu)
85 myPythia.Initialize(
'FIXT',mutype[pid],
'p+',p)
86 for n
in range(nMult):
90 myPythia.GenerateEvent()
93 for itrk
in range(1,myPythia.GetN()+1):
94 did = myPythia.GetK(itrk,2)
95 dpx,dpy,dpz =
rotate(ctheta,stheta,cphi,sphi,myPythia.GetP(itrk,1),myPythia.GetP(itrk,2),myPythia.GetP(itrk,3))
96 psq = dpx**2+dpy**2+dpz**2
98 m = array(
'd',[did,dpx,dpy,dpz,E])
99 part = ROOT.TVectorD(5,m)
101 nPart = dPart.GetEntries()
102 if dPart.GetSize() == nPart: dPart.Expand(nPart+10)
105 if nMade%10000==0: print(
'made so far ',nMade)
109myPythia.SetMSTU(11, 6)
110print(
"created nJob ",nJob,
':',nStart,
' - ',nEnd,
" events")
rotate(ctheta, stheta, cphi, sphi, px, py, pz)