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 // This example is provided by the Geant4-DNA 26 // This example is provided by the Geant4-DNA collaboration 27 // Any report or published results obtained us 27 // Any report or published results obtained using the Geant4-DNA software 28 // shall cite the following Geant4-DNA collabo 28 // shall cite the following Geant4-DNA collaboration publication: 29 // Med. Phys. 37 (2010) 4692-4708 29 // Med. Phys. 37 (2010) 4692-4708 30 // The Geant4-DNA web site is available at htt 30 // The Geant4-DNA web site is available at http://geant4-dna.org 31 // 31 // 32 // If you use this example, please cite the fo 32 // If you use this example, please cite the following publication: 33 // Rad. Prot. Dos. 133 (2009) 2-11 33 // Rad. Prot. Dos. 133 (2009) 2-11 34 34 35 #include "CellParameterisation.hh" 35 #include "CellParameterisation.hh" 36 #include "G4LogicalVolume.hh" 36 #include "G4LogicalVolume.hh" 37 #include "G4SystemOfUnits.hh" << 38 37 39 // SINGLETON << 38 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 40 CellParameterisation * CellParameterisation::g << 41 39 42 CellParameterisation::CellParameterisation 40 CellParameterisation::CellParameterisation 43 (G4Material * nucleus1, G4Material * cytoplas << 41 (G4int NoBoxes, G4float DimBoxX, G4float DimBoxY, G4float DimBoxZ, >> 42 G4Material * nucleus1, G4Material * cytoplasm1, 44 G4Material * nucleus2, G4Material * cytoplas 43 G4Material * nucleus2, G4Material * cytoplasm2, 45 G4Material * nucleus3, G4Material * cytoplas 44 G4Material * nucleus3, G4Material * cytoplasm3 46 ) 45 ) 47 { 46 { 48 fNucleusMaterial1 = nucleus1; 47 fNucleusMaterial1 = nucleus1; 49 fCytoplasmMaterial1 = cytoplasm1; 48 fCytoplasmMaterial1 = cytoplasm1; 50 fNucleusMaterial2 = nucleus2; 49 fNucleusMaterial2 = nucleus2; 51 fCytoplasmMaterial2 = cytoplasm2; 50 fCytoplasmMaterial2 = cytoplasm2; 52 fNucleusMaterial3 = nucleus3; 51 fNucleusMaterial3 = nucleus3; 53 fCytoplasmMaterial3 = cytoplasm3; 52 fCytoplasmMaterial3 = cytoplasm3; 54 53 >> 54 fNoCellBoxes = NoBoxes; >> 55 fDimCellBoxX = DimBoxX; >> 56 fDimCellBoxY = DimBoxY; >> 57 fDimCellBoxZ = DimBoxZ; >> 58 >> 59 fMapCell = new G4ThreeVector[fNoCellBoxes]; >> 60 fMaterial = new G4float[fNoCellBoxes]; >> 61 fMass = new G4float[fNoCellBoxes]; >> 62 55 G4int ncols,nlines; 63 G4int ncols,nlines; 56 G4int shiftX, shiftY, shiftZ; 64 G4int shiftX, shiftY, shiftZ; 57 G4double x,y,z,mat,den,tmp,density; << 65 G4float x,y,z,mat,den,tmp,sizeZ; 58 G4double denCyto1, denCyto2, denCyto3, denN << 59 << 60 ncols = nlines = shiftX = shiftY = shiftZ = << 61 x = y = z = mat = den = tmp = density = << 62 denCyto1 = denCyto2 = denCyto3 = denNucl1 << 63 66 64 // READ PHANTOM << 67 ncols=0; nlines=0; 65 fNucleusMass = 0; << 66 fCytoplasmMass = 0; << 67 << 68 fDimCellBoxX = fDimCellBoxY = fDimCellBoxZ << 69 68 >> 69 // READ PHANTOM >> 70 70 FILE *fMap; 71 FILE *fMap; 71 fMap = fopen("phantom.dat","r"); 72 fMap = fopen("phantom.dat","r"); 72 << 73 73 while (1) 74 while (1) 74 { 75 { 75 if (nlines == 0) << 76 if (nlines >= 0 && nlines <=1 ) ncols = fscanf(fMap,"%f %f %f",&tmp,&tmp,&sizeZ); 76 { << 77 if (nlines == 2) ncols = fscanf(fMap,"%i %i %i",&shiftX,&shiftY,&shiftZ); // VOXEL SHIFT IN Z ASSUMED TO BE NEGATIVE 77 ncols = fscanf(fMap,"%i %i %i",&fPhant << 78 if (nlines == 3) ncols = fscanf(fMap,"%f %f %f",&tmp,&tmp,&tmp); 78 fMapCell = new G4ThreeVector[fPhantomTota << 79 if (nlines == 4) ncols = fscanf(fMap,"%f %f %f",&tmp,&tmp,&tmp); 79 fMaterial = new G4double[fPhantomTot << 80 if (nlines > 4) ncols = fscanf(fMap,"%f %f %f %f %f %f",&x,&y,&z,&mat,&den,&tmp); 80 fMass = new G4double[fPhantomTot << 81 fTissueType = new G4int[fPhantomTotalP << 82 } << 83 << 84 if (nlines == 1) << 85 { << 86 ncols = fscanf(fMap,"%lf %lf %lf",&fDi << 87 fDimCellBoxX=fDimCellBoxX*micrometer; << 88 fDimCellBoxY=fDimCellBoxY*micrometer; << 89 fDimCellBoxZ=fDimCellBoxZ*micrometer; << 90 } << 91 << 92 // VOXEL SHIFT IN Z ASSUMED TO BE NEGATI << 93 if (nlines == 2) ncols = fscanf(fMap,"%i << 94 << 95 if (nlines == 3) ncols = fscanf(fMap,"%l << 96 << 97 if (nlines == 4) ncols = fscanf(fMap,"%l << 98 << 99 if (nlines > 4) ncols = fscanf(fMap,"%l << 100 << 101 if (ncols < 0) break; 81 if (ncols < 0) break; 102 82 103 // VOXEL SHIFT IN ORDER TO CENTER PHANTO << 83 G4ThreeVector v(x+shiftX,y+shiftY,z-1500/sizeZ-shiftZ); // VOXEL SHIFT IN ORDER TO CENTER PHANTOM 104 G4ThreeVector v(x+shiftX,y+shiftY,z-1500 << 84 105 if (nlines>4) 85 if (nlines>4) 106 { 86 { 107 << 108 fMapCell[nlines-5]=v; 87 fMapCell[nlines-5]=v; 109 fMaterial[nlines-5]=mat; 88 fMaterial[nlines-5]=mat; 110 fMass[nlines-5]=den; 89 fMass[nlines-5]=den; 111 << 112 // fTissueType: 1 is Cytoplasm - 2 is Nucl << 113 << 114 if( fMaterial[nlines-5] == 2 ) // fM << 115 { << 116 if( fMass[nlines-5] == 1 ) << 117 { << 118 fTissueType[nlines-5]=2; << 119 } << 120 if( fMass[nlines-5] == 2 ) << 121 { << 122 fTissueType[nlines-5]=2; << 123 } << 124 if( fMass[nlines-5] == 3 ) << 125 { << 126 fTissueType[nlines-5]=2; << 127 } << 128 } << 129 << 130 else if( fMaterial[nlines-5] == 1 ) << 131 { << 132 if( fMass[nlines-5] == 1 ) << 133 { << 134 fTissueType[nlines-5]=1; << 135 } << 136 if( fMass[nlines-5] == 2 ) << 137 { << 138 fTissueType[nlines-5]=2; << 139 } << 140 if( fMass[nlines-5] == 3 ) << 141 { << 142 fTissueType[nlines-5]=1; << 143 } << 144 } << 145 << 146 // << 147 << 148 if (std::abs(mat-2)<1.e-30) // NUCLEUS << 149 { << 150 if (std::abs(den-1)<1.e-30) density = de << 151 if (std::abs(den-2)<1.e-30) density = de << 152 if (std::abs(den-3)<1.e-30) density = de << 153 fNucleusMass = fNucleusMass + densit << 154 } << 155 << 156 if (std::abs(mat-1)<1.e-30) // CYTOP << 157 { << 158 if (std::abs(den-1)<1e-30) density = den << 159 if (std::abs(den-2)<1e-30) density = den << 160 if (std::abs(den-3)<1e-30) density = den << 161 fCytoplasmMass = fCytoplasmMass + densit << 162 } << 163 << 164 } 90 } 165 91 166 nlines++; 92 nlines++; 167 } 93 } 168 fclose(fMap); 94 fclose(fMap); 169 << 95 170 // NUCLEUS IN GREEN 96 // NUCLEUS IN GREEN 171 97 172 fNucleusAttributes1 = new G4VisAttributes; 98 fNucleusAttributes1 = new G4VisAttributes; 173 fNucleusAttributes1->SetColour(G4Colour(0,.8 99 fNucleusAttributes1->SetColour(G4Colour(0,.8,0)); 174 fNucleusAttributes1->SetForceSolid(false); 100 fNucleusAttributes1->SetForceSolid(false); 175 101 176 fNucleusAttributes2 = new G4VisAttributes; 102 fNucleusAttributes2 = new G4VisAttributes; 177 fNucleusAttributes2->SetColour(G4Colour(0,.9 103 fNucleusAttributes2->SetColour(G4Colour(0,.9,0)); 178 fNucleusAttributes2->SetForceSolid(false); 104 fNucleusAttributes2->SetForceSolid(false); 179 105 180 fNucleusAttributes3 = new G4VisAttributes; 106 fNucleusAttributes3 = new G4VisAttributes; 181 fNucleusAttributes3->SetColour(G4Colour(0,1, 107 fNucleusAttributes3->SetColour(G4Colour(0,1,0)); 182 fNucleusAttributes3->SetForceSolid(false); 108 fNucleusAttributes3->SetForceSolid(false); 183 109 184 // CYTOPLASM IN RED 110 // CYTOPLASM IN RED 185 111 186 fCytoplasmAttributes1 = new G4VisAttributes; 112 fCytoplasmAttributes1 = new G4VisAttributes; 187 fCytoplasmAttributes1->SetColour(G4Colour(1, 113 fCytoplasmAttributes1->SetColour(G4Colour(1,0,0)); 188 fCytoplasmAttributes1->SetForceSolid(false); 114 fCytoplasmAttributes1->SetForceSolid(false); 189 115 190 fCytoplasmAttributes2 = new G4VisAttributes; 116 fCytoplasmAttributes2 = new G4VisAttributes; // nucleoli in yellow 191 fCytoplasmAttributes2->SetColour(G4Colour(1. 117 fCytoplasmAttributes2->SetColour(G4Colour(1.,1.,0)); 192 fCytoplasmAttributes2->SetForceSolid(false); 118 fCytoplasmAttributes2->SetForceSolid(false); 193 119 194 fCytoplasmAttributes3 = new G4VisAttributes; 120 fCytoplasmAttributes3 = new G4VisAttributes; 195 fCytoplasmAttributes3->SetColour(G4Colour(1, 121 fCytoplasmAttributes3->SetColour(G4Colour(1,0,0)); 196 fCytoplasmAttributes3->SetForceSolid(false); 122 fCytoplasmAttributes3->SetForceSolid(false); >> 123 } 197 124 198 // << 125 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 199 gInstance = this; << 200 } << 201 126 202 CellParameterisation::~CellParameterisation() 127 CellParameterisation::~CellParameterisation() 203 { 128 { 204 delete[] fMapCell; 129 delete[] fMapCell; 205 delete[] fMaterial; 130 delete[] fMaterial; 206 delete[] fMass; 131 delete[] fMass; 207 delete[] fTissueType; << 208 } 132 } 209 133 >> 134 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 135 210 void CellParameterisation::ComputeTransformati 136 void CellParameterisation::ComputeTransformation 211 (const G4int copyNo, G4VPhysicalVolume* physVo 137 (const G4int copyNo, G4VPhysicalVolume* physVol) const 212 { 138 { 213 G4ThreeVector origin << 139 G4ThreeVector 214 ( << 140 origin( 215 fMapCell[copyNo].x()*fDimCellBoxX, << 141 fMapCell[copyNo].x()*fDimCellBoxX*2, 216 fMapCell[copyNo].y()*fDimCellBoxY, << 142 fMapCell[copyNo].y()*fDimCellBoxY*2, 217 fMapCell[copyNo].z()*fDimCellBoxZ << 143 fMapCell[copyNo].z()*fDimCellBoxZ*2); 218 ); << 219 144 220 physVol->SetTranslation(origin); 145 physVol->SetTranslation(origin); 221 } 146 } 222 147 >> 148 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 149 223 void CellParameterisation::ComputeDimensions 150 void CellParameterisation::ComputeDimensions 224 (G4Box&, const G4int, const G4VPhysicalVolume* << 151 (G4Box& /*trackerChamber*/, const G4int /*copyNo*/, const G4VPhysicalVolume*) const 225 {} 152 {} 226 153 >> 154 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 155 227 G4Material* 156 G4Material* 228 CellParameterisation::ComputeMaterial(const G4 157 CellParameterisation::ComputeMaterial(const G4int copyNo, 229 G4VPhysi << 158 G4VPhysicalVolume* physVol, 230 const G4 << 159 const G4VTouchable*) 231 { 160 { 232 if( fMaterial[copyNo] == 2 ) // fMaterial 161 if( fMaterial[copyNo] == 2 ) // fMaterial 2 is nucleus 233 { 162 { 234 if( fMass[copyNo] == 1 ) 163 if( fMass[copyNo] == 1 ) 235 { 164 { 236 physVol->GetLogicalVolume()->SetVisAttri << 165 physVol->SetName("physicalNucleus"); 237 return fNucleusMaterial1; << 166 physVol->GetLogicalVolume()->SetVisAttributes( fNucleusAttributes1 ); >> 167 return fNucleusMaterial1; 238 } 168 } 239 if( fMass[copyNo] == 2 ) 169 if( fMass[copyNo] == 2 ) 240 { 170 { 241 physVol->GetLogicalVolume()->SetVisAttri << 171 physVol->SetName("physicalNucleus"); 242 return fNucleusMaterial2; << 172 physVol->GetLogicalVolume()->SetVisAttributes( fNucleusAttributes2 ); >> 173 return fNucleusMaterial2; 243 } 174 } 244 if( fMass[copyNo] == 3 ) 175 if( fMass[copyNo] == 3 ) 245 { 176 { 246 physVol->GetLogicalVolume()->SetVisAttri << 177 physVol->SetName("physicalNucleus"); 247 return fNucleusMaterial3; << 178 physVol->GetLogicalVolume()->SetVisAttributes( fNucleusAttributes3 ); >> 179 return fNucleusMaterial3; 248 } 180 } 249 } 181 } 250 182 251 else if( fMaterial[copyNo] == 1 ) // fMate 183 else if( fMaterial[copyNo] == 1 ) // fMaterial 1 is cytoplasm 252 { 184 { 253 if( fMass[copyNo] == 1 ) 185 if( fMass[copyNo] == 1 ) 254 { 186 { 255 physVol->GetLogicalVolume()->SetVisAttri << 187 physVol->SetName("physicalCytoplasm"); 256 return fCytoplasmMaterial1; << 188 physVol->GetLogicalVolume()->SetVisAttributes( fCytoplasmAttributes1 ); >> 189 return fCytoplasmMaterial1; 257 } 190 } 258 if( fMass[copyNo] == 2 ) 191 if( fMass[copyNo] == 2 ) 259 { 192 { 260 // nucleoli so taken as nucleus ! << 193 physVol->SetName("physicalNucleus"); // nucleoli 261 physVol->GetLogicalVolume()->SetVisAttri << 194 physVol->GetLogicalVolume()->SetVisAttributes( fCytoplasmAttributes2 ); 262 return fCytoplasmMaterial2; << 195 return fCytoplasmMaterial2; 263 } 196 } 264 if( fMass[copyNo] == 3 ) 197 if( fMass[copyNo] == 3 ) 265 { 198 { 266 physVol->GetLogicalVolume()->SetVisAttri << 199 physVol->SetName("physicalCytoplasm"); 267 return fCytoplasmMaterial3; << 200 physVol->GetLogicalVolume()->SetVisAttributes( fCytoplasmAttributes3 ); >> 201 return fCytoplasmMaterial3; 268 } 202 } 269 } 203 } 270 204 271 return physVol->GetLogicalVolume()->GetMat 205 return physVol->GetLogicalVolume()->GetMaterial(); 272 } 206 } 273 207