Example #1
0
def ConstructGeom():
  print("* Constructing geometry...")
  # reset world material
  air= G4Material.GetMaterial("G4_AIR")
  g4py.ezgeom.SetWorldMaterial(air)

  # target
  global target
  target= G4EzVolume("Target")
  au= G4Material.GetMaterial("G4_Au")
  target.CreateTubeVolume(au, 0., 1.*cm, 1.*mm)
  target.PlaceIt(G4ThreeVector(0.,0.,-10.*cm))

  # dummy box
  global detector_box, detector_box_pv
  detector_box= G4EzVolume("DetectorBox")
  detector_box.CreateBoxVolume(air, 20.*cm, 20.*cm, 40.*cm)
  detector_box_pv= detector_box.PlaceIt(G4ThreeVector(0.,0.,20.*cm))

  # calorimeter
  global cal
  cal= G4EzVolume("Calorimeter")
  nai= G4Material.GetMaterial("G4_SODIUM_IODIDE")
  cal.CreateBoxVolume(nai, 5.*cm, 5.*cm, 30.*cm)
  dd= 5.*cm
  for ical in range(-1, 2):
    calPos= G4ThreeVector(dd*ical, 0., 0.)
    print(calPos)
    cal.PlaceIt(calPos, ical+1, detector_box)
Example #2
0
def ConstructGeom():
    print "* Constructing geometry..."
    world_r = 100. * m
    # reset world material
    vac = G4Material.GetMaterial("G4_Galactic")
    g4py.ezgeom.SetWorldMaterial(vac)
    g4py.ezgeom.ResizeWorld(world_r, world_r, world_r)
    # a snoopy world is placed
    global snoopy, snoopyPhys, scoreLog
    snoopy = G4EzVolume("Snoopy")
    snoopy.CreateTubeVolume(vac, 0., 10 * m, 50. * m)
    snoopyPhys = snoopy.PlaceIt(G4ThreeVector(0., 0., 0. * m))
    snoopyLog = snoopyPhys.GetLogicalVolume()
    snoopy.SetVisibility(False)
    # a target box is placed
    global target, targetPhys
    iron = G4Material.GetMaterial("G4_Fe")
    air = G4Material.GetMaterial("G4_AIR")
    tungsten = G4Material.GetMaterial("G4_W")
    lead = G4Material.GetMaterial("G4_Pb")
    alum = G4Material.GetMaterial("G4_Al")
    target = G4EzVolume("Target")
    target.CreateTubeVolume(tungsten, 0., 25. * cm, 25. * cm)
    targetPhys = target.PlaceIt(G4ThreeVector(0., 0., -50. * m + 25. * cm), 1,
                                snoopy)
    target.SetColor(G4Color(0.0, 0.5, 0.5, 1.0))
    target.SetVisibility(True)
    # = 0.1m3 = 2t
    # a hadron absorber is placed
    absorber = G4EzVolume("Absorber")
    # iron alloys saturate at 1.6-2.2T
    #                             inner radius outer radius length
    absorber.CreateTubeVolume(iron, 0., 100. * cm, 150. * cm)
    absorberPhys = absorber.PlaceIt(
        G4ThreeVector(0., 0., -50 * m + 2 * 25. * cm + 150. * cm), 1, snoopy)
    absorber.SetColor(G4Color(0.898, 0.902, 0.91, 1.0))
    absorber.SetVisibility(True)
    xx = G4VisAttributes()
    xx.SetForceWireframe(True)
    absorberlog = absorberPhys.GetLogicalVolume()
    absorberlog.SetVisAttributes(xx)
    # scoring plane
    scorez = -50. * m + 2 * 25. * cm + 2 * 150. * cm + 1 * mm
    score = G4EzVolume("Score")
    score.CreateTubeVolume(vac, 0., 50. * m, 1. * mm)
    scorePhys = score.PlaceIt(G4ThreeVector(0., 0., scorez), 1, snoopy)
    scoreLog = scorePhys.GetLogicalVolume()
    g4py.ezgeom.Construct()
