[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 | // $Id: testMaterialPropertyVector.cc,v 1.6 2006/06/29 19:13:36 gunter Exp $ |
---|
| 28 | // GEANT4 tag $Name: materials-V09-02-18 $ |
---|
| 29 | // |
---|
| 30 | // |
---|
| 31 | // ------------------------------------------------------------ |
---|
| 32 | |
---|
| 33 | #include "G4MaterialPropertyVector.hh" |
---|
| 34 | |
---|
| 35 | void LoopUntilPressEnter(); |
---|
| 36 | |
---|
| 37 | int main () |
---|
| 38 | { |
---|
| 39 | const G4int NUMENTRIES = 32; |
---|
| 40 | G4double aPhotonMomentum, anAbsorptionCoefficient; |
---|
| 41 | |
---|
| 42 | G4double PPCKOV[NUMENTRIES] = |
---|
| 43 | { 4.010E-9, 4.144E-9, // see (**) |
---|
| 44 | 2.038E-9, 2.072E-9, 2.107E-9, 2.143E-9, 2.181E-9, |
---|
| 45 | 2.220E-9, 2.260E-9, 2.302E-9, 2.346E-9, 2.391E-9, |
---|
| 46 | 2.438E-9, 2.486E-9, 2.537E-9, 2.590E-9, 2.645E-9, |
---|
| 47 | 2.702E-9, 2.763E-9, 2.825E-9, 2.891E-9, 2.960E-9, |
---|
| 48 | 3.032E-9, 3.108E-9, 3.188E-9, 3.271E-9, 3.360E-9, |
---|
| 49 | 3.453E-9, 3.552E-9, 3.656E-9, 3.767E-9, 3.884E-9, |
---|
| 50 | }; |
---|
| 51 | |
---|
| 52 | G4double ABSCO[NUMENTRIES] = |
---|
| 53 | { 1750.0, 1450.0, // see (**) |
---|
| 54 | 344.8, 408.2, 632.9, 917.4, 1234.6, 1388.9, |
---|
| 55 | 1515.2, 1724.1, 1886.8, 2000.0, 2631.6, 3571.4, |
---|
| 56 | 4545.5, 4761.9, 5263.2, 5263.2, 5555.6, 5263.2, |
---|
| 57 | 5263.2, 4761.9, 4545.5, 4166.7, 3703.7, 3333.3, |
---|
| 58 | 3000.0, 2850.0, 2700.0, 2450.0, 2200.0, 1950.0, |
---|
| 59 | }; |
---|
| 60 | |
---|
| 61 | // (**) Were at the end of the lists: I put them at the beginning to |
---|
| 62 | // test reordering. |
---|
| 63 | |
---|
| 64 | |
---|
| 65 | // Test Vector creation |
---|
| 66 | // -------------------- |
---|
| 67 | G4cout << "Test Vector creation" << G4endl; |
---|
| 68 | G4cout << "--------------------" << G4endl << G4endl; |
---|
| 69 | |
---|
| 70 | G4MaterialPropertyVector absco(PPCKOV, ABSCO, NUMENTRIES); |
---|
| 71 | absco.DumpVector(); |
---|
| 72 | LoopUntilPressEnter(); |
---|
| 73 | |
---|
| 74 | // Test GetProperty |
---|
| 75 | // ---------------- |
---|
| 76 | G4cout << "Test GetProperty" << G4endl; |
---|
| 77 | G4cout << "----------------" << G4endl << G4endl; |
---|
| 78 | G4cout << "Input a photon momentum value (MeV) for which you wish" << G4endl; |
---|
| 79 | G4cout << "to find the absorption coefficient: " << G4endl; |
---|
| 80 | |
---|
| 81 | G4cin >> aPhotonMomentum; |
---|
| 82 | G4cout << G4endl; |
---|
| 83 | |
---|
| 84 | aPhotonMomentum *= aPhotonMomentum*MeV; |
---|
| 85 | |
---|
| 86 | anAbsorptionCoefficient = absco.GetProperty(aPhotonMomentum); |
---|
| 87 | |
---|
| 88 | G4cout << "The absorption coefficient is: " |
---|
| 89 | << anAbsorptionCoefficient |
---|
| 90 | << G4endl; |
---|
| 91 | LoopUntilPressEnter(); |
---|
| 92 | |
---|
| 93 | // Test AddElement |
---|
| 94 | // --------------- |
---|
| 95 | G4cout << "Test AddElement" << G4endl; |
---|
| 96 | G4cout << "---------------" << G4endl << G4endl; |
---|
| 97 | G4cout << "Add the entry just created" << G4endl; |
---|
| 98 | LoopUntilPressEnter(); |
---|
| 99 | |
---|
| 100 | absco.AddElement(aPhotonMomentum, anAbsorptionCoefficient); |
---|
| 101 | absco.DumpVector(); |
---|
| 102 | |
---|
| 103 | // Test RemoveElement |
---|
| 104 | // ------------------ |
---|
| 105 | G4cout << "Test RemoveElement" << G4endl; |
---|
| 106 | G4cout << "------------------" << G4endl << G4endl; |
---|
| 107 | G4cout << "Input a photon momentum value for which you wish" << G4endl; |
---|
| 108 | G4cout << "to remove the OPVEntry: " << G4endl; |
---|
| 109 | |
---|
| 110 | G4cin >> aPhotonMomentum; |
---|
| 111 | G4cout << G4endl; |
---|
| 112 | |
---|
| 113 | aPhotonMomentum *= aPhotonMomentum*MeV; |
---|
| 114 | |
---|
| 115 | absco.RemoveElement(aPhotonMomentum); |
---|
| 116 | absco.DumpVector(); |
---|
| 117 | |
---|
| 118 | // Test the iterator |
---|
| 119 | // ----------------- |
---|
| 120 | G4cout << "Test the iterator" << G4endl; |
---|
| 121 | G4cout << "-----------------" << G4endl << G4endl; |
---|
| 122 | LoopUntilPressEnter(); |
---|
| 123 | |
---|
| 124 | absco.ResetIterator(); |
---|
| 125 | |
---|
| 126 | while (++absco) |
---|
| 127 | { |
---|
| 128 | G4cout << absco.GetPhotonMomentum()/MeV << "MeV \t" |
---|
| 129 | << absco.GetProperty() << G4endl; |
---|
| 130 | } |
---|
| 131 | G4cout << "\n\n <END OF TEST>" << G4endl; |
---|
| 132 | |
---|
| 133 | return EXIT_SUCCESS; |
---|
| 134 | } |
---|
| 135 | |
---|
| 136 | // LoopUntilPressEnter |
---|
| 137 | // ------------------- |
---|
| 138 | // |
---|
| 139 | void LoopUntilPressEnter() |
---|
| 140 | { |
---|
| 141 | char ch; |
---|
| 142 | G4cout << "Press <Enter> to continue ... "; |
---|
| 143 | while ( G4cin.get(ch) ) |
---|
| 144 | { |
---|
| 145 | if (ch == '\n') break; |
---|
| 146 | } |
---|
| 147 | G4cout << G4endl; |
---|
| 148 | } |
---|