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] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /processes/electromagnetic/lowenergy/src/G4DopplerProfile.cc (Version 11.3.0) and /processes/electromagnetic/lowenergy/src/G4DopplerProfile.cc (Version 10.0.p4)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 //                                                 26 //
                                                   >>  27 // $Id: G4DopplerProfile.cc 66241 2012-12-13 18:34:42Z gunter $
 27 //                                                 28 //
 28 // Author: Maria Grazia Pia (Maria.Grazia.Pia@     29 // Author: Maria Grazia Pia (Maria.Grazia.Pia@cern.ch)
 29 //                                                 30 //
 30 // History:                                        31 // History:
 31 // -----------                                     32 // -----------
 32 // 31 Jul 2001   MGP        Created                33 // 31 Jul 2001   MGP        Created
 33 //                                                 34 //
 34 // -------------------------------------------     35 // -------------------------------------------------------------------
 35                                                    36 
 36 #include "G4DopplerProfile.hh"                     37 #include "G4DopplerProfile.hh"
 37 #include "G4DataVector.hh"                         38 #include "G4DataVector.hh"
 38 #include "G4SystemOfUnits.hh"                      39 #include "G4SystemOfUnits.hh"
 39 #include "G4VEMDataSet.hh"                         40 #include "G4VEMDataSet.hh"
 40 #include "G4EMDataSet.hh"                          41 #include "G4EMDataSet.hh"
 41 #include "G4CompositeEMDataSet.hh"                 42 #include "G4CompositeEMDataSet.hh"
 42 #include "G4VDataSetAlgorithm.hh"                  43 #include "G4VDataSetAlgorithm.hh"
 43 #include "G4LogLogInterpolation.hh"                44 #include "G4LogLogInterpolation.hh"
 44                                                    45 
 45 #include <fstream>                                 46 #include <fstream>
 46 #include <sstream>                                 47 #include <sstream>
 47 #include "Randomize.hh"                            48 #include "Randomize.hh"
 48                                                    49 
 49 //....oooOO0OOooo........oooOO0OOooo........oo <<  50 // The following deprecated header is included because <functional> seems not to be found on MGP's laptop
                                                   >>  51 //#include "function.h"
                                                   >>  52 
                                                   >>  53 // Constructor
 50                                                    54 
 51 G4DopplerProfile::G4DopplerProfile(G4int minZ,     55 G4DopplerProfile::G4DopplerProfile(G4int minZ, G4int maxZ)
 52   : zMin(minZ), zMax(maxZ)                         56   : zMin(minZ), zMax(maxZ)
 53 {                                                  57 {  
                                                   >>  58   nBiggs = 31;
                                                   >>  59 
 54   LoadBiggsP("/doppler/p-biggs");                  60   LoadBiggsP("/doppler/p-biggs");
 55                                                    61 
 56   for (G4int Z=zMin; Z<zMax+1; Z++)                62   for (G4int Z=zMin; Z<zMax+1; Z++)
 57     {                                              63     {
 58       LoadProfile("/doppler/profile",Z);           64       LoadProfile("/doppler/profile",Z);
 59     }                                              65     }
 60 }                                                  66 }
 61                                                    67 
 62 //....oooOO0OOooo........oooOO0OOooo........oo << 
 63                                                << 
 64 // Destructor                                      68 // Destructor
 65 G4DopplerProfile::~G4DopplerProfile()              69 G4DopplerProfile::~G4DopplerProfile()
 66 {                                                  70 {
 67   for (auto& pos : profileMap)                 <<  71   std::map<G4int,G4VEMDataSet*,std::less<G4int> >::iterator pos;
                                                   >>  72   for (pos = profileMap.begin(); pos != profileMap.end(); ++pos)
 68     {                                              73     {
 69       G4VEMDataSet* dataSet = pos.second;      <<  74       G4VEMDataSet* dataSet = (*pos).second;
 70       delete dataSet;                              75       delete dataSet;
 71       dataSet = nullptr;                       <<  76       dataSet = 0;
 72     }                                              77     }
 73 }                                                  78 }
 74                                                    79 
 75 //....oooOO0OOooo........oooOO0OOooo........oo << 
 76                                                    80 
 77 size_t G4DopplerProfile::NumberOfProfiles(G4in     81 size_t G4DopplerProfile::NumberOfProfiles(G4int Z) const
 78 {                                                  82 {
 79   G4int n = 0;                                     83   G4int n = 0;
 80   if (Z>= zMin && Z <= zMax) n = nShells[Z-1];     84   if (Z>= zMin && Z <= zMax) n = nShells[Z-1];
 81   return n;                                        85   return n;
 82 }                                                  86 }
 83                                                    87 
 84 //....oooOO0OOooo........oooOO0OOooo........oo << 
 85                                                    88 
 86 const G4VEMDataSet* G4DopplerProfile::Profiles     89 const G4VEMDataSet* G4DopplerProfile::Profiles(G4int Z) const
 87 {                                                  90 {
                                                   >>  91   std::map<G4int,G4VEMDataSet*,std::less<G4int> >::const_iterator pos;
 88   if (Z < zMin || Z > zMax)                        92   if (Z < zMin || Z > zMax) 
 89     G4Exception("G4DopplerProfile::Profiles",      93     G4Exception("G4DopplerProfile::Profiles",
 90         "em1005",FatalException,"Z outside bou     94         "em1005",FatalException,"Z outside boundaries");
 91   auto pos = profileMap.find(Z);               <<  95   pos = profileMap.find(Z);
 92   G4VEMDataSet* dataSet = (*pos).second;           96   G4VEMDataSet* dataSet = (*pos).second;
 93   return dataSet;                                  97   return dataSet;
 94 }                                                  98 }
 95                                                    99 
 96 //....oooOO0OOooo........oooOO0OOooo........oo << 
 97                                                   100 
 98 const G4VEMDataSet* G4DopplerProfile::Profile(    101 const G4VEMDataSet* G4DopplerProfile::Profile(G4int Z, G4int shellIndex) const
 99 {                                                 102 {
100   const G4VEMDataSet* profis = Profiles(Z);       103   const G4VEMDataSet* profis = Profiles(Z);
101   const G4VEMDataSet* profi = profis->GetCompo    104   const G4VEMDataSet* profi = profis->GetComponent(shellIndex);
102   return profi;                                   105   return profi;
103 }                                                 106 }
104                                                   107 
105 //....oooOO0OOooo........oooOO0OOooo........oo << 
106                                                   108 
107 void G4DopplerProfile::PrintData() const          109 void G4DopplerProfile::PrintData() const
108 {                                                 110 {
109   for (G4int Z=zMin; Z<zMax; Z++)                 111   for (G4int Z=zMin; Z<zMax; Z++)
110     {                                             112     {
111       const G4VEMDataSet* profis = Profiles(Z)    113       const G4VEMDataSet* profis = Profiles(Z);
112       profis->PrintData();                        114       profis->PrintData();
113     }                                             115     }
114 }                                                 116 }
115                                                   117 
116 //....oooOO0OOooo........oooOO0OOooo........oo << 
117                                                   118 
118 void G4DopplerProfile::LoadBiggsP(const G4Stri    119 void G4DopplerProfile::LoadBiggsP(const G4String& fileName)
119 {                                                 120 {
120   std::ostringstream ost;                         121   std::ostringstream ost;  
121   ost << fileName << ".dat";                      122   ost << fileName << ".dat";
122   G4String name(ost.str());                       123   G4String name(ost.str());
123                                                   124   
124   const char* path = G4FindDataDir("G4LEDATA") << 125   char* path = getenv("G4LEDATA");
125   if (!path)                                      126   if (!path)
126     {                                             127     { 
127       G4Exception("G4DopplerProfile::LoadBiggs    128       G4Exception("G4DopplerProfile::LoadBiggsP",
128         "em0006",FatalException,"G4LEDATA envi    129         "em0006",FatalException,"G4LEDATA environment variable not set");
129       return;                                     130       return;
130     }                                             131     }
131                                                   132   
132   G4String pathString(path);                      133   G4String pathString(path);
133   G4String dirFile = pathString + name;           134   G4String dirFile = pathString + name;
134   std::ifstream file(dirFile);                    135   std::ifstream file(dirFile);
135   std::filebuf* lsdp = file.rdbuf();              136   std::filebuf* lsdp = file.rdbuf();
136                                                   137 
137   if (! (lsdp->is_open()) )                       138   if (! (lsdp->is_open()) )
138     {                                             139     {
139       G4String s1("data file: ");                 140       G4String s1("data file: ");
140       G4String s2(" not found");                  141       G4String s2(" not found");
141       G4String excep = s1 + dirFile + s2;         142       G4String excep = s1 + dirFile + s2;
142       G4Exception("G4DopplerProfile::LoadBiggs    143       G4Exception("G4DopplerProfile::LoadBiggsP",
143         "em0003",FatalException,excep);           144         "em0003",FatalException,excep);
144     }                                             145     }
145                                                   146 
146   G4double p;                                     147   G4double p;
147   while(!file.eof())                              148   while(!file.eof()) 
148     {                                             149     {
149       file >> p;                                  150       file >> p;
150       biggsP.push_back(p);                        151       biggsP.push_back(p);
151     }                                             152     }
152                                                   153 
153   // Make sure that the number of data loaded     154   // Make sure that the number of data loaded corresponds to the number in Biggs' paper
154   if (biggsP.size() != nBiggs)                    155   if (biggsP.size() != nBiggs)
155     G4Exception("G4DopplerProfile::LoadBiggsP"    156     G4Exception("G4DopplerProfile::LoadBiggsP",
156         "em1006",FatalException,"Number of mom    157         "em1006",FatalException,"Number of momenta read in is not 31");
157 }                                                 158 }
158                                                   159 
159 //....oooOO0OOooo........oooOO0OOooo........oo << 
160                                                   160 
161 void G4DopplerProfile::LoadProfile(const G4Str    161 void G4DopplerProfile::LoadProfile(const G4String& fileName,G4int Z)
162 {                                                 162 {
163   std::ostringstream ost;                         163   std::ostringstream ost;
164   ost << fileName << "-" << Z << ".dat";          164   ost << fileName << "-" << Z << ".dat";
165   G4String name(ost.str());                       165   G4String name(ost.str());
166                                                   166   
167   const char* path = G4FindDataDir("G4LEDATA") << 167   char* path = getenv("G4LEDATA");
168   if (!path)                                      168   if (!path)
169     {                                             169     { 
170       G4String excep("G4LEDATA environment var    170       G4String excep("G4LEDATA environment variable not set");
171       G4Exception("G4DopplerProfile::LoadProfi    171       G4Exception("G4DopplerProfile::LoadProfile",
172         "em0006",FatalException,excep);           172         "em0006",FatalException,excep);
173       return;                                     173       return;
174     }                                             174     }
175                                                   175   
176   G4String pathString(path);                      176   G4String pathString(path);
177   G4String dirFile = pathString + name;           177   G4String dirFile = pathString + name;
178   std::ifstream file(dirFile);                    178   std::ifstream file(dirFile);
179   std::filebuf* lsdp = file.rdbuf();              179   std::filebuf* lsdp = file.rdbuf();
180                                                   180 
181   if (! (lsdp->is_open()) )                       181   if (! (lsdp->is_open()) )
182     {                                             182     {
183       G4String s1("data file: ");                 183       G4String s1("data file: ");
184       G4String s2(" not found");                  184       G4String s2(" not found");
185       G4String excep = s1 + dirFile + s2;         185       G4String excep = s1 + dirFile + s2;
186       G4Exception("G4DopplerProfile::LoadProfi    186       G4Exception("G4DopplerProfile::LoadProfile",
187         "em0003",FatalException,excep);           187         "em0003",FatalException,excep);
188     }                                             188     }
189                                                   189 
190   G4double p;                                     190   G4double p;
191   G4int nShell = 0;                               191   G4int nShell = 0;
192                                                   192 
193   // Create CompositeDataSet for the current Z    193   // Create CompositeDataSet for the current Z
194   G4VDataSetAlgorithm* interpolation = new G4L    194   G4VDataSetAlgorithm* interpolation = new G4LogLogInterpolation;
195   G4VEMDataSet* dataSetForZ = new G4CompositeE    195   G4VEMDataSet* dataSetForZ = new G4CompositeEMDataSet(interpolation,1.,1.,1,1);
196                                                   196 
197   while (!file.eof())                             197   while (!file.eof()) 
198     {                                             198     {
199       nShell++;                                   199       nShell++;
200       G4DataVector* profi = new G4DataVector;     200       G4DataVector* profi = new G4DataVector;
201       G4DataVector* biggs = new G4DataVector;     201       G4DataVector* biggs = new G4DataVector;
202                                                   202 
203       // Read in profile data for the current     203       // Read in profile data for the current shell
204       for (size_t i=0; i<nBiggs; i++)             204       for (size_t i=0; i<nBiggs; i++)
205   {                                               205   { 
206     file >> p;                                    206     file >> p;
207     profi->push_back(p);                          207     profi->push_back(p);
208           biggs->push_back(biggsP[i]);            208           biggs->push_back(biggsP[i]);
                                                   >> 209     //    if (i == 16) G4cout << "profile = " << p << G4endl;
209   }                                               210   }
210                                                   211 
211       // Create G4EMDataSet for the current sh    212       // Create G4EMDataSet for the current shell
212       G4VDataSetAlgorithm* algo = interpolatio    213       G4VDataSetAlgorithm* algo = interpolation->Clone();
213       G4VEMDataSet* dataSet = new G4EMDataSet(    214       G4VEMDataSet* dataSet = new G4EMDataSet(Z, biggs, profi, algo, 1., 1., true);
214                                                   215      
215       // Add current shell profile component t    216       // Add current shell profile component to G4CompositeEMDataSet for the current Z
216       dataSetForZ->AddComponent(dataSet);         217       dataSetForZ->AddComponent(dataSet);
217     }                                             218     }
218                                                   219 
219   // Fill in number of shells for the current     220   // Fill in number of shells for the current Z
220   nShells.push_back(nShell);                      221   nShells.push_back(nShell);
221                                                   222  
222   profileMap[Z] = dataSetForZ;                    223   profileMap[Z] = dataSetForZ;
223 }                                                 224 }
224                                                   225 
225 //....oooOO0OOooo........oooOO0OOooo........oo << 
226                                                   226 
227  G4double G4DopplerProfile::RandomSelectMoment    227  G4double G4DopplerProfile::RandomSelectMomentum(G4int Z, G4int shellIndex) const
228 {                                                 228 {
229   G4double value = 0.;                            229   G4double value = 0.;
230   const G4VEMDataSet* profis = Profiles(Z);       230   const G4VEMDataSet* profis = Profiles(Z);
231   value = profis->RandomSelect(shellIndex);       231   value = profis->RandomSelect(shellIndex);
232   return value;                                   232   return value;
233 }                                                 233 }
234                                                   234