Example #3
0
def ConstructGeom():
    print "* Constructing geometry..."
    # reset world material
    global absorber
    air = G4Material.GetMaterial("G4_AIR", 1)
    galactic = G4Material.GetMaterial("G4_Galactic", 1)
    absorber = {}  # material's dictionary to be used by a radiobutton
    aluminum = G4Material.GetMaterial("G4_Al", 1)
    iron = G4Material.GetMaterial("G4_Fe", 1)
    silver = G4Material.GetMaterial("G4_Ag", 1)
    gold = G4Material.GetMaterial("G4_Au", 1)
    lead = G4Material.GetMaterial("G4_Pb", 1)
    water = G4Material.GetMaterial("G4_WATER", 1)
    absorber = {
        "air": air,
        "aluminum": aluminum,
        "iron": iron,
        "lead": lead,
        "water": water,
        "gold": gold
    }
    g4py.ezgeom.SetWorldMaterial(galactic)
    g4py.ezgeom.ResizeWorld(120. * cm, 120. * cm, 100. * cm)
    # water phantom
    global water_phantom, water_phantom_pv

    water_phantom = G4EzVolume("WaterPhantom")
    water_phantom.CreateBoxVolume(water, 110. * cm, 110. * cm, 10. * cm)

    water_phantom_pv = water_phantom.PlaceIt(G4ThreeVector(0., 0., 0. * cm))
Example #4
0
 def ConstructOrb(self, nameString, material, locationArray, unit,
                  maxRadius):
     orb = G4EzVolume(nameString)  # initialize volume
     orbPos = G4ThreeVector(locationArray[0] * unit,
                            locationArray[1] * unit, locationArray[2] *
                            unit)  # specify xyz location of volume
     orb.CreateOrbVolume(material, maxRadius * unit)  # create volume
     orb.PlaceIt(orbPos)  # add volume to space
Example #5
0
 def ConstructTube(self, nameString, material, locationArray, unit,
                   minRadius, maxRadius, length, phi0, dphi):
     tube = G4EzVolume(nameString)  # initialize volume
     tubePos = G4ThreeVector(locationArray[0] * unit,
                             locationArray[1] * unit, locationArray[2] *
                             unit)  # specify xyz location of volume
     tube.CreateTubeVolume(material, minRadius * unit, maxRadius * unit,
                           length * unit, phi0, dphi * deg)  # create volume
     tube.PlaceIt(tubePos)  # add volume to space
Example #6
0
 def ConstructBox(self, nameString, material, locationArray, unit,
                  dimensionsArray):
     box = G4EzVolume(nameString)  #initialize volume
     boxPos = G4ThreeVector(locationArray[0] * unit,
                            locationArray[1] * unit, locationArray[2] *
                            unit)  # specify xyz location of volume
     box.CreateBoxVolume(material, dimensionsArray[0] * unit,
                         dimensionsArray[1] * unit,
                         dimensionsArray[2] * unit)  # create volume
     box.PlaceIt(boxPos)  # add volume to space
Example #7
0
 def ConstructSphere(self, nameString, material, locationArray, unit,
                     minRadius, maxRadius, phi0, dphi, theta0, dtheta):
     sphere = G4EzVolume(nameString)  #initialize volume
     spherePos = G4ThreeVector(locationArray[0] * unit,
                               locationArray[1] * unit, locationArray[2] *
                               unit)  # specify xyz location of volume
     sphere.CreateShpereVolume(
         material, minRadius * unit, maxRadius * unit, phi0, dphi * deg,
         theta0, dtheta * deg
     )  # haha "Shpere" not "Sphere"  --> check docs https://nusoft.fnal.gov/larsoft/doxsvn/html/pyEzgeom_8cc_source.html#l00116
     sphere.PlaceIt(spherePos)  # add volume to space
