Geant4_10
CellParameterisation.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 // This example is provided by the Geant4-DNA collaboration
27 // Any report or published results obtained using the Geant4-DNA software
28 // shall cite the following Geant4-DNA collaboration publication:
29 // Med. Phys. 37 (2010) 4692-4708
30 // The Geant4-DNA web site is available at http://geant4-dna.org
31 //
32 // If you use this example, please cite the following publication:
33 // Rad. Prot. Dos. 133 (2009) 2-11
34 
35 #include "CellParameterisation.hh"
36 #include "G4LogicalVolume.hh"
37 
38 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
39 
41 (G4int NoBoxes, G4float DimBoxX, G4float DimBoxY, G4float DimBoxZ,
42  G4Material * nucleus1, G4Material * cytoplasm1,
43  G4Material * nucleus2, G4Material * cytoplasm2,
44  G4Material * nucleus3, G4Material * cytoplasm3
45  )
46 {
47  fNucleusMaterial1 = nucleus1;
48  fCytoplasmMaterial1 = cytoplasm1;
49  fNucleusMaterial2 = nucleus2;
50  fCytoplasmMaterial2 = cytoplasm2;
51  fNucleusMaterial3 = nucleus3;
52  fCytoplasmMaterial3 = cytoplasm3;
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 
64  G4int shiftX, shiftY, shiftZ;
65  G4float x,y,z,mat,den,tmp,sizeZ;
66 
67  ncols=0; nlines=0;
68 
69  // READ PHANTOM
70 
71  FILE *fMap;
72  fMap = fopen("phantom.dat","r");
73 
74  while (1)
75  {
76  if (nlines >= 0 && nlines <=1 ) ncols = fscanf(fMap,"%f %f %f",&tmp,&tmp,&sizeZ);
77  if (nlines == 2) ncols = fscanf(fMap,"%i %i %i",&shiftX,&shiftY,&shiftZ); // VOXEL SHIFT IN Z ASSUMED TO BE NEGATIVE
78  if (nlines == 3) ncols = fscanf(fMap,"%f %f %f",&tmp,&tmp,&tmp);
79  if (nlines == 4) ncols = fscanf(fMap,"%f %f %f",&tmp,&tmp,&tmp);
80  if (nlines > 4) ncols = fscanf(fMap,"%f %f %f %f %f %f",&x,&y,&z,&mat,&den,&tmp);
81  if (ncols < 0) break;
82 
83  G4ThreeVector v(x+shiftX,y+shiftY,z-1500/sizeZ-shiftZ); // VOXEL SHIFT IN ORDER TO CENTER PHANTOM
84 
85  if (nlines>4)
86  {
87  fMapCell[nlines-5]=v;
88  fMaterial[nlines-5]=mat;
89  fMass[nlines-5]=den;
90  }
91 
92  nlines++;
93  }
94  fclose(fMap);
95 
96  // NUCLEUS IN GREEN
97 
98  fNucleusAttributes1 = new G4VisAttributes;
99  fNucleusAttributes1->SetColour(G4Colour(0,.8,0));
100  fNucleusAttributes1->SetForceSolid(false);
101 
102  fNucleusAttributes2 = new G4VisAttributes;
103  fNucleusAttributes2->SetColour(G4Colour(0,.9,0));
104  fNucleusAttributes2->SetForceSolid(false);
105 
106  fNucleusAttributes3 = new G4VisAttributes;
107  fNucleusAttributes3->SetColour(G4Colour(0,1,0));
108  fNucleusAttributes3->SetForceSolid(false);
109 
110  // CYTOPLASM IN RED
111 
112  fCytoplasmAttributes1 = new G4VisAttributes;
113  fCytoplasmAttributes1->SetColour(G4Colour(1,0,0));
114  fCytoplasmAttributes1->SetForceSolid(false);
115 
116  fCytoplasmAttributes2 = new G4VisAttributes; // nucleoli in yellow
117  fCytoplasmAttributes2->SetColour(G4Colour(1.,1.,0));
118  fCytoplasmAttributes2->SetForceSolid(false);
119 
120  fCytoplasmAttributes3 = new G4VisAttributes;
121  fCytoplasmAttributes3->SetColour(G4Colour(1,0,0));
122  fCytoplasmAttributes3->SetForceSolid(false);
123 }
124 
125 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
126 
128 {
129  delete[] fMapCell;
130  delete[] fMaterial;
131  delete[] fMass;
132 }
133 
134 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
135 
137 (const G4int copyNo, G4VPhysicalVolume* physVol) const
138 {
140  origin(
141  fMapCell[copyNo].x()*fDimCellBoxX*2,
142  fMapCell[copyNo].y()*fDimCellBoxY*2,
143  fMapCell[copyNo].z()*fDimCellBoxZ*2);
144 
145  physVol->SetTranslation(origin);
146 }
147 
148 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
149 
151 (G4Box& /*trackerChamber*/, const G4int /*copyNo*/, const G4VPhysicalVolume*) const
152 {}
153 
154 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
155 
156 G4Material*
158  G4VPhysicalVolume* physVol,
159  const G4VTouchable*)
160 {
161  if( fMaterial[copyNo] == 2 ) // fMaterial 2 is nucleus
162  {
163  if( fMass[copyNo] == 1 )
164  {
165  physVol->SetName("physicalNucleus");
166  physVol->GetLogicalVolume()->SetVisAttributes( fNucleusAttributes1 );
167  return fNucleusMaterial1;
168  }
169  if( fMass[copyNo] == 2 )
170  {
171  physVol->SetName("physicalNucleus");
172  physVol->GetLogicalVolume()->SetVisAttributes( fNucleusAttributes2 );
173  return fNucleusMaterial2;
174  }
175  if( fMass[copyNo] == 3 )
176  {
177  physVol->SetName("physicalNucleus");
178  physVol->GetLogicalVolume()->SetVisAttributes( fNucleusAttributes3 );
179  return fNucleusMaterial3;
180  }
181  }
182 
183  else if( fMaterial[copyNo] == 1 ) // fMaterial 1 is cytoplasm
184  {
185  if( fMass[copyNo] == 1 )
186  {
187  physVol->SetName("physicalCytoplasm");
188  physVol->GetLogicalVolume()->SetVisAttributes( fCytoplasmAttributes1 );
189  return fCytoplasmMaterial1;
190  }
191  if( fMass[copyNo] == 2 )
192  {
193  physVol->SetName("physicalNucleus"); // nucleoli
194  physVol->GetLogicalVolume()->SetVisAttributes( fCytoplasmAttributes2 );
195  return fCytoplasmMaterial2;
196  }
197  if( fMass[copyNo] == 3 )
198  {
199  physVol->SetName("physicalCytoplasm");
200  physVol->GetLogicalVolume()->SetVisAttributes( fCytoplasmAttributes3 );
201  return fCytoplasmMaterial3;
202  }
203  }
204 
205  return physVol->GetLogicalVolume()->GetMaterial();
206 }
Float_t den
Definition: plot.C:37
void SetColour(const G4Colour &)
Float_t tmp
Definition: plot.C:37
G4Material * GetMaterial() const
Definition: G4Box.hh:63
float G4float
Definition: G4Types.hh:77
G4Material * ComputeMaterial(const G4int copyNo, G4VPhysicalVolume *physVol, const G4VTouchable *)
void ComputeTransformation(const G4int copyNo, G4VPhysicalVolume *physVol) const
void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
tuple x
Definition: test.py:50
void SetName(const G4String &pName)
int G4int
Definition: G4Types.hh:78
Float_t mat
Definition: plot.C:40
Double_t y
Definition: plot.C:279
void SetTranslation(const G4ThreeVector &v)
tuple v
Definition: test.py:18
G4LogicalVolume * GetLogicalVolume() const
tuple z
Definition: test.py:28
ncols
Definition: plot.C:54
fclose(fp)
nlines
void SetVisAttributes(const G4VisAttributes *pVA)
CellParameterisation(G4int NoBoxes, G4float DimBoxX, G4float DimBoxY, G4float DimBoxZ, G4Material *nucleus1, G4Material *cytoplasm1, G4Material *nucleus2, G4Material *cytoplasm2, G4Material *nucleus3, G4Material *cytoplasm3)