229 pmom=[5.,10.,15.,20.,25.,50.,75.,100.,150.,200.,250,300.,400.,500.,750.,1000.,1500.,2500.,5000.,7500.,10000.]
230 mutype = {-13:
'gamma/mu+',13:
'gamma/mu-'}
234 h[
'g_'+
str(pid)+t] = ROOT.TGraph()
235 h[
'g_'+
str(pid)+t].SetName(
'g_'+
str(pid)+t)
238 print(
'run pythia6 for ',pid,
' on ',t,
'with p=',P)
241 ut.bookHist(h,
"Qhist"+tag,
"Q;[GeV]", 100, 0., 50.)
242 ut.bookHist(h,
"pTehist"+tag,
"pT of scattered muon;[GeV]", 100, 0., 50.)
243 ut.bookHist(h,
"xhist"+tag,
"x", 100, 0., 1.)
244 ut.bookHist(h,
"yhist"+tag,
"y", 100, 0., 1.)
245 ut.bookHist(h,
"pTrhist"+tag,
"pT of radiated parton; [GeV]", 100, 0., 50.)
246 ut.bookHist(h,
"pTdhist"+tag,
"ratio pT_parton/pT_muon", 100, 0., 5.)
247 ut.bookHist(h,
"nMult"+tag,
"particle multiplicity", 50, -0.5, 49.5)
248 ut.bookHist(h,
"nMultcha"+tag,
"charged particle multiplicity", 50, -0.5, 49.5)
249 ut.bookHist(h,
"nMultneu"+tag,
"neutral particle multiplicity", 50, -0.5, 49.5)
251 myPythia = ROOT.TPythia6()
253 myPythia.SetPARP(2,2)
254 R =
int(time.time()%900000000)
255 myPythia.SetMRPY(1,R)
257 myPythia.SetMSTU(11, 11)
258 myPythia.Initialize(
'FIXT',mutype[pid],t,P)
259 for n
in range(nstat):
260 myPythia.GenerateEvent()
262 for i
in range(1,myPythia.GetN()+1):
263 tmp = ROOT.Pythia8.Vec4(myPythia.GetP(i,1),myPythia.GetP(i,2),myPythia.GetP(i,3),myPythia.GetP(i,4))
264 print(i,myPythia.GetK(i,2),tmp.pAbs())
265 pProton = ROOT.Pythia8.Vec4(myPythia.GetP(2,1),myPythia.GetP(2,2),myPythia.GetP(2,3),myPythia.GetP(2,4))
266 peIn = ROOT.Pythia8.Vec4(myPythia.GetP(1,1),myPythia.GetP(1,2),myPythia.GetP(1,3),myPythia.GetP(1,4))
267 peOut = ROOT.Pythia8.Vec4(myPythia.GetP(3,1),myPythia.GetP(3,2),myPythia.GetP(3,3),myPythia.GetP(3,4))
268 pPhoton = peIn - peOut
270 Q2 = - pPhoton.m2Calc()
271 W2 = (pProton + pPhoton).m2Calc()
272 x = Q2 / (2. * (pProton * pPhoton))
273 y = (pProton * pPhoton) / (pProton * peIn)
274 h[
'Qhist'+tag].Fill( ROOT.TMath.Sqrt(Q2) )
275 h[
'xhist'+tag].Fill( x )
276 h[
'yhist'+tag].Fill( y )
277 h[
'pTehist'+tag].Fill( peOut.pT() )
281 for i
in range(1,myPythia.GetN()+1):
283 pidCode = myPythia.GetK(i,2)
284 ch = myPythia.Pychge(pidCode)
285 if abs( ch )>0 : nMult[1]+=1
286 elif pidCode != 22 : nMult[2]+=1
287 tmp = ROOT.Pythia8.Vec4(myPythia.GetP(i,1),myPythia.GetP(i,2),myPythia.GetP(i,3),myPythia.GetP(i,4))
288 h[
'pTrhist'+tag].Fill( tmp.pT() )
289 h[
'pTdhist'+tag].Fill( tmp.pT() / peOut.pT() )
290 h[
'nMult'+tag].Fill(nMult[0])
291 h[
'nMultcha'+tag].Fill(nMult[1])
292 h[
'nMultneu'+tag].Fill(nMult[2])
299 h[
'g_'+
str(pid)+t].SetPoint(np,P,xsec)
301 fout = ROOT.TFile(
'muDIScrossSec_Pythia6.root',
'RECREATE')
304 h[
'g_'+
str(pid)+t].Write()
307 for x
in [
"nMult"+tag,
"nMultcha"+tag,
"nMultneu"+tag,
"Qhist"+tag,
"pTehist"+tag,
308 "xhist"+tag,
"yhist"+tag,
"pTrhist"+tag,
"pTdhist"+tag]:
334 pmom=[50.,75.,100.,150.,200.,250,300.,400.,500.,750.,1000.,1500.,2500.,5000.,7500.,10000.]
335 mutype = {-13:
'mu+',13:
'mu-'}
340 h[
'g_'+
str(pid)+g] = ROOT.TGraph()
341 h[
'g_'+
str(pid)+g].SetName(
'g_'+
str(pid)+g)
344 generators[g]=ROOT.Pythia8.Pythia()
345 if g==
'p': generators[g].settings.mode(
"Beams:idB", 2212)
346 else: generators[g].settings.mode(
"Beams:idB", 2112)
347 generators[g].settings.mode(
"Next:numberCount",options.heartbeat)
348 generators[g].settings.mode(
"Beams:frameType", 2)
349 generators[g].settings.parm(
"Beams:eA",P)
350 generators[g].settings.mode(
"Beams:idA", pid)
351 generators[g].settings.parm(
"Beams:eB",0.)
352 generators[g].readString(
"PDF:pSet = "+options.PDFpSet)
355 generators[g].readString(
"WeakBosonExchange:ff2ff(t:gmZ) = on")
358 generators[g].readString(
"WeakBosonExchange:ff2ff(t:W) = on")
361 generators[g].settings.parm(
"PhaseSpace:Q2Min", Q2min)
364 generators[g].readString(
"SpaceShower:dipoleRecoil = on")
368 generators[g].readString(
"SpaceShower:pTmaxMatch = 2")
371 generators[g].readString(
"PDF:lepton = off")
372 generators[g].readString(
"TimeShower:QEDshowerByL = off")
377 ut.bookHist(h,
"Qhist"+tag,
"Q;[GeV]", 100, 0., 50.)
378 ut.bookHist(h,
"pTehist"+tag,
"pT of scattered muon;[GeV]", 100, 0., 50.)
379 ut.bookHist(h,
"xhist"+tag,
"x", 100, 0., 1.)
380 ut.bookHist(h,
"yhist"+tag,
"y", 100, 0., 1.)
381 ut.bookHist(h,
"pTrhist"+tag,
"pT of radiated parton; [GeV]", 100, 0., 50.)
382 ut.bookHist(h,
"pTdhist"+tag,
"ratio pT_parton/pT_muon", 100, 0., 5.)
383 ut.bookHist(h,
"nMult"+tag,
"particle multiplicity", 50, -0.5, 49.5)
384 ut.bookHist(h,
"nMultcha"+tag,
"charged particle multiplicity", 50, -0.5, 49.5)
385 ut.bookHist(h,
"nMultneu"+tag,
"neutral particle multiplicity", 50, -0.5, 49.5)
387 for n
in range(nstat):
388 rc = generators[g].next()
390 event = generators[g].event
392 pProton = event[2].p()
395 pPhoton = peIn - peOut
397 Q2 = - pPhoton.m2Calc()
398 W2 = (pProton + pPhoton).m2Calc()
399 x = Q2 / (2. * (pProton * pPhoton))
400 y = (pProton * pPhoton) / (pProton * peIn)
401 h[
'Qhist'+tag].Fill( ROOT.TMath.Sqrt(Q2) )
402 h[
'xhist'+tag].Fill( x )
403 h[
'yhist'+tag].Fill( y )
404 h[
'pTehist'+tag].Fill( event[6].pT() )
407 for i
in range(event.size()):
409 if (event[i].status()>0):
411 if abs( event[i].chargeType() )>0 : nMult[1]+=1
412 elif event[i].id() != 22 : nMult[2]+=1
413 if (event[i].statusAbs() == 43):
414 h[
'pTrhist'+tag].Fill( event[i].pT() )
415 h[
'pTdhist'+tag].Fill( event[i].pT() / event[6].pT() )
416 h[
'nMult'+tag].Fill(nMult[0])
417 h[
'nMultcha'+tag].Fill(nMult[1])
418 h[
'nMultneu'+tag].Fill(nMult[2])
420 xsec = ROOT.fixInfo(generators[g])
421 h[
'g_'+
str(pid)+g].SetPoint(np,P,xsec)
423 fout = ROOT.TFile(
'muDIScrossSec_Pythia8.root',
'RECREATE')
426 h[
'g_'+
str(pid)+g].Write()
429 for x
in [
"nMult"+tag,
"nMultcha"+tag,
"nMultneu"+tag,
"Qhist"+tag,
"pTehist"+tag,
430 "xhist"+tag,
"yhist"+tag,
"pTrhist"+tag,
"pTdhist"+tag]:
450 if withElossFunction:
451 ut.readHists(h,
"meanEloss.root")
452 eLoss = h[
'TCeloss'].FindObject(
'pol3').Clone(
'eLoss')
454 myPythia = ROOT.TPythia6()
456 myPythia.SetPARP(2,2)
457 for kf
in [211,321,130,310,3112,3122,3222,3312,3322,3334]:
458 kc = myPythia.Pycomp(kf)
459 myPythia.SetMDCY(kc,1,0)
460 R =
int(time.time()%900000000)
461 myPythia.SetMRPY(1,R)
462 mutype = {-13:
'gamma/mu+',13:
'gamma/mu-'}
466 fout = ROOT.TFile(
'muonDis_'+
str(options.run)+
'.root',
'recreate')
467 dTree = ROOT.TTree(
'DIS',
'muon DIS')
468 iMuon = ROOT.TClonesArray(
"TParticle")
469 iMuonBranch = dTree.Branch(
"InMuon",iMuon,32000,-1)
470 dPart = ROOT.TClonesArray(
"TParticle")
471 dPartBranch = dTree.Branch(
"Particles",dPart,32000,-1)
473 fin = ROOT.TFile(options.muonIn)
475 nTOT = sTree.GetEntries()
476 nEnd = min(nTOT,options.nStart + options.nEvents)
478 myPythia.SetMSTU(11, 11)
479 print(
"start production ",options.nStart,nEnd)
481 for k
in range(options.nStart,nEnd):
482 rc = sTree.GetEvent(k)
484 px,py,pz = sTree.px,sTree.py,sTree.pz
485 x,y,z = sTree.x,sTree.y,sTree.z-SND_Z
486 pid,w =
int(sTree.id),sTree.w
487 if withElossFunction:
488 E = sTree.E - eLoss.Eval(sTree.E)
491 p = ROOT.TMath.Sqrt(px*px+py*py+pz*pz)
492 Peloss = ROOT.TMath.Sqrt(E*E-muonMass*muonMass)
496 theta = ROOT.TMath.ACos(pz/p)
497 phi = ROOT.TMath.ATan2(py,px)
498 ctheta,stheta = ROOT.TMath.Cos(theta),ROOT.TMath.Sin(theta)
499 cphi,sphi = ROOT.TMath.Cos(phi),ROOT.TMath.Sin(phi)
501 muPart = ROOT.TParticle(pid,0,0,0,0,0,px*escale,py*escale,pz*escale,E,x,y,z,t)
503 myPythia.Initialize(
'FIXT',mutype[pid],nucleon,E)
504 for n
in range(options.nMult):
508 myPythia.GenerateEvent()
511 for itrk
in range(1,myPythia.GetN()+1):
512 did = myPythia.GetK(itrk,2)
513 dpx,dpy,dpz =
rotate(ctheta,stheta,cphi,sphi,myPythia.GetP(itrk,1),myPythia.GetP(itrk,2),myPythia.GetP(itrk,3))
514 psq = dpx**2+dpy**2+dpz**2
516 part = ROOT.TParticle(did,0,0,0,0,0,dpx,dpy,dpz,E,x,y,z,t)
517 part.SetWeight(w/
float(options.nMult))
519 nPart = dPart.GetEntries()
520 if dPart.GetSize() == nPart: dPart.Expand(nPart+10)
523 if nMade%options.heartbeat==0: print(
'made so far ',options.run,
' :',nMade,time.ctime())
527 myPythia.SetMSTU(11, 6)
528 print(
"finished ",options.run)
642 NinteractionLength = 3
643 fin = ROOT.TFile(
'muDIScrossSec.root')
645 for pid
in [
'13',
'-13']:
646 h[
'g_'+pid] = fin.Get(
'g_'+pid).Clone(
'g_'+pid)
647 ut.bookHist(h,
'inMu_'+
str(pid),
'Energy',200,0.,5000.,20,0.0,19.5)
648 ut.bookHist(h,
'xy_In'+
str(pid),
' x/y muon In',120,-60.,60.,120,-60.,60.)
649 ut.bookCanvas(h,
'sec',
'xsec',900,600,1,1)
650 ut.bookHist(h,
'muDISXsec',
';E [GeV];#sigma [mb]',100,0.,10000.)
652 h[
'muDISXsec'].SetMinimum(0.)
653 h[
'muDISXsec'].SetMaximum(30.E-3)
654 h[
'muDISXsec'].Draw()
655 h[
'muDISXsec'].SetStats(0)
656 h[
'g_13'] .SetLineColor(ROOT.kGreen)
657 h[
'g_13'] .SetLineWidth(4)
658 h[
'g_13'] .Draw(
'same')
659 h[
'g_-13'] .Draw(
'same')
660 h[
'sec'].Print(
'muonXsec.png')
662 h[
'sTree'] = ROOT.TChain(
'DIS')
664 for cycle
in range(options.nMult):
665 for run
in range(1,11):
667 f = ROOT.TFile(
'muonDis_'+
str(run+cycle*100+k)+
'.root')
669 print(
"file corrupted ",run+cycle*100+k)
671 sTree.AddFile(
'muonDis_'+
str(run+cycle*100+k)+
'.root')
672 newFile = ROOT.TFile(
'muonDIS_SND.root',
'RECREATE')
673 newTree = sTree.CloneTree(0)
677 muonEnergy = muon.Energy()
678 pid = muon.GetPdgCode()
679 wLHC = 5.83388*muon.GetWeight()/options.nMult/10.
680 wDis = NinteractionLength * 97.5 / 1.67E-24 * h[
'g_'+
str(pid)].Eval(muonEnergy ) * 1E-27
682 rc = h[
'inMu_'+
str(pid)].Fill(muonEnergy,out.GetEntries(),wLHC*wDis)
685 lam = ( (SND_Z-z_int)-muon.Vz() ) / muon.Pz()
686 mxex = muon.Vx()+lam*muon.Px()
687 myex = muon.Vy()+lam*muon.Py()
689 rc = h[
'xy_In'+
str(muon.GetPdgCode())].Fill(mxex,myex,muon.GetWeight())
690 neutralParticles = []
691 chargedParticles = []
696 hname =
"E_"+
str(pid)
698 ut.bookHist(h,hname,
'Energy',1000,0.,5000.)
699 ut.bookHist(h,
'2dEsnd_'+
str(pid),
'E in SND',1000,0.,5000.,100,0.,5000.)
700 ut.bookHist(h,
'test1_'+
str(pid),
'E in SND',100,0.,5000.)
701 ut.bookHist(h,
'test2_'+
str(pid),
'E in SND',100,0.,5000.)
702 ut.bookHist(h,
'origin_xy'+
str(pid),
'E in SND',100,-100.,100.,100,-100.,100.)
703 ut.bookHist(h,
'2dEsnd_Veto_'+
str(pid),
'E in SND',1000,0.,5000.,100,0.,5000.)
704 ut.bookHist(h,
'Veto_mult_'+
str(pid),
'veto multiplicity',100,0.,100.)
705 ut.bookHist(h,
"xy_"+
str(pid),
'x/y ',120,-60.,60.,120,-60.,60.)
706 rc = h[hname].Fill(E,p.GetWeight())
707 lamP = (SND_Z-z_int)/p.Pz()
708 xex = mxex + lamP*p.Px()
709 yex = myex + lamP*p.Py()
710 rc = h[
"xy_"+
str(pid)].Fill(xex,yex,p.GetWeight())
711 if abs(pid)
in [211,321,13,2212]: chargedParticles.append([pid,E])
718 if -8 > xex
and xex >-49
and 15 < yex
and yex < 57:
719 if pid
in [130,2112,-2112]: neutralParticles.append([pid,E,muonEnergy,wDis*wLHC])
720 rc = h[
"2dEsnd_"+
str(pid)].Fill(E,muonEnergy ,wDis*wLHC)
721 rc = h[
"test1_"+
str(pid)].Fill(muonEnergy ,wLHC)
722 rc = h[
"test2_"+
str(pid)].Fill(muonEnergy)
723 if abs(pid)
in [211,321,13,2212]:
724 if E > 1*u.GeV: veto =
True
726 for x
in neutralParticles:
727 rc = h[
"Veto_mult_"+
str(x[0])].Fill(len(chargedParticles))
728 if len(chargedParticles)>0: rc = h[
'origin_xy'+
str(x[0])].Fill(mxex,myex,x[3])
729 if not veto
and len(neutralParticles)==1:
730 rc = h[
"2dEsnd_Veto_"+
str(x[0])].Fill(x[1],x[2],x[3])
731 if len(neutralParticles)>0: rc = newTree.Fill()
735 ut.bookCanvas(h,
'muDIS_SND2',
'incoming muon energy',1500,900,2,1)
736 c=h[
'muDIS_SND2'].cd(1)
737 hname =
"inMuEsnd_2112"
738 h[hname] = h[
"2dEsnd_2112" ].ProjectionY(hname)
739 ut.makeIntegralDistrib(h,hname)
740 h[
'I-'+hname].SetTitle(
'incoming muon energy;> E [GeV/c];N arbitrary units')
741 h[
'I-'+hname].SetMinimum(1.E-6)
743 h[
'I-'+hname].SetStats(0)
744 h[
'I-'+hname].SetLineWidth(3)
745 h[
'I-'+hname].Draw(
'hist')
746 c=h[
'muDIS_SND2'].cd(2)
747 h[hname].SetTitle(
'incoming muon energy; E [GeV/c];N arbitrary units')
749 h[hname].SetLineWidth(3)
750 h[hname].Draw(
'hist')
751 h[
'muDIS_SND2'].Print(
'inMuEnergy.png')
752 parts = [130,2112,-2112]
754 hname =
"Esnd_"+
str(pid)
755 h[hname] = h[
"2dEsnd_"+
str(pid)].ProjectionX(hname)
756 h[
"Esnd_Veto_"+
str(pid)] = h[
"2dEsnd_Veto_"+
str(pid)].ProjectionX(
"Esnd_Veto_"+
str(pid))
757 ut.makeIntegralDistrib(h,hname)
758 h[
'I-'+hname].GetXaxis().SetRangeUser(0.,1000.)
759 h[
'I-'+hname].SetMinimum(1E-6)
760 ut.makeIntegralDistrib(h,
"Esnd_Veto_"+
str(pid))
761 ut.bookCanvas(h,
'muDIS_SND',
'Kl and neutrons arriving at SND',2500,900,3,1)
762 for k
in range(len(parts)):
765 tc=h[
'muDIS_SND'].cd(k+1)
767 pname = PDG.GetParticle(parts[k]).GetName()
768 hname =
"Esnd_"+
str(parts[k])
769 hnameVeto =
"Esnd_Veto_"+
str(parts[k])
770 for X
in [hname,hnameVeto]:
771 h[
'IFB-'+X] = h[
'I-'+X].Clone(
'IFB-'+X)
772 h[
'IFB-'+X].Scale(150.*fbScale)
773 h[
'IFB-'+X].SetTitle(pname+
';> E [GeV/c];N /150 fb^{-1}')
774 h[
'IFB-'+X]. GetYaxis().SetTitleOffset(1.4)
775 h[
'IFB-'+X].SetMaximum(90*150.)
776 h[
'IFB-'+X].SetStats(0)
777 h[
'IFB-'+X].SetLineWidth(3)
778 h[
'IFB-'+X].SetMinimum(0.1)
779 h[
'IFB-'+hname].Draw(
'hist')
780 h[
'IFB-'+hnameVeto].SetLineColor(ROOT.kRed)
781 h[
'IFB-'+hnameVeto].Draw(
'histsame')
783 histVeto = h[
'I-Esnd_Veto_'+
str(parts[k])]
784 R = hist.GetBinContent(1)
785 RVeto = histVeto.GetBinContent(1)
786 print(
" %s: %5.2F N/sec %5.2F N fb with Veto: %5.2F N fb "%(pname,R,R*fbScale,RVeto*fbScale))
787 R = hist.GetBinContent(3)
788 RVeto = histVeto.GetBinContent(3)
789 print(
"E>10GeV, %s: %5.2F N/sec %5.2F N fb with Veto: %5.2F N fb "%(pname,R,R*fbScale,RVeto*fbScale))
790 R = hist.GetBinContent(21)
791 RVeto= histVeto.GetBinContent(21)
792 print(
"E>100GeV, %s: %5.2E N/sec %5.2F N fb with Veto: %5.2F N fb "%(pname,R,R*fbScale,RVeto*fbScale))
793 R = hist.GetBinContent(41)
794 RVeto= histVeto.GetBinContent(41)
795 print(
"E>200GeV, %s: %5.2E N/sec %5.2F N fb with Veto: %5.2F N fb "%(pname,R,R*fbScale,RVeto*fbScale))
796 R = hist.GetBinContent(101)
797 RVeto = histVeto.GetBinContent(101)
798 print(
"E>500GeV, %s: %5.2E N/sec %5.2F N fb with Veto: %5.2F N fb "%(pname,R,R*fbScale,RVeto*fbScale))
799 h[
'muDIS_SND'].Print(
'muDIS_SND.png')
800 h[
'muDIS_SND'].Print(
'muDIS_SND.pdf')
802 norm = normalization[version]
804 ut.readHists(h,
"efficiency.root")
805 h[
'efficiency'] = h[
'eff'].FindObject(
'eloss_px').Clone(
'efficiency')
807 rc = h[
'efficiency'].Fit(fname,
'S',
'',20,300.)
808 effFun = h[
'efficiency'].GetFunction(fname)
810 ut.readHists(h,
"meanEloss.root")
811 eLoss = h[
'TCeloss'].FindObject(
'pol3').Clone(
'eLoss')
813 fnames = {13:
"unit30_Nm.root",-13:
"unit30_Pm.root"}
814 ut.bookCanvas(h,
'muDIS_SNDXY_1',
'muons',1200,900,1,1)
815 ut.bookCanvas(h,
'muDIS_SNDXY_2',
'muons',1200,900,1,1)
816 ut.bookCanvas(h,
'muDIS_SNDE',
'muons',1200,900,1,1)
818 fin = ROOT.TFile(fnames[mu])
819 ut.bookHist(h,
'xy_'+
str(mu),
'x/y;x [cm];y [cm];N/sec/cm^{2} ' , 200,-100.,100.,200,-100.,100.)
820 ut.bookHist(h,
'xyMS_'+
str(mu),
'x/y;x [cm];y [cm];N/sec/cm^{2} ',200,-100.,100.,200,-100.,100.)
821 ut.bookHist(h,
'xyW_'+
str(mu),
'x/y;x [cm];y [cm];N/sec/cm^{2} ' , 200,-100.,100.,200,-100.,100.)
822 ut.bookHist(h,
'xysco_'+
str(mu),
'x/y;x [cm];y [cm];N/sec/cm^{2} ' , 200,-100.,100.,200,-100.,100.)
823 ut.bookHist(h,
'xyMSW_'+
str(mu),
'x/y;x [cm];y [cm];N/sec/cm^{2} ',200,-100.,100.,200,-100.,100.)
824 ut.bookHist(h,
'Esco_'+
str(mu),
'E in SND',1000,0.,5000.)
825 ut.bookHist(h,
'Esnd_'+
str(mu),
'E in SND',1000,0.,5000.)
826 ut.bookHist(h,
'EsndMS_'+
str(mu),
'E in SND',1000,0.,5000.)
827 ut.bookHist(h,
'Efaser_'+
str(mu),
'E in faser',1000,0.,5000.)
828 ut.bookHist(h,
'EfaserMS_'+
str(mu),
'E in faser',1000,0.,5000.)
829 ut.bookHist(h,
'tanThetaXY_'+
str(mu),
'tan theta X/Y',200,-0.01,0.01,200,-0.01,0.01)
830 ut.bookHist(h,
'tanThetaXY30_'+
str(mu),
'tan theta X/Y',200,-0.01,0.01,200,-0.01,0.01)
831 ut.bookHist(h,
'tanThetaXYSND_'+
str(mu),
'tan theta X/Y',200,-0.01,0.01,200,-0.01,0.01)
832 ut.bookHist(h,
'tanThetaXYMS_'+
str(mu),
'tan theta X/Y',200,-0.01,0.01,200,-0.01,0.01)
833 ut.bookHist(h,
'tanThetaXYMSfaser_'+
str(mu),
'tan theta X/Y',200,-0.01,0.01,200,-0.01,0.01)
834 ut.bookHist(h,
'theta',
'mult scattering angle',200,-1.,1.)
836 px,py,pz = sTree.px,sTree.py,sTree.pz
838 if version == 0: m2cm = 100
839 x,y,z = sTree.x,sTree.y,sTree.z*m2cm
841 pid,w =
int(sTree.id),sTree.w
842 p = ROOT.TMath.Sqrt(px*px+py*py+pz*pz)
844 rc = h[
"Esco_"+
str(mu)].Fill(p,wLHC)
845 rc = h[
'xysco_'+
str(pid)].Fill(x,y,wLHC)
848 if p < effPMax: wLHC=wLHC*effFun.Eval(p)
849 Psnd = p - eLoss.Eval(p)
852 if version == 1: Psnd = p - 26.
857 rc = h[
'xy_'+
str(pid)].Fill(mxex,myex)
858 rc = h[
'xyW_'+
str(pid)].Fill(mxex,myex,wLHC)
859 tanThetaX = ROOT.TMath.Tan(ROOT.TMath.ATan2(px,pz))
860 tanThetaY = ROOT.TMath.Tan(ROOT.TMath.ATan2(py,pz))
861 rc = h[
'tanThetaXY_'+
str(mu)].Fill(tanThetaX,tanThetaY,wLHC)
863 rc = h[
'tanThetaXY30_'+
str(mu)].Fill(tanThetaX,tanThetaY,wLHC)
864 if -8 > mxex
and mxex >-49
and 15 < myex
and myex < 57:
865 rc = h[
"Esnd_"+
str(mu)].Fill(Psnd,wLHC)
866 if -12 < mxex
and mxex < 12
and -12 < myex
and myex < 12:
867 rc = h[
"Efaser_"+
str(mu)].Fill(Psnd,wLHC)
869 for r
in range(Rmult):
873 thetaX = rnr.Gaus(0.,h[
'MS'].Eval(p))
874 thetaY = rnr.Gaus(0.,h[
'MS'].Eval(p))
875 rc = h[
'theta'].Fill(thetaX)
876 rc = h[
'theta'].Fill(thetaY)
877 mxexMS = mxex + (SND_Z-z)*ROOT.TMath.Tan(thetaX)
878 myexMS = myex + (SND_Z-z)*ROOT.TMath.Tan(thetaY)
879 tanThetaX = ROOT.TMath.Tan(ROOT.TMath.ATan2(px,pz)+thetaX)
880 tanThetaY = ROOT.TMath.Tan(ROOT.TMath.ATan2(py,pz)+thetaY)
881 rc = h[
'tanThetaXYSND_'+
str(mu)].Fill(tanThetaX,tanThetaY,wLHC/Rmult)
883 rc = h[
'xyMS_'+
str(pid)].Fill(mxexMS,myexMS)
884 rc = h[
'xyMSW_'+
str(pid)].Fill(mxexMS,myexMS,wLHC/Rmult)
885 if -8 > mxexMS
and mxexMS >-49
and 15 < myexMS
and myexMS < 57:
886 rc = h[
"EsndMS_"+
str(mu)].Fill(Psnd,wLHC/Rmult)
887 if Psnd >0: rc = h[
'tanThetaXYMS_'+
str(mu)].Fill(tanThetaX,tanThetaY,wLHC/Rmult)
888 if -12 < mxexMS
and mxexMS < 12
and -12 < myexMS
and myexMS < 12:
889 rc = h[
"EfaserMS_"+
str(mu)].Fill(Psnd,wLHC/Rmult)
890 if Psnd >0: rc = h[
'tanThetaXYMSfaser_'+
str(mu)].Fill(tanThetaX,tanThetaY,wLHC/Rmult)
891 for hname
in [
"Esco_"+
str(mu),
"Esnd_"+
str(mu),
"EsndMS_"+
str(mu),
"Efaser_"+
str(mu),
"EfaserMS_"+
str(mu)]:
892 if 'I-'+hname
in h: A=h.pop(
'I-'+hname)
894 ut.makeIntegralDistrib(h,hname)
895 h[
'I-'+hname].GetXaxis().SetRangeUser(0.,10000.)
896 h[
'I-'+hname].SetMinimum(1E-6)
897 pname = PDG.GetParticle(mu).GetName()
898 if hname.find(
"Esco")==0:
899 print(
"at scoring plane %s, %s: %5.2F N/sec "%(pname,hname,h[
'I-'+hname].GetBinContent(1)))
901 print(
"at SND dE=-30GeV %s, %s: %5.2F N/sec "%(pname,hname,h[
'I-'+hname].GetBinContent(1)))
902 h[
'snd_1'] = ROOT.TLine(-49,15,-8,15)
903 h[
'snd_2'] = ROOT.TLine(-49,57,-8,57)
904 h[
'snd_3'] = ROOT.TLine(-49,57,-49,15)
905 h[
'snd_4'] = ROOT.TLine(-8,57,-8,15)
906 h[
'fas_1'] = ROOT.TLine(-12,12,12,12)
907 h[
'fas_2'] = ROOT.TLine(-12,-12,12,-12)
908 h[
'fas_3'] = ROOT.TLine(-12,-12,-12,12)
909 h[
'fas_4'] = ROOT.TLine(12,-12,12,12)
911 h[
'snd_'+
str(n)] .SetLineColor(ROOT.kBlack)
912 h[
'snd_'+
str(n)] .SetLineWidth(5)
913 h[
'snd_'+
str(n)] .SetLineStyle(1)
914 h[
'fas_'+
str(n)] .SetLineColor(ROOT.kCyan)
915 h[
'fas_'+
str(n)] .SetLineWidth(5)
916 h[
'fas_'+
str(n)] .SetLineStyle(2)
917 for Y
in [
'xyMSW_',
'xysco_']:
919 h[Y+
str(mu)].SetStats(0)
921 h[Y+
str(mu)].GetXaxis().SetRangeUser(-60.,60.)
922 h[Y+
str(mu)].GetYaxis().SetRangeUser(-60.,60.)
925 h[Y+
str(mu)].GetXaxis().SetRangeUser(-80.,80.)
926 h[Y+
str(mu)].GetYaxis().SetRangeUser(-80.,80.)
927 if mu<0: h[Y+
str(mu)].SetTitle(
"#mu^{+}")
928 if mu>0: h[Y+
str(mu)].SetTitle(
"#mu^{-}")
929 tc = h[
'muDIS_SNDXY_1'].cd()
930 tc.SetRightMargin(0.2)
931 h[Y+
'13'].GetZaxis().SetTitleOffset(1.3)
932 h[Y+
'13'].Draw(
'colz')
934 pal = h[Y+
'13'].GetListOfFunctions()[0]
939 h[
'snd_'+
str(n)].Draw(
'same')
940 if withFaser: h[
'fas_'+
str(n)].Draw(
'same')
941 tc = h[
'muDIS_SNDXY_2'].cd()
942 tc.SetRightMargin(0.2)
943 h[Y+
'-13'].GetZaxis().SetTitleOffset(1.5)
944 h[Y+
'-13'].Draw(
'colz')
946 pal = h[Y+
'-13'].GetListOfFunctions()[0]
951 h[
'snd_'+
str(n)].Draw(
'same')
952 if withFaser: h[
'fas_'+
str(n)].Draw(
'same')
954 myPrint(h[
'muDIS_SNDXY_1'],
'muDIS_SNDXY_muM')
955 myPrint(h[
'muDIS_SNDXY_2'],
'muDIS_SNDXY_muP')
957 myPrint(h[
'muDIS_SNDXY_1'],
'muDIS_SCOXY_muM')
958 myPrint(h[
'muDIS_SNDXY_2'],
'muDIS_SCOXY_muP')
960 R = h[
'I-EsndMS_13'].GetBinContent(1)+h[
'I-EsndMS_-13'].GetBinContent(1)
961 print(
'mu+ and mu- at SND: %5.2F N/sec %5.2F Hz/cm2'%(R,R/(41.*42.)))
962 R = h[
'I-EfaserMS_13'].GetBinContent(1)+h[
'I-EfaserMS_-13'].GetBinContent(1)
963 print(
'mu+ and mu- at Faser: %5.2F N/sec %5.2F Hz/cm2'%(R,R/(24.*24.)))
964 rc = h[
'muDIS_SNDE'].cd(1)
966 h[
'I-Esnd_-13'].SetLineColor(ROOT.kRed)
967 h[
'I-Esnd_13'].SetLineColor(ROOT.kBlue)
968 h[
'I-Esnd_13'].SetFillStyle(2)
969 h[
'I-Esnd_13'].SetStats(0)
970 h[
'I-Esnd_-13'].SetStats(0)
971 h[
'I-Esnd_-13'].SetFillStyle(2)
972 h[
'I-Esnd_13'].SetMinimum(1E-3)
973 h[
'I-Esnd_13'].SetTitle(
';>P [GeV/c]; Hz')
974 h[
'I-Esnd_13'].Draw(
'BAR')
975 h[
'I-Esnd_-13'].Draw(
'sameBAR')
976 h[
't-13' ]=ROOT.TLatex(500,0.1,PDG.GetParticle(-13).GetName())
977 h[
't13' ]=ROOT.TLatex(2500,0.3,PDG.GetParticle(13).GetName())
978 h[
't13' ].SetTextColor(ROOT.kWhite)
979 h[
't13' ].Draw(
'same')
980 h[
't-13'].Draw(
'same')
981 h[
'muDIS_SNDE'].Print(
'muDIS_ESND.png')
1002 norm = normalization[version]
1003 path=
"/mnt/hgfs/microDisk/CERNBOX/SND@LHC/FLUKA/"
1005 if Plimit: pMin = 30.
1007 fnames = {13:path+
"muons_up/version0/unit30_Nm.root",-13:path+
"muons_up/version0/unit30_Pm.root"}
1009 if Plimit: pMin = 27.
1010 fnames = {13:path+
"muons_up/version1/unit30_Nm.root",-13:path+
"muons_up/version1/unit30_Pm.root"}
1012 if Plimit: pMin = 27.
1013 fnames = {13:path+
"muons_down/muons_VCdown_IR1-LHC.root"}
1015 ut.bookCanvas(h,
'TXY',
'muons',1800,650,2,1)
1016 ut.bookCanvas(h,
'TE',
'muons',1800,650,2,1)
1017 ut.bookCanvas(h,
'TW',
'muons',1800,650,2,1)
1020 ut.bookHist(h,
'xySCO_'+
str(mu),
'x/y;x [cm];y [cm];N/sec/cm^{2} ' , 200,-100.,100.,200,-100.,100.)
1021 ut.bookHist(h,
'xySND_'+
str(mu),
'x/y;x [cm];y [cm];N/sec/cm^{2} ' , 200,-100.,100.,200,-100.,100.)
1022 ut.bookHist(h,
'xySNDX_'+
str(mu),
'x/y;x [cm];y [cm];N/sec/cm^{2} ' , 200,-100.,100.,200,-100.,100.)
1023 ut.bookHist(h,
'E_'+
str(mu),
';E [GeV]; N / 5 GeV',1000,0.,5000.)
1024 ut.bookHist(h,
'W_'+
str(mu),
'w',100,0.,0.15)
1026 fin = ROOT.TFile(fnames[mu])
1027 for sTree
in fin.nt:
1029 if version == 0: m2cm = 100.
1030 P = ROOT.TVector3(sTree.px,sTree.py,sTree.pz)
1031 if P.Mag()<pMin:
continue
1032 X = ROOT.TVector3(sTree.x,sTree.y,sTree.z*m2cm)
1033 pid,w =
int(sTree.id),sTree.w
1035 rc = h[
'xySCO_'+
str(pid)].Fill(X[0],X[1],wLHC)
1036 rc = h[
"E_"+
str(pid)].Fill(P.Mag(),wLHC)
1037 rc = h[
'W_'+
str(pid)].Fill(w)
1038 lam = ( SND_Z-X[2])/P[2]
1040 rc = h[
'xySND_'+
str(pid)].Fill(Xex[0],Xex[1],wLHC)
1041 if abs(sTree.x)>50.
or abs(sTree.y)>50.: rc = h[
'xySNDX_'+
str(pid)].Fill(Xex[0],Xex[1],wLHC)
1043 for Y
in [
'xySCO_',
'xySND_',
'xySNDX_']:
1044 if version==0
and Y==
'xySNDX_':
continue
1048 h[Y+
str(mu)].SetStats(0)
1049 h[Y+
str(mu)].SetMaximum(5.)
1050 if mu<0: h[Y+
str(mu)].SetTitle(
"#mu^{+}")
1051 if mu>0: h[Y+
str(mu)].SetTitle(
"#mu^{-}")
1053 tc.SetRightMargin(0.2)
1054 h[Y+
str(mu)].GetZaxis().SetTitleOffset(1.3)
1055 h[Y+
str(mu)].Draw(
'colz')
1057 pal = h[Y+
str(mu)].GetListOfFunctions()[0]
1060 if not Y.find(
'xySND')<0:
1061 for n
in range(1,5):
1062 h[
'snd_'+
str(n)].Draw(
'same')
1063 if withFaser: h[
'fas_'+
str(n)].Draw(
'same')
1064 myPrint(h[
'TXY'],
'FlukaMuons'+Y+
'v'+
str(version))
1070 if mu<0: h[
"E_"+
str(mu)].SetTitle(
"#mu^{+}")
1071 if mu>0: h[
"E_"+
str(mu)].SetTitle(
"#mu^{-}")
1072 h[
"E_"+
str(mu)].SetStats(0)
1073 h[
"E_"+
str(mu)].Draw()
1074 myPrint(h[
'TE'],
'FlukaMuonsE_v'+
str(version))
1080 if mu<0: h[
"W_"+
str(mu)].SetTitle(
"#mu^{+}")
1081 if mu>0: h[
"W_"+
str(mu)].SetTitle(
"#mu^{-}")
1082 h[
"W_"+
str(mu)].SetStats(0)
1083 h[
"W_"+
str(mu)].Draw()
1084 myPrint(h[
'TW'],
'FlukaMuonsW_v'+
str(version))
1086 if not 'stats' in h: h[
'stats'] = {}
1087 h[
'stats'][version] = {}
1088 stats = h[
'stats'][version]
1091 for z
in [
'snd',
'fas']:
1093 for Y
in [
'xySND_',
'xySNDX_']:
1095 xMin = hist.GetXaxis().FindBin(h[z+
'_1'].GetX1())
1096 xMax = hist.GetXaxis().FindBin(h[z+
'_1'].GetX2())
1097 yMin = hist.GetYaxis().FindBin(h[z+
'_1'].GetY1())
1098 yMax = hist.GetYaxis().FindBin(h[z+
'_2'].GetY1())
1103 sqcm = (xMax-xMin)*(yMax-yMin)
1104 stats[mu][z].append(hist.Integral(xMin,xMax,yMin,yMax))
1105 stats[mu][z].append(sqcm)
1106 stats[mu][
'total'] = h[
'xySND_'+
str(mu)].GetSumOfWeights()
1107 stats[mu][
'1x1'] = h[
'xySND_'+
str(mu)].GetSumOfWeights() - h[
'xySNDX_'+
str(mu)].GetSumOfWeights()
1109 print(
"-------- "+PDG.GetParticle(mu).GetName()+
" ----------")
1110 if version==1
and 0
in h[
'stats']:
1111 print(
'increae of rates, total: %5.2F absolute(1x1) %5.2F new/old=%5.2F'%(stats[mu][
'1x1']/stats[mu][
'total'],stats[mu][
'1x1'],stats[mu][
'1x1']/h[
'stats'][0][mu][
'1x1']))
1112 newOvOld = (stats[mu][
'snd'][0] -stats[mu][
'snd'][1])/(h[
'stats'][0][mu][
'snd'][0] -h[
'stats'][0][mu][
'snd'][1])
1113 newOvOldTOT = stats[mu][
'snd'][0]/h[
'stats'][0][mu][
'snd'][0]
1114 print(
'increae of rates, SND: %5.2F absolute(1x1) %5.2F new/old=%5.2F new/old(tot)=%5.2F'%(stats[mu][
'snd'][1]/stats[mu][
'snd'][0],stats[mu][
'snd'][0] -stats[mu][
'snd'][1],newOvOld,newOvOldTOT ))
1115 newOvOld = (stats[mu][
'fas'][0] -stats[mu][
'fas'][1])/(h[
'stats'][0][mu][
'fas'][0] -h[
'stats'][0][mu][
'fas'][1])
1116 newOvOldTOT = stats[mu][
'fas'][0]/h[
'stats'][0][mu][
'fas'][0]
1117 print(
'increae of rates, FAS: %5.2F absolute(1x1) %5.2F new/old=%5.2F new/old(tot)=%5.2F'%(stats[mu][
'fas'][1]/stats[mu][
'fas'][0] ,stats[mu][
'fas'][0] -stats[mu][
'fas'][1],newOvOld,newOvOldTOT ))
1119 print(
'increae of rates, total: %5.2F absolute(1x1) %5.2F'%(h[
'xySNDX_'+
str(mu)].GetSumOfWeights()/h[
'xySND_'+
str(mu)].GetSumOfWeights(),
1120 h[
'xySND_'+
str(mu)].GetSumOfWeights()-h[
'xySNDX_'+
str(mu)].GetSumOfWeights()) )
1121 print(
'increae of rates, SND: %5.2F absolute(1x1) %5.2F'%(stats[mu][
'snd'][1]/stats[mu][
'snd'][0],stats[mu][
'snd'][0] -stats[mu][
'snd'][1] ))
1122 print(
'increae of rates, FAS: %5.2F absolute(1x1) %5.2F'%(stats[mu][
'fas'][1]/stats[mu][
'fas'][0] ,stats[mu][
'fas'][0] -stats[mu][
'fas'][1] ))
1124 if version==1
and 0
in h[
'stats']:
1125 for z
in [
'snd',
'fas']:
1126 sumMu = h[
'stats'][1][13][z][0]+h[
'stats'][1][-13][z][0]
1127 increase = sumMu/(h[
'stats'][0][13][z][0]+h[
'stats'][0][-13][z][0])
1128 print(
'%s: %5.2F /cm2/s increase: %5.2F '%(z,sumMu/h[
'stats'][1][13][z][2],increase))
1174def muondEdX(version=2,njobs=100,path='',withFaser=False, plotOnly=True):
1181 neuPartList = [22,130,310,2112,-2112,3122,-3122,3322,-3322]
1183 norm = normalization[version]
1185 ut.bookHist(h,
'eloss',
'energyLoss', 500,0., 5000.,500,0.,500.)
1186 ut.bookHist(h,
'dx',
'multiple scattering x', 500,0., 5000.,1000,-0.02,0.02)
1187 ut.bookHist(h,
'dy',
'multiple scattering y', 500,0., 5000.,1000,-0.02,0.02)
1188 ut.bookHist(h,
'oE',
'original energy', 500,0.,5000.)
1189 ut.bookHist(h,
'oL',
'flight path', 100,0.,10000.)
1190 ut.bookHist(h,
'3d',
'exit points',200,-100.,100.,200,-100.,100.,600,-500.,100.)
1191 ut.bookHist(h,
'z',
'last z ',1000,-1000.,1000.)
1192 ut.bookHist(h,
'SNDmuP',
'SND entry points',200,-100.,100.,200,-100.,100.)
1193 ut.bookHist(h,
'SNDmuM',
'SND entry points',200,-100.,100.,200,-100.,100.)
1194 ut.bookHist(h,
'SNDmuP_E',
'SND muon enery',200,0.,5000.)
1195 ut.bookHist(h,
'SNDmuM_E',
'SND muon energy',200,0.,5000.)
1196 ut.bookHist(h,
'allmuE_13',
'all muon enery',200,0.,5000.)
1197 ut.bookHist(h,
'allmuE_-13',
'all muon energy',200,0.,5000.)
1198 ut.bookHist(h,
'SNDMuFiltermuP',
'SND entry points',200,-100.,100.,200,-100.,100.)
1199 ut.bookHist(h,
'SNDMuFiltermuM',
'SND entry points',200,-100.,100.,200,-100.,100.)
1200 ut.bookHist(h,
'xy_13',
'x/y;x [cm];y [cm];N/sec/cm^{2} ' , 200,-100.,100.,200,-100.,100.)
1201 ut.bookHist(h,
'xy_-13',
'x/y;x [cm];y [cm];N/sec/cm^{2} ' , 200,-100.,100.,200,-100.,100.)
1203 for p
in neuPartList: ut.bookHist(h,
"E_"+
str(p),
'Energy', 500,0.,5000.)
1205 if version == 3: g = ROOT.TFile(path+
'muGeant4_VCdown_0/geofile_full.conical.Ntuple-TGeant4.root')
1206 elif version == 2: g = ROOT.TFile(path+
'muGeant4_0/geofile_full.conical.Ntuple-TGeant4.root')
1207 else: g = ROOT.TFile(path+
'muMinusGeant4_0/geofile_full.conical.Ntuple-TGeant4.root')
1208 geoManager = g.FAIRGeom
1209 for subjob
in range(njobs):
1210 if version == 3: muons = [path+
'muGeant4_VCdown_'+
str(subjob)+
'/ship.conical.Ntuple-TGeant4.root']
1211 elif version == 2: muons = [path+
'muGeant4_'+
str(subjob)+
'/ship.conical.Ntuple-TGeant4.root']
1212 else: muons = [path+
'muMinusGeant4_'+
str(subjob)+
'/ship.conical.Ntuple-TGeant4.root',path+
'muPlusGeant4_'+
str(subjob)+
'/ship.conical.Ntuple-TGeant4.root']
1214 h[fname] = ROOT.TFile(fname)
1217 for sTree
in h[fname].cbmsim:
1219 muon = sTree.MCTrack[0]
1220 w = norm*muon.GetWeight()
1221 muID = muon.GetPdgCode()
1222 if muon.GetPdgCode()==0:
1223 print(
'something strange here PdgCode=0',fname)
1224 rc = h[
'oE'].Fill(muon.GetEnergy(),w)
1225 for x
in sTree.MCTrack:
1226 pid = x.GetPdgCode()
1227 if pid
in neuPartList: rc = h[
"E_"+
str(pid)].Fill(x.GetEnergy())
1229 for p
in sTree.vetoPoint:
1230 track = p.GetTrackID()
1231 if track < 0:
continue
1232 if track != 0:
continue
1234 if not track
in trajectories: trajectories[track]={}
1235 traj = trajectories[track]
1237 middle = ROOT.TVector3(p.GetX(),p.GetY(),p.GetZ())
1238 first = 2*middle - end
1239 Pin = ROOT.Math.PxPyPzMVector(p.GetPx(),p.GetPy(),p.GetPz(),muonMass)
1240 Pout = ROOT.Math.PxPyPzMVector(p.LastMom()[0],p.LastMom()[1],p.LastMom()[2],muonMass)
1243 if sTree.ScifiPoint.GetEntries()>0
or sTree.MuFilterPoint.GetEntries()>0
and end.z() < -24.5:
1244 print(
'something strange here, pout.z<0',nEv,fname,sTree.ScifiPoint.GetEntries(),sTree.MuFilterPoint.GetEntries())
1247 test = end + 1./Pout.Z()*p.LastMom()
1248 node = geoManager.FindNode(test[0],test[1],test[2])
1249 enterCave = node.GetName() .find(
'Vrock') <0
1250 traj[first[2]]=[first[0],first[1],Pin,
False]
1251 traj[end[2]]=[end[0],end[1],Pout,enterCave]
1252 for track
in trajectories:
1253 traj = trajectories[track]
1254 zPos = list(traj.keys())
1256 T = [ROOT.TGraph(),ROOT.TGraph()]
1260 T[j].SetPoint(k,z,traj[z][j])
1262 xex,yex = T[0].Eval(0),T[1].Eval(0)
1263 if xex==0
and yex==0:
1266 print(nEv,fname,track,traj,zPos)
1267 rc = h[
'xy_'+
str(muID)].Fill(xex,yex,w)
1270 if not traj[z][3]:
continue
1271 oEnergy = muon.GetEnergy()
1274 h[
'allmuE_'+
str(muID)].Fill(P.E())
1276 eloss = muon.GetEnergy() - P.E()
1277 rc = h[
'eloss'].Fill(oEnergy,eloss,w)
1278 start = ROOT.TVector3(sTree.MCTrack[0].GetStartX(),sTree.MCTrack[0].GetStartY(),sTree.MCTrack[0].GetStartZ())
1280 rc = h[
'oL'].Fill(L.Mag(),w)
1282 dAlpha = muon.GetPx()/muon.GetPz() - P.X()/P.Z()
1283 rc = h[
'dx'].Fill(oEnergy,dAlpha)
1284 dAlpha = muon.GetPy()/muon.GetPz()- P.Y()/P.Z()
1285 rc = h[
'dy'].Fill(oEnergy,dAlpha)
1286 rc = h[
'3d'].Fill(traj[z][0],traj[z][1],z,w)
1289 for p
in sTree.ScifiPoint:
1291 omu = p.GetTrackID()
1292 if omu != 0
or abs(p.PdgCode()) != 13:
continue
1294 if p.PdgCode()<0: hname =
'SNDmuP'
1295 rc = h[hname].Fill(p.GetX(),p.GetY(),w)
1296 mom = ROOT.TVector3(p.GetPx(),p.GetPy(),p.GetPz())
1297 rc = h[hname+
'_E'].Fill(mom.Mag(),w)
1301 for p
in sTree.MuFilterPoint:
1303 omu = p.GetTrackID()
1304 if omu != 0
or abs(p.PdgCode()) != 13:
continue
1305 hname =
'SNDMuFiltermuM'
1306 if p.PdgCode()<0: hname =
'SNDMuFiltermuP'
1307 rc = h[hname].Fill(p.GetX(),p.GetY(),w)
1312 for p
in sTree.ScifiPoint:
1313 if abs(p.PdgCode()) != 13:
continue
1314 if p.GetDetectorID()==47:
1319 ut.writeHists(h,
'muondEdX_'+
str(version)+
'.root')
1321 ut.readHists(h,
'muondEdX_'+
str(version)+
'.root')
1323 for det
in [
'SND',
'SNDMuFilter']:
1324 S = h[det+
'muP'].Clone(
'S')
1327 nx,ny = h[hname].GetXaxis().GetNbins(),h[hname].GetYaxis().GetNbins()
1328 projx = S.ProjectionX()
1329 projy = S.ProjectionY()
1330 for ix
in range(1,nx+1):
1331 if projx.GetBinContent(ix)>0:
1332 xmin = projx.GetBinCenter(ix)-projx.GetBinWidth(ix)/2.
1334 for ix
in range(nx,0,-1):
1335 if projx.GetBinContent(ix)>0:
1336 xmax = projx.GetBinCenter(ix)+projx.GetBinWidth(ix)/2.
1338 for iy
in range(1,ny+1):
1339 if projy.GetBinContent(iy)>0:
1340 ymin = projy.GetBinCenter(iy)-projy.GetBinWidth(iy)/2.
1342 for iy
in range(ny,0,-1):
1343 if projy.GetBinContent(iy)>0:
1344 ymax = projy.GetBinCenter(iy)+projy.GetBinWidth(iy)/2.
1346 sqcm = (xmax-xmin)*(ymax-ymin)
1347 muP = h[det+
'muP'].GetSumOfWeights()
1348 muM = h[det+
'muM'].GetSumOfWeights()
1349 print(
"%s square: %5.2F,%5.2F,%5.2F,%5.2F"%(det,xmin,xmax,ymin,ymax))
1350 print(
" mu+ rate = %5.2F Hz %5.2F Hz/cm2"%(muP,muP/sqcm))
1351 print(
" mu- rate = %5.2F Hz %5.2F Hz/cm2"%(muM,muM/sqcm))
1352 print(
" sum rate = %5.2F Hz %5.2F Hz/cm2"%(muM+muP,(muM+muP)/sqcm))
1354 ut.bookCanvas(h,
'TCeloss',
'eloss',900,600,1,1)
1355 tc = h[
'TCeloss'].cd()
1356 h[
'eloss_mean'] = h[
'eloss'].ProfileX(
'mean',1,-1,
'g')
1357 h[
'eloss_mean'].GetXaxis().SetRangeUser(10,5000)
1359 h[
'eloss_mean'].Fit(fname,
'S',
'',20.,5000.)
1361 h[
'eloss_mean'].SetTitle(
'; incoming momentun [GeV/c] ; mean energy loss [GeV]')
1362 h[
'eloss_mean'].Draw(
'hist')
1363 fun = h[
'eloss_mean'].GetFunction(fname)
1366 stats = h[
'eloss_mean'].FindObject(
'stats')
1367 stats.SetOptFit(111)
1372 stats.SetY2NDC(0.75)
1376 ut.bookCanvas(h,
'eff',
'efficiency',900,600,1,1)
1378 eff = h[
'eloss'].ProjectionX()
1381 eff.SetTitle(
"; incoming momentun [GeV/c] ; efficiency")
1382 eff.GetXaxis().SetRangeUser(0.,500.)
1386 ut.bookCanvas(h,
'TCMS',
'multiple scattering',900,600,1,1)
1388 msDx = h[
'dx'].ProfileX(
'msDx',1,-1,
's')
1389 N = msDx.GetNbinsX()
1390 Xmin = msDx.GetBinCenter(1)-msDx.GetBinWidth(1)
1391 Xmax = msDx.GetBinCenter(N)+msDx.GetBinWidth(N)
1392 ut.bookHist(h,
'msDxE',
'msDxE',N,Xmin,Xmax)
1395 for j
in range(1,msDx.GetNbinsX()+1):
1396 tmp = h[
'dy'].ProjectionY(
'tmp',j,j)
1399 if tmp.GetEntries()>20:
1400 rc = tmp.Fit(
'gaus',
'SQL')
1401 fitResult = rc.Get()
1402 rms = fitResult.Parameter(2)
1403 Erms = fitResult.ParError(2)
1404 msDxE.SetBinContent(j,rms)
1405 msDxE.SetBinError(j,Erms)
1406 msDxE.SetTitle(
"; incoming momentun [GeV/c] ; MS angle [rad]")
1407 msDxE.SetMaximum(0.02)
1408 msDxE.SetMinimum(0.0001)
1410 msDxE.GetXaxis().SetRangeUser(0.,1000.)
1412 rc = msDxE.Fit(h[
'MS'],
'S',
'',20.,400.)
1414 stats = msDxE.FindObject(
'stats')
1415 stats.SetOptFit(111)
1416 h[
'MS'].Draw(
'same')
1417 myPrint(h[
'TCMS'],
'multipleScattering_'+
str(version))
1420 ut.bookCanvas(h,
'TXY',
'muons',1800,650,2,1)
1424 hist = h[
'xy_'+
str(mu)]
1427 if mu<0: hist.SetTitle(
"#mu^{+}")
1428 if mu>0: hist.SetTitle(
"#mu^{-}")
1430 tc.SetRightMargin(0.2)
1431 hist.GetZaxis().SetTitleOffset(1.3)
1434 pal = hist.GetListOfFunctions()[0]
1437 for n
in range(1,5):
1438 h[
'snd_'+
str(n)].Draw(
'same')
1439 if withFaser: h[
'fas_'+
str(n)].Draw(
'same')
1440 myPrint(h[
'TXY'],
'Geant4Muonsxy_v'+
str(version))
1446 for z
in [
'snd',
'fas']:
1448 hist = h[
'xy_'+
str(mu)]
1449 xMin = hist.GetXaxis().FindBin(h[z+
'_1'].GetX1())
1450 xMax = hist.GetXaxis().FindBin(h[z+
'_1'].GetX2())
1451 yMin = hist.GetYaxis().FindBin(h[z+
'_1'].GetY1())
1452 yMax = hist.GetYaxis().FindBin(h[z+
'_2'].GetY1())
1457 sqcm = (xMax-xMin)*(yMax-yMin)
1458 stats[mu][z].append(hist.Integral(xMin,xMax,yMin,yMax))
1459 stats[mu][z].append(sqcm)
1460 print(
'%s, %s: total = %5.2F Hz %5.2F Hz/cm2 '%(mu,z,stats[mu][z][0],stats[mu][z][0]/stats[mu][z][1]))
1463 ut.bookCanvas(h,
'Tmuons',
'muons',1600,900,2,1)
1464 fin = ROOT.TFile(
'muDIScrossSec.root')
1466 L = {
'13':
'SNDmuM',
'-13':
'SNDmuP'}
1468 h[
'g_'+pid] = fin.Get(
'g_'+pid).Clone(
'g_'+pid)
1469 hname = L[pid]+
'_inter'
1470 if pid==
'13': h[L[pid]+
'_E'].SetLineColor(ROOT.kRed)
1471 else: h[L[pid]+
'_E'].SetLineColor(ROOT.kBlue)
1472 h[L[pid]+
'_E'].SetTitle(
';E [GeV]; N/s')
1473 h[L[pid]+
'_E'].SetStats(0)
1474 h[hname]=h[L[pid]+
'_E'].Clone(hname)
1475 for k
in range(1,h[hname].GetNbinsX()+1):
1476 muonEnergy = h[L[pid]+
'_E'].GetBinCenter(k)
1477 wDis = 5.9*19.3 / 1.67E-24 * h[
'g_'+
str(pid)].Eval(muonEnergy) * 1E-27
1478 h[hname].SetBinContent(k,wDis*h[L[pid]+
'_E'].GetBinContent(k))
1479 ut.makeIntegralDistrib(h,L[pid]+
'_E')
1480 ut.makeIntegralDistrib(h,hname)
1481 tc = h[
'Tmuons'].cd(1)
1483 h[
'I-SNDmuM_E'].Draw(
'hist')
1484 h[
'I-SNDmuP_E'].Draw(
'histsame')
1485 tc = h[
'Tmuons'].cd(2)
1487 h[
'I-SNDmuM_inter'].Draw(
'hist')
1488 h[
'I-SNDmuP_inter'].Draw(
'histsame')
1490 myPrint(h[
'Tmuons'],
'Geant4MuonE_v'+
str(version))
1560def muonDISfull(cycle = 0, sMin=0,sMax=200,rMin=1,rMax=11,path = '/eos/experiment/ship/user/truf/SND/muonDis/',debug=0,version=1,pythia6=True):
1563 geofile =
'geofile_full.conical.muonDIS-TGeant4.root'
1564 geofileExample =
'run_1_1/'+geofile
1565 datafile =
'ship.conical.muonDIS-TGeant4.root'
1567 muRange = [
'muMinusGeant4',
'muPlusGeant4']
1568 geofile =
'geofile_full.conical.Ntuple-TGeant4.root'
1569 geofileExample =
'muMinusGeant4_0/'+geofile
1570 datafile =
'/ship.conical.Ntuple-TGeant4.root'
1571 if cycle ==100: datafile =
'/ship.conical.Ntuple-TGeant4_boost100.0.root'
1574 norm = normalization[version]
1575 fin = ROOT.TFile(
'muDIScrossSec.root')
1577 for pid
in [
'13',
'-13']:
1578 h[
'g_'+pid] = fin.Get(
'g_'+pid).Clone(
'g_'+pid)
1579 ut.bookHist(h,
'wDIS_'+pid,
'muon DIS probability',100,0.,0.1)
1580 for z
in [
'0',
'inter']:
1581 ut.bookHist(h,
'inMu_'+z+
str(pid),
'muon Energy vs #direct hits',200,0.,5000.,20,0.0,19.5)
1582 ut.bookHist(h,
"xyz_mu_"+z+
str(pid),
'x/y /z',200,-100.,100.,200,-100.,100.,
int(600/redfac3d) ,-500.,100.)
1583 neuPartList = [22,130,310,2112,-2112,3122,-3122,3322,-3322]
1584 ut.bookHist(h,
'fullStats',
'statistics',2000,-0.5,1999.5)
1585 ut.bookHist(h,
'pidsDict',
'pids dictionary',100,-0.5,99.5)
1588 h[
'pidsDict'].SetBinContent(n,x)
1591 for p
in neuPartList:
1592 for o
in [
'',
'_secondary']:
1593 ut.bookHist(h,
'inE_'+
str(p)+o,
'energy',500,0.,5000.,600,-500.,100.)
1594 ut.bookHist(h,
'inE_Concrete_'+
str(p)+o,
'energy',500,0.,5000.,600,-500.,100.)
1595 ut.bookHist(h,
"E_"+
str(p),
'Energy', 500,0.,5000.,200,-30.,170.)
1596 ut.bookHist(h,
"E_veto_"+
str(p),
'Energy', 500,0.,5000.,200,-30.,170.)
1597 ut.bookHist(h,
"E_vetoParticle_"+
str(p),
'Energy', 500,0.,50.,20,-0.5,19.5)
1598 ut.bookHist(h,
"Eprim_"+
str(p),
'Energy', 500,0.,5000.,200,-30.,170.)
1599 ut.bookHist(h,
"Eprim_veto_"+
str(p),
'Energy', 500,0.,5000.,200,-30.,170.)
1600 ut.bookHist(h,
"startZ_"+
str(p),
'z',200,-100.,300.)
1601 ut.bookHist(h,
"xyz_Inter_"+
str(p),
'x/y/z ',200,-100.,100.,200,-100.,100.,
int(400/redfac3d),-100.,100.)
1602 ut.bookHist(h,
"xyzE100_Inter_"+
str(p),
'x/y/z ',200,-100.,100.,200,-100.,100.,
int(400/redfac3d),-100.,100.)
1603 ut.bookHist(h,
"xyzVeto_Inter_"+
str(p),
'x/y/z ',200,-100.,100.,200,-100.,100.,
int(400/redfac3d),-100.,100.)
1604 ut.bookHist(h,
"xyz_muInter_"+
str(p),
'x/y /z',200,-100.,100.,200,-100.,100.,
int(600/redfac3d) ,-500.,100.)
1605 ut.bookHist(h,
"xyz_origin_"+
str(p),
'x/y /z',200,-100.,100.,200,-100.,100.,
int(600/redfac3d) ,-500.,100.)
1606 ut.bookHist(h,
"z_veto_"+
str(p),
'z veto vs z neutral',100,-50.,50.,100,-50.,50.)
1607 ut.bookHist(h,
"xy_z-30_veto_"+
str(p),
'xy at z=-30cm',200,-100.,100.,200,-100.,100.)
1608 ut.bookHist(h,
"xy_z-30_"+
str(p),
'xy at z=-30cm',200,-100.,100.,200,-100.,100.)
1612 if path.find(
'eos')<0: g = ROOT.TFile.Open(path+geofileExample)
1613 else: g = ROOT.TFile.Open(os.environ[
'EOSSHIP']+path+geofileExample)
1614 geoManager = g.FAIRGeom
1615 if path.find(
'eos')<0:
1616 topDir = os.listdir(path)
1618 topDir =
str( subprocess.check_output(
"xrdfs "+os.environ[
'EOSSHIP']+
" ls -l "+path,shell=
True) )
1620 for run
in range(rMin,rMax):
1622 for subjob
in range(sMin,sMax):
1624 if options.Emin==0: prod =
'run_'+
str(run+cycle*100+k)+
'_'+
str(subjob)
1625 else: prod =
"ecut"+
str(options.Emin)+
'_run_'+
str(run+cycle*100+k)+
'_'+
str(subjob)
1627 prod = k+
"_"+
str(subjob)
1628 if path.find(
'eos')<0:
1629 if not prod
in topDir:
1630 print(
'prod not found ',prod)
1632 if not geofile
in os.listdir(path+prod):
1633 print(
'no geofile found ',path+prod)
1636 if not "/"+prod
in topDir:
1637 print(
'prod not found on eos',prod)
1639 temp = subprocess.check_output(
"xrdfs "+os.environ[
'EOSSHIP']+
" ls -l "+path+prod,shell=
True)
1640 if not geofile
in str(temp):
1641 print(
'no geofile found on eos',path+prod)
1643 if pythia6: rc = h[
'fullStats'].Fill(run+cycle*100+k)
1644 if path.find(
'eos')<0: h[
'f'] = ROOT.TFile.Open(path+prod+datafile)
1645 else: h[
'f'] = ROOT.TFile.Open(os.environ[
'EOSSHIP']+path+prod+datafile)
1647 for sTree
in h[
'f'].cbmsim:
1649 if nEv%1000 == 0: print(
'N ',nEv,prod)
1650 muon = sTree.MCTrack[0]
1651 muonEnergy = muon.GetEnergy()
1652 mupid = muon.GetPdgCode()
1653 muInterVx = ROOT.TVector3(muon.GetStartX(),muon.GetStartY(),muon.GetStartZ())
1658 wLHC = norm*muon.GetWeight()/
float(nMult)
1659 wInter = sTree.MCTrack[2].GetWeight()
1661 wDis = wInter / 1.67E-24 * h[
'g_'+
str(mupid)].Eval(muonEnergy ) * 1E-27
1662 rc = h[
'wDIS_'+
str(mupid)].Fill(wDis)
1665 W = norm*muon.GetWeight()
1666 rc = h[
'inMu_0'+
str(mupid)].Fill(muonEnergy,0,W)
1667 rc = h[
'xyz_mu_0'+
str(mupid)].Fill(muon.GetStartX(),muon.GetStartY(),muon.GetStartZ(),W)
1670 for d
in sTree.MCTrack:
1671 motherOf[d] = d.GetMotherId()
1672 daughterOf = dict(zip(motherOf.values(), motherOf.keys()))
1677 for m
in sTree.MCTrack:
1679 Apid = abs(m.GetPdgCode())
1680 if Apid
in neuPartList:
1682 nodeOrigin = geoManager.FindNode(m.GetStartX(),m.GetStartY(),m.GetStartZ())
1683 om = nodeOrigin.GetName()
1684 if not( om==
'VTI18_1' or om==
'Vrock_1' or om==
'cave_1'):
continue
1690 endZ = d.GetStartZ()
1691 nodeInter = geoManager.FindNode(d.GetStartX(),d.GetStartY(),d.GetStartZ())
1692 if nodeInter.GetName()==
'VTI18_1' or nodeInter.GetName()==
'Vrock_1': concrete =
True
1693 if not endZ<999.:
continue
1695 if m.GetProcID()!=0 : origin =
'_secondary'
1696 rc = h[
'inE_'+
str(m.GetPdgCode())+origin].Fill(m.GetEnergy(),endZ,W)
1697 if concrete: rc = h[
'inE_Concrete_'+
str(m.GetPdgCode())+origin].Fill(m.GetEnergy(),endZ,W)
1698 elif debug>2
and m.GetEnergy()>75.
and endZ>-25.
and endZ<25.
and Apid==130 :
1700 print(
'tagged ',h[
'f'].GetName(),nEv,tagged)
1704 nm = nodeInter.GetName()
1705 if nm!=
'VTI18_1' and nm!=
'Vrock_1' and nm!=
'cave_1' and endZ<25:
1707 neutrals[n] = [m.GetProcID(),nm,d.GetStartX(),d.GetStartY(),d.GetStartZ()]
1708 if sTree.ScifiPoint.GetEntries()<1:
continue
1709 if len(neutrals)<1 :
continue
1713 E = sTree.MCTrack[x].GetEnergy()
1716 if debug>3: print(
'debug',len(neutrals),E,sTree.MCTrack[x])
1719 vetoPoint, zMinCharged = -1,999.
1720 for det
in [sTree.ScifiPoint,sTree.MuFilterPoint]:
1724 part = PDG.GetParticle(p.PdgCode())
1726 if part: charge = part.Charge()
1727 if charge != 0
and p.GetZ() < zMinCharged :
1728 vetoPoint,zMinCharged = p,p.GetZ()
1729 if debug>2
and tagged >0:
1730 print(
"What happened",neu)
1731 Npart = sTree.MCTrack[neu]
1732 E = Npart.GetEnergy()
1733 pid = Npart.GetPdgCode()
1735 neutInterVx = [neutrals[neu][2],neutrals[neu][3],neutrals[neu][4]]
1736 veto = zMinCharged < neutInterVx[2]
1737 rc = h[
'xyz_Inter_'+
str(pid)].Fill(neutInterVx[0],neutInterVx[1],neutInterVx[2],W)
1738 if E>100.: rc = h[
'xyzE100_Inter_'+
str(pid)].Fill(neutInterVx[0],neutInterVx[1],neutInterVx[2],W)
1739 rc = h[
'xyz_origin_'+
str(pid)].Fill(Npart.GetStartX(),Npart.GetStartY(),Npart.GetStartZ(),W)
1740 rc = h[
'xyz_muInter_'+
str(pid)].Fill(muInterVx.X(),muInterVx.Y(),muInterVx.Z(),W)
1742 rc = h[
'xyzVeto_Inter_'+
str(pid)].Fill(neutInterVx[0],neutInterVx[1],neutInterVx[2],W)
1743 rc = h[
"E_veto_"+
str(pid)].Fill(E,neutInterVx[2],W)
1745 P = ROOT.TVector3(p.GetPx(),p.GetPy(),p.GetPz())
1746 pidVeto = p.PdgCode()
1747 if not pidVeto
in pidsDictRev:
1748 print(
"!!!! unknown pid",pidVeto)
1749 L = len(pidsDictRev)
1750 pidsDictRev[pidVeto] = L
1751 rc = h[
'pidsDict'].SetBinContent(L+1,pidVeto)
1752 rc = h[
"E_vetoParticle_"+
str(pid)].Fill(P.Mag(),pidsDictRev[pidVeto],W)
1753 rc = h[
"z_veto_"+
str(pid)].Fill(neutInterVx[2],zMinCharged)
1755 rc = h[
"E_"+
str(pid)].Fill(E,neutInterVx[2],W)
1756 if Npart.GetProcID()==0:
1757 if veto: rc = h[
"Eprim_veto_"+
str(pid)].Fill(E,neutInterVx[2],W)
1758 else: rc = h[
"Eprim_"+
str(pid)].Fill(E,neutInterVx[2],W)
1761 for p
in sTree.MuFilterPoint:
1762 if p.GetZ()<50.
and p.GetZ()>0:
1763 track = p.GetTrackID()
1764 if track<0:
continue
1765 V = sTree.MCTrack[track]
1766 if V.GetStartZ()<-35:
1767 rc = h[
"xy_z-30_"+
str(pid)].Fill(p.GetX(),p.GetY(),W)
1768 if veto: rc = h[
"xy_z-30_veto_"+
str(pid)].Fill(p.GetX(),p.GetY(),W)
1770 h[
'3d']=h[
'xyz_muInter_130'].Clone(
'3d')
1771 h[
'3d'].Add(h[
'xyz_muInter_2112'])
1772 h[
'3d'].Add(h[
'xyz_muInter_-2112'])
1774 if options.Emin==0: ut.writeHists(h,
"muonDISfull-"+
str(sMin)+
"_"+
str(sMax)+
"_"+
str(cycle)+
".root")
1775 else: ut.writeHists(h,
"muonDISfull-"+
str(options.Emin)+
'_'+
str(sMin)+
"_"+
str(sMax)+
"_"+
str(cycle)+
".root")
1777 ut.writeHists(h,
"muonGeant4full-"+
str(sMin)+
"_"+
str(sMax)+
".root")
1803def analyzeDIS(NsubJobs=0,delta=13,hists="../Muons Extended Scoring Plane/muonDISfull.root",runCoverage=6.):
1805 pathToPlots =
"/mnt/hgfs/microDisk/SND@LHC/MuonDis/reMake2022"
1807 if options.pythia6<0:
1808 pathToPlots =
"/mnt/hgfs/microDisk/CERNBOX/SND@LHC/MuonGeant4/"
1809 latex =
'latex-geant4.tex'
1812 ut.readHists(h,hists)
1816 sMin,sMax = s,s+delta
1817 print(
"reading muonDISfull-"+
str(sMin)+
"_"+
str(sMax)+
".root" )
1818 ut.readHists(h,
"muonDISfull-"+
str(sMin)+
"_"+
str(sMax)+
".root")
1821 ut.bookCanvas(h,
'muDIS_SND2',
'incoming muon energy',1500,900,2,1)
1822 c=h[
'muDIS_SND2'].cd(1)
1824 h[hname] = h[
"inMu_013" ].ProjectionX(hname)
1825 h[hname].Add(h[
"inMu_0-13" ].ProjectionX())
1826 ut.makeIntegralDistrib(h,hname)
1827 h[
'I-'+hname].SetTitle(
'incoming muon energy;> E [GeV/c];N arbitrary units')
1828 h[
'I-'+hname].SetMinimum(1.E-6)
1829 h[
'I-'+hname].SetStats(0)
1830 h[
'I-'+hname].SetLineWidth(3)
1831 h[
'I-'+hname].Draw(
'hist')
1832 c=h[
'muDIS_SND2'].cd(2)
1833 h[hname].SetTitle(
'incoming muon energy; E [GeV/c];N arbitrary units')
1834 h[hname].SetStats(0)
1835 h[hname].SetLineWidth(3)
1836 h[hname].Draw(
'hist')
1837 myPrint(h[
'muDIS_SND2'],
'inMuEnergy.png',pathToPlots=pathToPlots)
1839 c=h[
'muDIS_SND2'].cd(1)
1841 for x
in [
'13',
'-13']:
1842 h[
"xy_mu_0"+x] = h[
"xyz_mu_0"+x].Project3D(
'yx')
1843 h[
"xy_mu_0"+x].SetName(
"xy_mu_0"+x)
1844 h[
"xy_mu_0"+x].SetStats(0)
1845 h[
"xy_mu_0"+x].SetTitle(PDG.GetParticle(
int(x)).GetName()+
' ;x [cm]; y [cm]')
1846 h[
"xy_mu_0"+x].Draw(
'colz')
1847 c=h[
'muDIS_SND2'].cd(2)
1848 myPrint(h[
'muDIS_SND2'],
'inMu_0XY',pathToPlots=pathToPlots)
1849 h[
"xyz_mu_0"]=h[
"xyz_mu_013"].Clone(
"xyz_mu_0")
1850 h[
"xyz_mu_0"].Add(h[
"xyz_mu_0-13"])
1851 h[
"yz_mu_0"] = h[
"xyz_mu_0"].Project3D(
'yz')
1852 h[
"yz_mu_0"].SetName(
"yz_mu_0")
1853 h[
"yz_mu_0"].SetStats(0)
1854 h[
"yz_mu_0"].SetTitle(
"; z [cm]; y [cm]")
1855 ut.bookCanvas(h,
'muDIS_SNDyz',
'incoming muon',1200,900,1,1)
1856 c=h[
'muDIS_SNDyz'].cd()
1857 h[
"yz_mu_0"].Draw(
'colz')
1858 myPrint(h[
'muDIS_SNDyz'],
'inMu_0YZ',pathToPlots=pathToPlots)
1860 parts = [130,2112,-2112,310,3122,-3122,3322,-3322,22]
1863 ut.bookCanvas(h,
'muDIS_N0In',
'primary neutrals',1200,1200,3,3)
1864 for k
in range(len(parts)):
1866 pname = PDG.GetParticle(pid).GetName()
1867 tc=h[
'muDIS_N0In'].cd(k+1)
1869 hname =
"inE_"+
str(pid)
1870 hConcr =
"inE_Concrete_"+
str(pid)
1871 hout =
"inE_out_"+
str(pid)
1872 h[hout] = h[hname].Clone(hout)
1873 h[hout].Add(h[hConcr],-1.)
1874 h[hout+
'_projx'] = h[hout].ProjectionX(hout+
'_projx')
1875 h[hname+
'_projx'] = h[hname].ProjectionX(hname+
'_projx')
1876 h[hout+
'_projx'].SetMarkerStyle(20)
1877 h[hname+
'_projx'].SetMarkerStyle(27)
1878 h[hname+
'_projx'].SetStats(0)
1879 binw =
int(h[hname+
'_projx'].GetBinWidth(1))
1880 h[hname+
'_projx'].GetYaxis().SetTitle(
'N [Hz/'+
str(binw)+
'GeV]')
1881 h[hout+
'_projx'].SetMarkerStyle(29)
1882 h[hname+
'_projx'].GetXaxis().SetRangeUser(0.,2900.)
1883 h[hname+
'_projx'].GetXaxis().SetTitle(
'Energy [GeV] ')
1884 h[hname+
'_projx'].SetTitle(pname)
1885 h[hname+
'_projx'].GetYaxis().SetTitleOffset(1.2)
1886 h[hname+
'_projx'].SetMaximum(20.)
1887 h[hname+
'_projx'].Draw(
'PHIST')
1888 h[hname+
'_projx'].Draw(
'histsame')
1889 h[hout+
'_projx'].SetLineColor(ROOT.kRed)
1890 h[hout+
'_projx'].Draw(
'SAMEPHIST')
1891 h[hout+
'_projx'].Draw(
'histsame')
1892 myPrint(h[
'muDIS_N0In'],
'EofPrimNeutrals',pathToPlots=pathToPlots)
1894 tname =
'muDIS_inSND'
1895 ut.bookCanvas(h,tname,
'neutrals not in concrete and z>-25cm',1200,1200,3,3)
1896 for k
in range(len(parts)):
1898 pname = PDG.GetParticle(pid).GetName()
1901 h[
"inE_prim_"+
str(pid)] = h[
"inE_"+
str(pid)].Clone(
"inE_prim_"+
str(pid))
1902 h[
"inE_prim_"+
str(pid)].Add(h[
"inE_Concrete_"+
str(pid)],-1)
1903 h[
"inE_seco_"+
str(pid)] = h[
"inE_"+
str(pid)+
'_secondary'].Clone(
"inE_"+
str(pid)+
'_secondary_out')
1904 h[
"inE_seco_"+
str(pid)].Add(h[
"inE_Concrete_"+
str(pid)+
'_secondary'],-1)
1905 for x
in [
'prim_',
'seco_']:
1906 zmin = h[
"inE_"+x+
str(pid)].GetYaxis().FindBin(-25.)
1907 zmax = h[
"inE_"+x+
str(pid)].GetYaxis().FindBin(+25.)
1908 hname =
"inE_"+x+
str(pid)+
'_SND'
1909 h[hname] = h[
"inE_"+x+
str(pid)].ProjectionX(hname,zmin,zmax)
1910 h[hname].SetStats(0)
1911 binw =
int(h[hname].GetBinWidth(1))
1912 h[hname].GetYaxis().SetTitle(
'N [Hz/'+
str(binw)+
'GeV]')
1913 h[hname].GetXaxis().SetRangeUser(0.,2900.)
1914 h[hname].GetXaxis().SetTitle(
'Energy [GeV] ')
1915 h[hname].SetTitle(pname)
1916 h[hname].GetYaxis().SetTitleOffset(1.2)
1917 h[hname].SetMaximum(20.)
1918 h[hname].SetMinimum(1.E-6)
1919 hname =
"inE_prim_"+
str(pid)+
'_SND'
1920 h[hname].SetLineColor(ROOT.kRed)
1921 h[hname].Draw(
'hist')
1922 hname =
"inE_seco_"+
str(pid)+
'_SND'
1923 h[hname].SetLineColor(ROOT.kBlue)
1924 h[hname].Draw(
'histsame')
1925 myPrint(h[tname],
'EofNeutralsInSND',pathToPlots=pathToPlots)
1928 colour[
''] = ROOT.kRed
1929 colour[
'_secondary'] = ROOT.kBlue
1930 minMax = {
'out_':[9,1E-6],
'Concrete_':[30.,1E-5]}
1931 for k
in range(len(parts)):
1933 for origin
in [
'_secondary',
'']:
1934 hname =
"inE_"+
str(pid)+origin
1935 hConcr =
"inE_Concrete_"+
str(pid) +origin
1936 hout =
"inE_out_"+
str(pid)+origin
1937 h[hout] = h[hname].Clone(hout)
1938 h[hout].Add(h[hConcr],-1.)
1940 for c
in [
'out_',
'Concrete_']:
1941 tname =
'muDIS_neuZend'+c
1942 ut.bookCanvas(h,tname,
'end vertex z',1200,1200,3,3)
1943 for k
in range(len(parts)):
1945 pname = PDG.GetParticle(pid).GetName()
1948 for origin
in [
'_secondary',
'']:
1950 hname =
"inE_"+c+
str(pid)+origin
1951 h[hname+
'_projz'] = h[hname].ProjectionY(hname+
'_projz')
1952 h[hname+
'_projz'].SetLineColor(colour[origin])
1953 h[hname+
'_projz'].SetStats(0)
1954 binw =
int(h[hname+
'_projz'].GetBinWidth(1))
1955 h[hname+
'_projz'].GetYaxis().SetTitle(
'N [Hz/'+
str(binw)+
'GeV]')
1956 h[hname+
'_projz'].GetXaxis().SetTitle(
'z [cm] ')
1957 h[hname+
'_projz'].SetTitle(pname)
1958 h[hname+
'_projz'].GetYaxis().SetTitleOffset(1.2)
1959 h[hname+
'_projz'].SetMaximum(minMax[c][0])
1960 h[hname+
'_projz'].SetMinimum(minMax[c][1])
1961 if origin==
'_secondary': h[hname+
'_projz'].Draw(
'HIST')
1962 else: h[hname+
'_projz'].Draw(
'HISTsame')
1963 myPrint(h[tname],c+
'zEndOfNeutrals',pathToPlots=pathToPlots)
1967 for hist
in [
'xyz_muInter',
'xyz_Inter',
'xyzE100_Inter',
'xyz_origin',
'inE',
'inE_Concrete',
'xyzVeto_Inter',
'z_veto']:
1970 if pid==22:
continue
1972 h[hist] = h[hist+
'_'+
str(pid)].Clone(hist)
1974 else: h[hist].Add(h[hist+
'_'+
str(pid)])
1975 h[
'inE-noConc']=h[
'inE'].Clone(
'inE-noConc')
1976 h[
'inE-noConc'].Add(h[
'inE_Concrete'],-1.)
1977 h[
'inE-noConc_22']=h[
'inE_22'].Clone(
'inE-noConc_22')
1978 h[
'inE-noConc_22'].Add(h[
'inE_Concrete_22'],-1.)
1979 for hist
in [
'xyz_muInter',
'xyz_Inter',
'xyzE100_Inter',
'xyz_origin',
'inE',
'inE-noConc',
'xyzVeto_Inter',
'z_veto']:
1980 if h[hist].ClassName() ==
'TH2D':
1981 h[hist+
'_z']=h[hist].ProjectionY(hist+
'_z')
1982 h[hist+
'_22_z']=h[hist+
'_22'].ProjectionY(hist+
'_22_z')
1983 h[hist+
'_22_z'].SetTitle(
';z [cm]')
1984 h[hist+
'_z'].SetTitle(
';z [cm]')
1986 for g
in [
'',
'_22']:
1987 h[hist+g+
'_z'] =h[hist+g].ProjectionZ(hist+g+
'_z')
1988 h[hist+g+
'_z'].SetTitle(
';z [cm]')
1989 h[hist+g+
'_xy']=h[hist+g].Project3D(
'yx')
1990 h[hist+g+
'_xy'].SetName(hist+g+
'_xy')
1991 h[hist+g+
'_xy'].SetTitle(
';x [cm]; y [cm]')
1992 h[hist+g+
'_xy'].SetStats(0)
1993 h[hist+g+
'_xz']=h[hist+g].Project3D(
'xz')
1994 h[hist+g+
'_xz'].SetName(hist+g+
'_xz')
1995 h[hist+g+
'_xz'].SetTitle(
';z [cm]; x [cm]')
1996 h[hist+g+
'_xz'].SetStats(0)
1997 h[hist+g+
'_yz']=h[hist+g].Project3D(
'yz')
1998 h[hist+g+
'_yz'].SetName(hist+g+
'_yz')
1999 h[hist+g+
'_yz'].SetTitle(
';z [cm]; y [cm]')
2000 h[hist+g+
'_yz'].SetStats(0)
2001 h[hist+
'_z'].SetStats(0)
2002 h[hist+
'_z'].SetTitle(
'; z [cm]')
2003 ut.bookCanvas(h,
'vertices'+hist+
'_z',
'vertices '+hist,1200,900,1,1)
2004 tc = h[
'vertices'+hist+
'_z'].cd()
2005 if hist==
'z_veto': tc.SetLogy()
2006 if hist==
'xyzVeto_Inter': tc.SetLogy()
2007 if hist
in [
'xyz_muInter',
'xyz_origin']:
2010 h[hist+
'_22_z'].SetStats(0)
2011 h[hist+
'_22_z'].SetLineColor(ROOT.kRed)
2012 h[hist+
'_22_z'].Draw()
2013 h[hist+
'_z'].Draw(
'same')
2014 if hist==
'xyzE100_Inter':
2017 if h[hist+
'_z'].GetEntries()>10:
2018 rc = h[hist+
'_z'].Fit(
'expo',
'S',
'',-25.,30.)
2019 fitresult = rc.Get()
2020 txtlam =
'#lambda =%4.1Fcm'%(-1./fitresult.GetParams()[1])
2021 rc = h[hist+
'_22_z'].Fit(
'expo',
'SL',
'',-30.,10.)
2022 fitresult = rc.Get()
2023 funRad =h[hist+
'_22_z'].GetFunction(
'expo')
2024 funRad.SetBit(ROOT.TF1.kNotDraw)
2025 funRad.SetLineColor(h[hist+
'_22_z'].GetLineColor())
2026 txtrad =
'X_{0} =%4.1Fcm'%(-1./fitresult.GetParams()[1])
2027 h[hist+
'_z'].GetFunction(
'expo').SetLineColor(h[hist+
'_z'].GetLineColor())
2029 h[hist+
'_22_z'].Draw(
'same')
2031 T.DrawLatex(-10,0.005,txtlam)
2033 myPrint(h[
'vertices'+hist+
'_z'],hist+
'_z',pathToPlots=pathToPlots)
2034 if h[hist].ClassName() ==
'TH3D':
2035 for proj
in [
'xy',
'xz',
'yz']:
2036 ut.bookCanvas(h,
'vertices'+hist+
'_'+proj,
'vertices '+hist,1200,900,1,1)
2037 tc = h[
'vertices'+hist+
'_'+proj].cd()
2038 h[hist+
'_'+proj].Draw(
'colz')
2039 myPrint(h[
'vertices'+hist+
'_'+proj],hist+
'_'+proj,pathToPlots=pathToPlots)
2041 ut.bookCanvas(h,
'verticesinE_z',
'vertices inE_z',1200,900,1,1)
2042 h[
'verticesinE_z'].cd()
2043 h[
"inE-noConc_z"].SetLineColor(ROOT.kRed)
2044 h[
"inE_z"].Draw(
'hist')
2045 h[
"inE-noConc_z"].Draw(
'samehist')
2046 myPrint(h[
'verticesinE_z'],
"inE_z",pathToPlots=pathToPlots)
2047 ut.bookCanvas(h,
'verticesxyz_Inter_z',
'vertices xyz_Inter_z',1200,900,1,1)
2048 h[
'verticesxyz_Inter_z'].cd()
2049 h[
'xyz_Inter_z'].GetXaxis().SetRangeUser(-50.,100.)
2050 h[
"xyz_Inter_z"].Draw(
'hist')
2051 myPrint(h[
'verticesxyz_Inter_z'],
"verticesxyz_Inter_z",pathToPlots=pathToPlots)
2055 ut.bookCanvas(h,
'mult',
' ',1200,900,1,1)
2058 mults = {22:[19,ROOT.kMagenta],130:[20,ROOT.kRed],2112:[22,ROOT.kBlue],-2112:[23,ROOT.kCyan],
2059 310:[21,ROOT.kOrange],3122:[24,ROOT.kGreen-1],-3122:[25,ROOT.kGreen+1],
2060 3322:[26,ROOT.kGreen-2],-3322:[27,ROOT.kGreen+2]}
2061 h[
'legmult']=ROOT.TLegend(0.6,0.6,0.82,0.75)
2063 hist =
'mult_'+
str(m)
2065 h[hist].SetTitle(
'; N')
2066 h[hist].SetMarkerStyle(mults[m][0])
2067 h[hist].SetMarkerColor(mults[m][1])
2068 h[hist].SetLineColor(mults[m][1])
2069 rc = h[
'legmult'].AddEntry(h[hist],PDG.GetParticle(m).GetName(),
'PL')
2071 for m
in mults: h[
'mult_'+
str(m)].Draw(
'same')
2072 h[
'legmult'].Draw(
'same')
2073 myPrint(h[
'mult'],
"neutralMultiplicities",pathToPlots=pathToPlots)
2075 ut.makeIntegralDistrib(h,
"inE_"+
str(pid))
2076 ut.makeIntegralDistrib(h,
"inE_Concrete_"+
str(pid))
2077 for o
in [
"",
"prim"]:
2078 hname =
"Esnd"+o+
"_"+
str(pid)
2079 h[hname] = h[
"E"+o+
"_"+
str(pid)].ProjectionX(hname)
2080 h[
"Esnd"+o+
"_all_"+
str(pid)] = h[
"E"+o+
"_veto_"+
str(pid)].ProjectionX(
"Esnd"+o+
"_all_"+
str(pid))
2081 h[
"Esnd"+o+
"_all_"+
str(pid)] .Add(h[hname] )
2082 ut.makeIntegralDistrib(h,hname)
2083 h[
'I-'+hname].GetXaxis().SetRangeUser(0.,1000.)
2084 h[
'I-'+hname].SetMinimum(1E-6)
2085 ut.makeIntegralDistrib(h,
"Esnd"+o+
"_all_"+
str(pid))
2087 ut.bookCanvas(h,
'muDIS_SNDwithVeto',
'neutrals arriving at SND',1800,1200,3,3)
2088 for k
in range(len(parts)):
2089 tc=h[
'muDIS_SNDwithVeto'].cd(k+1)
2091 pname = PDG.GetParticle(parts[k]).GetName()
2092 hnameScaled =
"Esnd_"+
str(parts[k])+
"_fb150"
2093 h[hnameScaled] = h[
"Esnd_"+
str(parts[k])].Clone(hnameScaled)
2094 h[hnameScaled].Scale(150.*fbScale/runCoverage)
2095 h[hnameScaled].GetXaxis().SetRangeUser(0,500)
2096 h[hnameScaled].SetStats(0)
2097 h[hnameScaled].SetMaximum(4E6)
2098 h[hnameScaled].SetTitle(pname+
'; E [GeV/c];N/10GeV /150 fb^{-1}')
2099 h[hnameScaled].SetLineWidth(3)
2100 h[hnameScaled].Draw(
'hist')
2101 myPrint(h[
'muDIS_SNDwithVeto'],
'EofNeutralsInSND_vetoApplied',pathToPlots=pathToPlots)
2103 ut.bookCanvas(h,
'muDIS_SNDnoVetoRequired',
'neutrals arriving at SND',1800,1200,3,3)
2104 for k
in range(len(parts)):
2105 tc=h[
'muDIS_SNDnoVetoRequired'].cd(k+1)
2107 pname = PDG.GetParticle(parts[k]).GetName()
2108 hnameScaled =
"Esnd_all_"+
str(parts[k])+
"_fb150"
2109 h[hnameScaled] = h[
"Esnd_all_"+
str(parts[k])].Clone(hnameScaled)
2110 h[hnameScaled].Scale(150.*fbScale/runCoverage)
2111 h[hnameScaled].GetXaxis().SetRangeUser(0,500)
2112 h[hnameScaled].SetStats(0)
2113 h[hnameScaled].SetMaximum(4E6)
2114 h[hnameScaled].SetTitle(pname+
'; E [GeV/c];N/10GeV /150 fb^{-1}')
2115 h[hnameScaled].SetLineWidth(3)
2116 h[hnameScaled].Draw(
'hist')
2117 myPrint(h[
'muDIS_SNDnoVetoRequired'],
'EofNeutralsInSND_NoVetoApplied',pathToPlots=pathToPlots)
2119 for o
in [
"",
"prim"]:
2120 ut.bookCanvas(h,
'muDIS_SND'+o,
'neutrals arriving at SND',1800,1200,3,3)
2121 for k
in range(len(parts)):
2122 tc=h[
'muDIS_SND'+o].cd(k+1)
2125 pname = PDG.GetParticle(parts[k]).GetName()
2126 hname =
"Esnd"+o+
"_"+
str(parts[k])
2127 hnameAll =
"Esnd"+o+
"_all_"+
str(parts[k])
2128 for X
in [hname,hnameAll]:
2129 h[
'IFB-'+X] = h[
'I-'+X].Clone(
'IFB-'+X)
2130 h[
'IFB-'+X].Scale(150.*fbScale)
2131 h[
'IFB-'+X].SetTitle(pname+
';> E [GeV/c];N /150 fb^{-1}')
2132 h[
'IFB-'+X]. GetYaxis().SetTitleOffset(1.4)
2133 h[
'IFB-'+X]. GetXaxis().SetRangeUser(0.1,1200.)
2134 h[
'IFB-'+X].SetMaximum(2E7)
2135 h[
'IFB-'+X].SetStats(0)
2136 h[
'IFB-'+X].SetLineWidth(3)
2137 h[
'IFB-'+X].SetMinimum(1.0)
2138 h[
'IFB-'+hnameAll].Draw(
'hist')
2139 h[
'IFB-'+hname].SetLineColor(ROOT.kRed)
2140 h[
'IFB-'+hname].Draw(
'histsame')
2141 hist = h[
'I-'+hname]
2142 histAll = h[
'I-'+hnameAll]
2143 print(
"----> results for "+o)
2144 for E
in [0,10,100,200,300,500,1000]:
2146 RVeto = hist.GetBinContent(n) / runCoverage
2147 R = histAll.GetBinContent(n) / runCoverage
2149 if parts[k]
in FASERNU:
2150 if E
in FASERNU[parts[k]]:
2151 faser =
"%5.2G"%( FASERNU[parts[k]][E]*scaleFactor )
2152 print(
"E>%i GeV, %s: %5.2F N/sec %5.2F N fb with Veto: %5.2F N fb | %5.2G veto %5.2G (%s) "%(E,pname,R,R*fbScale,RVeto*fbScale,R*150.*fbScale,RVeto*150.*fbScale,faser))
2153 myPrint(h[
'muDIS_SND'+o],
'muDIS_SND'+o,pathToPlots=pathToPlots)
2155 fout = open(latex,
'w')
2156 platex = {2112:
'$n$' ,-2112:
'$\overline{n}$' ,130:
'$K_L$',310:
'$K_S$',3122:
'$\Lambda$',-3122:
'$\overline{\Lambda}$',3322:
'$\Xi + \overline{\Xi}$',22:
'$\gamma$'}
2158 for x
in [2112,-2112,130,310,3122,-3122,3322,22]:
2160 for E
in [10,100,200,300,500,1000]:
2161 pname = PDG.GetParticle(x).GetName()
2162 hnameAll =
"Esnd"+
"_all_"+
str(x)
2163 histAll = h[
'I-'+hnameAll]
2164 n = histAll.FindBin(E)
2165 R = histAll.GetBinContent(n) / runCoverage
2166 if x == 3322: R+=h[
'I-'+hnameAll.replace(
'3322',
'-3322')].GetBinContent(n) / runCoverage
2167 R150 = R*150.*fbScale
2168 if R150<1E-8: R150=0
2169 if R150<1000: line +=
"& $%5.1F$"%(R150)
2170 else: line +=
"& $%6.2G$"%(R150)
2173 xline = line.replace(
'E+0',
'\,10^')
2175 fout.write(
"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n")
2176 for x
in [2112,-2112,130,310,3122,-3122,3322,22]:
2178 for E
in [10,100,200,300,500,1000]:
2179 pname = PDG.GetParticle(x).GetName()
2180 hname =
"Esnd_"+
str(x)
2183 R = hist.GetBinContent(n) / runCoverage
2184 if x == 3322: R+=h[
'I-'+hname.replace(
'3322',
'-3322')].GetBinContent(n) / runCoverage
2185 R150 = R*150.*fbScale
2186 if R150<1E-8: R150=0
2187 if R150<1000: line +=
"& $%5.1F$"%(R150)
2188 else: line +=
"& $%6.2G$"%(R150)
2191 xline = line.replace(
'E+0',
'\,10^')
2193 fout.write(
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n")
2194 for x
in [2112,-2112,130,310,3122,-3122,3322,22]:
2196 for E
in [10,100,300,1000]:
2197 faser = FASERNU[x][E]*scaleFactor
2198 if x == 3322: faser+=FASERNU[-x][E]*scaleFactor
2199 if faser<1000: line +=
"& $%5.1F$"%(faser)
2200 else: line +=
"& $%6.2G$"%(faser)
2203 xline = line.replace(
'E+0',
'\,10^')