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)


  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.4 2010/11/01 18:18:57 vnivanch Exp $
                                                   >>  27 // GEANT4 tag $Name: geant4-09-04 $
                                                   >>  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 );
 82 }                                                  90 }
 83                                                    91 
                                                   >>  92 
 84 // ###########################################     93 // #########################################################################
 85                                                    94 
 86 G4bool G4ExtDEDXTable::IsApplicable(G4int atom <<  95 G4bool G4ExtDEDXTable::BuildPhysicsVector(G4int ionZ, 
 87   G4int atomicNumberElem  // Atomic number of  <<  96                                           const G4String& matName) {
 88 )                                              <<  97 
 89 {                                              <<  98   return IsApplicable( ionZ, matName );
                                                   >>  99 }
                                                   >> 100 
                                                   >> 101 // #########################################################################
                                                   >> 102 
                                                   >> 103 G4bool G4ExtDEDXTable::IsApplicable(
                                                   >> 104          G4int atomicNumberIon,  // Atomic number of ion
                                                   >> 105          G4int atomicNumberElem  // Atomic number of elemental material
                                                   >> 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;                            << 262 
197     }                                          << 263 #ifdef G4VERBOSE
                                                   >> 264         G4cout << "G4IonDEDXTable::AddPhysicsVector() Error: "
                                                   >> 265                << "Vector already exists. Remove first before replacing."
                                                   >> 266                << G4endl;
                                                   >> 267 #endif
                                                   >> 268         return false;
                                                   >> 269      }