Example #8
0
 def ConstructCone(self, nameString, material, locationArray, unit,
                   minRadius1, maxRadius1, minRadius2, maxRadius2, height,
                   phi0, dphi):
     cone = G4EzVolume(nameString)  #initialize volume
     conePos = G4ThreeVector(locationArray[0] * unit,
                             locationArray[1] * unit, locationArray[2] *
                             unit)  # specify xyz location of volume
     cone.CreateConeVolume(material, minRadius1 * unit, maxRadius1 * unit,
                           minRadius2 * unit, maxRadius2 * unit,
                           height * unit, phi0, dphi * deg)  # create volume
     cone.PlaceIt(conePos)  # add volume to space
Example #9
0
def ConstructGeom():
    print "* Constructing geometry..."
    # reset world material
    air = G4Material.GetMaterial("G4_AIR")
    g4py.ezgeom.SetWorldMaterial(air)

    # phantom
    global phantom
    phantom = G4EzVolume("DetectorBox")
    water = G4Material.GetMaterial("G4_WATER")
    phantom.CreateBoxVolume(water, 40. * cm, 40. * cm, 50. * cm)
    phantom.PlaceIt(G4ThreeVector(0., 0., 20. * cm))
    vsize = phantom.VoxelizeIt(100, 100, 100)
    print "voxel size=", vsize
Example #10
0
rand_engine = Ranlux64Engine()
HepRandom.setTheEngine(rand_engine)
HepRandom.setTheSeed(20050830L)
g4py.NISTmaterials.Construct()
g4py.ezgeom.Construct()
g4py.EMSTDpl.Construct()
g4py.ParticleGun.Construct()

# World definition
emptiness = G4Material.GetMaterial("G4_Galactic")
g4py.ezgeom.SetWorldMaterial(emptiness)
g4py.ezgeom.ResizeWorld(121. * cm, 121. * cm, 400. * cm)

# Phantom definition
phantom_material = G4Material.GetMaterial(material)
phantom = G4EzVolume("PhantomBox")
phantom_zwidth = phantom_thickness * cm
phantom_zlocation = 100. * cm
phantom.CreateBoxVolume(phantom_material, 120.0 * cm, 120.0 * cm,
                        phantom_zwidth)
phantom.SetColor(0., 0.9, 1.0)
phantom_box_pv = phantom.PlaceIt(
    G4ThreeVector(0. * cm, 0. * cm, phantom_zlocation))

