[807] | 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 | // |
---|
[1337] | 26 | // $Id: DicomNestedPhantomParameterisation.cc,v 1.6 2009/11/10 18:48:46 arce Exp $ |
---|
| 27 | // GEANT4 tag $Name: geant4-09-04-beta-01 $ |
---|
[1230] | 28 | // |
---|
| 29 | // -------------------------------------------------------------------- |
---|
[807] | 30 | #include "DicomNestedPhantomParameterisation.hh" |
---|
| 31 | |
---|
| 32 | #include "G4VPhysicalVolume.hh" |
---|
| 33 | #include "G4VTouchable.hh" |
---|
| 34 | #include "G4ThreeVector.hh" |
---|
| 35 | #include "G4Box.hh" |
---|
| 36 | #include "G4LogicalVolume.hh" |
---|
| 37 | #include "G4Material.hh" |
---|
| 38 | |
---|
[1230] | 39 | DicomNestedPhantomParameterisation:: |
---|
| 40 | DicomNestedPhantomParameterisation(const G4ThreeVector& voxelSize, |
---|
| 41 | std::vector<G4Material*>& mat): |
---|
| 42 | G4VNestedParameterisation(), fdX(voxelSize.x()), |
---|
| 43 | fdY(voxelSize.y()), fdZ(voxelSize.z()), fMaterials(mat) |
---|
[807] | 44 | { |
---|
| 45 | // Position of voxels. |
---|
[1230] | 46 | // x and y positions are already defined in DetectorConstruction by using |
---|
| 47 | // replicated volume. Here only we need to define is z positions of voxels. |
---|
[807] | 48 | } |
---|
| 49 | |
---|
| 50 | DicomNestedPhantomParameterisation::~DicomNestedPhantomParameterisation() |
---|
| 51 | { |
---|
| 52 | } |
---|
| 53 | |
---|
[1230] | 54 | void DicomNestedPhantomParameterisation:: |
---|
[1337] | 55 | SetNoVoxel( unsigned int nx, unsigned int ny, unsigned int nz ) |
---|
[807] | 56 | { |
---|
| 57 | fnX = nx; |
---|
| 58 | fnY = ny; |
---|
| 59 | fnZ = nz; |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | // |
---|
| 63 | // Material assignment to geometry. |
---|
| 64 | // |
---|
[1230] | 65 | G4Material* DicomNestedPhantomParameterisation:: |
---|
| 66 | ComputeMaterial(G4VPhysicalVolume*, const G4int copyNoZ, |
---|
| 67 | const G4VTouchable* parentTouch) |
---|
[807] | 68 | { |
---|
[1230] | 69 | // protection for initialization and vis at idle state |
---|
| 70 | // |
---|
| 71 | if(parentTouch==0) return fMaterials[0]; |
---|
| 72 | |
---|
[807] | 73 | // Copy number of voxels. |
---|
| 74 | // Copy number of X and Y are obtained from replication number. |
---|
| 75 | // Copy nymber of Z is the copy number of current voxel. |
---|
| 76 | G4int ix = parentTouch->GetReplicaNumber(0); |
---|
| 77 | G4int iy = parentTouch->GetReplicaNumber(1); |
---|
| 78 | G4int iz = copyNoZ; |
---|
| 79 | |
---|
[1230] | 80 | G4int copyNo = ix + fnX*iy + fnX*fnY*iz; |
---|
[807] | 81 | |
---|
[1337] | 82 | unsigned int matIndex = GetMaterialIndex(copyNo); |
---|
[807] | 83 | |
---|
| 84 | return fMaterials[ matIndex ]; |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | //------------------------------------------------------------------ |
---|
[1337] | 88 | unsigned int DicomNestedPhantomParameterisation:: |
---|
| 89 | GetMaterialIndex( unsigned int copyNo ) const |
---|
[807] | 90 | { |
---|
| 91 | return *(fMaterialIndices+copyNo); |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | // |
---|
[1230] | 95 | // Number of Materials |
---|
| 96 | // Material scanner is required for preparing physics tables and so on before |
---|
| 97 | // starting simulation, so that G4 has to know number of materials. |
---|
| 98 | // |
---|
| 99 | G4int DicomNestedPhantomParameterisation::GetNumberOfMaterials() const |
---|
| 100 | { |
---|
[807] | 101 | return fMaterials.size(); |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | // |
---|
| 105 | // GetMaterial |
---|
| 106 | // This is needed for material scanner and realizing geometry. |
---|
| 107 | // |
---|
[1230] | 108 | G4Material* DicomNestedPhantomParameterisation::GetMaterial(G4int i) const |
---|
| 109 | { |
---|
[807] | 110 | return fMaterials[i]; |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | // |
---|
| 114 | // Transformation of voxels. |
---|
| 115 | // |
---|
[1230] | 116 | void DicomNestedPhantomParameterisation:: |
---|
| 117 | ComputeTransformation(const G4int copyNo, G4VPhysicalVolume* physVol) const |
---|
| 118 | { |
---|
[807] | 119 | G4ThreeVector position(0.,0.,(2*copyNo+1)*fdZ - fdZ*fnZ); |
---|
| 120 | physVol->SetTranslation(position); |
---|
| 121 | } |
---|
| 122 | |
---|
| 123 | // |
---|
| 124 | // Dimensions are always same in this RE02 example. |
---|
| 125 | // |
---|
[1230] | 126 | void DicomNestedPhantomParameterisation:: |
---|
| 127 | ComputeDimensions( G4Box& box, const G4int, const G4VPhysicalVolume* ) const |
---|
| 128 | { |
---|
[807] | 129 | box.SetXHalfLength(fdX); |
---|
| 130 | box.SetYHalfLength(fdY); |
---|
| 131 | box.SetZHalfLength(fdZ); |
---|
| 132 | } |
---|