Files
geant4/source/processes/scoring/include/G4EnergySplitter.icc
T
2016-06-09 16:25:56 +02:00

107 lines
4.6 KiB
Plaintext

//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
#include "G4RegularNavigationHelper.hh"
#include "G4UIcommand.hh"
#include "G4PhantomParameterisation.hh"
//-----------------------------------------------------------------------
inline void G4EnergySplitter::GetLastVoxelID( G4int& voxelID)
{
voxelID = (*(G4RegularNavigationHelper::theStepLengths.begin())).first;
}
//-----------------------------------------------------------------------
inline void G4EnergySplitter::GetFirstVoxelID( G4int& voxelID)
{
voxelID = (*(G4RegularNavigationHelper::theStepLengths.rbegin())).first;
}
//-----------------------------------------------------------------------
inline void G4EnergySplitter::GetVoxelID( G4int stepNo, G4int& voxelID )
{
if( stepNo < 0 || stepNo >= G4int(G4RegularNavigationHelper::theStepLengths.size()) ) {
G4Exception("G4EnergySplitter::GetVoxelID",
"Invalid stepNo, smaller than 0 or bigger or equal to number of voxels traversed",
FatalErrorInArgument,
G4String("stepNo = " + G4UIcommand::ConvertToString(stepNo) + ", number of voxels = " + G4UIcommand::ConvertToString(G4int(G4RegularNavigationHelper::theStepLengths.size())) ).c_str());
}
std::vector< std::pair<G4int,G4double> >::const_iterator ite = G4RegularNavigationHelper::theStepLengths.begin();
advance( ite, stepNo );
voxelID = (*ite).first;
}
//-----------------------------------------------------------------------
inline void G4EnergySplitter::GetStepLength( G4int stepNo, G4double& stepLength )
{
std::vector< std::pair<G4int,G4double> >::const_iterator ite = G4RegularNavigationHelper::theStepLengths.begin();
advance( ite, stepNo );
stepLength = (*ite).second;
}
//-----------------------------------------------------------------------
inline void G4EnergySplitter::GetVoxelIDAndLength( G4int stepNo, G4int& voxelID, G4double& stepLength )
{
GetVoxelID( stepNo, voxelID );
GetStepLength( stepNo, stepLength);
}
//-----------------------------------------------------------------------
inline void G4EnergySplitter::GetLengthAndEnergyDeposited( G4int stepNo, G4int& voxelID, G4double& stepLength, G4double &energyLoss)
{
GetVoxelIDAndLength( stepNo, voxelID, stepLength );
energyLoss = theEnergies[stepNo];
}
//-----------------------------------------------------------------------
inline void G4EnergySplitter::GetLengthAndInitialEnergy( G4double &preStepEnergy, G4int stepNo, G4int& voxelID, G4double& stepLength, G4double &initialEnergy)
{
GetVoxelIDAndLength( stepNo, voxelID, stepLength );
initialEnergy = preStepEnergy;
for( G4int ii = 0; ii < stepNo; ii++ ){
initialEnergy -= theEnergies[stepNo];
}
}
//-----------------------------------------------------------------------
inline void G4EnergySplitter::SetNIterations( G4int niter )
{
theNIterations = niter;
}
//-----------------------------------------------------------------------
inline G4Material* G4EnergySplitter::GetVoxelMaterial( G4int stepNo )
{
if( !thePhantomParam ) GetPhantomParam(TRUE);
G4int voxelID;
GetVoxelID( stepNo, voxelID );
return thePhantomParam->GetMaterial( voxelID );
}