00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include "G4PhysicalVolumeMassScene.hh"
00034
00035 #include "G4VSolid.hh"
00036 #include "G4Vector3D.hh"
00037 #include "G4PhysicalVolumeModel.hh"
00038 #include "G4LogicalVolume.hh"
00039 #include "G4Polyhedron.hh"
00040 #include "G4Material.hh"
00041 #include "G4VPVParameterisation.hh"
00042 #include "G4UnitsTable.hh"
00043
00044 G4PhysicalVolumeMassScene::G4PhysicalVolumeMassScene
00045 (G4PhysicalVolumeModel* pPVModel):
00046 fpPVModel (pPVModel),
00047 fVolume (0.),
00048 fMass (0.),
00049 fpLastPV (0),
00050 fPVPCount (0),
00051 fLastDepth (0),
00052 fLastDensity (0.)
00053 {}
00054
00055 G4PhysicalVolumeMassScene::~G4PhysicalVolumeMassScene () {}
00056
00057 void G4PhysicalVolumeMassScene::Reset ()
00058 {
00059 fVolume = 0.;
00060 fMass = 0.;
00061 fpLastPV = 0;
00062 fPVPCount = 0;
00063 fLastDepth = 0;
00064 fLastDensity = 0.;
00065 fDensityStack.clear();
00066 }
00067
00068 void G4PhysicalVolumeMassScene::AccrueMass (const G4VSolid& solid)
00069 {
00070 G4int currentDepth = fpPVModel->GetCurrentDepth();
00071 G4VPhysicalVolume* pCurrentPV = fpPVModel->GetCurrentPV();
00072
00073 G4Material* pCurrentMaterial = fpPVModel->GetCurrentMaterial();
00074
00075 if (pCurrentPV != fpLastPV) {
00076 fpLastPV = pCurrentPV;
00077 fPVPCount = 0;
00078 }
00079
00080 G4double currentVolume = ((G4VSolid&)solid).GetCubicVolume();
00081 G4double currentDensity = pCurrentMaterial->GetDensity();
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097 if (currentDepth == 0) fVolume = currentVolume;
00098
00099 if (currentDepth > fLastDepth) {
00100 fDensityStack.push_back (fLastDensity);
00101 } else if (currentDepth < fLastDepth) {
00102 fDensityStack.pop_back();
00103 }
00104 fLastDepth = currentDepth;
00105 fLastDensity = currentDensity;
00106 G4double motherDensity = 0.;
00107 if (currentDepth > 0) motherDensity = fDensityStack.back();
00108
00109 G4double subtractedMass = currentVolume * motherDensity;
00110 G4double addedMass = currentVolume * currentDensity;
00111 fMass -= subtractedMass;
00112 fMass += addedMass;
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126 if (fMass < 0.) {
00127 G4cout <<
00128 "G4PhysicalVolumeMassScene::AccrueMass: WARNING:"
00129 "\n Mass going negative for \""
00130 << pCurrentPV->GetName() <<
00131 "\", copy "
00132 << pCurrentPV->GetCopyNo() <<
00133 ". Larger than mother?"
00134 << G4endl;
00135 }
00136 }