# Beam definition
beam = g4py.MedicalBeam.Construct()
beam.particle = particle_type
beam.kineticE = particle_energy * MeV
beam.sourcePosition = G4ThreeVector(0. * cm, 0. * cm, -90. * cm)
beam.fieldXY = [120. * cm, 120. * cm]
beam.SSD = 190. * cm
Example #11
0
def ConstructGeom():
    print "* Constructing geometry..."
    # reset world material
    vac = G4Material.GetMaterial("G4_Galactic")
    g4py.ezgeom.SetWorldMaterial(vac)
    g4py.ezgeom.ResizeWorld(world_r / 2., world_r / 2., world_r)
    # a snoopy world is placed
    global snoopy, snoopyPhys, scoreLog
    snoopy = G4EzVolume("Snoopy")
    snoopy.CreateTubeVolume(vac, 0., 20 * m, world_r / 2.)
    snoopyPhys = snoopy.PlaceIt(G4ThreeVector(0., 0., 0. * m))
    snoopyLog = snoopyPhys.GetLogicalVolume()
    snoopy.SetVisibility(False)
    # a target box is placed
    global target, targetPhys
    iron = G4Material.GetMaterial("G4_Fe")
    air = G4Material.GetMaterial("G4_AIR")
    water = G4Material.GetMaterial("G4_WATER")
    tungsten = G4Material.GetMaterial("G4_W")
    lead = G4Material.GetMaterial("G4_Pb")
    alum = G4Material.GetMaterial("G4_Al")
    elementMo = G4Element("Molybdenum", "Mo", 42., 95.94 * g / mole)
    molybdenum = G4Material("molybdenum", 10.22 * g / cm3, 1)
    molybdenum.AddElement(elementMo, 1.00)
    #
    if fullTungsten:
        target = G4EzVolume("Target")
        slit = G4EzVolume("Slit")
        slitDZ = 0.5 * cm
        targetDZ = 5. * cm
        # target is sliced, 4 slits of 1cm, 10cm tungsten blocks
        target.CreateTubeVolume(tungsten, 0., 25. * cm, targetDZ)
        target.SetColor(G4Color(0.0, 0.5, 0.5, 1.0))
        target.SetVisibility(True)
        # additional 5 interaction lengths
        #targetOpt = G4EzVolume("TargetOpt")
        #targetOpt.CreateTubeVolume(tungsten, 0., 25.*cm,     25.*cm)
        #targetOpt.SetColor(G4Color(0.0,0.5,0.5,1.0))
        #targetOpt.SetVisibility(True)
        slit.CreateTubeVolume(water, 0., 25. * cm, slitDZ)
        slit.SetVisibility(False)
        targetPhys = []
        slitPhys = []
        targetL = 0 * cm
        z0Pos = -50. * m
        for i in range(4):
            targetPhys.append(
                target.PlaceIt(
                    G4ThreeVector(0., 0., z0Pos + targetL + targetDZ), 1,
                    snoopy))
            slitPhys.append(
                slit.PlaceIt(
                    G4ThreeVector(0., 0.,
                                  z0Pos + targetL + 2 * targetDZ + slitDZ), 1,
                    snoopy))
            targetL += 2 * (slitDZ + targetDZ)
        targetPhys.append(
            target.PlaceIt(G4ThreeVector(0., 0., z0Pos + targetL + targetDZ),
                           1, snoopy))
        targetL += 2 * (targetDZ)
        # put iron around
        moreShielding = G4EzVolume("moreShielding")
        moreShielding.CreateTubeVolume(iron, 30. * cm, 400. * cm, targetL / 2.)
        moreShieldingPhys = moreShielding.PlaceIt(
            G4ThreeVector(0., 0., z0Pos + targetL / 2.), 1, snoopy)


