Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 /// \file runAndEvent/RE02/src/RE02NestedPhant << 27 /// \brief Implementation of the RE02NestedPha << 28 // << 29 // << 30 ////////////////////////////////////////////// 26 /////////////////////////////////////////////////////////////////////////////// 31 #include "RE02NestedPhantomParameterisation.hh 27 #include "RE02NestedPhantomParameterisation.hh" 32 28 >> 29 #include "G4VPhysicalVolume.hh" >> 30 #include "G4VTouchable.hh" >> 31 #include "G4ThreeVector.hh" 33 #include "G4Box.hh" 32 #include "G4Box.hh" 34 #include "G4LogicalVolume.hh" 33 #include "G4LogicalVolume.hh" 35 #include "G4Material.hh" 34 #include "G4Material.hh" 36 #include "G4ThreeVector.hh" << 37 #include "G4VPhysicalVolume.hh" << 38 #include "G4VTouchable.hh" << 39 35 40 //============================================ 36 //======================================================================= 41 // (RE02NestedPhantomParameterisation) 37 // (RE02NestedPhantomParameterisation) 42 // 38 // 43 // (Description) 39 // (Description) 44 // Class for nested parameterisation. 40 // Class for nested parameterisation. 45 // This parameterisation handles material 41 // This parameterisation handles material and transfomation of voxles. 46 // 42 // 47 // T.Aso Created. Nov.2007. 43 // T.Aso Created. Nov.2007. 48 // 44 // 49 ////////////////////////////////////////////// 45 //////////////////////////////////////////////////////////////////// 50 << 46 RE02NestedPhantomParameterisation::RE02NestedPhantomParameterisation( 51 //....oooOO0OOooo........oooOO0OOooo........oo << 47 const G4ThreeVector& voxelSize, 52 RE02NestedPhantomParameterisation ::RE02Nested << 48 G4int nz, 53 const G4ThreeVector& voxelSize, G4int nz, st << 49 std::vector<G4Material*>& mat): 54 : G4VNestedParameterisation(), << 50 G4VNestedParameterisation(),fdX(voxelSize.x()),fdY(voxelSize.y()),fdZ(voxelSize.z()), 55 fdX(voxelSize.x()), << 51 fNz(nz),fmat(mat) 56 fdY(voxelSize.y()), << 52 { 57 fdZ(voxelSize.z()), << 53 // Position of voxels. 58 fNz(nz), << 54 // x and y positions are already defined in DetectorConstruction 59 fMat(mat) << 55 // by using replicated volume. Here only we need to define is z positions of voxles. 60 { << 61 // Position of voxels. << 62 // x and y positions are already defined in << 63 // by using replicated volume. Here only we << 64 // of voxles. << 65 fpZ.clear(); 56 fpZ.clear(); 66 G4double zp; 57 G4double zp; 67 for (G4int iz = 0; iz < fNz; iz++) { << 58 for ( G4int iz = 0; iz < fNz; iz++){ 68 zp = (-fNz + 1 + 2 * iz) * fdZ; << 59 zp = (-fNz+1+2*iz)*fdZ; 69 fpZ.push_back(zp); 60 fpZ.push_back(zp); 70 } 61 } >> 62 71 } 63 } 72 64 73 //....oooOO0OOooo........oooOO0OOooo........oo << 65 RE02NestedPhantomParameterisation::~RE02NestedPhantomParameterisation(){ 74 RE02NestedPhantomParameterisation::~RE02Nested << 75 { << 76 fpZ.clear(); 66 fpZ.clear(); 77 } 67 } 78 68 79 //....oooOO0OOooo........oooOO0OOooo........oo << 80 // 69 // 81 // Material assignment to geometry. 70 // Material assignment to geometry. 82 // 71 // 83 G4Material* RE02NestedPhantomParameterisation << 72 G4Material* RE02NestedPhantomParameterisation::ComputeMaterial(G4VPhysicalVolume* currentVol, 84 << 73 const G4int copyNo, 85 << 74 const G4VTouchable* parentTouch) 86 { 75 { 87 if (parentTouch == 0) << 76 if(parentTouch==0) return fmat[0]; // protection for initialization and vis at idle state 88 return fMat[0]; // protection for initial << 77 // Copy number of voxels. 89 // vis at idle state << 90 // Copy number of voxels. << 91 // Copy number of X and Y are obtained from 78 // Copy number of X and Y are obtained from replication number. 92 // Copy nymber of Z is the copy number of cu 79 // Copy nymber of Z is the copy number of current voxel. 93 G4int ix = parentTouch->GetReplicaNumber(0); 80 G4int ix = parentTouch->GetReplicaNumber(0); 94 G4int iy = parentTouch->GetReplicaNumber(1); 81 G4int iy = parentTouch->GetReplicaNumber(1); 95 G4int iz = copyNo; 82 G4int iz = copyNo; 96 // For demonstration purpose,a couple of mat 83 // For demonstration purpose,a couple of materials are chosen alternately. 97 G4Material* mat = 0; << 84 G4Material* mat=0; 98 if (ix % 2 == 0 && iy % 2 == 0 && iz % 2 == << 85 if ( ix%2 == 0 && iy%2 == 0 && iz%2 == 0 ) mat = fmat[0]; 99 mat = fMat[0]; << 86 else mat = fmat[1]; 100 else << 101 mat = fMat[1]; << 102 87 103 return mat; 88 return mat; 104 } 89 } 105 90 106 //....oooOO0OOooo........oooOO0OOooo........oo << 107 // 91 // 108 // Number of Materials 92 // Number of Materials 109 // Material scanner is required for preparing << 93 // Material scanner is required for preparing physics tables and so on before 110 // stating simulation, so that G4 has to know 94 // stating simulation, so that G4 has to know number of materials. 111 G4int RE02NestedPhantomParameterisation::GetNu << 95 G4int RE02NestedPhantomParameterisation::GetNumberOfMaterials() const{ 112 { << 96 return fmat.size(); 113 return fMat.size(); << 114 } 97 } 115 98 116 //....oooOO0OOooo........oooOO0OOooo........oo << 117 // 99 // 118 // GetMaterial 100 // GetMaterial 119 // This is needed for material scanner and re 101 // This is needed for material scanner and realizing geometry. 120 // 102 // 121 G4Material* RE02NestedPhantomParameterisation: << 103 G4Material* RE02NestedPhantomParameterisation::GetMaterial(G4int i) const{ 122 { << 104 return fmat[i]; 123 return fMat[i]; << 124 } 105 } 125 106 126 //....oooOO0OOooo........oooOO0OOooo........oo << 127 // 107 // 128 // Transformation of voxels. 108 // Transformation of voxels. 129 // 109 // 130 void RE02NestedPhantomParameterisation ::Compu << 110 void RE02NestedPhantomParameterisation::ComputeTransformation(const G4int copyNo, 131 << 111 G4VPhysicalVolume* physVol)const{ 132 { << 112 G4ThreeVector position(0.,0.,fpZ[copyNo]); 133 G4ThreeVector position(0., 0., fpZ[copyNo]); << 134 physVol->SetTranslation(position); 113 physVol->SetTranslation(position); 135 } 114 } 136 115 137 //....oooOO0OOooo........oooOO0OOooo........oo << 138 // 116 // 139 // Dimensions are always same in this RE02 exa 117 // Dimensions are always same in this RE02 example. 140 // 118 // 141 void RE02NestedPhantomParameterisation ::Compu << 119 void RE02NestedPhantomParameterisation::ComputeDimensions(G4Box& box, 142 << 120 const G4int , 143 { << 121 const G4VPhysicalVolume* ) const{ 144 box.SetXHalfLength(fdX); 122 box.SetXHalfLength(fdX); 145 box.SetYHalfLength(fdY); 123 box.SetYHalfLength(fdY); 146 box.SetZHalfLength(fdZ); 124 box.SetZHalfLength(fdZ); 147 } 125 } 148 126