198                                                   270 
199     dedxMapElements[key] = physicsVector;      << 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 = 0;
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 || nmbVectors == 0) {
336            << " File content of " << fileName  << 429 #ifdef G4VERBOSE
337            << " Nvectors= " << nmbVectors << G << 430     G4cout << "G4ExtDEDXTable::RetrievePhysicsVector() " 
338     ifilestream.close();                       << 431      << " The file is empty "<< nmbVectors 
                                                   >> 432      << G4endl;
                                                   >> 433 #endif
339     return false;                                 434     return false;
340   }                                            << 435   }  
                                                   >> 436   for(size_t i = 0; i<nmbVectors; ++i) {
341                                                   437 
342   for (G4int i = 0; i < nmbVectors; ++i) {     << 
343     G4String line = "";                           438     G4String line = "";
344     // Loop checking, 07-Aug-2015, Vladimir Iv << 439     while( line.empty() ) {
345     while (line.empty()) {                     << 440 
346       getline(ifilestream, line);              << 441       getline( ifilestream, line );
347       if (ifilestream.fail()) {                << 442       if( ifilestream.fail() ) { 
348         G4cout << "G4ExtDEDXTable::RetrievePhy << 443 #ifdef G4VERBOSE  
349                << " File content of " << fileN << 444   G4cout << "G4ExtDEDXTable::RetrievePhysicsTable() " 
350         ifilestream.close();                   << 445          << " File content of " << fileName << " ill-formated." 
351         return false;                          << 446          << G4endl;
                                                   >> 447 #endif          
                                                   >> 448   ifilestream.close(); 
                                                   >> 449   return false; 
352       }                                           450       }
353                                                   451 
354       std::string::size_type pos = line.find_f << 452       std::string::size_type pos = line.find_first_of("#");
355       if (pos != std::string::npos && pos > 0) << 453       if(pos != std::string::npos && pos > 0) {
356         line = line.substr(0, pos);            << 454   line = line.substr(0, pos);
357       }                                           455       }
358     }                                             456     }
359                                                   457 
360     std::istringstream headerstream(line);     << 458     std::istringstream headerstream( line );     
361                                                   459 
362     std::string::size_type atomicNumberIon;       460     std::string::size_type atomicNumberIon;
363     headerstream >> atomicNumberIon;              461     headerstream >> atomicNumberIon;
364                                                   462 
365     G4String materialName;                        463     G4String materialName;
366     headerstream >> materialName;                 464     headerstream >> materialName;
367                                                   465 
368     if (headerstream.fail() || std::string::np << 466     if( headerstream.fail() || std::string::npos == atomicNumberIon) {
369       G4cout << "G4ExtDEDXTable::RetrievePhysi << 467  
370              << " File content of " << fileNam << 468 #ifdef G4VERBOSE  
371              << " (vector header)." << G4endl; << 469       G4cout << "G4ExtDEDXTable::RetrievePhysicsTable() " 
                                                   >> 470        << " File content of " << fileName << " ill-formated "
                                                   >> 471        << " (vector header)." 
                                                   >> 472        << G4endl;
                                                   >> 473 #endif          
372       ifilestream.close();                        474       ifilestream.close();
373       return false;                               475       return false;
374     }                                          << 476     } 
375                                                   477 
376     std::string::size_type atomicNumberMat;       478     std::string::size_type atomicNumberMat;
377     headerstream >> atomicNumberMat;              479     headerstream >> atomicNumberMat;
378                                                   480 
379     if (headerstream.eof() || std::string::npo << 481     if( headerstream.eof() || std::string::npos == atomicNumberMat) { 
380       atomicNumberMat = 0;                     << 482       atomicNumberMat = 0; 
381     }                                             483     }
382                                                   484 
383     G4int vectorType;                             485     G4int vectorType;
384     ifilestream >> vectorType;                    486     ifilestream >> vectorType;
385                                                << 487       
386     G4PhysicsVector* physicsVector = CreatePhy    488     G4PhysicsVector* physicsVector = CreatePhysicsVector(vectorType);
387                                                   489 
388     if (physicsVector == nullptr) {            << 490     if(physicsVector == 0) {
                                                   >> 491 #ifdef G4VERBOSE  
389       G4cout << "G4ExtDEDXTable::RetrievePhysi    492       G4cout << "G4ExtDEDXTable::RetrievePhysicsTable  "
390              << " illegal physics Vector type  << 493        << " illegal physics Vector type " << vectorType
                                                   >> 494        << " in  " << fileName 
                                                   >> 495        << G4endl;
                                                   >> 496 #endif          
391       ifilestream.close();                        497       ifilestream.close();
392       return false;                               498       return false;
393     }                                             499     }
394                                                   500 
395     if (! physicsVector->Retrieve(ifilestream, << 501     if( !physicsVector -> Retrieve(ifilestream, true) ) {
396       G4cout << "G4ExtDEDXTable::RetrievePhysi << 502   
397              << " File content of " << fileNam << 503 #ifdef G4VERBOSE  
                                                   >> 504       G4cout << "G4ExtDEDXTable::RetrievePhysicsTable() " 
                                                   >> 505        << " File content of " << fileName << " ill-formated." 
                                                   >> 506        << G4endl;
                                                   >> 507 #endif          
398       ifilestream.close();                        508       ifilestream.close();
399       return false;                               509       return false;
400     }                                          << 510     } 
401     physicsVector->FillSecondDerivatives();    << 511 
                                                   >> 512     physicsVector -> SetSpline(true);
402                                                   513 
403     // Retrieved vector is added to material s    514     // Retrieved vector is added to material store
404     if (! AddPhysicsVector(                    << 515     if( !AddPhysicsVector(physicsVector, (G4int)atomicNumberIon, 
405           physicsVector, (G4int)atomicNumberIo << 516         materialName, (G4int)atomicNumberMat) ) {
406     {                                          << 517 
407       delete physicsVector;                       518       delete physicsVector;
408       ifilestream.close();                        519       ifilestream.close();
409       return false;                               520       return false;
410     }                                             521     }
411   }                                               522   }
412                                                   523 
413   ifilestream.close();                            524   ifilestream.close();
414                                                   525 
415   return true;                                    526   return true;
416 }                                                 527 }
417                                                   528 
418 // ###########################################    529 // #########################################################################
419                                                   530 
420 G4PhysicsVector* G4ExtDEDXTable::CreatePhysics << 531 G4PhysicsVector* G4ExtDEDXTable::CreatePhysicsVector(G4int vectorType) {
421 {                                              << 532 
422   G4PhysicsVector* physicsVector = nullptr;    << 533   G4PhysicsVector* physicsVector = 0;
423                                                   534 
424   switch (vectorType) {                           535   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                                                   536 
437     default:                                   << 537   case T_G4PhysicsLinearVector: 
438       break;                                   << 538     physicsVector = new G4PhysicsLinearVector();
                                                   >> 539     break;
                                                   >> 540 
                                                   >> 541   case T_G4PhysicsLogVector: 
                                                   >> 542     physicsVector = new G4PhysicsLogVector();
                                                   >> 543     break;
                                                   >> 544 
                                                   >> 545   case T_G4PhysicsLnVector: 
                                                   >> 546     physicsVector = new G4PhysicsLnVector();
                                                   >> 547     break;
                                                   >> 548 
                                                   >> 549   case T_G4PhysicsFreeVector: 
                                                   >> 550     physicsVector = new G4PhysicsFreeVector();
                                                   >> 551     break;
                                                   >> 552 
                                                   >> 553   case T_G4PhysicsOrderedFreeVector: 
                                                   >> 554     physicsVector = new G4PhysicsOrderedFreeVector();
                                                   >> 555     break;
                                                   >> 556 
                                                   >> 557   case T_G4LPhysicsFreeVector: 
                                                   >> 558     physicsVector = new G4LPhysicsFreeVector();
                                                   >> 559     break;
                                                   >> 560   
                                                   >> 561   default:
                                                   >> 562     break;
439   }                                               563   }
440   return physicsVector;                           564   return physicsVector;
441 }                                                 565 }
442                                                   566 
443 // ###########################################    567 // #########################################################################
444                                                   568 
445 G4int G4ExtDEDXTable::FindAtomicNumberElement( << 569 G4int G4ExtDEDXTable::FindAtomicNumberElement(
446 {                                              << 570                                    G4PhysicsVector* physicsVector
447   G4int atomicNumber = 0;                      << 571                                                    ) {
448                                                   572 
449   auto iter = dedxMapElements.begin();         << 573   G4int atomicNumber = 0;
450   auto iter_end = dedxMapElements.end();       << 
451                                                   574 
452   for (; iter != iter_end; ++iter) {           << 575   G4IonDEDXMapElem::iterator iter = dedxMapElements.begin();
453     if ((*iter).second == physicsVector) {     << 576   G4IonDEDXMapElem::iterator iter_end = dedxMapElements.end();
454       G4IonDEDXKeyElem key = (*iter).first;    << 577   
455       atomicNumber = key.second;               << 578   for(;iter != iter_end; iter++) {
456     }                                          << 579 
                                                   >> 580      if( (*iter).second == physicsVector ) {
                                                   >> 581 
                                                   >> 582         G4IonDEDXKeyElem key = (*iter).first;
                                                   >> 583         atomicNumber = key.second;
                                                   >> 584      }
457   }                                               585   }
458                                                   586 
459   return atomicNumber;                            587   return atomicNumber;
460 }                                                 588 }
461                                                   589 
462 // ###########################################    590 // #########################################################################
463                                                   591 
464 void G4ExtDEDXTable::ClearTable()              << 592 void G4ExtDEDXTable::ClearTable() {
465 {                                              << 593 
466   auto iterMat = dedxMapMaterials.begin();     << 594   G4IonDEDXMapMat::iterator iterMat = dedxMapMaterials.begin();
467   auto iterMat_end = dedxMapMaterials.end();   << 595   G4IonDEDXMapMat::iterator iterMat_end = dedxMapMaterials.end();
                                                   >> 596 
                                                   >> 597   for(;iterMat != iterMat_end; iterMat++) { 
468                                                   598 
469   for (; iterMat != iterMat_end; ++iterMat) {  << 599     G4PhysicsVector* vec = iterMat -> second;
470     G4PhysicsVector* vec = iterMat->second;    << 
471                                                   600 
472     delete vec;                                << 601     if(vec != 0) delete vec;
473   }                                               602   }
474                                                   603 
475   dedxMapElements.clear();                        604   dedxMapElements.clear();
476   dedxMapMaterials.clear();                       605   dedxMapMaterials.clear();
477 }                                                 606 }
478                                                   607 
479 // ###########################################    608 // #########################################################################
480                                                   609 
481 void G4ExtDEDXTable::DumpMap()                 << 610 void G4ExtDEDXTable::DumpMap() {
482 {                                              << 
483   auto iterMat = dedxMapMaterials.begin();     << 
484   auto iterMat_end = dedxMapMaterials.end();   << 
485                                                   611 
486   G4cout << std::setw(15) << std::right << "At << 612   G4IonDEDXMapMat::iterator iterMat = dedxMapMaterials.begin();
487          << "Material name" << std::setw(25) < << 613   G4IonDEDXMapMat::iterator iterMat_end = dedxMapMaterials.end();
488                                                   614 
489   for (; iterMat != iterMat_end; ++iterMat) {  << 615   G4cout << std::setw(15) << std::right
490     G4IonDEDXKeyMat key = iterMat->first;      << 616          << "Atomic nmb ion"
491     G4PhysicsVector* physicsVector = iterMat-> << 617          << std::setw(25) << std::right
                                                   >> 618          << "Material name"
                                                   >> 619          << std::setw(25) << std::right
                                                   >> 620          << "Atomic nmb material"
                                                   >> 621          << G4endl;
                                                   >> 622 
                                                   >> 623   for(;iterMat != iterMat_end; iterMat++) {
                                                   >> 624       G4IonDEDXKeyMat key = iterMat -> first;
                                                   >> 625       G4PhysicsVector* physicsVector = iterMat -> second; 
                                                   >> 626 
                                                   >> 627       G4int atomicNumberIon = key.first;
                                                   >> 628       G4String matIdentifier = key.second;
492                                                   629 
493     G4int atomicNumberIon = key.first;         << 630       G4int atomicNumberElem = FindAtomicNumberElement(physicsVector);
494     G4String matIdentifier = key.second;       << 
495                                                   631 
496     G4int atomicNumberElem = FindAtomicNumberE << 632       if(physicsVector != 0) {
                                                   >> 633          G4cout << std::setw(15) << std::right
                                                   >> 634                 << atomicNumberIon
                                                   >> 635                 << std::setw(25) << std::right
                                                   >> 636                 << matIdentifier
                                                   >> 637                 << std::setw(25) << std::right;
497                                                   638 
498     if (physicsVector != nullptr) {            << 639          if(atomicNumberElem > 0) G4cout << atomicNumberElem;
499       G4cout << std::setw(15) << std::right << << 640          else G4cout << "N/A";
500              << matIdentifier << std::setw(25) << 
501                                                   641 
502       if (atomicNumberElem > 0) {              << 642          G4cout << G4endl;
503         G4cout << atomicNumberElem;            << 
504       }                                        << 
505       else {                                   << 
506         G4cout << "N/A";                       << 
507       }                                           643       }
508                                                << 
509       G4cout << G4endl;                        << 
510     }                                          << 
511   }                                               644   }
                                                   >> 645 
512 }                                                 646 }
513                                                   647 
514 // ###########################################    648 // #########################################################################
                                                   >> 649 
515                                                   650