Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4PixeShellDataSet.cc
이 파일의 문서화 페이지로 가기
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: G4PixeShellDataSet.cc 70904 2013-06-07 10:34:25Z gcosmo $
28 //
29 // Author: Maria Grazia Pia (Maria.Grazia.Pia@cern.ch)
30 //
31 // History:
32 // -----------
33 // 1 Aug 2001 MGP Created
34 // 09.10.01 V.Ivanchenko Add case z=0
35 // 9 Mar 2008 MGP Cleaned up unreadable code modified by former developer
36 // (Further clean-up needed)
37 // 31 Jul 2008 MGP Revised
38 //
39 // -------------------------------------------------------------------
40 
41 #include "G4PixeShellDataSet.hh"
42 #include "G4DataSet.hh"
43 #include "G4IInterpolator.hh"
44 #include <fstream>
45 #include <sstream>
46 
47 
49  G4IInterpolator* algo,
50  const G4String& modelK,
51  const G4String& modelL,
52  const G4String& modelM,
53  G4double eUnit,
54  G4double dataUnit):
55  z(zeta),
56  algorithm(algo),
57  unitEnergies(eUnit),
58  unitData(dataUnit)
59 {
60  if (algorithm == 0) G4Exception("G4PixeShellDataSet::G4PixeShellDataSet",
61  "pii00000301",
63  "interpolation == 0");
64 
65  crossModel.push_back(modelK);
66  crossModel.push_back(modelL);
67  crossModel.push_back(modelM);
68 
69  shellName.push_back("k");
70  shellName.push_back("l");
71  shellName.push_back("m");
72 
73  size_t sizeK = modelK.size();
74  size_t sizeL = modelL.size();
75  size_t sizeM = modelM.size();
76 
77  if (sizeK > 0) subShellName.push_back("k");
78 
79  if (sizeK > 0 && sizeL > 0)
80  {
81  subShellName.push_back("l1");
82  subShellName.push_back("l2");
83  subShellName.push_back("l3");
84  }
85  if (sizeK > 0 && sizeL > 0 && sizeM >0)
86  {
87  subShellName.push_back("m1");
88  subShellName.push_back("m2");
89  subShellName.push_back("m3");
90  subShellName.push_back("m4");
91  subShellName.push_back("m5");
92  }
93 }
94 
95 
97 {
99  if (algorithm) delete algorithm;
100 }
101 
102 
104 {
105  // Returns the sum over the shells corresponding to e
106  G4double value = 0.;
107 
108  std::vector<G4IDataSet *>::const_iterator i(components.begin());
109  std::vector<G4IDataSet *>::const_iterator end(components.end());
110 
111  while (i != end)
112  {
113  value += (*i)->FindValue(energy);
114  i++;
115  }
116  return value;
117 }
118 
119 
121 {
122  const size_t n = NumberOfComponents();
123 
124  G4cout << "The data set has " << n << " components" << G4endl;
125  G4cout << G4endl;
126 
127  size_t i = 0;
128 
129  while (i < n)
130  {
131  G4cout << "--- Component " << i << " ---" << G4endl;
132  GetComponent(i)->PrintData();
133  i++;
134  }
135 }
136 
137 
139  G4DataVector* data,
140  G4int componentId)
141 {
142  G4IDataSet* component = components[componentId];
143 
144  if (component)
145  {
146  component->SetEnergiesData(energies, data, 0);
147  return;
148  }
149 
150  std::ostringstream message;
151  message << "G4PixeShellDataSet::SetEnergiesData - component " << componentId << " not found";
152 
153  G4Exception("G4PixeShellDataSet::SetEnergiesData",
154  "pii000000310",
156  message.str().c_str());
157 }
158 
159 
161 {
163 
164  // Load shell cross sections
165 
166  G4int nShells = subShellName.size();
167 
168  for (G4int subShellIndex=0; subShellIndex<nShells; subShellIndex++)
169  {
170  G4String subName = subShellName[subShellIndex];
171  G4String fullFileName = FullFileName(file,subName);
172 
173  // Create component DataSet with the data from the current subshell
174  G4IDataSet* dataSet = new G4DataSet(z,algorithm);
175  dataSet->LoadData(fullFileName);
176 
177  // Add component to the ShellDataSet
178  AddComponent(dataSet);
179  }
180 
181  return true;
182 }
183 
184 
186 {
187  // Dummy implementation
188  return true;
189 }
190 
191 
193 {
194  while (!components.empty())
195  {
196  if (components.back()) delete components.back();
197  components.pop_back();
198  }
199 }
200 
201 
203  const G4String& subShell) const
204 {
205  char* path = getenv("G4PIIDATA");
206  if (!path)
207  G4Exception("G4PixeShellDataSet::FullFileName",
208  "pii00000320",
210  "G4PIIDATA environment variable not set");
211 
212  // Identify the shell this subshell belongs to
213  G4int shellIndex = TranslateShell(subShell);
214  G4String shellString = shellName[shellIndex];
215  G4String shellModel = crossModel[shellIndex];
216 
217  std::ostringstream fullFileName;
218 
219  fullFileName
220  //<< path
221  << "pixe/"
222  << file
223  << '/'
224  << shellString
225  << '/'
226  << shellModel
227  << '/'
228  << subShell
229  << '-' ;
230 // << z
231  // << ".dat";
232 
233  G4String test(fullFileName.str().c_str());
234  // std::cout << "PixeShellDataSet - Reading data from file " << test << std::endl;
235 
236  return G4String(fullFileName.str().c_str());
237 }
238 
240 {
241  // By default return K shell
242  G4int index = 0;
243 
244  if (subShell == "l1" || subShell == "l2" || subShell == "l3" ) index = 1;
245  if (subShell == "m1" ||
246  subShell == "m2" ||
247  subShell == "m3" ||
248  subShell == "m4" ||
249  subShell == "m5" ) index = 2;
250  return index;
251 }
std::vector< G4String > crossModel
virtual void AddComponent(G4IDataSet *dataSet)
virtual size_t NumberOfComponents(void) const
virtual void PrintData(void) const
#define G4endl
Definition: G4ios.hh:61
Double_t z
void message(RunManager *runmanager)
Definition: ts_scorers.cc:72
std::vector< G4String > subShellName
const XML_Char const XML_Char * data
Definition: expat.h:268
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
const XML_Char int const XML_Char * value
Definition: expat.h:331
std::vector< G4IDataSet * > components
virtual void SetEnergiesData(G4DataVector *x, G4DataVector *data, G4int component=0)=0
virtual G4bool SaveData(const G4String &fileName) const
double energy
Definition: plottest35.C:25
virtual const G4IDataSet * GetComponent(G4int componentId) const
virtual G4bool LoadData(const G4String &fileName)=0
G4int TranslateShell(const G4String &subShell) const
G4String FullFileName(const G4String &particleType, const G4String &subShell) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
int G4int
Definition: G4Types.hh:78
TFile * file
std::vector< G4String > shellName
virtual G4double FindValue(G4double energy, G4int componentId=0) const
virtual void PrintData(void) const =0
G4GLOB_DLL std::ostream G4cout
virtual void SetEnergiesData(G4DataVector *energies, G4DataVector *data, G4int componentId)
virtual G4bool LoadData(const G4String &fileName)
Char_t n[5]
G4IInterpolator * algorithm