Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DicomNestedPhantomParameterisation.cc
Go to the documentation of this file.
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 //
28 //
29 // $Id$
30 //
31 
33 
34 #include "G4VPhysicalVolume.hh"
35 #include "G4VTouchable.hh"
36 #include "G4ThreeVector.hh"
37 #include "G4Box.hh"
38 #include "G4LogicalVolume.hh"
39 #include "G4Material.hh"
40 
41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
44  std::vector<G4Material*>& mat):
45  G4VNestedParameterisation(), fdX(voxelSize.x()),
46  fdY(voxelSize.y()), fdZ(voxelSize.z()), fMaterials(mat)
47 {
48  fnX = 0;
49  fnY = 0;
50  fnZ = 0;
51  fMaterialIndices = 0;
52 
53  // Position of voxels.
54  // x and y positions are already defined in DetectorConstruction by using
55  // replicated volume. Here only we need to define is z positions of voxels.
56 }
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
60 {
61 }
62 
63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
65 SetNoVoxel( unsigned int nx, unsigned int ny, unsigned int nz )
66 {
67  fnX = nx;
68  fnY = ny;
69  fnZ = nz;
70 }
71 
72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
75  const G4VTouchable* parentTouch)
76 {
77  // protection for initialization and vis at idle state
78  //
79  if(parentTouch==0) return fMaterials[0];
80 
81  // Copy number of voxels.
82  // Copy number of X and Y are obtained from replication number.
83  // Copy nymber of Z is the copy number of current voxel.
84  G4int ix = parentTouch->GetReplicaNumber(0);
85  G4int iy = parentTouch->GetReplicaNumber(1);
86  G4int iz = copyNoZ;
87 
88  G4int copyNo = ix + fnX*iy + fnX*fnY*iz;
89 
90  unsigned int matIndex = GetMaterialIndex(copyNo);
91 
92  return fMaterials[ matIndex ];
93 }
94 
95 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
97 GetMaterialIndex( unsigned int copyNo ) const
98 {
99  return *(fMaterialIndices+copyNo);
100 }
101 
102 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
103 // Number of Materials
104 // Material scanner is required for preparing physics tables and so on before
105 // starting simulation, so that G4 has to know number of materials.
106 //
108 {
109  return fMaterials.size();
110 }
111 
112 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
113 //
114 // GetMaterial
115 // This is needed for material scanner and realizing geometry.
116 //
118 {
119  return fMaterials[i];
120 }
121 
122 //
123 // Transformation of voxels.
124 //
126 ComputeTransformation(const G4int copyNo, G4VPhysicalVolume* physVol) const
127 {
128  G4ThreeVector position(0.,0.,(2*copyNo+1)*fdZ - fdZ*fnZ);
129  physVol->SetTranslation(position);
130 }
131 
132 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
133 //
134 // Dimensions are always same in this RE02 example.
135 //
137 ComputeDimensions( G4Box& box, const G4int, const G4VPhysicalVolume* ) const
138 {
139  box.SetXHalfLength(fdX);
140  box.SetYHalfLength(fdY);
141  box.SetZHalfLength(fdZ);
142 }