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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 /examples/advanced/eRosita/physics/src/G4RDDopplerProfile.cc (Version 11.3.0) and /examples/advanced/eRosita/physics/src/G4RDDopplerProfile.cc (Version 10.7.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 //                                                 27 //
 28 // Author: Maria Grazia Pia (Maria.Grazia.Pia@     28 // Author: Maria Grazia Pia (Maria.Grazia.Pia@cern.ch)
 29 //                                                 29 //
 30 // History:                                        30 // History:
 31 // -----------                                     31 // -----------
 32 // 31 Jul 2001   MGP        Created                32 // 31 Jul 2001   MGP        Created
 33 //                                                 33 //
 34 // -------------------------------------------     34 // -------------------------------------------------------------------
 35                                                    35 
 36 #include "G4RDDopplerProfile.hh"                   36 #include "G4RDDopplerProfile.hh"
 37 #include "G4DataVector.hh"                         37 #include "G4DataVector.hh"
 38 #include "G4SystemOfUnits.hh"                      38 #include "G4SystemOfUnits.hh"
 39 #include "G4RDVEMDataSet.hh"                       39 #include "G4RDVEMDataSet.hh"
 40 #include "G4RDEMDataSet.hh"                        40 #include "G4RDEMDataSet.hh"
 41 #include "G4RDCompositeEMDataSet.hh"               41 #include "G4RDCompositeEMDataSet.hh"
 42 #include "G4RDVDataSetAlgorithm.hh"                42 #include "G4RDVDataSetAlgorithm.hh"
 43 #include "G4RDLogLogInterpolation.hh"              43 #include "G4RDLogLogInterpolation.hh"
 44                                                    44 
 45 #include <fstream>                                 45 #include <fstream>
 46 #include <sstream>                                 46 #include <sstream>
 47 #include "Randomize.hh"                            47 #include "Randomize.hh"
 48                                                    48 
 49 // The following deprecated header is included     49 // The following deprecated header is included because <functional> seems not to be found on MGP's laptop
 50 //#include "function.h"                            50 //#include "function.h"
 51                                                    51 
 52 // Constructor                                     52 // Constructor
 53                                                    53 
 54 G4RDDopplerProfile::G4RDDopplerProfile(G4int m     54 G4RDDopplerProfile::G4RDDopplerProfile(G4int minZ, G4int maxZ)
 55   : zMin(minZ), zMax(maxZ)                         55   : zMin(minZ), zMax(maxZ)
 56 {                                                  56 {  
 57   nBiggs = 31;                                     57   nBiggs = 31;
 58                                                    58 
 59   LoadBiggsP("/doppler/p-biggs");                  59   LoadBiggsP("/doppler/p-biggs");
 60                                                    60 
 61   for (G4int Z=zMin; Z<zMax+1; Z++)                61   for (G4int Z=zMin; Z<zMax+1; Z++)
 62     {                                              62     {
 63       LoadProfile("/doppler/profile",Z);           63       LoadProfile("/doppler/profile",Z);
 64     }                                              64     }
 65 }                                                  65 }
 66                                                    66 
 67 // Destructor                                      67 // Destructor
 68 G4RDDopplerProfile::~G4RDDopplerProfile()          68 G4RDDopplerProfile::~G4RDDopplerProfile()
 69 {                                                  69 {
 70   std::map<G4int,G4RDVEMDataSet*,std::less<G4i     70   std::map<G4int,G4RDVEMDataSet*,std::less<G4int> >::iterator pos;
 71   for (pos = profileMap.begin(); pos != profil     71   for (pos = profileMap.begin(); pos != profileMap.end(); ++pos)
 72     {                                              72     {
 73       G4RDVEMDataSet* dataSet = (*pos).second;     73       G4RDVEMDataSet* dataSet = (*pos).second;
 74       delete dataSet;                              74       delete dataSet;
 75       dataSet = 0;                                 75       dataSet = 0;
 76     }                                              76     }
 77 }                                                  77 }
 78                                                    78 
 79                                                    79 
 80 size_t G4RDDopplerProfile::NumberOfProfiles(G4     80 size_t G4RDDopplerProfile::NumberOfProfiles(G4int Z) const
 81 {                                                  81 {
 82   G4int n = 0;                                     82   G4int n = 0;
 83   if (Z>= zMin && Z <= zMax) n = nShells[Z-1];     83   if (Z>= zMin && Z <= zMax) n = nShells[Z-1];
 84   return n;                                        84   return n;
 85 }                                                  85 }
 86                                                    86 
 87                                                    87 
 88 const G4RDVEMDataSet* G4RDDopplerProfile::Prof     88 const G4RDVEMDataSet* G4RDDopplerProfile::Profiles(G4int Z) const
 89 {                                                  89 {
 90   std::map<G4int,G4RDVEMDataSet*,std::less<G4i     90   std::map<G4int,G4RDVEMDataSet*,std::less<G4int> >::const_iterator pos;
 91   if (Z < zMin || Z > zMax)                        91   if (Z < zMin || Z > zMax)
 92     G4Exception("G4RDDopplerProfile::Profiles(     92     G4Exception("G4RDDopplerProfile::Profiles()", "OutOfRange",
 93                 FatalException, "Z outside bou     93                 FatalException, "Z outside boundaries!");
 94   pos = profileMap.find(Z);                        94   pos = profileMap.find(Z);
 95   G4RDVEMDataSet* dataSet = (*pos).second;         95   G4RDVEMDataSet* dataSet = (*pos).second;
 96   return dataSet;                                  96   return dataSet;
 97 }                                                  97 }
 98                                                    98 
 99                                                    99 
100 const G4RDVEMDataSet* G4RDDopplerProfile::Prof    100 const G4RDVEMDataSet* G4RDDopplerProfile::Profile(G4int Z, G4int shellIndex) const
101 {                                                 101 {
102   const G4RDVEMDataSet* profis = Profiles(Z);     102   const G4RDVEMDataSet* profis = Profiles(Z);
103   const G4RDVEMDataSet* profi = profis->GetCom    103   const G4RDVEMDataSet* profi = profis->GetComponent(shellIndex);
104   return profi;                                   104   return profi;
105 }                                                 105 }
106                                                   106 
107                                                   107 
108 void G4RDDopplerProfile::PrintData() const        108 void G4RDDopplerProfile::PrintData() const
109 {                                                 109 {
110   for (G4int Z=zMin; Z<zMax; Z++)                 110   for (G4int Z=zMin; Z<zMax; Z++)
111     {                                             111     {
112       const G4RDVEMDataSet* profis = Profiles(    112       const G4RDVEMDataSet* profis = Profiles(Z);
113       profis->PrintData();                        113       profis->PrintData();
114     }                                             114     }
115 }                                                 115 }
116                                                   116 
117                                                   117 
118 void G4RDDopplerProfile::LoadBiggsP(const G4St    118 void G4RDDopplerProfile::LoadBiggsP(const G4String& fileName)
119 {                                                 119 {
120   std::ostringstream ost;                         120   std::ostringstream ost;  
121   ost << fileName << ".dat";                      121   ost << fileName << ".dat";
122   G4String name(ost.str());                       122   G4String name(ost.str());
123                                                   123   
124   const char* path = G4FindDataDir("G4LEDATA") << 124   char* path = std::getenv("G4LEDATA");
125   if (!path)                                      125   if (!path)
126     {                                             126     { 
127       G4String excep("G4LEDATA environment var    127       G4String excep("G4LEDATA environment variable not set!");
128       G4Exception("G4RDDopplerProfile::LoadBig    128       G4Exception("G4RDDopplerProfile::LoadBiggsP()",
129                   "InvalidSetup", FatalExcepti    129                   "InvalidSetup", FatalException, excep);
130     }                                             130     }
131                                                   131   
132   G4String pathString(path);                      132   G4String pathString(path);
133   G4String dirFile = pathString + name;           133   G4String dirFile = pathString + name;
134   std::ifstream file(dirFile);                    134   std::ifstream file(dirFile);
135   std::filebuf* lsdp = file.rdbuf();              135   std::filebuf* lsdp = file.rdbuf();
136                                                   136 
137   if (! (lsdp->is_open()) )                       137   if (! (lsdp->is_open()) )
138     {                                             138     {
139       G4String s1("Data file: ");                 139       G4String s1("Data file: ");
140       G4String s2(" not found");                  140       G4String s2(" not found");
141       G4String excep = s1 + dirFile + s2;         141       G4String excep = s1 + dirFile + s2;
142       G4Exception("G4RDDopplerProfile::LoadBig    142       G4Exception("G4RDDopplerProfile::LoadBiggsP()",
143                   "DataNotFound", FatalExcepti    143                   "DataNotFound", FatalException, excep);
144     }                                             144     }
145                                                   145 
146   G4double p;                                     146   G4double p;
147   while(!file.eof())                              147   while(!file.eof()) 
148     {                                             148     {
149       file >> p;                                  149       file >> p;
150       biggsP.push_back(p);                        150       biggsP.push_back(p);
151     }                                             151     }
152                                                   152 
153   // Make sure that the number of data loaded     153   // Make sure that the number of data loaded corresponds to the number in Biggs' paper
154   if (biggsP.size() != nBiggs)                    154   if (biggsP.size() != nBiggs)
155     G4Exception("G4RDDopplerProfile::LoadBiggs    155     G4Exception("G4RDDopplerProfile::LoadBiggsP()", "InvalidCondition",
156                 FatalException, "Number of mom    156                 FatalException, "Number of momenta read in is not 31!");
157 }                                                 157 }
158                                                   158 
159                                                   159 
160 void G4RDDopplerProfile::LoadProfile(const G4S    160 void G4RDDopplerProfile::LoadProfile(const G4String& fileName,G4int Z)
161 {                                                 161 {
162   std::ostringstream ost;                         162   std::ostringstream ost;
163   ost << fileName << "-" << Z << ".dat";          163   ost << fileName << "-" << Z << ".dat";
164   G4String name(ost.str());                       164   G4String name(ost.str());
165                                                   165   
166   const char* path = G4FindDataDir("G4LEDATA") << 166   char* path = std::getenv("G4LEDATA");
167   if (!path)                                      167   if (!path)
168     {                                             168     { 
169       G4String excep("G4LEDATA environment var    169       G4String excep("G4LEDATA environment variable not set!");
170       G4Exception("G4RDDopplerProfile::LoadPro    170       G4Exception("G4RDDopplerProfile::LoadProfile()",
171                   "InvalidSetup", FatalExcepti    171                   "InvalidSetup", FatalException, excep);
172     }                                             172     }
173                                                   173   
174   G4String pathString(path);                      174   G4String pathString(path);
175   G4String dirFile = pathString + name;           175   G4String dirFile = pathString + name;
176   std::ifstream file(dirFile);                    176   std::ifstream file(dirFile);
177   std::filebuf* lsdp = file.rdbuf();              177   std::filebuf* lsdp = file.rdbuf();
178                                                   178 
179   if (! (lsdp->is_open()) )                       179   if (! (lsdp->is_open()) )
180     {                                             180     {
181       G4String s1("Data file: ");                 181       G4String s1("Data file: ");
182       G4String s2(" not found");                  182       G4String s2(" not found");
183       G4String excep = s1 + dirFile + s2;         183       G4String excep = s1 + dirFile + s2;
184       G4Exception("G4RDDopplerProfile::LoadPro    184       G4Exception("G4RDDopplerProfile::LoadProfile()",
185                   "DataNotFound", FatalExcepti    185                   "DataNotFound", FatalException, excep);
186     }                                             186     }
187                                                   187 
188   G4double p;                                     188   G4double p;
189   G4int nShell = 0;                               189   G4int nShell = 0;
190                                                   190 
191   // Create CompositeDataSet for the current Z    191   // Create CompositeDataSet for the current Z
192   G4RDVDataSetAlgorithm* interpolation = new G    192   G4RDVDataSetAlgorithm* interpolation = new G4RDLogLogInterpolation;
193   G4RDVEMDataSet* dataSetForZ = new G4RDCompos    193   G4RDVEMDataSet* dataSetForZ = new G4RDCompositeEMDataSet(interpolation,1.,1.,1,1);
194                                                   194 
195   while (!file.eof())                             195   while (!file.eof()) 
196     {                                             196     {
197       nShell++;                                   197       nShell++;
198       G4DataVector* profi = new G4DataVector;     198       G4DataVector* profi = new G4DataVector;
199       G4DataVector* biggs = new G4DataVector;     199       G4DataVector* biggs = new G4DataVector;
200                                                   200 
201       // Read in profile data for the current     201       // Read in profile data for the current shell
202       for (size_t i=0; i<nBiggs; i++)             202       for (size_t i=0; i<nBiggs; i++)
203   {                                               203   { 
204     file >> p;                                    204     file >> p;
205     profi->push_back(p);                          205     profi->push_back(p);
206           biggs->push_back(biggsP[i]);            206           biggs->push_back(biggsP[i]);
207     //    if (i == 16) G4cout << "profile = "     207     //    if (i == 16) G4cout << "profile = " << p << G4endl;
208   }                                               208   }
209                                                   209 
210       // Create G4RDEMDataSet for the current     210       // Create G4RDEMDataSet for the current shell
211       G4RDVDataSetAlgorithm* algo = interpolat    211       G4RDVDataSetAlgorithm* algo = interpolation->Clone();
212       G4RDVEMDataSet* dataSet = new G4RDEMData    212       G4RDVEMDataSet* dataSet = new G4RDEMDataSet(Z, biggs, profi, algo, 1., 1., true);
213                                                   213      
214       // Add current shell profile component t    214       // Add current shell profile component to G4RDCompositeEMDataSet for the current Z
215       dataSetForZ->AddComponent(dataSet);         215       dataSetForZ->AddComponent(dataSet);
216     }                                             216     }
217                                                   217 
218   // Fill in number of shells for the current     218   // Fill in number of shells for the current Z
219   nShells.push_back(nShell);                      219   nShells.push_back(nShell);
220                                                   220  
221   profileMap[Z] = dataSetForZ;                    221   profileMap[Z] = dataSetForZ;
222 }                                                 222 }
223                                                   223 
224                                                   224 
225  G4double G4RDDopplerProfile::RandomSelectMome    225  G4double G4RDDopplerProfile::RandomSelectMomentum(G4int Z, G4int shellIndex) const
226 {                                                 226 {
227   G4double value = 0.;                            227   G4double value = 0.;
228   const G4RDVEMDataSet* profis = Profiles(Z);     228   const G4RDVEMDataSet* profis = Profiles(Z);
229   value = profis->RandomSelect(shellIndex);       229   value = profis->RandomSelect(shellIndex);
230   return value;                                   230   return value;
231 }                                                 231 }
232                                                   232