7from typing
import NamedTuple
12ROOT.gROOT.ProcessLine(
'#include "FairModule.h"')
24 """Target block and beam configuration for one multiple-scattering study point."""
33 "Fig3":
Setup(0.1 * u.cm,
"lead", 2 * u.GeV, 0.2),
34 "Fig4":
Setup(0.1 * u.cm,
"lead", 8 * u.GeV, 0.04),
35 "Fig5":
Setup(0.1 * u.cm,
"lead", 14 * u.GeV, 0.02),
36 "Fig6":
Setup(1.44 * u.cm,
"copper", 11.7 * u.GeV, 0.045),
37 "Fig7":
Setup(1.44 * u.cm,
"copper", 7.3 * u.GeV, 0.045),
41thickness, material, momentum, maxTheta = setup[s]
46outFile =
"msc" + s +
".root"
47theSeed = int(10000 * time.time() % 10000000)
51ROOT.gRandom.SetSeed(theSeed)
56timer = ROOT.TStopwatch()
60run = ROOT.FairRunSim()
62sink = ROOT.FairRootFileSink(outFile)
64ROOT.SetOwnership(sink,
False)
65run.SetUserConfig(
"g4Config.C")
66rtdb = run.GetRuntimeDb()
69run.SetMaterials(
"media.geo")
71cave = ROOT.ShipCave(
"CAVE")
72cave.SetGeometryFileName(
"cave.geo")
80 ROOT.pyFairModule.__init__(self, self)
83 print(
"Construct Block")
84 top = ROOT.gGeoManager.GetTopVolume()
85 geoLoad = ROOT.FairGeoLoader.Instance()
86 geoFace = geoLoad.getGeoInterface()
87 media = geoFace.getMedia()
88 geoBuild = geoLoad.getGeoBuilder()
89 ShipMedium = media.getMedium(material)
90 W = ROOT.gGeoManager.GetMedium(material)
92 geoBuild.createMedium(ShipMedium)
93 W = ROOT.gGeoManager.GetMedium(material)
94 aBox = ROOT.gGeoManager.MakeBox(
"target", W, 100.0 * u.cm, 100.0 * u.cm, thickness)
95 top.AddNode(aBox, 1, ROOT.TGeoTranslation(0, 0, 0))
98 print(
"not implemented!")
101sensPlane = ROOT.exitHadronAbsorber()
102sensPlane.SetEnergyCut(ecut * u.GeV)
104 sensPlane.SetOnlyMuons()
105sensPlane.SetZposition(thickness + 10 * u.cm)
106run.AddModule(sensPlane)
110primGen = ROOT.FairPrimaryGenerator()
111myPgun = ROOT.FairBoxGenerator(13, 1)
112myPgun.SetPRange(momentum - 0.01, momentum + 0.01)
113myPgun.SetPhiRange(0, 0)
114myPgun.SetThetaRange(0, 0)
115myPgun.SetXYZ(0.0 * u.cm, 0.0 * u.cm, -10.0 * u.cm - (thickness))
116primGen.AddGenerator(myPgun)
117run.SetGenerator(primGen)
119run.SetGenerator(primGen)
122gMC = ROOT.TVirtualMC.GetMC()
124fStack = gMC.GetStack()
125fStack.SetMinPoints(1)
126fStack.SetEnergyCut(-1.0)
132ROOT.gROOT.ProcessLine(
'#include "Geant4/G4EmParameters.hh"')
133emP = ROOT.G4EmParameters.Instance()
136import rootUtils
as ut
138f = ROOT.gROOT.GetListOfFiles()[0]
140ut.bookHist(h,
"theta",
"scattering angle " + str(momentum) +
"GeV/c;{Theta}(rad)", 500, 0, maxTheta)
141sTree = f.Get(
"cbmsim")
142for n
in range(sTree.GetEntries()):
143 rc = sTree.GetEvent(n)
144 for aHit
in sTree.vetoPoint:
145 if aHit.GetTrackID() != 0:
147 pt = ROOT.TMath.Sqrt(aHit.GetPx() ** 2 + aHit.GetPy() ** 2)
148 scat = ROOT.TMath.ATan2(pt, aHit.GetPz())
149 rc = h[
"theta"].Fill(scat)
150ut.bookCanvas(h, key=s, title=s, nx=900, ny=600, cx=1, cy=1)
153h[
"theta_100"] = h[
"theta"].Clone(
"theta_100")
154h[
"theta_100"] = h[
"theta"].Rebin(5)
155h[
"theta_100"].Scale(1.0 / h[
"theta_100"].GetMaximum())
157h[s].Print(s +
".png")
158h[s].Print(s +
".root")
160f.Write(h[
"theta"].GetName())
161f.Write(h[
"theta_100"].GetName())
165rtime = timer.RealTime()
166ctime = timer.CpuTime()
168print(
"Macro finished successfully.")
169print(
"Output file is ", outFile)
170print(
"Real time ", rtime,
" s, CPU time ", ctime,
"s")
None ConstructGeometry(self)
create_config(str DecayVolumeMedium="helium", float Yheight=6.0, int strawDesign=10, str shieldName="TRY_2026", int nuTargetPassive=1, bool SND=True, SND_design=None, TARGET_YAML=None)
None configure(darkphoton=None)