| [1199] | 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 | // Anton.Lechner@cern.ch
|
|---|
| 28 | //
|
|---|
| 29 | // Environment variable TESTTARGET must be specified (see GNUmakefile)
|
|---|
| 30 | //
|
|---|
| 31 |
|
|---|
| 32 | #include "G4MaterialStoppingICRU73.hh"
|
|---|
| 33 | #include "G4SimpleMaterialStoppingICRU73.hh"
|
|---|
| 34 | #include "G4IronStoppingICRU73.hh"
|
|---|
| 35 | #include <sstream>
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 | G4bool Compare(G4PhysicsVector* physicsVector,
|
|---|
| 39 | G4double refDEDXValue,
|
|---|
| 40 | G4double kinEnergyPerNucleon,
|
|---|
| 41 | G4int atomicNumberIon,
|
|---|
| 42 | const G4String& matIdentifier) {
|
|---|
| 43 |
|
|---|
| 44 | G4double tableDEDXValue = -1.0;
|
|---|
| 45 |
|
|---|
| 46 | if(physicsVector != 0) {
|
|---|
| 47 | size_t nmbBins = physicsVector -> GetVectorLength();
|
|---|
| 48 | G4double lowerEnergyEdge = physicsVector -> GetLowEdgeEnergy(0);
|
|---|
| 49 | G4double upperEnergyEdge = physicsVector -> GetLowEdgeEnergy(nmbBins-1);
|
|---|
| 50 |
|
|---|
| 51 | if(kinEnergyPerNucleon <= upperEnergyEdge &&
|
|---|
| 52 | kinEnergyPerNucleon >= lowerEnergyEdge) {
|
|---|
| 53 | G4bool b;
|
|---|
| 54 |
|
|---|
| 55 | tableDEDXValue = physicsVector -> GetValue(kinEnergyPerNucleon, b);
|
|---|
| 56 | }
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
| 59 | // G4cout << *physicsVector << G4endl;
|
|---|
| 60 |
|
|---|
| 61 | G4cout << " E/A1(MeV) = " << kinEnergyPerNucleon / MeV
|
|---|
| 62 | << ", Z(Ion) = " << atomicNumberIon
|
|---|
| 63 | << ", Mat = " << matIdentifier
|
|---|
| 64 | << " -- dE/dx(MeV*cm2/mg) = "
|
|---|
| 65 | << tableDEDXValue / (MeV * cm2 / (0.001 * g))
|
|---|
| 66 | << ", Ref(MeV*cm2/mg) = "
|
|---|
| 67 | << refDEDXValue / (MeV * cm2 / (0.001 * g))
|
|---|
| 68 | << ":";
|
|---|
| 69 |
|
|---|
| 70 | G4double eps = 0.0001 * (MeV * cm2 / (0.001 * g));
|
|---|
| 71 |
|
|---|
| 72 | if( refDEDXValue < (tableDEDXValue - eps) ||
|
|---|
| 73 | refDEDXValue > (tableDEDXValue + eps) ) {
|
|---|
| 74 |
|
|---|
| 75 | G4cout << " Test failed" << G4endl;
|
|---|
| 76 | return false;
|
|---|
| 77 | }
|
|---|
| 78 | else G4cout << " Test passed" << G4endl;
|
|---|
| 79 |
|
|---|
| 80 | return true;
|
|---|
| 81 | }
|
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 | G4bool CompareDEDXValues(G4VIonDEDXTable* table,
|
|---|
| 85 | G4double refDEDXValue,
|
|---|
| 86 | G4double kinEnergyPerNucleon,
|
|---|
| 87 | G4int atomicNumberIon,
|
|---|
| 88 | G4int atomicNumberMat) {
|
|---|
| 89 |
|
|---|
| 90 | G4PhysicsVector* physicsVector =
|
|---|
| 91 | table -> GetPhysicsVector(atomicNumberIon,
|
|---|
| 92 | atomicNumberMat);
|
|---|
| 93 |
|
|---|
| 94 | std::stringstream ss;
|
|---|
| 95 | ss << atomicNumberMat;
|
|---|
| 96 |
|
|---|
| 97 | return Compare(physicsVector, refDEDXValue, kinEnergyPerNucleon,
|
|---|
| 98 | atomicNumberIon, ss.str());
|
|---|
| 99 | }
|
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 | G4bool CompareDEDXValues(G4VIonDEDXTable* table,
|
|---|
| 103 | G4double refDEDXValue,
|
|---|
| 104 | G4double kinEnergyPerNucleon,
|
|---|
| 105 | G4int atomicNumberIon,
|
|---|
| 106 | const G4String& matName) {
|
|---|
| 107 |
|
|---|
| 108 | G4PhysicsVector* physicsVector =
|
|---|
| 109 | table -> GetPhysicsVector(atomicNumberIon,
|
|---|
| 110 | matName);
|
|---|
| 111 | return Compare(physicsVector, refDEDXValue, kinEnergyPerNucleon,
|
|---|
| 112 | atomicNumberIon, matName);
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 |
|
|---|
| 116 | G4bool TestApplicability(G4VIonDEDXTable* table,
|
|---|
| 117 | G4bool shouldBeApplicable,
|
|---|
| 118 | G4int atomicNumberIon,
|
|---|
| 119 | const G4String& matName) {
|
|---|
| 120 |
|
|---|
| 121 | G4bool isApplicable = table -> IsApplicable(atomicNumberIon, matName);
|
|---|
| 122 |
|
|---|
| 123 | G4cout << " Z(Ion) = " << atomicNumberIon
|
|---|
| 124 | << ", Mat = " << matName
|
|---|
| 125 | << " -- ";
|
|---|
| 126 |
|
|---|
| 127 | if(shouldBeApplicable) {
|
|---|
| 128 | G4cout << " Should be applicable: ";
|
|---|
| 129 | if(isApplicable) G4cout << "Test passed." << G4endl;
|
|---|
| 130 | else { G4cout << "Test failed." << G4endl; return false; }
|
|---|
| 131 | }
|
|---|
| 132 | else {
|
|---|
| 133 | G4cout << " Should not be applicable: ";
|
|---|
| 134 | if(!isApplicable) G4cout << "Test passed." << G4endl;
|
|---|
| 135 | else { G4cout << "Test failed." << G4endl; return false; }
|
|---|
| 136 | }
|
|---|
| 137 | return true;
|
|---|
| 138 | }
|
|---|
| 139 |
|
|---|
| 140 |
|
|---|
| 141 | int main() {
|
|---|
| 142 |
|
|---|
| 143 | G4double unitDEDX = (MeV * cm2 / (0.001 * g));
|
|---|
| 144 |
|
|---|
| 145 | G4SimpleMaterialStoppingICRU73* icru73elem =
|
|---|
| 146 | new G4SimpleMaterialStoppingICRU73();
|
|---|
| 147 |
|
|---|
| 148 | G4MaterialStoppingICRU73* icru73comp = new G4MaterialStoppingICRU73();
|
|---|
| 149 |
|
|---|
| 150 | G4IronStoppingICRU73* icru73iron = new G4IronStoppingICRU73();
|
|---|
| 151 |
|
|---|
| 152 | G4cout << "### Test of DEDX tables (ICRU 73) ###" << G4endl;
|
|---|
| 153 |
|
|---|
| 154 | G4cout << "#### I. Testing Function GetPhysicsVector() ###" << G4endl;
|
|---|
| 155 |
|
|---|
| 156 | G4cout << G4endl << "### A. G4SimpleMaterialStoppingICRU73:" << G4endl;
|
|---|
| 157 |
|
|---|
| 158 | // Reference values taken directly from ICRU 73 tables
|
|---|
| 159 | CompareDEDXValues(icru73elem, 8.31 * unitDEDX, 0.025, 3, 1 );
|
|---|
| 160 | CompareDEDXValues(icru73elem, 3.312 * unitDEDX, 1.5, 8, 50);
|
|---|
| 161 | CompareDEDXValues(icru73elem, 10.99 * unitDEDX, 10., 18, 10);
|
|---|
| 162 | CompareDEDXValues(icru73elem, 4.412 * unitDEDX, 10., 18, 92);
|
|---|
| 163 |
|
|---|
| 164 | CompareDEDXValues(icru73elem, 8.31 * unitDEDX, 0.025, 3, "G4_H");
|
|---|
| 165 | CompareDEDXValues(icru73elem, 3.312 * unitDEDX, 1.5, 8, "G4_Sn");
|
|---|
| 166 | CompareDEDXValues(icru73elem, 10.99 * unitDEDX, 10., 18, "G4_Ne");
|
|---|
| 167 | CompareDEDXValues(icru73elem, 4.412 * unitDEDX, 10., 18, "G4_U");
|
|---|
| 168 |
|
|---|
| 169 | G4cout << G4endl << "### B. G4MaterialStoppingICRU73:" << G4endl;
|
|---|
| 170 |
|
|---|
| 171 | // Reference values taken directly from ICRU 73 tables
|
|---|
| 172 | CompareDEDXValues(icru73comp, 2.748 * unitDEDX, 0.025, 3, "G4_A-150_TISSUE");
|
|---|
| 173 | CompareDEDXValues(icru73comp, 1.909 * unitDEDX, 0.025, 3, "G4_CARBON_DIOXIDE");
|
|---|
| 174 | CompareDEDXValues(icru73comp, 4.225 * unitDEDX, 10.0 , 10, "G4_MYLAR");
|
|---|
| 175 |
|
|---|
| 176 | // Reference values taken directly from revised ICRU 73 tables
|
|---|
| 177 | CompareDEDXValues(icru73comp, 0.19364 * unitDEDX, 25.0, 3, "G4_WATER");
|
|---|
| 178 | CompareDEDXValues(icru73comp, 3.6037 * unitDEDX, 0.025, 6, "G4_WATER");
|
|---|
| 179 | CompareDEDXValues(icru73comp, 1.6302 * unitDEDX, 10.0, 6, "G4_WATER");
|
|---|
| 180 | CompareDEDXValues(icru73comp, 0.079682 * unitDEDX, 1000.0, 6, "G4_WATER");
|
|---|
| 181 | CompareDEDXValues(icru73comp, 1.2296 * unitDEDX, 80.0, 12, "G4_WATER");
|
|---|
| 182 | CompareDEDXValues(icru73comp, 7.1917 * unitDEDX, 15.0, 15, "G4_WATER");
|
|---|
| 183 | CompareDEDXValues(icru73comp, 4.7505 * unitDEDX, 30.0, 16, "G4_WATER");
|
|---|
| 184 | CompareDEDXValues(icru73comp, 0.76464 * unitDEDX, 800.0, 18, "G4_WATER");
|
|---|
| 185 | CompareDEDXValues(icru73comp, 12.836 * unitDEDX, 0.09, 18, "G4_WATER");
|
|---|
| 186 | CompareDEDXValues(icru73comp, 0.39022 * unitDEDX, 250.0, 10, "G4_WATER");
|
|---|
| 187 |
|
|---|
| 188 | G4cout << G4endl << "### C. G4IronStoppingICRU73:" << G4endl;
|
|---|
| 189 |
|
|---|
| 190 | // Reference values taken directly from ICRU 73 tables
|
|---|
| 191 | CompareDEDXValues(icru73iron, 27.6 * unitDEDX, 0.025, 26, "G4_H");
|
|---|
| 192 | CompareDEDXValues(icru73iron, 30.72 * unitDEDX, 1.5, 26, "G4_Al");
|
|---|
| 193 | CompareDEDXValues(icru73iron, 13.75 * unitDEDX, 10.0 , 26, "G4_Kr");
|
|---|
| 194 |
|
|---|
| 195 | G4cout << G4endl << "#### II. Testing Function IsApplicable() ###" << G4endl;
|
|---|
| 196 |
|
|---|
| 197 | G4cout << G4endl << "### A. G4SimpleMaterialStoppingICRU73:" << G4endl;
|
|---|
| 198 |
|
|---|
| 199 | TestApplicability(icru73elem, true, 3, "G4_H");
|
|---|
| 200 | TestApplicability(icru73elem, true, 8, "G4_Sn");
|
|---|
| 201 | TestApplicability(icru73elem, true, 18, "G4_Ne");
|
|---|
| 202 | TestApplicability(icru73elem, true, 18, "G4_U");
|
|---|
| 203 | TestApplicability(icru73elem, false, 19, "G4_H");
|
|---|
| 204 | TestApplicability(icru73elem, false, 2, "G4_Sn");
|
|---|
| 205 | TestApplicability(icru73elem, false, 3, "G4_Cr");
|
|---|
| 206 |
|
|---|
| 207 | G4cout << G4endl << "### B. G4MaterialStoppingICRU73:" << G4endl;
|
|---|
| 208 |
|
|---|
| 209 | TestApplicability(icru73comp, true, 3, "G4_MYLAR");
|
|---|
| 210 | TestApplicability(icru73comp, true, 8, "G4_POLYETHYLENE");
|
|---|
| 211 | TestApplicability(icru73comp, true, 18, "G4_CARBON_DIOXIDE");
|
|---|
| 212 | TestApplicability(icru73comp, true, 18, "G4_A-150_TISSUE");
|
|---|
| 213 | TestApplicability(icru73comp, false, 19, "G4_MYLAR");
|
|---|
| 214 | TestApplicability(icru73comp, false, 2, "G4_MYLAR");
|
|---|
| 215 | TestApplicability(icru73comp, false, 3, "G4_Cr");
|
|---|
| 216 |
|
|---|
| 217 | G4cout << G4endl << "### B. G4IronStoppingICRU73:" << G4endl;
|
|---|
| 218 |
|
|---|
| 219 | TestApplicability(icru73iron, true, 26, "G4_H");
|
|---|
| 220 | TestApplicability(icru73iron, true, 26, "G4_Ne");
|
|---|
| 221 | TestApplicability(icru73iron, true, 26, "G4_Kr");
|
|---|
| 222 | TestApplicability(icru73iron, false, 19, "G4_H");
|
|---|
| 223 | TestApplicability(icru73iron, false, 26, "G4_Sn");
|
|---|
| 224 | TestApplicability(icru73iron, false, 3, "G4_Cr");
|
|---|
| 225 |
|
|---|
| 226 | G4cout << G4endl << "################# DONE #################" << G4endl;
|
|---|
| 227 |
|
|---|
| 228 | delete icru73elem;
|
|---|
| 229 | delete icru73comp;
|
|---|
| 230 | delete icru73iron;
|
|---|
| 231 |
|
|---|
| 232 | return 0;
|
|---|
| 233 | }
|
|---|
| 234 |
|
|---|