{"id":19924618,"url":"https://github.com/artemis-beta/g4-basic","last_synced_at":"2025-03-01T10:27:16.889Z","repository":{"id":81705977,"uuid":"101227709","full_name":"artemis-beta/G4-Basic","owner":"artemis-beta","description":"Attempt to Simplify Geant4 Python","archived":false,"fork":false,"pushed_at":"2019-02-10T21:46:10.000Z","size":27,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-12T00:26:25.338Z","etag":null,"topics":["g4","geant4","hep","particlephysics","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/artemis-beta.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-23T21:47:07.000Z","updated_at":"2019-02-10T21:46:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"c8ebefdd-48c0-4a8c-b70f-5fb803adb4d0","html_url":"https://github.com/artemis-beta/G4-Basic","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artemis-beta%2FG4-Basic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artemis-beta%2FG4-Basic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artemis-beta%2FG4-Basic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artemis-beta%2FG4-Basic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/artemis-beta","download_url":"https://codeload.github.com/artemis-beta/G4-Basic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241351894,"owners_count":19948745,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["g4","geant4","hep","particlephysics","python"],"created_at":"2024-11-12T22:18:19.611Z","updated_at":"2025-03-01T10:27:16.880Z","avatar_url":"https://github.com/artemis-beta.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# G4-Basic\n\nThe purpose of this module is to greatly simplify the creation of basic geometries and the firing of particle guns at these geometries. This method features a single class which can create a simulation by using just three parameters.\n\n## Trying it out with Docker\n\nEven without GEANT4 installed on your system you can still try out G4-Basic via Docker, I have prepared a docker image with the software [here](https://hub.docker.com/r/artemisbeta/geant4). Make sure you run the container with `-u 0` so you can install git and clone this repository.\n\n## Parsing of Units\n\nBefore discussing G4-Basic I would firstly like to introduce the unit parser. Traditionally units can be imported from the `Geant4` module and then used multiplicatively, e.g. 10 metres being `10*G4.m`. To cut back further the requirements for running GEANT4 I have built in string parsing which is able to recognise a unit, and if it exists within the module, do the multiplication for you. For example `'10m'` as an argument would yield the same result.\n\n## The G4Session Class\n\nTo create a simulation in one statement you need to create two dictionaries, one containing all the parameters for the geometry objects, and one which will be used to initialise the particle gun. Optionally you can add volumes and create particle guns later using `addVolume` and `addParticleGun`.\n\nFor the volume dictionary the required arguments are the type of volume `vol_type` of which there are five types: `Box`, `Tube`, `Cone`, `Sphere` and `Orb`, the position of the shape `position` which can be expressed either as floats or strings which are parsed, the material of the shape `material` and the optional parameter `colour`. \nA list of materials is given by running:\n```\ng4basic.listMaterials()\n```\nYou can view the required parameters for the shapes [here](http://www.apc.univ-paris7.fr/~franco/g4doxy4.10/html/class_g4_ez_volume.html), however if the parameters are invalid when running the script the information will be expressed within the logging information also. \n\nTo create a 10x10x3m cuboid of lead:\n```\nvolume_dict = {'Calo' : {'vol_type'   : 'Box',\n                         'position'   : (0., 0., '-20m'),\n                         'dimensions' : ('10m', '10m', '3m'),\n                         'material'   : 'Pb',\n                         'colour'     : 'blue'}}\n\n```\n\nFor the particle gun dictionary the arguments are the particle to be fired `particle`, the position of the particle gun `position` and one of two possibilities for defining the energy. The first option is to specify `energy` and `direction`, the second is to supply the `momentum`:\n\nTo create a particle gun firing electrons at 3GeV:\n\n```\npgun_dict = {'particle' : 'e-', 'energy' : '3GeV', 'direction' : (0,0,1),\n             'position' : (0, 0, '-20m')}\n```\n\nor\n\n```\npgun_dict = {'particle' : 'e-', 'momentum' : (0, 0, '3GeV'),\n             'position' : (0, 0, '-20m')}\n```\n\nyou can also choose to add geometry or the particle later, for the same examples:\n\n```\nimport g4basic as g4b\n\nmy_session = g4b.G4Session()\n\nmy_session.addVolume('Calo', 'Pb', 'Box', ('10m', '10m', '3m'), (0., 0., '-20m'), colour='blue')\n\nmy_session.addParticleGun('e-', (0, 0, '-20m'), energy='3GeV', direction=(0,0,1))\n```\n\nAn instance of the `G4Session` class also allows specification of Physics List `phys_list` a full list of which is available in the `help` function for this class:\n\n```\nmy_session = g4basic.G4Session(volumes_dict=volume_dict, guns_opt_dict=pgun_dict, phys_list='QGSP_BERT')\n```\n\nTo run the simulation we use the `runSimulation` command, by default the viewer utilised uses OpenGL `OGLIX`, shows the particle hits and trajectories, creates a single event and positions the camera at a theta-phi angle of (80,20) displaying the objects in style `wireframe`:\n\n```\nx.runSimulation(nevts=10, viewer='OGLIX', hits=True, trajectories='smooth', logo=False, view=(80,20), style='surface')\n```\n\nthe `logo` option simply displays the 3D G4 logo or the 2D logo if `'2d'` is used as an argument.\n\nSee the `examples` folder in this module for a working example.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fartemis-beta%2Fg4-basic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fartemis-beta%2Fg4-basic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fartemis-beta%2Fg4-basic/lists"}