10 import g4py.MedicalBeam
23 ROOT.gStyle.SetTextFont(42)
24 ROOT.gStyle.SetTitleFont(42,
"X")
25 ROOT.gStyle.SetLabelFont(42,
"X")
26 ROOT.gStyle.SetTitleFont(42,
"Y")
27 ROOT.gStyle.SetLabelFont(42,
"Y")
30 gCanvas= ROOT.TCanvas(
"water_phantom_plots",
31 "Water Phantom Demo Plots",
38 gPad1= ROOT.TPad(
"2D",
"2D", 0.02, 0.5, 0.98, 1.)
42 ROOT.gStyle.SetPalette(1);
45 hist_dose2d= ROOT.TH2D(
"2D Dose",
"Dose Distribution",
48 hist_dose2d.SetXTitle(
"Z (mm)")
49 hist_dose2d.SetYTitle(
"X (mm)")
50 hist_dose2d.SetStats(0)
51 hist_dose2d.Draw(
"colz")
55 gPad2= ROOT.TPad(
"Z",
"Z", 0.02, 0., 0.98, 0.5)
60 hist_dosez= ROOT.TH1D(
"Z Dose",
"Depth Dose", 200, 0., 400.)
61 hist_dosez.SetXTitle(
"(mm)")
62 hist_dosez.SetYTitle(
"Accumulated Dose (MeV)")
69 hist_dose2d.Draw(
"colz")
82 "My Primary Generator Action"
85 G4VUserPrimaryGeneratorAction.__init__(self)
89 self.particleGun.GeneratePrimaryVertex(event)
96 print "*** End of Run"
97 print "- Run sammary : (id= %d, #events= %d)" \
98 % (run.GetRunID(), run.GetNumberOfEventToBeProcessed())
109 ROOT.gSystem.ProcessEvents()
120 "SD for score voxels"
123 G4VSensitiveDetector.__init__(self,
"ScoreVoxel")
126 preStepPoint= step.GetPreStepPoint()
127 if(preStepPoint.GetCharge() == 0):
130 track= step.GetTrack()
131 touchable= track.GetTouchable()
132 voxel_id= touchable.GetReplicaNumber()
133 dedx= step.GetTotalEnergyDeposit()
135 hist_dose2d.Fill(xz[1], xz[0], dedx/MeV)
136 if(
abs(xz[0]) <= 100 ):
137 hist_dosez.Fill(xz[1], dedx/MeV)
163 myMaterials= demo_wp.MyMaterials()
164 myMaterials.Construct()
166 myDC= demo_wp.MyDetectorConstruction()
167 gRunManager.SetUserInitialization(myDC)
170 gRunManager.SetUserInitialization(myPL)
174 gRunManager.SetUserAction(myPGA)
177 gRunManager.SetUserAction(myRA)
180 gRunManager.SetUserAction(myEA)
193 beam= g4py.MedicalBeam.Construct()
194 beam.particle=
"proton"
195 beam.kineticE= 230.*MeV
200 beam.fieldXY= [5.*cm, 5.*cm]
203 gRunManager.Initialize()
207 myDC.SetSDtoScoreVoxel(scoreSD)
213 gRunManager.BeamOn(100)