#
    else:  # new design with mixture Molybdaen and Tungsten
        slitDZ = 0.5 * cm
        diameter = 30. * cm
        spaceTopBot = 10. * cm
        spaceSide = 5. * cm
        slit = G4EzVolume("Slit")
        slit.CreateBoxVolume(water, diameter, diameter, slitDZ)
        slit.SetVisibility(False)
        targetPhys = []
        targetVol = []
        slitPhys = []
        targetL = 0 * cm
        z0Pos = -50. * m
        #          material,length
        layout = {1:[molybdenum,8.*cm],\
                  2:[molybdenum,2.5*cm],3:[molybdenum,2.5*cm],4:[molybdenum,2.5*cm],5:[molybdenum,2.5*cm],\
                  6:[molybdenum,2.5*cm],7:[molybdenum,2.5*cm],8:[molybdenum,2.5*cm],\
                  9:[molybdenum,5.0*cm],10:[molybdenum,5.0*cm],\
                 11:[molybdenum,6.5*cm],\
                 12:[molybdenum,8.0*cm],13:[molybdenum,8.0*cm],\
                 14:[tungsten,5.*cm],15:[tungsten,8.*cm],16:[tungsten,10.*cm],17:[tungsten,35.*cm] }
        for i in range(1, 18):
            targetVol.append(G4EzVolume("Target_Layer_" + str(i)))
            targetVol[i - 1].CreateBoxVolume(layout[i][0], diameter, diameter,
                                             layout[i][1])
            if layout[i][0] == tungsten:
                targetVol[i - 1].SetColor(G4Color(0.0, 0.5, 0.5, 1.0))
            else:
                targetVol[i - 1].SetColor(G4Color(0.3, 0.2, 0.5, 1.0))
            targetVol[i - 1].SetVisibility(True)
            targetPhys.append(targetVol[i - 1].PlaceIt(
                G4ThreeVector(0., 0., z0Pos + targetL + layout[i][1] / 2.), 1,
                snoopy))
            if i < 17:
                slitPhys.append(
                    slit.PlaceIt(
                        G4ThreeVector(
                            0., 0.,
                            z0Pos + targetL + layout[i][1] + slitDZ / 2.), 1,
                        snoopy))
                targetL += slitDZ + layout[i][1]
            else:
                targetL += layout[i][1]
    # put iron around
        xTot = 400. * cm
        yTot = 400. * cm
        moreShieldingTopBot = G4EzVolume("moreShieldingTopBot")
        moreShieldingTopBot.CreateBoxVolume(iron, xTot, yTot / 2., targetL)
        moreShieldingTopPhys = moreShieldingTopBot.PlaceIt(
            G4ThreeVector(0., diameter / 2. + spaceTopBot + yTot / 4.,
                          z0Pos + targetL / 2.), 1, snoopy)
        moreShieldingBotPhys = moreShieldingTopBot.PlaceIt(
            G4ThreeVector(0., -diameter / 2. - spaceTopBot - yTot / 4.,
                          z0Pos + targetL / 2.), 1, snoopy)
        moreShieldingSide = G4EzVolume("moreShieldingSide")
        moreShieldingSide.CreateBoxVolume(iron, xTot / 2.,
                                          diameter + 1.9 * spaceTopBot,
                                          targetL)
        moreShieldingLeftPhys = moreShieldingSide.PlaceIt(
            G4ThreeVector(diameter / 2. + spaceSide + xTot / 4., 0.,
                          z0Pos + targetL / 2.), 1, snoopy)
        moreShieldingRightPhys = moreShieldingSide.PlaceIt(
            G4ThreeVector(-diameter / 2. - spaceSide - xTot / 4., 0.,
                          z0Pos + targetL / 2.), 1, snoopy)
    # = 0.1m3 = 2t
    # a hadron absorber is placed
    absorberL = 2 * 150. * cm
    absorber = G4EzVolume("Absorber")
    #                             inner radius outer radius length
    absorber.CreateTubeVolume(iron, 0., 400. * cm, absorberL / 2.)
    absorberPhys = absorber.PlaceIt(
        G4ThreeVector(0., 0., z0Pos + targetL + absorberL / 2. + 5. * cm), 1,
        snoopy)
    absorber.SetColor(G4Color(0.898, 0.902, 0.91, 1.0))
    absorber.SetVisibility(True)
    xx = G4VisAttributes()
    xx.SetForceWireframe(True)
    absorberlog = absorberPhys.GetLogicalVolume()
    absorberlog.SetVisAttributes(xx)
    # scoring plane
    afterHadronZ = z0Pos + targetL + absorberL + 5.1 * cm
    scorez = afterHadronZ
    score = G4EzVolume("Score")
    score.CreateTubeVolume(vac, 0., 20. * m, 1. * mm)
    scorePhys = score.PlaceIt(G4ThreeVector(0., 0., scorez), 1, snoopy)
    scoreLog = scorePhys.GetLogicalVolume()
    g4py.ezgeom.Construct()
