source: trunk/source/processes/electromagnetic/lowenergy/src/G4CompositeEMDataSet.cc@ 830

Last change on this file since 830 was 819, checked in by garnier, 17 years ago

import all except CVS

File size: 5.0 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: G4CompositeEMDataSet.cc,v 1.9 2006/06/29 19:38:46 gunter Exp $
28// GEANT4 tag $Name: geant4-09-01-patch-02 $
29//
30// Author: Maria Grazia Pia (Maria.Grazia.Pia@cern.ch)
31//
32// History:
33// -----------
34// 1 Aug 2001 MGP Created
35//
36// -------------------------------------------------------------------
37
38#include "G4CompositeEMDataSet.hh"
39#include "G4EMDataSet.hh"
40#include "G4VDataSetAlgorithm.hh"
41#include <fstream>
42#include <sstream>
43
44 G4CompositeEMDataSet :: G4CompositeEMDataSet(G4VDataSetAlgorithm* argAlgorithm, G4double argUnitEnergies, G4double argUnitData, G4int argMinZ, G4int argMaxZ)
45:
46 algorithm(argAlgorithm),
47 unitEnergies(argUnitEnergies),
48 unitData(argUnitData),
49 minZ(argMinZ),
50 maxZ(argMaxZ)
51{
52 if (algorithm == 0)
53 G4Exception("G4CompositeEMDataSet::G4CompositeEMDataSet - interpolation == 0");
54}
55
56
57
58 G4CompositeEMDataSet :: ~G4CompositeEMDataSet()
59{
60 CleanUpComponents();
61
62 if (algorithm)
63 delete algorithm;
64}
65
66
67
68
69
70
71G4double G4CompositeEMDataSet :: FindValue(G4double argEnergy, G4int argComponentId) const
72{
73 const G4VEMDataSet * component(GetComponent(argComponentId));
74
75 if (component)
76 return component->FindValue(argEnergy);
77
78 std::ostringstream message;
79 message << "G4CompositeEMDataSet::FindValue - component " << argComponentId << " not found";
80
81 G4Exception(message.str().c_str());
82
83 return 0.;
84}
85
86
87
88
89
90void G4CompositeEMDataSet :: PrintData(void) const
91{
92 const size_t n(NumberOfComponents());
93
94 G4cout << "The data set has " << n << " components" << G4endl;
95 G4cout << G4endl;
96
97 size_t i(0);
98
99 while (i<n)
100 {
101 G4cout << "--- Component " << i << " ---" << G4endl;
102 GetComponent(i)->PrintData();
103 i++;
104 }
105}
106
107
108
109
110
111void G4CompositeEMDataSet :: SetEnergiesData(G4DataVector * argEnergies, G4DataVector * argData, G4int argComponentId)
112{
113 G4VEMDataSet * component(components[argComponentId]);
114
115 if (component)
116 {
117 component->SetEnergiesData(argEnergies, argData, 0);
118 return;
119 }
120
121 std::ostringstream message;
122 message << "G4CompositeEMDataSet::SetEnergiesData - component " << argComponentId << " not found";
123
124 G4Exception(message.str().c_str());
125}
126
127
128
129
130
131G4bool G4CompositeEMDataSet :: LoadData(const G4String & argFileName)
132{
133 CleanUpComponents();
134
135 for (G4int z(minZ); z<maxZ; z++)
136 {
137 G4VEMDataSet * component=new G4EMDataSet(z, algorithm->Clone(), unitEnergies, unitData);
138 if (!component->LoadData(argFileName))
139 {
140 delete component;
141 return false;
142 }
143
144 AddComponent(component);
145 }
146
147 return true;
148}
149
150
151
152G4bool G4CompositeEMDataSet :: SaveData(const G4String & argFileName) const
153{
154 for (G4int z(minZ); z<maxZ; z++)
155 {
156 const G4VEMDataSet * component(GetComponent(z-minZ));
157
158 if (!component)
159 {
160 std::ostringstream message;
161 message << "G4CompositeEMDataSet::SaveData - component " << (z-minZ) << " not found";
162
163 G4Exception(message.str().c_str());
164 }
165
166 if (!component->SaveData(argFileName))
167 return false;
168 }
169
170 return true;
171}
172
173
174
175
176
177void G4CompositeEMDataSet :: CleanUpComponents(void)
178{
179 while (!components.empty())
180 {
181 if (components.back())
182 delete components.back();
183
184 components.pop_back();
185 }
186}
187
Note: See TracBrowser for help on using the repository browser.