Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RE02NestedPhantomParameterisation.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 //
26 /// \file runAndEvent/RE02/src/RE02NestedPhantomParameterisation.cc
27 /// \brief Implementation of the RE02NestedPhantomParameterisation class
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 //=======================================================================
42 // (RE02NestedPhantomParameterisation)
43 //
44 // (Description)
45 // Class for nested parameterisation.
46 // This parameterisation handles material and transfomation of voxles.
47 //
48 // T.Aso Created. Nov.2007.
49 //
50 ////////////////////////////////////////////////////////////////////
51 
52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55  G4int nz,
56  std::vector<G4Material*>& mat):
58  fdX(voxelSize.x()),fdY(voxelSize.y()),fdZ(voxelSize.z()),
59  fNz(nz),fMat(mat)
60 {
61  // Position of voxels.
62  // x and y positions are already defined in DetectorConstruction
63  // by using replicated volume. Here only we need to define is z positions
64  // of voxles.
65  fpZ.clear();
66  G4double zp;
67  for ( G4int iz = 0; iz < fNz; iz++){
68  zp = (-fNz+1+2*iz)*fdZ;
69  fpZ.push_back(zp);
70  }
71 
72 }
73 
74 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
76  fpZ.clear();
77 }
78 
79 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
80 //
81 // Material assignment to geometry.
82 //
84 ::ComputeMaterial(G4VPhysicalVolume* /*currentVol*/, const G4int copyNo,
85  const G4VTouchable* parentTouch)
86 {
87  if(parentTouch==0) return fMat[0]; // protection for initialization and
88  // vis at idle state
89  // Copy number of voxels.
90  // Copy number of X and Y are obtained from replication number.
91  // Copy nymber of Z is the copy number of current voxel.
92  G4int ix = parentTouch->GetReplicaNumber(0);
93  G4int iy = parentTouch->GetReplicaNumber(1);
94  G4int iz = copyNo;
95  // For demonstration purpose,a couple of materials are chosen alternately.
96  G4Material* mat=0;
97  if ( ix%2 == 0 && iy%2 == 0 && iz%2 == 0 ) mat = fMat[0];
98  else mat = fMat[1];
99 
100  return mat;
101 }
102 
103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
104 //
105 // Number of Materials
106 // Material scanner is required for preparing physics tables and so on before
107 // stating simulation, so that G4 has to know number of materials.
109  return fMat.size();
110 }
111 
112 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
113 //
114 // GetMaterial
115 // This is needed for material scanner and realizing geometry.
116 //
118  return fMat[i];
119 }
120 
121 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
122 //
123 // Transformation of voxels.
124 //
126 ::ComputeTransformation(const G4int copyNo, G4VPhysicalVolume* physVol) const{
127  G4ThreeVector position(0.,0.,fpZ[copyNo]);
128  physVol->SetTranslation(position);
129 }
130 
131 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
132 //
133 // Dimensions are always same in this RE02 example.
134 //
136 ::ComputeDimensions(G4Box& box, const G4int, const G4VPhysicalVolume* ) const{
137  box.SetXHalfLength(fdX);
138  box.SetYHalfLength(fdY);
139  box.SetZHalfLength(fdZ);
140 }
void SetZHalfLength(G4double dz)
Definition: G4Box.cc:172
void ComputeTransformation(const G4int no, G4VPhysicalVolume *currentPV) const
G4double z
Definition: TRTMaterials.hh:39
Definition: G4Box.hh:63
RE02NestedPhantomParameterisation(const G4ThreeVector &voxelSize, G4int nz, std::vector< G4Material * > &mat)
G4Material * ComputeMaterial(G4VPhysicalVolume *currentVol, const G4int repNo, const G4VTouchable *parentTouch=0)
void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
int G4int
Definition: G4Types.hh:78
Definition of the RE02NestedPhantomParameterisation class.
G4double iz
Definition: TRTMaterials.hh:39
void SetTranslation(const G4ThreeVector &v)
int position
Definition: filter.cc:7
virtual G4int GetReplicaNumber(G4int depth=0) const
Definition: G4VTouchable.cc:58
void SetYHalfLength(G4double dy)
Definition: G4Box.cc:152
void SetXHalfLength(G4double dx)
Definition: G4Box.cc:132
double G4double
Definition: G4Types.hh:76