| 1 | //
|
|---|
| 2 | // ********************************************************************
|
|---|
| 3 | // * License and Disclaimer *
|
|---|
| 4 | // * *
|
|---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of *
|
|---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and *
|
|---|
| 7 | // * conditions of the Geant4 Software License, included in the file *
|
|---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These *
|
|---|
| 9 | // * include a list of copyright holders. *
|
|---|
| 10 | // * *
|
|---|
| 11 | // * Neither the authors of this software system, nor their employing *
|
|---|
| 12 | // * institutes,nor the agencies providing financial support for this *
|
|---|
| 13 | // * work make any representation or warranty, express or implied, *
|
|---|
| 14 | // * regarding this software system or assume any liability for its *
|
|---|
| 15 | // * use. Please see the license in the file LICENSE and URL above *
|
|---|
| 16 | // * for the full disclaimer and the limitation of liability. *
|
|---|
| 17 | // * *
|
|---|
| 18 | // * This code implementation is the result of the scientific and *
|
|---|
| 19 | // * technical work of the GEANT4 collaboration. *
|
|---|
| 20 | // * By using, copying, modifying or distributing the software (or *
|
|---|
| 21 | // * any work based on the software) you agree to acknowledge its *
|
|---|
| 22 | // * use in resulting scientific publications, and indicate your *
|
|---|
| 23 | // * acceptance of all terms of the Geant4 Software license. *
|
|---|
| 24 | // ********************************************************************
|
|---|
| 25 | //
|
|---|
| 26 | //
|
|---|
| 27 | // $Id: G4TestUI.cc,v 1.6 2006/06/29 19:49:00 gunter Exp $
|
|---|
| 28 | // GEANT4 tag $Name: geant4-09-03-cand-01 $
|
|---|
| 29 | //
|
|---|
| 30 | // Author: Maria Grazia Pia (Maria.Grazia.Pia@cern.ch)
|
|---|
| 31 | //
|
|---|
| 32 | // History:
|
|---|
| 33 | // -----------
|
|---|
| 34 | // 07 Oct 2001 MGP Created
|
|---|
| 35 | //
|
|---|
| 36 | // -------------------------------------------------------------------
|
|---|
| 37 |
|
|---|
| 38 | #include "globals.hh"
|
|---|
| 39 | #include "G4TestUI.hh"
|
|---|
| 40 | #include "G4ProcessTest.hh"
|
|---|
| 41 | #include "G4Material.hh"
|
|---|
| 42 | #include "G4ParticleDefinition.hh"
|
|---|
| 43 | #include "G4Gamma.hh"
|
|---|
| 44 | #include "G4Electron.hh"
|
|---|
| 45 |
|
|---|
| 46 | G4TestUI::G4TestUI(): nIterations(0), polarised(false)
|
|---|
| 47 | {
|
|---|
| 48 | types.push_back("compton");
|
|---|
| 49 | types.push_back("conversion");
|
|---|
| 50 | types.push_back("photoelectric");
|
|---|
| 51 | types.push_back("rayleigh");
|
|---|
| 52 | types.push_back("bremsstrahlung");
|
|---|
| 53 | types.push_back("ionisation");
|
|---|
| 54 |
|
|---|
| 55 | topics.push_back("along");
|
|---|
| 56 | topics.push_back("post");
|
|---|
| 57 |
|
|---|
| 58 | categories.push_back("lowE");
|
|---|
| 59 | categories.push_back("standard");
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 | G4TestUI::~G4TestUI()
|
|---|
| 63 | { }
|
|---|
| 64 |
|
|---|
| 65 | void G4TestUI::configure()
|
|---|
| 66 | {
|
|---|
| 67 | selectNumberOfIterations();
|
|---|
| 68 | selectProcess();
|
|---|
| 69 | selectMaterial();
|
|---|
| 70 | selectEnergyRange();
|
|---|
| 71 | selectTestTopic();
|
|---|
| 72 | }
|
|---|
| 73 |
|
|---|
| 74 | void G4TestUI::selectMaterial()
|
|---|
| 75 | {
|
|---|
| 76 | const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
|
|---|
| 77 |
|
|---|
| 78 | G4int nMaterials = G4Material::GetNumberOfMaterials();
|
|---|
| 79 |
|
|---|
| 80 | G4cout << "Select the material among the available ones: " << G4endl;
|
|---|
| 81 | for (G4int mat = 0; mat < nMaterials; mat++)
|
|---|
| 82 | {
|
|---|
| 83 | G4cout << mat << ") "
|
|---|
| 84 | << (*theMaterialTable)[mat]->GetName()
|
|---|
| 85 | << G4endl;
|
|---|
| 86 | }
|
|---|
| 87 | G4cin >> materialId;
|
|---|
| 88 |
|
|---|
| 89 | G4Material* material = (*theMaterialTable)[materialId] ;
|
|---|
| 90 | G4cout << "The selected material is: " << material->GetName() << G4endl;
|
|---|
| 91 | }
|
|---|
| 92 |
|
|---|
| 93 | void G4TestUI::selectProcess()
|
|---|
| 94 | {
|
|---|
| 95 | selectProcessType();
|
|---|
| 96 | selectProcessCategory();
|
|---|
| 97 | isPolarised();
|
|---|
| 98 | }
|
|---|
| 99 |
|
|---|
| 100 | void G4TestUI::selectProcessType()
|
|---|
| 101 | {
|
|---|
| 102 | G4int processType;
|
|---|
| 103 | G4cout << "Process to be tested: " << G4endl
|
|---|
| 104 | << "Compton [1], GammaConversion [2], Photoelectric [3], Rayleigh [4]"
|
|---|
| 105 | << G4endl
|
|---|
| 106 | << "Bremsstrahlung [5], eIonisation [6]" << G4endl;
|
|---|
| 107 | G4cin >> processType;
|
|---|
| 108 | if (processType < 1 || processType > 6) G4Exception("Wrong input");
|
|---|
| 109 |
|
|---|
| 110 | type = processType - 1;
|
|---|
| 111 | }
|
|---|
| 112 |
|
|---|
| 113 | void G4TestUI::selectProcessCategory()
|
|---|
| 114 | {
|
|---|
| 115 | G4int selection;
|
|---|
| 116 | G4cout << "LowEnergy [1] or Standard [2]" << G4endl;
|
|---|
| 117 | G4cin >> selection;
|
|---|
| 118 | if (selection < 1 || selection > 2) G4Exception("Wrong input");
|
|---|
| 119 |
|
|---|
| 120 | category = selection - 1;
|
|---|
| 121 | }
|
|---|
| 122 |
|
|---|
| 123 | void G4TestUI::isPolarised()
|
|---|
| 124 | {
|
|---|
| 125 | if (type == 0)
|
|---|
| 126 | {
|
|---|
| 127 | G4int isPolarised;
|
|---|
| 128 | G4cout << "Polarised processes are available for: Compton"
|
|---|
| 129 | << G4endl
|
|---|
| 130 | << "Not Polarised [0] or Polarised [1] Process?"
|
|---|
| 131 | << G4endl;
|
|---|
| 132 | G4cin >> isPolarised;
|
|---|
| 133 | if (isPolarised > 0) polarised = true;
|
|---|
| 134 | }
|
|---|
| 135 | }
|
|---|
| 136 |
|
|---|
| 137 | void G4TestUI::selectTestTopic()
|
|---|
| 138 | {
|
|---|
| 139 | G4int iStep;
|
|---|
| 140 | G4cout << "PostStep [1] or AlongStep [2] test?" << G4endl;
|
|---|
| 141 | G4cin >> iStep;
|
|---|
| 142 | topic = iStep - 1;
|
|---|
| 143 | }
|
|---|
| 144 |
|
|---|
| 145 | void G4TestUI::selectNumberOfIterations()
|
|---|
| 146 | {
|
|---|
| 147 | G4cout << "How many iterations? " << G4endl;
|
|---|
| 148 | G4cin >> nIterations;
|
|---|
| 149 | if (nIterations <= 0) G4Exception("Wrong input");
|
|---|
| 150 | }
|
|---|
| 151 |
|
|---|
| 152 | void G4TestUI::selectEnergyRange()
|
|---|
| 153 | {
|
|---|
| 154 | G4cout << "Select min and max energy (MeV)" << G4endl;
|
|---|
| 155 | G4cin >> eMin >> eMax;
|
|---|
| 156 | if (eMin <= 0. || eMax < eMin) G4Exception("Wrong input");
|
|---|
| 157 | eMin = eMin * MeV;
|
|---|
| 158 | eMax = eMax * MeV;
|
|---|
| 159 | }
|
|---|
| 160 |
|
|---|
| 161 | const G4Material* G4TestUI::getSelectedMaterial() const
|
|---|
| 162 | {
|
|---|
| 163 | const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
|
|---|
| 164 | const G4Material* material = (*theMaterialTable)[materialId] ;
|
|---|
| 165 |
|
|---|
| 166 | return material;
|
|---|
| 167 | }
|
|---|
| 168 |
|
|---|
| 169 | G4int G4TestUI::getNumberOfIterations() const
|
|---|
| 170 | {
|
|---|
| 171 | return nIterations;
|
|---|
| 172 | }
|
|---|
| 173 |
|
|---|
| 174 | const G4String& G4TestUI::getTestTopic() const
|
|---|
| 175 | {
|
|---|
| 176 | return topics[topic];
|
|---|
| 177 | }
|
|---|
| 178 |
|
|---|
| 179 | const G4String& G4TestUI::getProcessType() const
|
|---|
| 180 | {
|
|---|
| 181 | return types[type];
|
|---|
| 182 | }
|
|---|
| 183 |
|
|---|
| 184 | const G4String& G4TestUI::getProcessCategory() const
|
|---|
| 185 | {
|
|---|
| 186 | return categories[category];
|
|---|
| 187 | }
|
|---|
| 188 |
|
|---|
| 189 | G4bool G4TestUI::getPolarisationSelection() const
|
|---|
| 190 | {
|
|---|
| 191 | return polarised;
|
|---|
| 192 | }
|
|---|
| 193 |
|
|---|
| 194 | G4ParticleDefinition* G4TestUI::getParticleDefinition() const
|
|---|
| 195 | {
|
|---|
| 196 | G4ParticleDefinition* def = 0;
|
|---|
| 197 | if (type <= 4)
|
|---|
| 198 | {
|
|---|
| 199 | def = G4Gamma::GammaDefinition();
|
|---|
| 200 | }
|
|---|
| 201 | else
|
|---|
| 202 | {
|
|---|
| 203 | def = G4Electron::ElectronDefinition();
|
|---|
| 204 | }
|
|---|
| 205 | return def;
|
|---|
| 206 | }
|
|---|
| 207 |
|
|---|
| 208 |
|
|---|