Skip to content

Commit 35d9121

Browse files
committed
use GLMakie in some cases for examples
1 parent e15e91f commit 35d9121

File tree

8 files changed

+44
-39
lines changed

8 files changed

+44
-39
lines changed

docs/src/examples/B4a.lit

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ function stepaction(step::G4Step, app::G4JLApplication)
254254
end
255255

256256
# ## Making the Application
257-
evtdisplay = G4JLEventDisplay(joinpath(@__DIR__, "B4aVis.jl"))
257+
evtdisplay = G4JLEventDisplay(joinpath(@__DIR__, "B4aVisSettings.jl"))
258258
Geant4.getConstructor(::B4aDetector)::Function = B4aConstruct
259259
app = G4JLApplication(detector = detector, # detector with parameters
260260
simdata = B4aSimData(), # simulation data
@@ -293,9 +293,7 @@ Plots.plot!(subplot=2, data.fEdepHist_Gap, title="Total EDep in Gaps", xlabel="E
293293

294294
Plots.plot!(subplot=3, data.fStepLenHist_Abs, title="Total StepLeng in Absorbers", xlabel="Step Length (mm)", label="Abs_StepLen", show=true)
295295
Plots.plot!(subplot=4, data.fStepLenHist_Gap, title="Total StepLeng in Gaps", xlabel="Step Length (mm)", label="Gap_StepLen", show=true)
296-
#nb PNG(img) #hide
297296
#md PNG(img) #hide
298-
#jl display("image/png", img)
299297

300298

301299

docs/src/examples/GPS.lit

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ using Geant4.SystemOfUnits: deg
2626
using Parameters
2727
using FHist
2828
using Plots
29-
#md import DisplayAs: PNG
30-
#nb import DisplayAs: PNG
29+
#md import DisplayAs: PNG #hide
30+
3131

3232
# ## Define the Detector
3333
# The GPS detector is a simple box filled with air. The detector is defined by the `GPSDetector` structure.
@@ -146,9 +146,7 @@ initialize(app)
146146
# We run the simulation with 100000 particles and plot the results.
147147
beamOn(app,100000)
148148
img = do_plot(app.simdata[1])
149-
#nb PNG(img)
150-
#md PNG(img)
151-
#jl display(img)
149+
#md PNG(img) #hide
152150

153151
# Let's change the GPS parameters and run the simulation again.
154152
ui`/gps/particle geantino`
@@ -166,6 +164,4 @@ ui`/gps/ene/intercept 1`
166164

167165
beamOn(app,100000)
168166
img = do_plot(app.simdata[1])
169-
#nb PNG(img)
170-
#md PNG(img)
171-
#jl display(img)
167+
#md PNG(img) #hide

docs/src/examples/HBC30.lit

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121
using Geant4
2222
using Geant4.SystemOfUnits
2323
using Printf, GeometryBasics
24-
using CairoMakie # to force loading G4Vis extension
24+
## to force loading G4Vis extension we need to load the following module
25+
#md using CairoMakie
26+
#nb using CairoMakie
27+
#jl using GLMakie
2528
#md import DisplayAs: PNG #hide
26-
#nb import DisplayAs: PNG #hide
27-
2829

2930
# ## Define the Detector
3031
# The HBC30 is cylinder of 30cm filled with liquid hydrogen
@@ -183,8 +184,11 @@ s = LScene(fig[1,1])
183184
drawdetector(s, app)
184185
nexttrigger(app); drawevent(s, app)
185186

186-
#md PNG(fig)
187-
#nb PNG(fig)
187+
#md # ```julia
188+
#md # display(fig)
189+
#md # ```
190+
#md PNG(fig) #hide
191+
#nb display(fig)
188192
#jl display(fig)
189193

190194
# Change the energy and type of particle and draw the next event that triggers
@@ -197,6 +201,9 @@ s = LScene(fig[1,1])
197201
drawdetector(s, app)
198202
nexttrigger(app); drawevent(s, app)
199203

200-
#md PNG(fig)
201-
#nb PNG(fig)
204+
#md # ```julia
205+
#md # display(fig)
206+
#md # ```
207+
#md PNG(fig) #hide
208+
#nb display(fig)
202209
#jl display(fig)

docs/src/examples/RE03.lit

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
# We will also use the `FHist` and `Plots` modules to handle the histograms and plots.
2525
using Geant4
2626
using Geant4.SystemOfUnits
27-
#md import DisplayAs: PNG
28-
#nb import DisplayAs: PNG
27+
#md import DisplayAs: PNG #hide
2928

3029
# ## Define Detector structure
3130
# The RE03 detector is a simple box filled with air. The detector is defined by the `RE03Detector` structure.
@@ -84,6 +83,6 @@ println("Central EDep = $(sum(t[10:20,10:20,:]))")
8483
# center of the scoring mesh.
8584
using CairoMakie
8685
img = heatmap(t[1:30,15,1:30])
87-
#nb PNG(img)
88-
#md PNG(img)
89-
#jl display(img)
86+
87+
#md PNG(img) #hide
88+

docs/src/examples/Solids.lit

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313

1414
using Geant4
1515
using Geant4.SystemOfUnits
16-
using CairoMakie ## to force loading G4Vis extension
16+
#md using CairoMakie ## to force loading G4Vis extension
17+
#nb using CairoMakie ## to force loading G4Vis extension
18+
#jl using GLMakie ## to force loading G4Vis extension
1719

1820
# Change the number of steps when drawing curbed surfaces from 24 (default) to 64
1921
HepPolyhedron!SetNumberOfRotationSteps(64)

docs/src/examples/TPCSim.lit

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ using PYTHIA8
3333
#nb using CairoMakie
3434
#jl using GLMakie
3535
using PYTHIA8: px, py, pz
36-
#md import DisplayAs: PNG
37-
#nb import DisplayAs: PNG
36+
#md import DisplayAs: PNG #hide
3837

3938

4039
# ## Define the TPC Detector
@@ -147,7 +146,6 @@ end
147146
# Overwriting the default `drawEvent` function defined in the G4Vis extension
148147
const G4Vis = Base.get_extension(Geant4, :G4Vis)
149148
function G4Vis.drawEvent(evtdisp::G4Vis.G4JLEventDisplay)
150-
println("Drawing event", typeof(evtdisp))
151149
s = evtdisp.lscene.scene
152150
settings = evtdisp.settings
153151
trajectories = G4EventManager!GetEventManager() |> GetConstCurrentEvent |> GetTrajectoryContainer
@@ -188,12 +186,18 @@ initialize(app)
188186

189187
# ## Run the Application
190188
beamOn(app, 1)
191-
#nb PNG(evtdisplay.figure)
192-
#md PNG(evtdisplay.figure)
189+
#md # ```julia
190+
#md # display(evtdisplay.figure)
191+
#md # ```
192+
#md PNG(evtdisplay.figure) #hide
193+
#nb display(evtdisplay.figure)
193194
#jl display(evtdisplay.figure)
194195

195196
# Another event
196197
beamOn(app, 1)
197-
#nb PNG(evtdisplay.figure)
198-
#md PNG(evtdisplay.figure)
198+
#md # ```julia
199+
#md # display(evtdisplay.figure)
200+
#md # ```
201+
#md PNG(evtdisplay.figure) #hide
202+
#nb display(evtdisplay.figure)
199203
#jl display(evtdisplay.figure)

docs/src/examples/TestEm3.lit

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@
6464
using Geant4
6565
using Geant4.SystemOfUnits
6666
using FHist, Plots, Printf
67-
#md import DisplayAs: PNG
68-
#nb import DisplayAs: PNG
67+
#md import DisplayAs: PNG #hide
6968

7069
# ## Define Detector structure
7170
# The detector is a sandwich calorimeter made of layers of sensitive and absorber materials. The detector is defined by the `TestEm3Detector` structure.
@@ -308,16 +307,16 @@ beamOn(app, 1000)
308307

309308
# ## Plot the results
310309
img = do_plot(app.simdata[1])
311-
#md PNG(img)
312-
#nb PNG(img)
310+
#md PNG(img) #hide
311+
#nb display(img)
313312
#jl display(img)
314313

315314
# ### Change the primary particle enerqy and run the simulation again
316315
SetParticleEnergy(particlegun, 100MeV)
317316
beamOn(app, 1000)
318317
img = do_plot(app.simdata[1])
319-
#md PNG(img)
320-
#nb PNG(img)
318+
#md PNG(img) #hide
319+
#nb display(img)
321320
#jl display(img)
322321

323322
# ### Change the geometry and run the simulation again
@@ -326,8 +325,8 @@ reinitialize(app, TestEm3Detector(absorThickness = [2.3mm, 5.7mm, 1mm],
326325
absorMaterial = ["G4_Pb", "G4_lAr", "G4_Al"]))
327326
beamOn(app, 1000)
328327
img = do_plot(app.simdata[1])
329-
#md PNG(img)
330-
#nb PNG(img)
328+
#md PNG(img) #hide
329+
#nb display(img)
331330
#jl display(img)
332331

333332

0 commit comments

Comments
 (0)