From 79a6bee7d88a217ea520dc51ec5b18ba4abf6d6b Mon Sep 17 00:00:00 2001 From: Pere Mato Date: Wed, 10 Apr 2024 11:30:13 +0200 Subject: [PATCH] Fixes --- tutorial/docs/geant4-jl-intro.ipynb | 219 ++++++++-------------------- 1 file changed, 59 insertions(+), 160 deletions(-) diff --git a/tutorial/docs/geant4-jl-intro.ipynb b/tutorial/docs/geant4-jl-intro.ipynb index c49095f..83c45b5 100644 --- a/tutorial/docs/geant4-jl-intro.ipynb +++ b/tutorial/docs/geant4-jl-intro.ipynb @@ -23,7 +23,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 2, "metadata": {}, "outputs": [ { @@ -60,13 +60,13 @@ }, { "cell_type": "code", - "execution_count": 94, + "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "Geant4.G4BoxAllocated(Ptr{Nothing} @0x000000016ba218c0)" + "Geant4.G4BoxAllocated(Ptr{Nothing} @0x0000000122536410)" ] }, "metadata": {}, @@ -87,7 +87,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -114,12 +114,12 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "To take the C++ pointer or the reference, the `CxxWrap` module provides the functions `CxxPtr` and `CxxRef`. This is often needed to comply with the Geant4 C++ interfaces. " + "To take the C++ pointer or the reference of a wrapped object, the `CxxWrap` module provides the functions `CxxPtr` and `CxxRef`. This is often needed to fullfil with the Geant4 C++ interfaces. " ] }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -148,7 +148,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -180,13 +180,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Calling class methods\n", - "In julia, `methods` are instances of functions with a given name, of which the multi-dispatch functionality will select the best one that matches the actual argument types. To call a C++ method of a class we need to pass the object as first argument." + "### Calling object methods\n", + "In julia, `methods` are instances of functions of a given name, of which the multi-dispatch functionality will select the best one that matches the actual argument types. To call a C++ method of a class we need to pass the wrapped object as first argument." ] }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -200,7 +200,7 @@ } ], "source": [ - "vol = GetCubicVolume(box)\n", + "vol = GetCubicVolume(box) # In C++ this would be box.GetCubicVolume()\n", "@test vol == 8 * GetXHalfLength(box) * GetYHalfLength(box) * GetZHalfLength(box) " ] }, @@ -213,132 +213,30 @@ }, { "cell_type": "code", - "execution_count": 46, + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "methods(GetCubicVolume)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Calling static class methods\n", + "In this case we do not have an object instance. The way it is done is by concatenating the class name with the method names with the symbol `!`. This is an example: " + ] + }, + { + "cell_type": "code", + "execution_count": 9, "metadata": {}, "outputs": [ { "data": { - "text/html": [ - "# 58 methods for generic function GetCubicVolume from \u001b[36mGeant4\u001b[39m:" - ], "text/plain": [ - "# 58 methods for generic function \"GetCubicVolume\" from \u001b[36mGeant4\u001b[39m:\n", - " [1] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{Ptr{Nothing}, CxxPtr{<:G4SubtractionSolid}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [2] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{Ptr{Nothing}, CxxPtr{<:G4UnionSolid}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [3] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{Ptr{Nothing}, CxxPtr{<:G4TwistedTubs}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [4] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{Ptr{Nothing}, CxxPtr{<:G4BooleanSolid}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [5] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{Ptr{Nothing}, CxxPtr{<:G4GenericTrap}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [6] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{Ptr{Nothing}, CxxPtr{<:G4TwistedTrd}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [7] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{Ptr{Nothing}, CxxPtr{<:G4TwistedBox}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [8] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{Ptr{Nothing}, CxxPtr{<:G4Tet}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [9] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{Ptr{Nothing}, CxxPtr{<:G4Paraboloid}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [10] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{Ptr{Nothing}, CxxPtr{<:G4EllipticalCone}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [11] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{Ptr{Nothing}, CxxPtr{<:G4EllipticalTube}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [12] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{Ptr{Nothing}, CxxPtr{<:G4CutTubs}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [13] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{Ptr{Nothing}, CxxPtr{<:G4Tubs}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [14] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{Ptr{Nothing}, CxxPtr{<:G4Hype}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [15] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{Ptr{Nothing}, CxxPtr{<:G4Para}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [16] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{Ptr{Nothing}, CxxPtr{<:G4Torus}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [17] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{Ptr{Nothing}, CxxPtr{<:G4Ellipsoid}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [18] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{Ptr{Nothing}, CxxPtr{<:G4Orb}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [19] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{Ptr{Nothing}, CxxPtr{<:G4Sphere}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [20] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{Ptr{Nothing}, CxxPtr{<:G4Cons}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [21] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{Ptr{Nothing}, CxxPtr{<:G4Trap}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [22] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{Ptr{Nothing}, CxxPtr{<:G4Trd}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [23] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{Ptr{Nothing}, CxxPtr{<:G4MultiUnion}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [24] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{Ptr{Nothing}, CxxPtr{<:G4Box}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [25] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{Ptr{Nothing}, CxxPtr{<:G4DisplacedSolid}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [26] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{Ptr{Nothing}, CxxPtr{<:G4Polyhedra}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [27] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{Ptr{Nothing}, CxxPtr{<:G4Polycone}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [28] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{Ptr{Nothing}, CxxPtr{<:G4VCSGfaceted}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [29] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{Ptr{Nothing}, CxxPtr{<:G4VSolid}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [30] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{G4SubtractionSolid, CxxRef{<:G4SubtractionSolid}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [31] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{G4UnionSolid, CxxRef{<:G4UnionSolid}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [32] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{G4TwistedTubs, CxxRef{<:G4TwistedTubs}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [33] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{G4BooleanSolid, CxxRef{<:G4BooleanSolid}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [34] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{G4GenericTrap, CxxRef{<:G4GenericTrap}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [35] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{G4TwistedTrd, CxxRef{<:G4TwistedTrd}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [36] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{G4TwistedBox, CxxRef{<:G4TwistedBox}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [37] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{G4Tet, CxxRef{<:G4Tet}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [38] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{G4Paraboloid, CxxRef{<:G4Paraboloid}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [39] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{G4EllipticalCone, CxxRef{<:G4EllipticalCone}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [40] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{G4EllipticalTube, CxxRef{<:G4EllipticalTube}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [41] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{G4CutTubs, CxxRef{<:G4CutTubs}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [42] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{G4Tubs, CxxRef{<:G4Tubs}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [43] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{G4Hype, CxxRef{<:G4Hype}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [44] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{G4Para, CxxRef{<:G4Para}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [45] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{G4Torus, CxxRef{<:G4Torus}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [46] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{G4Ellipsoid, CxxRef{<:G4Ellipsoid}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [47] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{G4Orb, CxxRef{<:G4Orb}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [48] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{G4Sphere, CxxRef{<:G4Sphere}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [49] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{G4Cons, CxxRef{<:G4Cons}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [50] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{G4Trap, CxxRef{<:G4Trap}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [51] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{G4Trd, CxxRef{<:G4Trd}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [52] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{G4MultiUnion, CxxRef{<:G4MultiUnion}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [53] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{G4Box, CxxRef{<:G4Box}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [54] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{G4DisplacedSolid, CxxRef{<:G4DisplacedSolid}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [55] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{G4VCSGfaceted, CxxRef{<:G4VCSGfaceted}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [56] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{G4Polycone, CxxRef{<:G4Polycone}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [57] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{G4Polyhedra, CxxRef{<:G4Polyhedra}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m\n", - " [58] GetCubicVolume(\u001b[90marg1\u001b[39m::\u001b[1mUnion\u001b[22m\u001b[0m{G4VSolid, CxxRef{<:G4VSolid}})\n", - "\u001b[90m @\u001b[39m \u001b[90m~/.julia/packages/CxxWrap/5IZvn/src/\u001b[39m\u001b[90m\u001b[4mCxxWrap.jl:624\u001b[24m\u001b[39m" + "1" ] }, "metadata": {}, @@ -346,7 +244,7 @@ } ], "source": [ - "methods(GetCubicVolume)" + "G4Random!getTheSeed() # This will call the C++ class method G4Random::getTheSeed()" ] }, { @@ -359,7 +257,7 @@ }, { "cell_type": "code", - "execution_count": 63, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -397,24 +295,28 @@ }, { "cell_type": "code", - "execution_count": 92, + "execution_count": 1, "metadata": {}, "outputs": [ { - "data": { - "text/plain": [ - "63.99961138371228" - ] - }, - "metadata": {}, - "output_type": "display_data" + "ename": "UndefVarError", + "evalue": "UndefVarError: `G4Box` not defined", + "output_type": "error", + "traceback": [ + "UndefVarError: `G4Box` not defined\n", + "\n", + "Stacktrace:\n", + " [1] top-level scope\n", + " @ ~/Development/Geant4.jl-tutorial/tutorial/docs/geant4-jl-intro.ipynb:1" + ] } ], "source": [ - "box1 = G4Box(\"box1\", 1,1,1) # construct boxes\n", - "box2 = G4Box(\"box2\", 2,2,2) \n", + "box1 = G4Box(\"box1\", 1,1,3) # construct boxes\n", + "box2 = G4Box(\"box2\", 1,3,1) \n", "union = G4UnionSolid(\"union\", CxxPtr(box1), CxxPtr(box2)) # construct a union solid with the same box\n", - "GetCubicVolume(union)" + "@show GetCubicVolume(union)\n", + "@show DistanceToIn(union, G4ThreeVector(10,10,10))\n" ] }, { @@ -426,25 +328,22 @@ }, { "cell_type": "code", - "execution_count": 93, + "execution_count": 13, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "63.99961138371228" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ - "box1 = box2 = G4Box(\"box\", 10,10,10)\n", - "#union = nothing\n", + "box1 = box2 = nothing\n", "GC.gc()\n", - "GetCubicVolume(union)" + "@show GetCubicVolume(union) # G4BooleanSolid cashes the volume\n", + "# DistanceToIn(union, G4ThreeVector(10,10,10)) # this will probabluy crash the program" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": {