Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/materials/src/G4ExtDEDXTable.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 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 /materials/src/G4ExtDEDXTable.cc (Version 11.3.0) and /materials/src/G4ExtDEDXTable.cc (Version 9.4.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 // $Id: G4ExtDEDXTable.cc,v 1.6 2010-12-24 12:23:39 vnivanch Exp $
                                                   >>  27 // GEANT4 tag $Name: not supported by cvs2svn $
                                                   >>  28 //
 26 // ===========================================     29 // ===========================================================================
 27 // GEANT4 class source file                        30 // GEANT4 class source file
 28 //                                                 31 //
 29 // Class:                G4ExtDEDXTable            32 // Class:                G4ExtDEDXTable
 30 //                                                 33 //
 31 // Base class:           G4VIonDEDXTable       <<  34 // Base class:           G4VIonDEDXTable 
 32 //                                             <<  35 // 
 33 // Author:               Anton Lechner (Anton.     36 // Author:               Anton Lechner (Anton.Lechner@cern.ch)
 34 //                                                 37 //
 35 // First implementation: 29. 02. 2009              38 // First implementation: 29. 02. 2009
 36 //                                                 39 //
 37 // Modifications:                                  40 // Modifications:
 38 // 03.11.2009 A. Lechner:  Added new methods B     41 // 03.11.2009 A. Lechner:  Added new methods BuildPhysicsVector according
 39 //            to interface changes in base cla     42 //            to interface changes in base class G4VIonDEDXTable.
 40 // 25.10.2010 V.Ivanchenko fixed bug in usage  <<  43 // 25.10.2010 V.Ivanchenko fixed bug in usage of iterators reported by the 
 41 //            Coverity tool                        44 //            Coverity tool
 42 // 01.11.2010 V.Ivanchenko fixed remaining bug <<  45 // 01.11.2010 V.Ivanchenko fixed remaining bugs reported by Coverity 
 43 //                                                 46 //
 44 //                                                 47 //
 45 // Class description:                              48 // Class description:
 46 //    Utility class for users to add their own     49 //    Utility class for users to add their own electronic stopping powers
 47 //    for ions. This class is dedicated for us     50 //    for ions. This class is dedicated for use with G4IonParametrisedLossModel
 48 //    of the low-energy electromagnetic packag     51 //    of the low-energy electromagnetic package.
 49 //                                                 52 //
 50 // Comments:                                       53 // Comments:
 51 //                                                 54 //
 52 // =========================================== <<  55 // =========================================================================== 
 53                                                <<  56 //
 54 #include "G4ExtDEDXTable.hh"                   << 
 55                                                    57 
 56 #include "G4PhysicsFreeVector.hh"              <<  58 #include "G4ExtDEDXTable.hh" 
 57 #include "G4PhysicsLinearVector.hh"            << 
 58 #include "G4PhysicsLogVector.hh"               << 
 59 #include "G4PhysicsVector.hh"                      59 #include "G4PhysicsVector.hh"
 60 #include "G4PhysicsVectorType.hh"                  60 #include "G4PhysicsVectorType.hh"
 61                                                <<  61 #include "G4LPhysicsFreeVector.hh"
                                                   >>  62 #include "G4PhysicsLogVector.hh"
                                                   >>  63 #include "G4PhysicsFreeVector.hh"
                                                   >>  64 #include "G4PhysicsOrderedFreeVector.hh"
                                                   >>  65 #include "G4PhysicsLinearVector.hh"
                                                   >>  66 #include "G4PhysicsLnVector.hh"
 62 #include <fstream>                                 67 #include <fstream>
 63 #include <iomanip>                             << 
 64 #include <sstream>                                 68 #include <sstream>
                                                   >>  69 #include <iomanip>
                                                   >>  70 
 65                                                    71 
 66 // ###########################################     72 // #########################################################################
 67                                                    73 
 68 G4ExtDEDXTable::~G4ExtDEDXTable() { ClearTable <<  74 G4ExtDEDXTable::G4ExtDEDXTable() {
                                                   >>  75 
                                                   >>  76 }
 69                                                    77 
 70 // ###########################################     78 // #########################################################################
 71                                                    79 
 72 G4bool G4ExtDEDXTable::BuildPhysicsVector(G4in <<  80 G4ExtDEDXTable::~G4ExtDEDXTable() {
 73 {                                              <<  81 
 74   return IsApplicable(ionZ, matZ);             <<  82   ClearTable();
 75 }                                                  83 }
 76                                                    84 
 77 // ###########################################     85 // #########################################################################
 78                                                    86 
 79 G4bool G4ExtDEDXTable::BuildPhysicsVector(G4in <<  87 G4bool G4ExtDEDXTable::BuildPhysicsVector(G4int ionZ, G4int matZ) {
 80 {                                              <<  88 
 81   return IsApplicable(ionZ, matName);          <<  89   return IsApplicable( ionZ, matZ );
                                                   >>  90 }
                                                   >>  91 
                                                   >>  92 
                                                   >>  93 // #########################################################################
                                                   >>  94 
                                                   >>  95 G4bool G4ExtDEDXTable::BuildPhysicsVector(G4int ionZ, 
                                                   >>  96                                           const G4String& matName) {
                                                   >>  97 
                                                   >>  98   return IsApplicable( ionZ, matName );
 82 }                                                  99 }
 83                                                   100 
 84 // ###########################################    101 // #########################################################################
 85                                                   102 
 86 G4bool G4ExtDEDXTable::IsApplicable(G4int atom << 103 G4bool G4ExtDEDXTable::IsApplicable(
 87   G4int atomicNumberElem  // Atomic number of  << 104          G4int atomicNumberIon,  // Atomic number of ion
 88 )                                              << 105          G4int atomicNumberElem  // Atomic number of elemental material
 89 {                                              << 106             ) {
                                                   >> 107   G4bool isApplicable = true; 
 90   G4IonDEDXKeyElem key = std::make_pair(atomic    108   G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
 91                                                   109 
 92   auto iter = dedxMapElements.find(key);       << 110   G4IonDEDXMapElem::iterator iter = dedxMapElements.find(key);
                                                   >> 111 
                                                   >> 112   if(iter == dedxMapElements.end()) isApplicable = false; 
 93                                                   113 
 94   return iter != dedxMapElements.end();        << 114   return isApplicable; 
 95 }                                                 115 }
 96                                                   116 
 97 // ###########################################    117 // #########################################################################
 98                                                   118 
 99 G4bool G4ExtDEDXTable::IsApplicable(G4int atom << 119 G4bool G4ExtDEDXTable::IsApplicable(
100   const G4String& matIdentifier  // Name or ch << 120          G4int atomicNumberIon,         // Atomic number of ion
101 )                                              << 121          const G4String& matIdentifier  // Name or chemical formula of material
102 {                                              << 122             ) {
                                                   >> 123   G4bool isApplicable = true; 
103   G4IonDEDXKeyMat key = std::make_pair(atomicN    124   G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
104                                                   125 
105   auto iter = dedxMapMaterials.find(key);      << 126   G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key);
106                                                   127 
107   return iter != dedxMapMaterials.end();       << 128   if(iter == dedxMapMaterials.end()) isApplicable = false; 
                                                   >> 129 
                                                   >> 130   return isApplicable; 
108 }                                                 131 }
109                                                   132 
110 // ###########################################    133 // #########################################################################
111                                                   134 
112 G4PhysicsVector* G4ExtDEDXTable::GetPhysicsVec << 135 G4PhysicsVector* G4ExtDEDXTable::GetPhysicsVector(
113   G4int atomicNumberElem  // Atomic number of  << 136          G4int atomicNumberIon,        // Atomic number of ion
114 )                                              << 137          G4int atomicNumberElem        // Atomic number of elemental material
115 {                                              << 138             ) {
                                                   >> 139 
                                                   >> 140   G4PhysicsVector* physVector = 0;
                                                   >> 141 
116   G4IonDEDXKeyElem key = std::make_pair(atomic    142   G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
117                                                   143 
118   auto iter = dedxMapElements.find(key);       << 144   G4IonDEDXMapElem::iterator iter = dedxMapElements.find(key);
                                                   >> 145 
                                                   >> 146   if(iter != dedxMapElements.end()) physVector = iter -> second; 
119                                                   147 
120   return (iter != dedxMapElements.end()) ? ite << 148   return physVector; 
121 }                                                 149 }
122                                                   150 
123 // ###########################################    151 // #########################################################################
124                                                   152 
125 G4PhysicsVector* G4ExtDEDXTable::GetPhysicsVec << 153 G4PhysicsVector*  G4ExtDEDXTable::GetPhysicsVector(
126   const G4String& matIdentifier  // Name or ch << 154          G4int atomicNumberIon,        // Atomic number of ion
127 )                                              << 155          const G4String& matIdentifier // Name or chemical formula of material
128 {                                              << 156             ) {
                                                   >> 157 
                                                   >> 158   G4PhysicsVector* physVector = 0;
                                                   >> 159 
129   G4IonDEDXKeyMat key = std::make_pair(atomicN    160   G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
130                                                   161 
131   auto iter = dedxMapMaterials.find(key);      << 162   G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key);
                                                   >> 163 
                                                   >> 164   if(iter != dedxMapMaterials.end()) physVector = iter -> second; 
132                                                   165 
133   return (iter != dedxMapMaterials.end()) ? it << 166   return physVector; 
134 }                                                 167 }
135                                                   168 
136 // ###########################################    169 // #########################################################################
137                                                   170 
138 G4double G4ExtDEDXTable::GetDEDX(G4double kinE << 171 G4double G4ExtDEDXTable::GetDEDX(
139   G4int atomicNumberIon,  // Atomic number of  << 172          G4double kinEnergyPerNucleon, // Kinetic energy per nucleon
140   G4int atomicNumberElem  // Atomic number of  << 173          G4int atomicNumberIon,        // Atomic number of ion
141 )                                              << 174          G4int atomicNumberElem        // Atomic number of elemental material
142 {                                              << 175           ) {
                                                   >> 176   G4double dedx = 0;
                                                   >> 177 
143   G4IonDEDXKeyElem key = std::make_pair(atomic    178   G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
144                                                   179 
145   auto iter = dedxMapElements.find(key);       << 180   G4IonDEDXMapElem::iterator iter = dedxMapElements.find(key);
                                                   >> 181 
                                                   >> 182   if( iter != dedxMapElements.end() ) {
                                                   >> 183      G4PhysicsVector* physicsVector = iter -> second; 
                                                   >> 184 
                                                   >> 185      G4bool b;
                                                   >> 186      dedx = physicsVector -> GetValue( kinEnergyPerNucleon, b );   
                                                   >> 187   }
146                                                   188 
147   return (iter != dedxMapElements.end()) ? (it << 189   return dedx; 
148 }                                                 190 }
149                                                   191 
150 // ###########################################    192 // #########################################################################
151                                                   193 
152 G4double G4ExtDEDXTable::GetDEDX(G4double kinE << 194 G4double G4ExtDEDXTable::GetDEDX(
153   G4int atomicNumberIon,  // Atomic number of  << 195          G4double kinEnergyPerNucleon, // Kinetic energy per nucleon
154   const G4String& matIdentifier  // Name or ch << 196          G4int atomicNumberIon,        // Atomic number of ion
155 )                                              << 197          const G4String& matIdentifier // Name or chemical formula of material
156 {                                              << 198           ) {
                                                   >> 199   G4double dedx = 0;
                                                   >> 200 
157   G4IonDEDXKeyMat key = std::make_pair(atomicN    201   G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
158                                                   202 
159   auto iter = dedxMapMaterials.find(key);      << 203   G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key);
                                                   >> 204 
                                                   >> 205   if(iter != dedxMapMaterials.end()) {
                                                   >> 206      G4PhysicsVector* physicsVector = iter -> second; 
                                                   >> 207 
                                                   >> 208      G4bool b;
                                                   >> 209      dedx = physicsVector -> GetValue( kinEnergyPerNucleon, b );   
                                                   >> 210   }
160                                                   211 
161   return (iter != dedxMapMaterials.end()) ? (i << 212   return dedx; 
162 }                                                 213 }
163                                                   214 
164 // ###########################################    215 // #########################################################################
165                                                   216 
166 G4bool G4ExtDEDXTable::AddPhysicsVector(G4Phys << 217 G4bool G4ExtDEDXTable::AddPhysicsVector(
167   G4int atomicNumberIon,  // Atomic number of  << 218         G4PhysicsVector* physicsVector, // Physics vector
168   const G4String& matIdentifier,  // Name of e << 219   G4int atomicNumberIon,          // Atomic number of ion
169   G4int atomicNumberElem  // Atomic number of  << 220         const G4String& matIdentifier,  // Name of elemental material
170 )                                              << 221         G4int atomicNumberElem          // Atomic number of elemental material
171 {                                              << 222               ) {
172   if (physicsVector == nullptr) {              << 223 
173     G4Exception("G4ExtDEDXTable::AddPhysicsVec << 224   if(physicsVector == 0) {
174       "Pointer to vector is null-pointer.");   << 225 
175     return false;                              << 226 #ifdef G4VERBOSE
                                                   >> 227      G4cout << "G4IonDEDXTable::AddPhysicsVector() Error: Pointer to vector"
                                                   >> 228             << " is null-pointer."
                                                   >> 229             << G4endl;
                                                   >> 230 #endif
                                                   >> 231 
                                                   >> 232      return false;
176   }                                               233   }
177                                                   234 
178   if (matIdentifier.empty()) {                 << 235   if(matIdentifier.empty()) {
179     G4Exception("G4ExtDEDXTable::AddPhysicsVec << 236 
180       "Invalid name of the material.");        << 237 #ifdef G4VERBOSE
181     return false;                              << 238      G4cout << "G4IonDEDXTable::AddPhysicsVector() Error: "
                                                   >> 239             << "Cannot add physics vector. Invalid name."
                                                   >> 240             << G4endl;
                                                   >> 241 #endif
                                                   >> 242 
                                                   >> 243      return false;
182   }                                               244   }
183                                                   245 
184   if (atomicNumberIon <= 2) {                  << 246   if(atomicNumberIon <= 2) {
185     G4Exception("G4ExtDEDXTable::AddPhysicsVec << 247 
186       "Illegal atomic number.");               << 248 #ifdef G4VERBOSE
187     return false;                              << 249      G4cout << "G4IonDEDXTable::AddPhysicsVector() Error: "
                                                   >> 250             << "Cannot add physics vector. Illegal atomic number."
                                                   >> 251             << G4endl;
                                                   >> 252 #endif
                                                   >> 253 
                                                   >> 254      return false;
188   }                                               255   }
189                                                   256 
190   if (atomicNumberElem > 0) {                  << 257   if(atomicNumberElem > 0) {
191     G4IonDEDXKeyElem key = std::make_pair(atom << 
192                                                   258 
193     if (dedxMapElements.count(key) == 1) {     << 259      G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
194       G4Exception("G4ExtDEDXTable::AddPhysicsV << 260 
195         "Vector already exist, remove it befor << 261      if(dedxMapElements.count(key) == 1) {
196       return false;                            << 
197     }                                          << 
198                                                   262 
199     dedxMapElements[key] = physicsVector;      << 263 #ifdef G4VERBOSE
                                                   >> 264         G4cout << "G4IonDEDXTable::AddPhysicsVector() Error: "
                                                   >> 265                << "Vector already exists. Remove first before replacing."
                                                   >> 266                << G4endl;
                                                   >> 267 #endif
                                                   >> 268         return false;
                                                   >> 269      }
                                                   >> 270 
                                                   >> 271      dedxMapElements[key] = physicsVector;
200   }                                               272   }
201                                                   273 
202   G4IonDEDXKeyMat mkey = std::make_pair(atomic    274   G4IonDEDXKeyMat mkey = std::make_pair(atomicNumberIon, matIdentifier);
203                                                   275 
204   if (dedxMapMaterials.count(mkey) == 1) {     << 276   if(dedxMapMaterials.count(mkey) == 1) {
205     G4Exception("G4ExtDEDXTable::AddPhysicsVec << 277 
206       "Vector already exist, remove it before  << 278 #ifdef G4VERBOSE
207     return false;                              << 279      G4cout << "G4IonDEDXTable::AddPhysicsVector() Error: "
                                                   >> 280             << "Vector already exists. Remove first before replacing."
                                                   >> 281             << G4endl;
                                                   >> 282 #endif
                                                   >> 283 
                                                   >> 284      return false;
208   }                                               285   }
209                                                   286 
210   dedxMapMaterials[mkey] = physicsVector;         287   dedxMapMaterials[mkey] = physicsVector;
211                                                   288 
212   return true;                                    289   return true;
213 }                                                 290 }
214                                                   291 
215 // ###########################################    292 // #########################################################################
216                                                   293 
217 G4bool G4ExtDEDXTable::RemovePhysicsVector(G4i << 294 G4bool G4ExtDEDXTable::RemovePhysicsVector(
218   const G4String& matIdentifier  // Name or ch << 295   G4int atomicNumberIon,         // Atomic number of ion
219 )                                              << 296         const G4String& matIdentifier  // Name or chemical formula of material
220 {                                              << 297               ) {
221   G4PhysicsVector* physicsVector = nullptr;    << 298 
                                                   >> 299   G4PhysicsVector* physicsVector = 0;
222                                                   300 
223   // Deleting key of physics vector from mater    301   // Deleting key of physics vector from material map
224   G4IonDEDXKeyMat key = std::make_pair(atomicN    302   G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
225                                                   303 
226   auto iter = dedxMapMaterials.find(key);      << 304   G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key);
                                                   >> 305 
                                                   >> 306   if(iter == dedxMapMaterials.end()) {
                                                   >> 307 
                                                   >> 308 #ifdef G4VERBOSE
                                                   >> 309     G4cout << "G4IonDEDXTable::RemovePhysicsVector() Warning: "
                                                   >> 310      << "Cannot remove physics vector. Vector not found."
                                                   >> 311      << G4endl;
                                                   >> 312 #endif
227                                                   313 
228   if (iter == dedxMapMaterials.end()) {        << 
229     G4Exception("G4ExtDEDXTable::RemovePhysics << 
230       "Pointer to vector is null-pointer.");   << 
231     return false;                                 314     return false;
232   }                                               315   }
233                                                   316 
234   physicsVector = (*iter).second;                 317   physicsVector = (*iter).second;
235   dedxMapMaterials.erase(key);                    318   dedxMapMaterials.erase(key);
236                                                   319 
237   // Deleting key of physics vector from eleme    320   // Deleting key of physics vector from elemental material map (if it exists)
238   G4IonDEDXMapElem::iterator it;                  321   G4IonDEDXMapElem::iterator it;
                                                   >> 322   
                                                   >> 323   for(it=dedxMapElements.begin(); it!=dedxMapElements.end(); ++it) {
239                                                   324 
240   for (it = dedxMapElements.begin(); it != ded << 325      if( (*it).second == physicsVector ) {
241     if ((*it).second == physicsVector) {       << 326         dedxMapElements.erase(it);
242       dedxMapElements.erase(it);               << 327         break;
243       break;                                   << 328      }
244     }                                          << 
245   }                                               329   }
246                                                   330 
247   // Deleting physics vector                      331   // Deleting physics vector
248   delete physicsVector;                           332   delete physicsVector;
249                                                   333 
250   return true;                                    334   return true;
251 }                                                 335 }
252                                                   336 
253 // ###########################################    337 // #########################################################################
254                                                   338 
255 G4bool G4ExtDEDXTable::StorePhysicsTable(const << 339 G4bool G4ExtDEDXTable::StorePhysicsTable(
256 )                                              << 340          const G4String& fileName // File name
257 {                                              << 341             ) {
258   G4bool success = true;                          342   G4bool success = true;
259                                                   343 
260   std::ofstream ofilestream;                      344   std::ofstream ofilestream;
261                                                   345 
262   ofilestream.open(fileName, std::ios::out);   << 346   ofilestream.open( fileName, std::ios::out );
263                                                   347 
264   if (! ofilestream) {                         << 348   if( !ofilestream ) {
265     G4ExceptionDescription ed;                 << 349 
266     ed << "Cannot open file " << fileName;     << 350 #ifdef G4VERBOSE
267     G4Exception("G4IonStoppingData::StorePhysi << 351      G4cout << "G4ExtDEDXTable::StorePhysicsVector() " 
268     success = false;                           << 352             << " Cannot open file "<< fileName 
269   }                                            << 353             << G4endl;
                                                   >> 354 #endif
                                                   >> 355       
                                                   >> 356      success = false;
                                                   >> 357   }   
270   else {                                          358   else {
271     size_t nmbMatTables = dedxMapMaterials.siz << 
272                                                   359 
273     ofilestream << nmbMatTables << G4endl << G << 360      size_t nmbMatTables = dedxMapMaterials.size();
274                                                   361 
275     auto iterMat = dedxMapMaterials.begin();   << 362      ofilestream << nmbMatTables << G4endl << G4endl; 
276     auto iterMat_end = dedxMapMaterials.end(); << 
277                                                   363 
278     for (; iterMat != iterMat_end; iterMat++)  << 364      G4IonDEDXMapMat::iterator iterMat = dedxMapMaterials.begin();
279       G4IonDEDXKeyMat key = iterMat->first;    << 365      G4IonDEDXMapMat::iterator iterMat_end = dedxMapMaterials.end();
280       G4PhysicsVector* physicsVector = iterMat << 
281                                                   366 
282       G4int atomicNumberIon = key.first;       << 367      for(;iterMat != iterMat_end; iterMat++) {
283       G4String matIdentifier = key.second;     << 368          G4IonDEDXKeyMat key = iterMat -> first;
                                                   >> 369          G4PhysicsVector* physicsVector = iterMat -> second; 
284                                                   370 
285       G4int atomicNumberElem = FindAtomicNumbe << 371          G4int atomicNumberIon = key.first;
                                                   >> 372          G4String matIdentifier = key.second;
286                                                   373 
287       if (physicsVector != nullptr) {          << 374          G4int atomicNumberElem = FindAtomicNumberElement(physicsVector);
288         ofilestream << atomicNumberIon << "  " << 
289                                                   375 
290         if (atomicNumberElem > 0) {            << 376          if(physicsVector != 0) {
291           ofilestream << "  " << atomicNumberE << 377         ofilestream << atomicNumberIon << "  " << matIdentifier;
292         }                                      << 
293                                                   378 
294         ofilestream << "  # <Atomic number ion << 379             if(atomicNumberElem > 0) ofilestream << "  " << atomicNumberElem;
295                                                   380 
296         if (atomicNumberElem > 0) {            << 381             ofilestream << "  # <Atomic number ion>  <Material name>  ";
297           ofilestream << "<Atomic number eleme << 
298         }                                      << 
299                                                   382 
300         ofilestream << G4endl << physicsVector << 383             if(atomicNumberElem > 0) ofilestream << "<Atomic number element>";
301                                                   384 
302         physicsVector->Store(ofilestream, true << 385             ofilestream << G4endl << physicsVector -> GetType() << G4endl;
303                                                   386 
304         ofilestream << G4endl;                 << 387             physicsVector -> Store(ofilestream, true);
305       }                                        << 388 
306       else {                                   << 389             ofilestream << G4endl;
307         G4Exception("G4IonStoppingData::StoreP << 390          }
308           "Cannot store vector.");             << 391          else {
309       }                                        << 392 
310     }                                          << 393 #ifdef G4VERBOSE
                                                   >> 394               G4cout << "G4ExtDEDXTable::StorePhysicsVector() " 
                                                   >> 395                      << " Cannot store physics vector." 
                                                   >> 396                      << G4endl;
                                                   >> 397 #endif
                                                   >> 398 
                                                   >> 399          }
                                                   >> 400      }
311   }                                               401   }
312                                                   402 
313   ofilestream.close();                            403   ofilestream.close();
314                                                   404 
315   return success;                              << 405   return success; 
316 }                                                 406 }
317                                                   407 
318 // ###########################################    408 // #########################################################################
319                                                   409 
320 G4bool G4ExtDEDXTable::RetrievePhysicsTable(co << 410 G4bool G4ExtDEDXTable::RetrievePhysicsTable(
321 {                                              << 411               const G4String& fileName  // File name
                                                   >> 412                      ) { 
                                                   >> 413 
322   std::ifstream ifilestream;                      414   std::ifstream ifilestream;
323   ifilestream.open(fileName, std::ios::in | st << 415   ifilestream.open( fileName, std::ios::in );
324   if (! ifilestream) {                         << 416   if( ! ifilestream ) {
325     G4ExceptionDescription ed;                 << 417 #ifdef G4VERBOSE
326     ed << "Cannot open file " << fileName;     << 418     G4cout << "G4ExtDEDXTable::RetrievePhysicsVector() " 
327     G4Exception("G4IonStoppingData::RetrievePh << 419      << " Cannot open file "<< fileName 
                                                   >> 420      << G4endl;
                                                   >> 421 #endif
328     return false;                                 422     return false;
329   }                                            << 423   }   
330                                                   424 
331   // std::string::size_type nmbVectors;        << 425   std::string::size_type nmbVectors;
332   G4int nmbVectors = 0;                        << 
333   ifilestream >> nmbVectors;                      426   ifilestream >> nmbVectors;
334   if (ifilestream.fail() || nmbVectors <= 0) { << 427 
335     G4cout << "G4ExtDEDXTable::RetrievePhysics << 428   if(nmbVectors == std::string::npos) {
336            << " File content of " << fileName  << 429 #ifdef G4VERBOSE
337            << " Nvectors= " << nmbVectors << G << 430     G4cout << "G4ExtDEDXTable::RetrievePhysicsVector() " 
338     ifilestream.close();                       << 431      << " The file is corrupted " << G4endl;
                                                   >> 432 #endif
339     return false;                                 433     return false;
340   }                                            << 434   }  
                                                   >> 435   G4int nm = G4int(nmbVectors);
                                                   >> 436   if(0 >= nm) {
                                                   >> 437 #ifdef G4VERBOSE
                                                   >> 438     G4cout << "G4ExtDEDXTable::RetrievePhysicsVector() " 
                                                   >> 439      << " The file is empty "<< nm << G4endl;
                                                   >> 440 #endif
                                                   >> 441     return false;
                                                   >> 442   }  
                                                   >> 443   for(G4int i = 0; i<nm; ++i) {
341                                                   444 
342   for (G4int i = 0; i < nmbVectors; ++i) {     << 
343     G4String line = "";                           445     G4String line = "";
344     // Loop checking, 07-Aug-2015, Vladimir Iv << 446     while( line.empty() ) {
345     while (line.empty()) {                     << 447 
346       getline(ifilestream, line);              << 448       getline( ifilestream, line );
347       if (ifilestream.fail()) {                << 449       if( ifilestream.fail() ) { 
348         G4cout << "G4ExtDEDXTable::RetrievePhy << 450 #ifdef G4VERBOSE  
349                << " File content of " << fileN << 451   G4cout << "G4ExtDEDXTable::RetrievePhysicsTable() " 
350         ifilestream.close();                   << 452          << " File content of " << fileName << " ill-formated." 
351         return false;                          << 453          << G4endl;
                                                   >> 454 #endif          
                                                   >> 455   ifilestream.close(); 
                                                   >> 456   return false; 
352       }                                           457       }
353                                                   458 
354       std::string::size_type pos = line.find_f << 459       std::string::size_type pos = line.find_first_of("#");
355       if (pos != std::string::npos && pos > 0) << 460       if(pos != std::string::npos && pos > 0) {
356         line = line.substr(0, pos);            << 461   line = line.substr(0, pos);
357       }                                           462       }
358     }                                             463     }
359                                                   464 
360     std::istringstream headerstream(line);     << 465     std::istringstream headerstream( line );     
361                                                   466 
362     std::string::size_type atomicNumberIon;       467     std::string::size_type atomicNumberIon;
363     headerstream >> atomicNumberIon;              468     headerstream >> atomicNumberIon;
364                                                   469 
365     G4String materialName;                        470     G4String materialName;
366     headerstream >> materialName;                 471     headerstream >> materialName;
367                                                   472 
368     if (headerstream.fail() || std::string::np << 473     if( headerstream.fail() || std::string::npos == atomicNumberIon) {
369       G4cout << "G4ExtDEDXTable::RetrievePhysi << 474  
370              << " File content of " << fileNam << 475 #ifdef G4VERBOSE  
371              << " (vector header)." << G4endl; << 476       G4cout << "G4ExtDEDXTable::RetrievePhysicsTable() " 
                                                   >> 477        << " File content of " << fileName << " ill-formated "
                                                   >> 478        << " (vector header)." 
                                                   >> 479        << G4endl;
                                                   >> 480 #endif          
372       ifilestream.close();                        481       ifilestream.close();
373       return false;                               482       return false;
374     }                                          << 483     } 
375                                                   484 
376     std::string::size_type atomicNumberMat;       485     std::string::size_type atomicNumberMat;
377     headerstream >> atomicNumberMat;              486     headerstream >> atomicNumberMat;
378                                                   487 
379     if (headerstream.eof() || std::string::npo << 488     if( headerstream.eof() || std::string::npos == atomicNumberMat) { 
380       atomicNumberMat = 0;                     << 489       atomicNumberMat = 0; 
381     }                                             490     }
382                                                   491 
383     G4int vectorType;                             492     G4int vectorType;
384     ifilestream >> vectorType;                    493     ifilestream >> vectorType;
385                                                << 494       
386     G4PhysicsVector* physicsVector = CreatePhy    495     G4PhysicsVector* physicsVector = CreatePhysicsVector(vectorType);
387                                                   496 
388     if (physicsVector == nullptr) {            << 497     if(physicsVector == 0) {
                                                   >> 498 #ifdef G4VERBOSE  
389       G4cout << "G4ExtDEDXTable::RetrievePhysi    499       G4cout << "G4ExtDEDXTable::RetrievePhysicsTable  "
390              << " illegal physics Vector type  << 500        << " illegal physics Vector type " << vectorType
                                                   >> 501        << " in  " << fileName 
                                                   >> 502        << G4endl;
                                                   >> 503 #endif          
391       ifilestream.close();                        504       ifilestream.close();
392       return false;                               505       return false;
393     }                                             506     }
394                                                   507 
395     if (! physicsVector->Retrieve(ifilestream, << 508     if( !physicsVector -> Retrieve(ifilestream, true) ) {
396       G4cout << "G4ExtDEDXTable::RetrievePhysi << 509   
397              << " File content of " << fileNam << 510 #ifdef G4VERBOSE  
                                                   >> 511       G4cout << "G4ExtDEDXTable::RetrievePhysicsTable() " 
                                                   >> 512        << " File content of " << fileName << " ill-formated." 
                                                   >> 513        << G4endl;
                                                   >> 514 #endif          
398       ifilestream.close();                        515       ifilestream.close();
399       return false;                               516       return false;
400     }                                          << 517     } 
401     physicsVector->FillSecondDerivatives();    << 518 
                                                   >> 519     physicsVector -> SetSpline(true);
402                                                   520 
403     // Retrieved vector is added to material s    521     // Retrieved vector is added to material store
404     if (! AddPhysicsVector(                    << 522     if( !AddPhysicsVector(physicsVector, (G4int)atomicNumberIon, 
405           physicsVector, (G4int)atomicNumberIo << 523         materialName, (G4int)atomicNumberMat) ) {
406     {                                          << 524 
407       delete physicsVector;                       525       delete physicsVector;
408       ifilestream.close();                        526       ifilestream.close();
409       return false;                               527       return false;
410     }                                             528     }
411   }                                               529   }
412                                                   530 
413   ifilestream.close();                            531   ifilestream.close();
414                                                   532 
415   return true;                                    533   return true;
416 }                                                 534 }
417                                                   535 
418 // ###########################################    536 // #########################################################################
419                                                   537 
420 G4PhysicsVector* G4ExtDEDXTable::CreatePhysics << 538 G4PhysicsVector* G4ExtDEDXTable::CreatePhysicsVector(G4int vectorType) {
421 {                                              << 539 
422   G4PhysicsVector* physicsVector = nullptr;    << 540   G4PhysicsVector* physicsVector = 0;
423                                                   541 
424   switch (vectorType) {                           542   switch (vectorType) {
425     case T_G4PhysicsLinearVector:              << 
426       physicsVector = new G4PhysicsLinearVecto << 
427       break;                                   << 
428                                                << 
429     case T_G4PhysicsLogVector:                 << 
430       physicsVector = new G4PhysicsLogVector(t << 
431       break;                                   << 
432                                                << 
433     case T_G4PhysicsFreeVector:                << 
434       physicsVector = new G4PhysicsFreeVector( << 
435       break;                                   << 
436                                                   543 
437     default:                                   << 544   case T_G4PhysicsLinearVector: 
438       break;                                   << 545     physicsVector = new G4PhysicsLinearVector();
                                                   >> 546     break;
                                                   >> 547 
                                                   >> 548   case T_G4PhysicsLogVector: 
                                                   >> 549     physicsVector = new G4PhysicsLogVector();
                                                   >> 550     break;
                                                   >> 551 
                                                   >> 552   case T_G4PhysicsLnVector: 
                                                   >> 553     physicsVector = new G4PhysicsLnVector();
                                                   >> 554     break;
                                                   >> 555 
                                                   >> 556   case T_G4PhysicsFreeVector: 
                                                   >> 557     physicsVector = new G4PhysicsFreeVector();
                                                   >> 558     break;
                                                   >> 559 
                                                   >> 560   case T_G4PhysicsOrderedFreeVector: 
                                                   >> 561     physicsVector = new G4PhysicsOrderedFreeVector();
                                                   >> 562     break;
                                                   >> 563 
                                                   >> 564   case T_G4LPhysicsFreeVector: 
                                                   >> 565     physicsVector = new G4LPhysicsFreeVector();
                                                   >> 566     break;
                                                   >> 567   
                                                   >> 568   default:
                                                   >> 569     break;
439   }                                               570   }
440   return physicsVector;                           571   return physicsVector;
441 }                                                 572 }
442                                                   573 
443 // ###########################################    574 // #########################################################################
444                                                   575 
445 G4int G4ExtDEDXTable::FindAtomicNumberElement( << 576 G4int G4ExtDEDXTable::FindAtomicNumberElement(
446 {                                              << 577                                    G4PhysicsVector* physicsVector
447   G4int atomicNumber = 0;                      << 578                                                    ) {
448                                                   579 
449   auto iter = dedxMapElements.begin();         << 580   G4int atomicNumber = 0;
450   auto iter_end = dedxMapElements.end();       << 
451                                                   581 
452   for (; iter != iter_end; ++iter) {           << 582   G4IonDEDXMapElem::iterator iter = dedxMapElements.begin();
453     if ((*iter).second == physicsVector) {     << 583   G4IonDEDXMapElem::iterator iter_end = dedxMapElements.end();
454       G4IonDEDXKeyElem key = (*iter).first;    << 584   
455       atomicNumber = key.second;               << 585   for(;iter != iter_end; iter++) {
456     }                                          << 586 
                                                   >> 587      if( (*iter).second == physicsVector ) {
                                                   >> 588 
                                                   >> 589         G4IonDEDXKeyElem key = (*iter).first;
                                                   >> 590         atomicNumber = key.second;
                                                   >> 591      }
457   }                                               592   }
458                                                   593 
459   return atomicNumber;                            594   return atomicNumber;
460 }                                                 595 }
461                                                   596 
462 // ###########################################    597 // #########################################################################
463                                                   598 
464 void G4ExtDEDXTable::ClearTable()              << 599 void G4ExtDEDXTable::ClearTable() {
465 {                                              << 600 
466   auto iterMat = dedxMapMaterials.begin();     << 601   G4IonDEDXMapMat::iterator iterMat = dedxMapMaterials.begin();
467   auto iterMat_end = dedxMapMaterials.end();   << 602   G4IonDEDXMapMat::iterator iterMat_end = dedxMapMaterials.end();
                                                   >> 603 
                                                   >> 604   for(;iterMat != iterMat_end; iterMat++) { 
468                                                   605 
469   for (; iterMat != iterMat_end; ++iterMat) {  << 606     G4PhysicsVector* vec = iterMat -> second;
470     G4PhysicsVector* vec = iterMat->second;    << 
471                                                   607 
472     delete vec;                                << 608     if(vec != 0) delete vec;
473   }                                               609   }
474                                                   610 
475   dedxMapElements.clear();                        611   dedxMapElements.clear();
476   dedxMapMaterials.clear();                       612   dedxMapMaterials.clear();
477 }                                                 613 }
478                                                   614 
479 // ###########################################    615 // #########################################################################
480                                                   616 
481 void G4ExtDEDXTable::DumpMap()                 << 617 void G4ExtDEDXTable::DumpMap() {
482 {                                              << 
483   auto iterMat = dedxMapMaterials.begin();     << 
484   auto iterMat_end = dedxMapMaterials.end();   << 
485                                                   618 
486   G4cout << std::setw(15) << std::right << "At << 619   G4IonDEDXMapMat::iterator iterMat = dedxMapMaterials.begin();
487          << "Material name" << std::setw(25) < << 620   G4IonDEDXMapMat::iterator iterMat_end = dedxMapMaterials.end();
488                                                   621 
489   for (; iterMat != iterMat_end; ++iterMat) {  << 622   G4cout << std::setw(15) << std::right
490     G4IonDEDXKeyMat key = iterMat->first;      << 623          << "Atomic nmb ion"
491     G4PhysicsVector* physicsVector = iterMat-> << 624          << std::setw(25) << std::right
                                                   >> 625          << "Material name"
                                                   >> 626          << std::setw(25) << std::right
                                                   >> 627          << "Atomic nmb material"
                                                   >> 628          << G4endl;
                                                   >> 629 
                                                   >> 630   for(;iterMat != iterMat_end; iterMat++) {
                                                   >> 631       G4IonDEDXKeyMat key = iterMat -> first;
                                                   >> 632       G4PhysicsVector* physicsVector = iterMat -> second; 
                                                   >> 633 
                                                   >> 634       G4int atomicNumberIon = key.first;
                                                   >> 635       G4String matIdentifier = key.second;
492                                                   636 
493     G4int atomicNumberIon = key.first;         << 637       G4int atomicNumberElem = FindAtomicNumberElement(physicsVector);
494     G4String matIdentifier = key.second;       << 
495                                                   638 
496     G4int atomicNumberElem = FindAtomicNumberE << 639       if(physicsVector != 0) {
                                                   >> 640          G4cout << std::setw(15) << std::right
                                                   >> 641                 << atomicNumberIon
                                                   >> 642                 << std::setw(25) << std::right
                                                   >> 643                 << matIdentifier
                                                   >> 644                 << std::setw(25) << std::right;
497                                                   645 
498     if (physicsVector != nullptr) {            << 646          if(atomicNumberElem > 0) G4cout << atomicNumberElem;
499       G4cout << std::setw(15) << std::right << << 647          else G4cout << "N/A";
500              << matIdentifier << std::setw(25) << 
501                                                   648 
502       if (atomicNumberElem > 0) {              << 649          G4cout << G4endl;
503         G4cout << atomicNumberElem;            << 
504       }                                        << 
505       else {                                   << 
506         G4cout << "N/A";                       << 
507       }                                           650       }
508                                                << 
509       G4cout << G4endl;                        << 
510     }                                          << 
511   }                                               651   }
                                                   >> 652 
512 }                                                 653 }
513                                                   654 
514 // ###########################################    655 // #########################################################################
                                                   >> 656 
515                                                   657