Example #12
0
def ConstructGeom():
    print "* Constructing geometry..."
    # reset world material
    vac = G4Material.GetMaterial("G4_Galactic")
    g4py.ezgeom.SetWorldMaterial(vac)
    g4py.ezgeom.ResizeWorld(world_r / 2., world_r / 2., world_r)
    # a snoopy world is placed
    global snoopy, snoopyPhys, scoreLog
    snoopy = G4EzVolume("Snoopy")
    snoopy.CreateTubeVolume(vac, 0., 20 * m, world_r / 2.)
    snoopyPhys = snoopy.PlaceIt(G4ThreeVector(0., 0., 0. * m))
    snoopyLog = snoopyPhys.GetLogicalVolume()
    snoopy.SetVisibility(False)
    # a target box is placed
    global target, targetPhys
    iron = G4Material.GetMaterial("G4_Fe")
    air = G4Material.GetMaterial("G4_AIR")
    water = G4Material.GetMaterial("G4_WATER")
    tungsten = G4Material.GetMaterial("G4_W")
    lead = G4Material.GetMaterial("G4_Pb")
    alum = G4Material.GetMaterial("G4_Al")
    target = G4EzVolume("Target")
    slit = G4EzVolume("Slit")
    slitDZ = 0.5 * cm
    targetDZ = 5. * cm
    # target is sliced, 4 slits of 1cm, 10cm tungsten blocks
    target.CreateTubeVolume(tungsten, 0., 25. * cm, targetDZ)
    target.SetColor(G4Color(0.0, 0.5, 0.5, 1.0))
    target.SetVisibility(True)
    # additional 5 interaction lengths
    #targetOpt = G4EzVolume("TargetOpt")
    #targetOpt.CreateTubeVolume(tungsten, 0., 25.*cm,     25.*cm)
    #targetOpt.SetColor(G4Color(0.0,0.5,0.5,1.0))
    #targetOpt.SetVisibility(True)
    #
    slit.CreateTubeVolume(water, 0., 25. * cm, slitDZ)
    slit.SetVisibility(False)
    targetPhys = []
    slitPhys = []
    targetL = 0 * cm
    z0Pos = -50. * m
    for i in range(4):
        targetPhys.append(
            target.PlaceIt(G4ThreeVector(0., 0., z0Pos + targetL + targetDZ),
                           1, snoopy))
        slitPhys.append(
            slit.PlaceIt(
                G4ThreeVector(0., 0., z0Pos + targetL + 2 * targetDZ + slitDZ),
                1, snoopy))
        targetL += 2 * (slitDZ + targetDZ)
    targetPhys.append(
        target.PlaceIt(G4ThreeVector(0., 0., z0Pos + targetL + targetDZ), 1,
                       snoopy))
    targetL += 2 * (targetDZ)
    # put iron around
    moreShielding = G4EzVolume("moreShielding")
    moreShielding.CreateTubeVolume(iron, 30. * cm, 400. * cm, targetL / 2.)
    moreShieldingPhys = moreShielding.PlaceIt(
        G4ThreeVector(0., 0., z0Pos + targetL / 2.), 1, snoopy)
    # = 0.1m3 = 2t
    # a hadron absorber is placed
    absorberL = 2 * 150. * cm
    absorber = G4EzVolume("Absorber")
    #                             inner radius outer radius length
    absorber.CreateTubeVolume(iron, 0., 400. * cm, absorberL / 2.)
    absorberPhys = absorber.PlaceIt(
        G4ThreeVector(0., 0., z0Pos + targetL + absorberL / 2.), 1, snoopy)
    absorber.SetColor(G4Color(0.898, 0.902, 0.91, 1.0))
    absorber.SetVisibility(True)
    xx = G4VisAttributes()
    xx.SetForceWireframe(True)
    absorberlog = absorberPhys.GetLogicalVolume()
    absorberlog.SetVisAttributes(xx)
    # scoring plane
    afterHadronZ = z0Pos + targetL + absorberL + 1 * mm
    scorez = afterHadronZ
    score = G4EzVolume("Score")
    score.CreateTubeVolume(vac, 0., 50. * m, 1. * mm)
    scorePhys = score.PlaceIt(G4ThreeVector(0., 0., scorez), 1, snoopy)
    scoreLog = scorePhys.GetLogicalVolume()
    g4py.ezgeom.Construct()