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 // G4PhysicsLinearVector class implementation << 27 // 26 // 28 // Authors: << 27 // $Id: G4PhysicsLinearVector.cc,v 1.12 2006/06/29 19:04:13 gunter Exp $ 29 // - 02 Dec. 1995, G.Cosmo: Structure created << 28 // GEANT4 tag $Name: geant4-09-01-patch-03 $ 30 // - 03 Mar. 1996, K.Amako: Implemented the 1s << 29 // 31 // Revisions: << 30 // 32 // - 11 Nov. 2000, H.Kurashige: Use STL vector << 31 //-------------------------------------------------------------------- 33 // ------------------------------------------- << 32 // GEANT 4 class implementation file >> 33 // >> 34 // G4PhysicsLinearVector.cc >> 35 // >> 36 // History: >> 37 // 02 Dec. 1995, G.Cosmo : Structure created based on object model >> 38 // 15 Feb. 1996, K.Amako : Implemented the 1st version >> 39 // 01 Jul. 1996, K.Amako : Cache mechanism and hidden bin from the >> 40 // user introduced. >> 41 // 26 Sep. 1996, K.Amako : Constructor with only 'bin size' added. >> 42 // 11 Nov. 2000, H.Kurashige : use STL vector for dataVector and binVector >> 43 // 9 Mar. 2001, H.Kurashige : add PhysicsVector type and Retrieve >> 44 // >> 45 //-------------------------------------------------------------------- 34 46 35 #include "G4PhysicsLinearVector.hh" 47 #include "G4PhysicsLinearVector.hh" 36 48 37 // ------------------------------------------- << 49 G4PhysicsLinearVector::G4PhysicsLinearVector() 38 G4PhysicsLinearVector::G4PhysicsLinearVector(G << 50 : dBin(0.), baseBin(0.) 39 : G4PhysicsVector(spline) << 40 { 51 { >> 52 edgeMin = 0.0; >> 53 edgeMax = 0.0; >> 54 numberOfBin = 0; 41 type = T_G4PhysicsLinearVector; 55 type = T_G4PhysicsLinearVector; 42 } 56 } 43 57 44 // ------------------------------------------- << 58 G4PhysicsLinearVector::G4PhysicsLinearVector(size_t theNbin) 45 G4PhysicsLinearVector::G4PhysicsLinearVector(G << 59 : dBin(0.), baseBin(0.) 46 s << 47 : G4PhysicsVector(spline) << 48 { 60 { 49 numberOfNodes = Nbin + 1; << 61 type = T_G4PhysicsLinearVector; 50 if (Nbin < 1 || Emin >= Emax) << 62 51 { << 63 // Add extra one bin (hidden to user) to handle correctly when 52 G4ExceptionDescription ed; << 64 // Energy=theEmax in getValue. 53 ed << "G4PhysicsLinearVector with wrong pa << 65 dataVector.reserve(theNbin+1); 54 << " Emin= " << Emin << " Emax= " << Em << 66 binVector.reserve(theNbin+1); 55 G4Exception("G4PhysicsLinearVector::G4Phys << 67 56 FatalException, ed, "theNbins << 68 numberOfBin = theNbin; 57 } << 69 58 if (numberOfNodes < 2) << 70 edgeMin = 0.; >> 71 edgeMax = 0.; >> 72 >> 73 lastBin = INT_MAX; >> 74 lastEnergy = -DBL_MAX; >> 75 lastValue = DBL_MAX; >> 76 >> 77 for (size_t i=0; i<=numberOfBin; i++) 59 { 78 { 60 numberOfNodes = 2; << 79 binVector.push_back(0.0); >> 80 dataVector.push_back(0.0); 61 } 81 } >> 82 } >> 83 >> 84 G4PhysicsLinearVector::G4PhysicsLinearVector(G4double theEmin, >> 85 G4double theEmax, size_t theNbin) >> 86 : dBin((theEmax-theEmin)/theNbin), >> 87 baseBin(theEmin/dBin) >> 88 { 62 type = T_G4PhysicsLinearVector; 89 type = T_G4PhysicsLinearVector; 63 90 64 binVector.resize(numberOfNodes); << 91 // Add extra one bin (hidden to user) to handle correctly when 65 dataVector.resize(numberOfNodes, 0.0); << 92 // Energy=theEmax in getValue. 66 binVector[0] = Emin; << 93 dataVector.reserve(theNbin+1); 67 binVector[numberOfNodes - 1] = Emax; << 94 binVector.reserve(theNbin+1); 68 Initialise(); << 95 69 if (2 < numberOfNodes) << 96 numberOfBin = theNbin; >> 97 >> 98 for (size_t i=0; i<numberOfBin+1; i++) 70 { 99 { 71 for(std::size_t i = 1; i <= idxmax; ++i) << 100 binVector.push_back( theEmin + i*dBin ); 72 { << 101 dataVector.push_back(0.0); 73 binVector[i] = edgeMin + i / invdBin; << 74 } << 75 } 102 } 76 } << 77 103 78 // ------------------------------------------- << 79 void G4PhysicsLinearVector::Initialise() << 80 { << 81 idxmax = numberOfNodes - 2; << 82 edgeMin = binVector[0]; 104 edgeMin = binVector[0]; 83 edgeMax = binVector[numberOfNodes - 1]; << 105 edgeMax = binVector[numberOfBin-1]; 84 invdBin = (idxmax + 1) / (edgeMax - edgeMin) << 85 } << 86 106 87 // ------------------------------------------- << 107 lastBin = INT_MAX; >> 108 lastEnergy = -DBL_MAX; >> 109 lastValue = DBL_MAX; >> 110 } >> 111 >> 112 G4PhysicsLinearVector::~G4PhysicsLinearVector(){} >> 113 >> 114 G4bool G4PhysicsLinearVector::Retrieve(std::ifstream& fIn, G4bool ascii) >> 115 { >> 116 G4bool success = G4PhysicsVector::Retrieve(fIn, ascii); >> 117 if (success) >> 118 { >> 119 G4double theEmin = binVector[0]; >> 120 dBin = binVector[1]-theEmin; >> 121 baseBin = theEmin/dBin; >> 122 } >> 123 return success; >> 124 } 88 125