[1350] | 1 | // |
---|
| 2 | // ******************************************************************** |
---|
| 3 | // * License and Disclaimer * |
---|
| 4 | // * * |
---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
| 7 | // * conditions of the Geant4 Software License, included in the file * |
---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
| 9 | // * include a list of copyright holders. * |
---|
| 10 | // * * |
---|
| 11 | // * Neither the authors of this software system, nor their employing * |
---|
| 12 | // * institutes,nor the agencies providing financial support for this * |
---|
| 13 | // * work make any representation or warranty, express or implied, * |
---|
| 14 | // * regarding this software system or assume any liability for its * |
---|
| 15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
| 16 | // * for the full disclaimer and the limitation of liability. * |
---|
| 17 | // * * |
---|
| 18 | // * This code implementation is the result of the scientific and * |
---|
| 19 | // * technical work of the GEANT4 collaboration. * |
---|
| 20 | // * By using, copying, modifying or distributing the software (or * |
---|
| 21 | // * any work based on the software) you agree to acknowledge its * |
---|
| 22 | // * use in resulting scientific publications, and indicate your * |
---|
| 23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
| 24 | // ******************************************************************** |
---|
| 25 | // |
---|
| 26 | #include "G4RegularNavigationHelper.hh" |
---|
| 27 | #include "G4UIcommand.hh" |
---|
| 28 | #include "G4PhantomParameterisation.hh" |
---|
| 29 | |
---|
| 30 | //----------------------------------------------------------------------- |
---|
| 31 | inline void G4EnergySplitter::GetLastVoxelID( G4int& voxelID) |
---|
| 32 | { |
---|
| 33 | voxelID = (*(G4RegularNavigationHelper::theStepLengths.begin())).first; |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | //----------------------------------------------------------------------- |
---|
| 37 | inline void G4EnergySplitter::GetFirstVoxelID( G4int& voxelID) |
---|
| 38 | { |
---|
| 39 | voxelID = (*(G4RegularNavigationHelper::theStepLengths.rbegin())).first; |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | //----------------------------------------------------------------------- |
---|
| 43 | inline void G4EnergySplitter::GetVoxelID( G4int stepNo, G4int& voxelID ) |
---|
| 44 | { |
---|
| 45 | if( stepNo < 0 || stepNo >= G4int(G4RegularNavigationHelper::theStepLengths.size()) ) { |
---|
| 46 | G4Exception("G4EnergySplitter::GetVoxelID", |
---|
| 47 | "Invalid stepNo, smaller than 0 or bigger or equal to number of voxels traversed", |
---|
| 48 | FatalErrorInArgument, |
---|
| 49 | G4String("stepNo = " + G4UIcommand::ConvertToString(stepNo) + ", number of voxels = " + G4UIcommand::ConvertToString(G4int(G4RegularNavigationHelper::theStepLengths.size())) ).c_str()); |
---|
| 50 | } |
---|
| 51 | std::vector< std::pair<G4int,G4double> >::const_iterator ite = G4RegularNavigationHelper::theStepLengths.begin(); |
---|
| 52 | advance( ite, stepNo ); |
---|
| 53 | voxelID = (*ite).first; |
---|
| 54 | |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | |
---|
| 58 | //----------------------------------------------------------------------- |
---|
| 59 | inline void G4EnergySplitter::GetStepLength( G4int stepNo, G4double& stepLength ) |
---|
| 60 | { |
---|
| 61 | std::vector< std::pair<G4int,G4double> >::const_iterator ite = G4RegularNavigationHelper::theStepLengths.begin(); |
---|
| 62 | advance( ite, stepNo ); |
---|
| 63 | stepLength = (*ite).second; |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | //----------------------------------------------------------------------- |
---|
| 67 | inline void G4EnergySplitter::GetVoxelIDAndLength( G4int stepNo, G4int& voxelID, G4double& stepLength ) |
---|
| 68 | { |
---|
| 69 | GetVoxelID( stepNo, voxelID ); |
---|
| 70 | GetStepLength( stepNo, stepLength); |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | //----------------------------------------------------------------------- |
---|
| 74 | inline void G4EnergySplitter::GetLengthAndEnergyDeposited( G4int stepNo, G4int& voxelID, G4double& stepLength, G4double &energyLoss) |
---|
| 75 | { |
---|
| 76 | GetVoxelIDAndLength( stepNo, voxelID, stepLength ); |
---|
| 77 | |
---|
| 78 | energyLoss = theEnergies[stepNo]; |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | //----------------------------------------------------------------------- |
---|
| 82 | inline void G4EnergySplitter::GetLengthAndInitialEnergy( G4double &preStepEnergy, G4int stepNo, G4int& voxelID, G4double& stepLength, G4double &initialEnergy) |
---|
| 83 | { |
---|
| 84 | GetVoxelIDAndLength( stepNo, voxelID, stepLength ); |
---|
| 85 | |
---|
| 86 | initialEnergy = preStepEnergy; |
---|
| 87 | for( G4int ii = 0; ii < stepNo; ii++ ){ |
---|
| 88 | initialEnergy -= theEnergies[stepNo]; |
---|
| 89 | } |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | //----------------------------------------------------------------------- |
---|
| 93 | inline void G4EnergySplitter::SetNIterations( G4int niter ) |
---|
| 94 | { |
---|
| 95 | theNIterations = niter; |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | //----------------------------------------------------------------------- |
---|
| 99 | inline G4Material* G4EnergySplitter::GetVoxelMaterial( G4int stepNo ) |
---|
| 100 | { |
---|
| 101 | if( !thePhantomParam ) GetPhantomParam(TRUE); |
---|
| 102 | G4int voxelID; |
---|
| 103 | GetVoxelID( stepNo, voxelID ); |
---|
| 104 | return thePhantomParam->GetMaterial( voxelID ); |
---|
| 105 | } |
---|
| 106 | |
---|