ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4PixeShellDataSet.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file 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 //
28 // Author: Maria Grazia Pia (Maria.Grazia.Pia@cern.ch)
29 //
30 // History:
31 // -----------
32 // 1 Aug 2001 MGP Created
33 // 09.10.01 V.Ivanchenko Add case z=0
34 // 9 Mar 2008 MGP Cleaned up unreadable code modified by former developer
35 // (Further clean-up needed)
36 // 31 Jul 2008 MGP Revised
37 //
38 // -------------------------------------------------------------------
39 
40 #include "G4PixeShellDataSet.hh"
41 #include "G4DataSet.hh"
42 #include "G4IInterpolator.hh"
43 #include <fstream>
44 #include <sstream>
45 
46 
48  G4IInterpolator* algo,
49  const G4String& modelK,
50  const G4String& modelL,
51  const G4String& modelM,
52  G4double eUnit,
53  G4double dataUnit):
54  z(zeta),
55  algorithm(algo),
56  unitEnergies(eUnit),
57  unitData(dataUnit)
58 {
59  if (algorithm == 0) G4Exception("G4PixeShellDataSet::G4PixeShellDataSet",
60  "pii00000301",
62  "interpolation == 0");
63 
64  crossModel.push_back(modelK);
65  crossModel.push_back(modelL);
66  crossModel.push_back(modelM);
67 
68  shellName.push_back("k");
69  shellName.push_back("l");
70  shellName.push_back("m");
71 
72  size_t sizeK = modelK.size();
73  size_t sizeL = modelL.size();
74  size_t sizeM = modelM.size();
75 
76  if (sizeK > 0) subShellName.push_back("k");
77 
78  if (sizeK > 0 && sizeL > 0)
79  {
80  subShellName.push_back("l1");
81  subShellName.push_back("l2");
82  subShellName.push_back("l3");
83  }
84  if (sizeK > 0 && sizeL > 0 && sizeM >0)
85  {
86  subShellName.push_back("m1");
87  subShellName.push_back("m2");
88  subShellName.push_back("m3");
89  subShellName.push_back("m4");
90  subShellName.push_back("m5");
91  }
92 }
93 
94 
96 {
98  if (algorithm) delete algorithm;
99 }
100 
101 
103 {
104  // Returns the sum over the shells corresponding to e
105  G4double value = 0.;
106 
107  std::vector<G4IDataSet *>::const_iterator i(components.begin());
108  std::vector<G4IDataSet *>::const_iterator end(components.end());
109 
110  while (i != end)
111  {
112  value += (*i)->FindValue(energy);
113  i++;
114  }
115  return value;
116 }
117 
118 
120 {
121  const size_t n = NumberOfComponents();
122 
123  G4cout << "The data set has " << n << " components" << G4endl;
124  G4cout << G4endl;
125 
126  size_t i = 0;
127 
128  while (i < n)
129  {
130  G4cout << "--- Component " << i << " ---" << G4endl;
131  GetComponent(i)->PrintData();
132  i++;
133  }
134 }
135 
136 
138  G4DataVector* data,
139  G4int componentId)
140 {
141  G4IDataSet* component = components[componentId];
142 
143  if (component)
144  {
145  component->SetEnergiesData(energies, data, 0);
146  return;
147  }
148 
149  std::ostringstream message;
150  message << "G4PixeShellDataSet::SetEnergiesData - component " << componentId << " not found";
151 
152  G4Exception("G4PixeShellDataSet::SetEnergiesData",
153  "pii000000310",
155  message.str().c_str());
156 }
157 
158 
160 {
162 
163  // Load shell cross sections
164 
165  G4int nShells = subShellName.size();
166 
167  for (G4int subShellIndex=0; subShellIndex<nShells; subShellIndex++)
168  {
169  G4String subName = subShellName[subShellIndex];
170  G4String fullFileName = FullFileName(file,subName);
171 
172  // Create component DataSet with the data from the current subshell
173  G4IDataSet* dataSet = new G4DataSet(z,algorithm);
174  dataSet->LoadData(fullFileName);
175 
176  // Add component to the ShellDataSet
177  AddComponent(dataSet);
178  }
179 
180  return true;
181 }
182 
183 
185 {
186  // Dummy implementation
187  return true;
188 }
189 
190 
192 {
193  while (!components.empty())
194  {
195  if (components.back()) delete components.back();
196  components.pop_back();
197  }
198 }
199 
200 
202  const G4String& subShell) const
203 {
204  char* path = std::getenv("G4PIIDATA");
205  if (!path)
206  G4Exception("G4PixeShellDataSet::FullFileName",
207  "pii00000320",
209  "G4PIIDATA environment variable not set");
210 
211  // Identify the shell this subshell belongs to
212  G4int shellIndex = TranslateShell(subShell);
213  G4String shellString = shellName[shellIndex];
214  G4String shellModel = crossModel[shellIndex];
215 
216  std::ostringstream fullFileName;
217 
218  fullFileName
219  //<< path
220  << "pixe/"
221  << file
222  << '/'
223  << shellString
224  << '/'
225  << shellModel
226  << '/'
227  << subShell
228  << '-' ;
229 // << z
230  // << ".dat";
231 
232  G4String test(fullFileName.str().c_str());
233  // std::cout << "PixeShellDataSet - Reading data from file " << test << std::endl;
234 
235  return G4String(fullFileName.str().c_str());
236 }
237 
239 {
240  // By default return K shell
241  G4int index = 0;
242 
243  if (subShell == "l1" || subShell == "l2" || subShell == "l3" ) index = 1;
244  if (subShell == "m1" ||
245  subShell == "m2" ||
246  subShell == "m3" ||
247  subShell == "m4" ||
248  subShell == "m5" ) index = 2;
249  return index;
250 }