source: trunk/source/materials/test/testMaterialPropertiesTable.cc@ 1244

Last change on this file since 1244 was 1199, checked in by garnier, 16 years ago

nvx fichiers dans CVS

File size: 9.8 KB
Line 
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: testMaterialPropertiesTable.cc,v 1.4 2006/06/29 19:13:33 gunter Exp $
28// GEANT4 tag $Name: materials-V09-02-18 $
29//
30//
31// ------------------------------------------------------------
32
33#include "G4ios.hh"
34#include "G4MaterialPropertyVector.hh"
35#include "G4MaterialPropertiesTable.hh"
36
37void LoopUntilPressEnter();
38
39int main()
40{
41 // Some Test Data
42
43 const G4int NUMENTRIES = 32;
44
45 G4double PPCKOV[NUMENTRIES] =
46 { 2.038E-9, 2.072E-9, 2.107E-9, 2.143E-9, 2.181E-9,
47 2.220E-9, 2.260E-9, 2.302E-9, 2.346E-9, 2.391E-9,
48 2.438E-9, 2.486E-9, 2.537E-9, 2.590E-9, 2.645E-9,
49 2.702E-9, 2.763E-9, 2.825E-9, 2.891E-9, 2.960E-9,
50 3.032E-9, 3.108E-9, 3.188E-9, 3.271E-9, 3.360E-9,
51 3.453E-9, 3.552E-9, 3.656E-9, 3.767E-9, 3.884E-9,
52 4.010E-9, 4.144E-9 };
53
54 G4double EFFIC[NUMENTRIES] =
55 { 0.005,0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07,
56 0.08, 0.09, 0.10, 0.115,0.13, 0.15, 0.16, 0.18,
57 0.195,0.22, 0.23, 0.24, 0.25, 0.255,0.26, 0.265,
58 0.26, 0.25, 0.24, 0.215,0.175,0.14, 0.085, 0.0 };
59
60
61 G4double RINDEX[NUMENTRIES] =
62 { 1.33, 1.33, 1.33, 1.33, 1.33, 1.33, 1.33,
63 1.33, 1.33, 1.34, 1.34, 1.34, 1.34, 1.34,
64 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34,
65 1.34, 1.34, 1.35, 1.35, 1.35, 1.35, 1.35,
66 1.35, 1.35, 1.35, 1.35 };
67
68
69 G4double ABSCO[NUMENTRIES] =
70 { 344.8, 408.2, 632.9, 917.4, 1234.6, 1388.9,
71 1515.2, 1724.1, 1886.8, 2000.0, 2631.6, 3571.4,
72 4545.5, 4761.9, 5263.2, 5263.2, 5555.6, 5263.2,
73 5263.2, 4761.9, 4545.5, 4166.7, 3703.7, 3333.3,
74 3000.0, 2850.0, 2700.0, 2450.0, 2200.0, 1950.0,
75 1750.0, 1450.0 };
76
77 G4MaterialPropertiesTable myMPT;
78
79//////////////////////////////////////////////////////////////////////////////
80// Test storage and Retrieval
81//////////////////////////////////////////////////////////////////////////////
82
83 G4cout << "\n\n\nTest AddProperty() and GetProperty()\n";
84 G4cout << "------------------------------------\n\n";
85 G4cout << "Store and Retrieve EFFIC and ABSCO\n\n";
86 LoopUntilPressEnter();
87
88 myMPT.AddProperty("EFFIC", PPCKOV, EFFIC, NUMENTRIES);
89
90 G4MaterialPropertyVector *mpv;
91 mpv = myMPT.GetProperty("EFFIC");
92
93 G4cout << "EFFIC" << G4endl;
94 G4cout << "-----" << G4endl;
95
96 mpv->DumpVector();
97 LoopUntilPressEnter();
98
99 myMPT.AddProperty("ABSCO", PPCKOV, ABSCO, NUMENTRIES);
100 mpv = myMPT.GetProperty("ABSCO");
101
102 G4cout << "ABSCO" << G4endl;
103 G4cout << "-----" << G4endl;
104 mpv->DumpVector();
105
106 LoopUntilPressEnter();
107
108//////////////////////////////////////////////////////////////////////////////
109// Test Generation of RINDEX entry
110//////////////////////////////////////////////////////////////////////////////
111
112 G4cout << "AddProperty RINDEX and Retrieve it again \n\n";
113 LoopUntilPressEnter();
114
115 myMPT.AddProperty("RINDEX", PPCKOV, RINDEX, NUMENTRIES);
116 mpv = myMPT.GetProperty("RINDEX");
117
118 G4cout << "RINDEX" << G4endl;
119 G4cout << "------" << G4endl;
120
121 mpv->DumpVector();
122
123 LoopUntilPressEnter();
124
125 // Test Remove Property
126 // --------------------
127 G4cout << "\nTest RemoveProperty() -- Remove EFFIC\n";
128 G4cout << "-------------------------------------\n\n";
129 G4cout << "Dump table contents to observe absence of EFFIC\n\n";
130 LoopUntilPressEnter();
131
132 myMPT.RemoveProperty("EFFIC");
133 myMPT.DumpTable();
134
135//////////////////////////////////////////////////////////////////////////////
136// Test AddEntry
137//////////////////////////////////////////////////////////////////////////////
138
139 G4cout << "\nTest AddEntry()\n";
140 G4cout << "---------------\n\n";
141 G4cout << "Add an element (3.166e-09, 1.34) to the Refraction Index \n";
142 G4cout << "Property vector, check to see that it has been \n";
143 G4cout << "inserted in its proper place. \n\n";
144 LoopUntilPressEnter();
145
146 mpv = myMPT.GetProperty("RINDEX");
147 myMPT.AddEntry("RINDEX", 3.166e-09, 1.34);
148
149 G4cout << "RINDEX" << G4endl;
150 G4cout << "------" << G4endl;
151 mpv->DumpVector();
152
153 G4cout << "TESTING GetPhotonMomentum()" << G4endl;
154 G4cout << "---------------------------" << G4endl;
155
156 for (int i=0; i < NUMENTRIES; i++) {
157 G4cerr << "Photon Momentum for " << RINDEX[i] << " "
158 << mpv->GetPhotonMomentum(RINDEX[i])
159 << G4endl;
160 }
161
162 LoopUntilPressEnter();
163
164//////////////////////////////////////////////////////////////////////////////
165// Test RemoveEntry
166//////////////////////////////////////////////////////////////////////////////
167
168 G4cout << "\nTest RemoveEntry()\n";
169 G4cout << "------------------\n\n";
170 G4cout << "Remove an element (3.166e-09, 1.34) from the Refraction \n";
171 G4cout << "Index Property vector, check to see that it has been \n";
172 G4cout << "removed from its proper place \n\n";
173 LoopUntilPressEnter();
174
175 mpv = myMPT.GetProperty("RINDEX");
176 myMPT.RemoveEntry("RINDEX", 3.166e-09);
177
178 G4cout << "RINDEX" << G4endl;
179 G4cout << "------" << G4endl;
180 mpv->DumpVector();
181 LoopUntilPressEnter();
182
183 myMPT.AddProperty("EFFIC", PPCKOV, EFFIC, NUMENTRIES);
184
185//////////////////////////////////////////////////////////////////////////////
186// Test Assignment operator for MaterialPropertyVector
187//////////////////////////////////////////////////////////////////////////////
188
189 G4cout << "\nTest Assignment Operator for MaterialPropertyVector\n";
190 G4cout << "--------------------------------------------------\n\n";
191
192 LoopUntilPressEnter();
193
194 G4MaterialPropertyVector testMPV1;
195 G4MaterialPropertyVector testMPV2;
196
197 testMPV1 = *myMPT.GetProperty("EFFIC");
198
199 G4cout << "Vector1\n\n";
200
201 testMPV1.DumpVector();
202 LoopUntilPressEnter();
203
204 testMPV2 = *myMPT.GetProperty("RINDEX");
205
206 G4cout << "Vector2\n\n";
207
208 testMPV2.DumpVector();
209 LoopUntilPressEnter();
210
211 testMPV1 = testMPV2;
212
213 G4cout << "Vector1\n\n";
214
215 testMPV1.DumpVector();
216 LoopUntilPressEnter();
217
218//////////////////////////////////////////////////////////////////////////////
219// Test Copy Constructor for MaterialPropertyVector
220//////////////////////////////////////////////////////////////////////////////
221
222 G4cout << "\nTest Copy Constructor for MaterialPropertyVector\n";
223 G4cout << "-----------------------------------------------\n\n";
224 G4cout << "Copying contents of Vector2 into Vector3\n\n";
225 LoopUntilPressEnter();
226
227 G4MaterialPropertyVector testMPV3(testMPV2);
228 G4cout << "Vector3\n\n";
229
230 testMPV2.DumpVector();
231
232 G4cout << "MinPM " << testMPV2.GetMinPhotonMomentum() << G4endl;
233 G4cout << "MaxPM " << testMPV2.GetMaxPhotonMomentum() << G4endl;
234 G4cout << "\n\n";
235 LoopUntilPressEnter();
236
237//////////////////////////////////////////////////////////////////////////////
238// Test Assignment operator for MaterialPropertiesTable
239//////////////////////////////////////////////////////////////////////////////
240
241 G4cout << "\nTest Assignment operator for MaterialPropertiesTable\n";
242 G4cout << "---------------------------------------------------\n\n";
243 G4cout << "Assign Table2 the contents of the current";
244 G4cout << "MaterialPropertiesTable\n\n";
245 LoopUntilPressEnter();
246
247 G4MaterialPropertiesTable myMPT2;
248 myMPT2 = myMPT;
249
250 G4cout << "Table2\n\n";
251
252 myMPT2.DumpTable();
253
254//////////////////////////////////////////////////////////////////////////////
255// Test Copy Constructor for MaterialPropertiesTable
256//////////////////////////////////////////////////////////////////////////////
257
258 G4cout << "\nTest Copy Constructor for MaterialPropertiesTable\n";
259 G4cout << "------------------------------------------------\n\n";
260 G4cout << "Assign Table3 the contents of Table2\n\n";
261 LoopUntilPressEnter();
262
263 G4MaterialPropertiesTable myMPT3(myMPT2);
264
265 G4cout << "Table3\n\n";
266
267 myMPT3.DumpTable();
268
269 G4cout << "\n\n\n<END OF TEST>\n\n\n";
270
271 return EXIT_SUCCESS;
272}
273
274// LoopUntilPressEnter
275// -------------------
276//
277void LoopUntilPressEnter()
278{
279 char ch;
280 G4cout << "Press <Enter> to continue ... ";
281 while ( G4cin.get(ch) )
282 {
283 if (ch == '\n') break;
284 }
285 G4cout << G4endl;
286}
287
Note: See TracBrowser for help on using the repository browser.