Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // 26 // 27 27 28 // 28 // 29 // Author: Riccardo Capra <capra@ge.infn.it> 29 // Author: Riccardo Capra <capra@ge.infn.it> 30 // Code review by MGP October 2007: removed in 30 // Code review by MGP October 2007: removed inheritance from concrete class 31 // more impro 31 // more improvements needed 32 // 32 // 33 // History: 33 // History: 34 // ----------- 34 // ----------- 35 // 30 Jun 2005 RC Created 35 // 30 Jun 2005 RC Created 36 // 14 Oct 2007 MGP Removed inheritan 36 // 14 Oct 2007 MGP Removed inheritance from concrete class G4ShellEMDataSet 37 // 37 // 38 // 15 Jul 2009 N.A.Karakatsanis 38 // 15 Jul 2009 N.A.Karakatsanis 39 // 39 // 40 // - LoadNonLogData 40 // - LoadNonLogData method was created to load only the non-logarithmic data from G4EMLOW 41 // dataset. It is 41 // dataset. It is essentially performing the data loading operations as in the past. 42 // 42 // 43 // - LoadData method 43 // - LoadData method was revised in order to calculate the logarithmic values of the data 44 // It retrieves th 44 // It retrieves the data values from the G4EMLOW data files but, then, calculates the 45 // respective log 45 // respective log values and loads them to seperate data structures. 46 // 46 // 47 // - SetLogEnergiesD 47 // - SetLogEnergiesData method was cretaed to set logarithmic values to G4 data vectors. 48 // The EM data set 48 // The EM data sets, initialized this way, contain both non-log and log values. 49 // These initializ 49 // These initialized data sets can enhance the computing performance of data interpolation 50 // operations 50 // operations 51 // 51 // 52 // 52 // 53 // ------------------------------------------- 53 // ------------------------------------------------------------------- 54 54 55 55 56 #include "G4DNACrossSectionDataSet.hh" 56 #include "G4DNACrossSectionDataSet.hh" 57 #include "G4VDataSetAlgorithm.hh" 57 #include "G4VDataSetAlgorithm.hh" 58 #include "G4EMDataSet.hh" 58 #include "G4EMDataSet.hh" 59 #include <vector> 59 #include <vector> 60 #include <fstream> 60 #include <fstream> 61 #include <sstream> 61 #include <sstream> 62 62 63 63 64 G4DNACrossSectionDataSet::G4DNACrossSectionDat 64 G4DNACrossSectionDataSet::G4DNACrossSectionDataSet(G4VDataSetAlgorithm* argAlgorithm, 65 G4double argUnitEnergies, 65 G4double argUnitEnergies, 66 G4double argUnitData) 66 G4double argUnitData) 67 : 67 : 68 algorithm(argAlgorithm), unitEnergies(argUn 68 algorithm(argAlgorithm), unitEnergies(argUnitEnergies), unitData(argUnitData) 69 { 69 { 70 z = 0; 70 z = 0; 71 71 72 } 72 } 73 73 74 74 75 G4DNACrossSectionDataSet::~G4DNACrossSectionDa 75 G4DNACrossSectionDataSet::~G4DNACrossSectionDataSet() 76 { 76 { 77 CleanUpComponents(); 77 CleanUpComponents(); 78 78 79 << 79 if (algorithm) 80 delete algorithm; 80 delete algorithm; 81 } 81 } 82 82 83 G4bool G4DNACrossSectionDataSet::LoadData(cons 83 G4bool G4DNACrossSectionDataSet::LoadData(const G4String & argFileName) 84 { 84 { 85 CleanUpComponents(); 85 CleanUpComponents(); 86 86 87 G4String fullFileName(FullFileName(argFileNa 87 G4String fullFileName(FullFileName(argFileName)); 88 std::ifstream in(fullFileName, std::ifstream 88 std::ifstream in(fullFileName, std::ifstream::binary|std::ifstream::in); 89 89 90 if (!in.is_open()) 90 if (!in.is_open()) 91 { 91 { 92 G4String message("Data file \""); 92 G4String message("Data file \""); 93 message+=fullFileName; 93 message+=fullFileName; 94 message+="\" not found"; 94 message+="\" not found"; 95 G4Exception("G4DNACrossSectionDataSet::L 95 G4Exception("G4DNACrossSectionDataSet::LoadData","em0003", 96 FatalException,message); 96 FatalException,message); 97 return false; 97 return false; 98 } 98 } 99 99 100 std::vector<G4DataVector *> columns; 100 std::vector<G4DataVector *> columns; 101 std::vector<G4DataVector *> log_columns; 101 std::vector<G4DataVector *> log_columns; 102 102 103 auto stream(new std::stringstream); << 103 std::stringstream *stream(new std::stringstream); 104 char c; 104 char c; 105 G4bool comment(false); 105 G4bool comment(false); 106 G4bool space(true); 106 G4bool space(true); 107 G4bool first(true); 107 G4bool first(true); 108 108 109 try 109 try 110 { 110 { 111 while (!in.eof()) 111 while (!in.eof()) 112 { 112 { 113 in.get(c); 113 in.get(c); 114 114 115 switch (c) 115 switch (c) 116 { 116 { 117 case '\r': 117 case '\r': 118 case '\n': 118 case '\n': 119 if (!first) 119 if (!first) 120 { 120 { 121 unsigned long i(0); 121 unsigned long i(0); 122 G4double value; 122 G4double value; 123 123 124 while (!stream->eof()) 124 while (!stream->eof()) 125 { 125 { 126 (*stream) >> value; 126 (*stream) >> value; 127 127 128 while (i>=columns.size()) 128 while (i>=columns.size()) 129 { 129 { 130 columns.push_back(new G4DataVector); 130 columns.push_back(new G4DataVector); 131 log_columns.push_back 131 log_columns.push_back(new G4DataVector); 132 } 132 } 133 133 134 columns[i]->push_back(value); 134 columns[i]->push_back(value); 135 135 136 // N. A. Karakatsanis 136 // N. A. Karakatsanis 137 // A condition is applied to check if negative 137 // A condition is applied to check if negative or zero values are present in the dataset. 138 // If yes, then a near-zero value is applied t 138 // If yes, then a near-zero value is applied to allow the computation of the logarithmic value 139 // If a value is zero, this simplification is 139 // If a value is zero, this simplification is acceptable 140 // If a value is negative, then it is not acce 140 // If a value is negative, then it is not acceptable and the data of the particular column of 141 // logarithmic values should not be used by in 141 // logarithmic values should not be used by interpolation methods. 142 // 142 // 143 // Therefore, G4LogLogInterpolation and G4LinL 143 // Therefore, G4LogLogInterpolation and G4LinLogLogInterpolation should not be used if negative values are present. 144 // Instead, G4LinInterpolation is safe in ever 144 // Instead, G4LinInterpolation is safe in every case 145 // SemiLogInterpolation is safe only if the en 145 // SemiLogInterpolation is safe only if the energy columns are non-negative 146 // G4LinLogInterpolation is safe only if the c 146 // G4LinLogInterpolation is safe only if the cross section data columns are non-negative 147 147 148 if (value <=0.) value = 148 if (value <=0.) value = 1e-300; 149 log_columns[i]->push_bac 149 log_columns[i]->push_back(std::log10(value)); 150 150 151 i++; 151 i++; 152 } 152 } 153 153 154 delete stream; 154 delete stream; 155 stream=new std::stringstream; 155 stream=new std::stringstream; 156 } 156 } 157 157 158 first=true; 158 first=true; 159 comment=false; 159 comment=false; 160 space=true; 160 space=true; 161 break; 161 break; 162 162 163 case '#': 163 case '#': 164 comment=true; 164 comment=true; 165 break; 165 break; 166 166 167 case '\t': 167 case '\t': 168 case ' ': 168 case ' ': 169 space = true; 169 space = true; 170 break; 170 break; 171 171 172 default: 172 default: 173 if (comment) { break; } 173 if (comment) { break; } 174 if (space && (!first)) { (*stream) << 174 if (space && (!first)) { (*stream) << ' '; } 175 175 176 first=false; 176 first=false; 177 (*stream) << c; 177 (*stream) << c; 178 space=false; 178 space=false; 179 } 179 } 180 } 180 } 181 } 181 } 182 catch(const std::ios::failure &e) 182 catch(const std::ios::failure &e) 183 { 183 { 184 // some implementations of STL could thr 184 // some implementations of STL could throw a "failture" exception 185 // when read wants read characters after 185 // when read wants read characters after end of file 186 } 186 } 187 187 188 delete stream; 188 delete stream; 189 189 190 std::size_t maxI(columns.size()); 190 std::size_t maxI(columns.size()); 191 191 192 if (maxI<2) 192 if (maxI<2) 193 { 193 { 194 G4String message("Data file \""); 194 G4String message("Data file \""); 195 message+=fullFileName; 195 message+=fullFileName; 196 message+="\" should have at least two co 196 message+="\" should have at least two columns"; 197 G4Exception("G4DNACrossSectionDataSet::L 197 G4Exception("G4DNACrossSectionDataSet::LoadData","em0005", 198 FatalException,message); 198 FatalException,message); 199 return false; 199 return false; 200 } 200 } 201 201 202 std::size_t i(1); 202 std::size_t i(1); 203 while (i<maxI) 203 while (i<maxI) 204 { 204 { 205 std::size_t maxJ(columns[i]->size()); 205 std::size_t maxJ(columns[i]->size()); 206 206 207 if (maxJ!=columns[0]->size()) 207 if (maxJ!=columns[0]->size()) 208 { 208 { 209 G4String message("Data file \""); 209 G4String message("Data file \""); 210 message+=fullFileName; 210 message+=fullFileName; 211 message+="\" has lines with a different nu 211 message+="\" has lines with a different number of columns"; 212 G4Exception("G4DNACrossSectionDataSet::Loa 212 G4Exception("G4DNACrossSectionDataSet::LoadData","em0005", 213 FatalException,message); 213 FatalException,message); 214 return false; 214 return false; 215 } 215 } 216 216 217 std::size_t j(0); 217 std::size_t j(0); 218 218 219 auto argEnergies=new G4DataVector; << 219 G4DataVector *argEnergies=new G4DataVector; 220 auto argData=new G4DataVector; << 220 G4DataVector *argData=new G4DataVector; 221 auto argLogEnergies=new G4DataVector; << 221 G4DataVector *argLogEnergies=new G4DataVector; 222 auto argLogData=new G4DataVector; << 222 G4DataVector *argLogData=new G4DataVector; 223 223 224 while(j<maxJ) 224 while(j<maxJ) 225 { 225 { 226 argEnergies->push_back(columns[0]->operato 226 argEnergies->push_back(columns[0]->operator[] (j)*GetUnitEnergies()); 227 argData->push_back(columns[i]->operator[] 227 argData->push_back(columns[i]->operator[] (j)*GetUnitData()); 228 argLogEnergies->push_back(log_columns[0]-> 228 argLogEnergies->push_back(log_columns[0]->operator[] (j) + std::log10(GetUnitEnergies())); 229 argLogData->push_back(log_columns[i]->oper 229 argLogData->push_back(log_columns[i]->operator[] (j) + std::log10(GetUnitData())); 230 j++; 230 j++; 231 } 231 } 232 232 233 AddComponent(new G4EMDataSet(G4int(i-1), 233 AddComponent(new G4EMDataSet(G4int(i-1), argEnergies, argData, argLogEnergies, argLogData, GetAlgorithm()->Clone(), GetUnitEnergies(), GetUnitData())); 234 234 235 i++; 235 i++; 236 } 236 } 237 237 238 i=maxI; 238 i=maxI; 239 while (i>0) 239 while (i>0) 240 { 240 { 241 i--; 241 i--; 242 delete columns[i]; 242 delete columns[i]; 243 delete log_columns[i]; 243 delete log_columns[i]; 244 } 244 } 245 245 246 return true; 246 return true; 247 } 247 } 248 248 249 249 250 G4bool G4DNACrossSectionDataSet::LoadNonLogDat 250 G4bool G4DNACrossSectionDataSet::LoadNonLogData(const G4String & argFileName) 251 { 251 { 252 CleanUpComponents(); 252 CleanUpComponents(); 253 253 254 G4String fullFileName(FullFileName(argFileNa 254 G4String fullFileName(FullFileName(argFileName)); 255 std::ifstream in(fullFileName, std::ifstream 255 std::ifstream in(fullFileName, std::ifstream::binary|std::ifstream::in); 256 256 257 if (!in.is_open()) 257 if (!in.is_open()) 258 { 258 { 259 G4String message("Data file \""); 259 G4String message("Data file \""); 260 message+=fullFileName; 260 message+=fullFileName; 261 message+="\" not found"; 261 message+="\" not found"; 262 G4Exception("G4DNACrossSectionDataSet::L 262 G4Exception("G4DNACrossSectionDataSet::LoadData","em0003", 263 FatalException,message); 263 FatalException,message); 264 return false; 264 return false; 265 } 265 } 266 266 267 std::vector<G4DataVector *> columns; 267 std::vector<G4DataVector *> columns; 268 268 269 auto stream(new std::stringstream); << 269 std::stringstream *stream(new std::stringstream); 270 char c; 270 char c; 271 G4bool comment(false); 271 G4bool comment(false); 272 G4bool space(true); 272 G4bool space(true); 273 G4bool first(true); 273 G4bool first(true); 274 274 275 try 275 try 276 { 276 { 277 while (!in.eof()) 277 while (!in.eof()) 278 { 278 { 279 in.get(c); 279 in.get(c); 280 280 281 switch (c) 281 switch (c) 282 { 282 { 283 case '\r': 283 case '\r': 284 case '\n': 284 case '\n': 285 if (!first) 285 if (!first) 286 { 286 { 287 unsigned long i(0); 287 unsigned long i(0); 288 G4double value; 288 G4double value; 289 289 290 while (!stream->eof()) 290 while (!stream->eof()) 291 { 291 { 292 (*stream) >> value; 292 (*stream) >> value; 293 293 294 while (i>=columns.size()) 294 while (i>=columns.size()) 295 { 295 { 296 columns.push_back(new G4DataVector); 296 columns.push_back(new G4DataVector); 297 } 297 } 298 298 299 columns[i]->push_back(value); 299 columns[i]->push_back(value); 300 300 301 i++; 301 i++; 302 } 302 } 303 303 304 delete stream; 304 delete stream; 305 stream=new std::stringstream; 305 stream=new std::stringstream; 306 } 306 } 307 307 308 first=true; 308 first=true; 309 comment=false; 309 comment=false; 310 space=true; 310 space=true; 311 break; 311 break; 312 312 313 case '#': 313 case '#': 314 comment=true; 314 comment=true; 315 break; 315 break; 316 316 317 case '\t': 317 case '\t': 318 case ' ': 318 case ' ': 319 space = true; 319 space = true; 320 break; 320 break; 321 321 322 default: 322 default: 323 if (comment) { break; } 323 if (comment) { break; } 324 if (space && (!first)) { (*stream) << 324 if (space && (!first)) { (*stream) << ' '; } 325 325 326 first=false; 326 first=false; 327 (*stream) << c; 327 (*stream) << c; 328 space=false; 328 space=false; 329 } 329 } 330 } 330 } 331 } 331 } 332 catch(const std::ios::failure &e) 332 catch(const std::ios::failure &e) 333 { 333 { 334 // some implementations of STL could thr 334 // some implementations of STL could throw a "failture" exception 335 // when read wants read characters after 335 // when read wants read characters after end of file 336 } 336 } 337 337 338 delete stream; 338 delete stream; 339 339 340 std::size_t maxI(columns.size()); 340 std::size_t maxI(columns.size()); 341 341 342 if (maxI<2) 342 if (maxI<2) 343 { 343 { 344 G4String message("Data file \""); 344 G4String message("Data file \""); 345 message+=fullFileName; 345 message+=fullFileName; 346 message+="\" should have at least two co 346 message+="\" should have at least two columns"; 347 G4Exception("G4DNACrossSectionDataSet::L 347 G4Exception("G4DNACrossSectionDataSet::LoadData","em0005", 348 FatalException,message); 348 FatalException,message); 349 return false; 349 return false; 350 } 350 } 351 351 352 std::size_t i(1); 352 std::size_t i(1); 353 while (i<maxI) 353 while (i<maxI) 354 { 354 { 355 std::size_t maxJ(columns[i]->size()); 355 std::size_t maxJ(columns[i]->size()); 356 356 357 if (maxJ!=columns[0]->size()) 357 if (maxJ!=columns[0]->size()) 358 { 358 { 359 G4String message("Data file \""); 359 G4String message("Data file \""); 360 message+=fullFileName; 360 message+=fullFileName; 361 message+="\" has lines with a different nu 361 message+="\" has lines with a different number of columns."; 362 G4Exception("G4DNACrossSectionDataSe 362 G4Exception("G4DNACrossSectionDataSet::LoadData","em0005", 363 FatalException,message); 363 FatalException,message); 364 return false; 364 return false; 365 } 365 } 366 366 367 std::size_t j(0); 367 std::size_t j(0); 368 368 369 auto argEnergies=new G4DataVector; << 369 G4DataVector *argEnergies=new G4DataVector; 370 auto argData=new G4DataVector; << 370 G4DataVector *argData=new G4DataVector; 371 371 372 while(j<maxJ) 372 while(j<maxJ) 373 { 373 { 374 argEnergies->push_back(columns[0]->operato 374 argEnergies->push_back(columns[0]->operator[] (j)*GetUnitEnergies()); 375 argData->push_back(columns[i]->operator[] 375 argData->push_back(columns[i]->operator[] (j)*GetUnitData()); 376 j++; 376 j++; 377 } 377 } 378 378 379 AddComponent(new G4EMDataSet(G4int(i-1), 379 AddComponent(new G4EMDataSet(G4int(i-1), argEnergies, argData, GetAlgorithm()->Clone(), GetUnitEnergies(), GetUnitData())); 380 380 381 i++; 381 i++; 382 } 382 } 383 383 384 i=maxI; 384 i=maxI; 385 while (i>0) 385 while (i>0) 386 { 386 { 387 i--; 387 i--; 388 delete columns[i]; 388 delete columns[i]; 389 } 389 } 390 390 391 return true; 391 return true; 392 } 392 } 393 393 394 394 395 G4bool G4DNACrossSectionDataSet::SaveData(cons 395 G4bool G4DNACrossSectionDataSet::SaveData(const G4String & argFileName) const 396 { 396 { 397 const std::size_t n(NumberOfComponents()); 397 const std::size_t n(NumberOfComponents()); 398 398 399 if (n==0) 399 if (n==0) 400 { 400 { 401 G4Exception("G4DNACrossSectionDataSet::S 401 G4Exception("G4DNACrossSectionDataSet::SaveData","em0005", 402 FatalException,"Expected 402 FatalException,"Expected at least one component"); 403 403 404 return false; 404 return false; 405 } 405 } 406 406 407 G4String fullFileName(FullFileName(argFileNa 407 G4String fullFileName(FullFileName(argFileName)); 408 std::ofstream out(fullFileName); 408 std::ofstream out(fullFileName); 409 409 410 if (!out.is_open()) 410 if (!out.is_open()) 411 { 411 { 412 G4String message("Cannot open \""); 412 G4String message("Cannot open \""); 413 message+=fullFileName; 413 message+=fullFileName; 414 message+="\""; 414 message+="\""; 415 G4Exception("G4DNACrossSectionDataSet::S 415 G4Exception("G4DNACrossSectionDataSet::SaveData","em0005", 416 FatalException,message); 416 FatalException,message); 417 return false; 417 return false; 418 } 418 } 419 419 420 auto iEnergies(GetComponent(0)->GetEnergies( << 420 G4DataVector::const_iterator iEnergies(GetComponent(0)->GetEnergies(0).begin()); 421 auto iEnergiesEnd(GetComponent(0)->GetEnergi << 421 G4DataVector::const_iterator iEnergiesEnd(GetComponent(0)->GetEnergies(0).end()); 422 auto iData(new G4DataVector::const_iterator << 422 G4DataVector::const_iterator * iData(new G4DataVector::const_iterator[n]); 423 423 424 std::size_t k(n); 424 std::size_t k(n); 425 425 426 while (k>0) 426 while (k>0) 427 { 427 { 428 k--; 428 k--; 429 iData[k]=GetComponent((G4int)k)->GetData 429 iData[k]=GetComponent((G4int)k)->GetData(0).cbegin(); 430 } 430 } 431 431 432 while (iEnergies!=iEnergiesEnd) 432 while (iEnergies!=iEnergiesEnd) 433 { 433 { 434 out.precision(10); 434 out.precision(10); 435 out.width(15); 435 out.width(15); 436 out.setf(std::ofstream::left); 436 out.setf(std::ofstream::left); 437 out << ((*iEnergies)/GetUnitEnergies()); 437 out << ((*iEnergies)/GetUnitEnergies()); 438 438 439 k=0; 439 k=0; 440 440 441 while (k<n) 441 while (k<n) 442 { 442 { 443 out << ' '; 443 out << ' '; 444 out.precision(10); 444 out.precision(10); 445 out.width(15); 445 out.width(15); 446 out.setf(std::ofstream::left); 446 out.setf(std::ofstream::left); 447 out << ((*(iData[k]))/GetUnitData()); 447 out << ((*(iData[k]))/GetUnitData()); 448 448 449 iData[k]++; 449 iData[k]++; 450 k++; 450 k++; 451 } 451 } 452 452 453 out << std::endl; 453 out << std::endl; 454 454 455 iEnergies++; 455 iEnergies++; 456 } 456 } 457 457 458 delete[] iData; 458 delete[] iData; 459 459 460 return true; 460 return true; 461 } 461 } 462 462 463 463 464 G4String G4DNACrossSectionDataSet::FullFileNam 464 G4String G4DNACrossSectionDataSet::FullFileName(const G4String& argFileName) const 465 { 465 { 466 const char* path = G4FindDataDir("G4LEDATA") 466 const char* path = G4FindDataDir("G4LEDATA"); 467 if (path == nullptr) << 467 if (!path) 468 { 468 { 469 G4Exception("G4DNACrossSectionDataSet::F 469 G4Exception("G4DNACrossSectionDataSet::FullFileName","em0006", 470 FatalException,"G4LEDATA 470 FatalException,"G4LEDATA environment variable not set."); 471 471 472 return ""; 472 return ""; 473 } 473 } 474 474 475 std::ostringstream fullFileName; 475 std::ostringstream fullFileName; 476 476 477 fullFileName << path << "/" << argFileName < 477 fullFileName << path << "/" << argFileName << ".dat"; 478 478 479 return G4String(fullFileName.str().c_str()); 479 return G4String(fullFileName.str().c_str()); 480 } 480 } 481 481 482 482 483 G4double G4DNACrossSectionDataSet::FindValue(G 483 G4double G4DNACrossSectionDataSet::FindValue(G4double argEnergy, G4int /* argComponentId */) const 484 { 484 { 485 // Returns the sum over the shells correspon 485 // Returns the sum over the shells corresponding to e 486 G4double value = 0.; 486 G4double value = 0.; 487 487 488 auto i(components.begin()); << 488 std::vector<G4VEMDataSet *>::const_iterator i(components.begin()); 489 auto end(components.end()); << 489 std::vector<G4VEMDataSet *>::const_iterator end(components.end()); 490 490 491 while (i!=end) 491 while (i!=end) 492 { 492 { 493 value+=(*i)->FindValue(argEnergy); 493 value+=(*i)->FindValue(argEnergy); 494 i++; 494 i++; 495 } 495 } 496 496 497 return value; 497 return value; 498 } 498 } 499 499 500 500 501 void G4DNACrossSectionDataSet::PrintData() con << 501 void G4DNACrossSectionDataSet::PrintData(void) const 502 { 502 { 503 const auto n = (G4int)NumberOfComponents(); << 503 const G4int n = (G4int)NumberOfComponents(); 504 504 505 G4cout << "The data set has " << n << " comp 505 G4cout << "The data set has " << n << " components" << G4endl; 506 G4cout << G4endl; 506 G4cout << G4endl; 507 507 508 G4int i(0); 508 G4int i(0); 509 509 510 while (i<n) 510 while (i<n) 511 { 511 { 512 G4cout << "--- Component " << i << " --- 512 G4cout << "--- Component " << i << " ---" << G4endl; 513 GetComponent(i)->PrintData(); 513 GetComponent(i)->PrintData(); 514 ++i; 514 ++i; 515 } 515 } 516 } 516 } 517 517 518 518 519 void G4DNACrossSectionDataSet::SetEnergiesData 519 void G4DNACrossSectionDataSet::SetEnergiesData(G4DataVector* argEnergies, 520 G4DataVector* argData, 520 G4DataVector* argData, 521 G4int argComponentId) 521 G4int argComponentId) 522 { 522 { 523 G4VEMDataSet * component(components[argCompo 523 G4VEMDataSet * component(components[argComponentId]); 524 524 525 if (component != nullptr) << 525 if (component) 526 { 526 { 527 component->SetEnergiesData(argEnergies, 527 component->SetEnergiesData(argEnergies, argData, 0); 528 return; 528 return; 529 } 529 } 530 530 531 std::ostringstream message; 531 std::ostringstream message; 532 message << "Component " << argComponentId << 532 message << "Component " << argComponentId << " not found"; 533 533 534 G4Exception("G4DNACrossSectionDataSet::SetEn 534 G4Exception("G4DNACrossSectionDataSet::SetEnergiesData","em0005", 535 FatalException,message.str(). 535 FatalException,message.str().c_str()); 536 536 537 } 537 } 538 538 539 539 540 void G4DNACrossSectionDataSet::SetLogEnergiesD 540 void G4DNACrossSectionDataSet::SetLogEnergiesData(G4DataVector* argEnergies, 541 G4DataVector* argData, 541 G4DataVector* argData, 542 G4Dat 542 G4DataVector* argLogEnergies, 543 G4Dat 543 G4DataVector* argLogData, 544 G4int argComponentId) 544 G4int argComponentId) 545 { 545 { 546 G4VEMDataSet * component(components[argCompo 546 G4VEMDataSet * component(components[argComponentId]); 547 547 548 if (component != nullptr) << 548 if (component) 549 { 549 { 550 component->SetLogEnergiesData(argEnergie 550 component->SetLogEnergiesData(argEnergies, argData, argLogEnergies, argLogData, 0); 551 return; 551 return; 552 } 552 } 553 553 554 std::ostringstream message; 554 std::ostringstream message; 555 message << "Component " << argComponentId << 555 message << "Component " << argComponentId << " not found"; 556 556 557 G4Exception("G4DNACrossSectionDataSet::SetLo 557 G4Exception("G4DNACrossSectionDataSet::SetLogEnergiesData","em0005", 558 FatalException,message.str(). 558 FatalException,message.str().c_str()); 559 559 560 } 560 } 561 561 562 562 563 void G4DNACrossSectionDataSet::CleanUpComponen 563 void G4DNACrossSectionDataSet::CleanUpComponents() 564 { 564 { 565 while (!components.empty()) 565 while (!components.empty()) 566 { 566 { 567 if (components.back() != nullptr) delete << 567 if (components.back()) delete components.back(); 568 components.pop_back(); 568 components.pop_back(); 569 } 569 } 570 } 570 } 571 571 572 572 573 573