Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
examples/extended/medical/dna/neuron/src/DetectorConstruction.cc
이 파일의 문서화 페이지로 가기
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 // and papers
31 // M. Batmunkh et al. J Radiat Res Appl Sci 8 (2015) 498-507
32 // O. Belov et al. Physica Medica 32 (2016) 1510-1520
33 // The Geant4-DNA web site is available at http://geant4-dna.org
34 //
35 // -------------------------------------------------------------------
36 // November 2016
37 // -------------------------------------------------------------------
38 //
39 // $ID$
42 
43 #include "DetectorConstruction.hh"
44 #include "G4SystemOfUnits.hh"
45 #include "G4Region.hh"
46 #include "G4ProductionCuts.hh"
47 #include "G4PhysicalConstants.hh"
48 #include "G4Colour.hh"
49 #include "G4VisAttributes.hh"
50 #include "G4RotationMatrix.hh"
51 #include <algorithm>
52 #include <iostream>
53 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55 
58  fpDefaultMaterial(0), fpWaterMaterial(0),
59  fpRegion(0), fCheckOverlaps(false)
60 {
61 
62 }
63 
64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
65 
67 {
68 
69 }
70 
71 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
72 
74 {
75 
76  // load Neuron positions and obtain parameters!
78 
80  return ConstructDetector();
81 
82 }
83 
84 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
85 
87 {
88  // Water is defined from NIST material database
90  G4Material * H2O = man->FindOrBuildMaterial("G4_WATER");
91  // Default materials in setup.
92  fpWaterMaterial = H2O;
93  G4Material * Vacuum = man->FindOrBuildMaterial("G4_Galactic");
94  //G4Material * Air = man->FindOrBuildMaterial("G4_AIR");
95  fpDefaultMaterial = Vacuum;
96 }
97 
98 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
99 
101 {
102  G4cout <<" ---- Begin of Neuron Construction! ---- "
103  <<"\n"<<" =========================================================="<<G4endl;
104 
105  // ===============================================
106  // WORLD VOLUME - filled by default material
107  // ===============================================
108 
109  // Dimensions of world volume are calculated as overall dimensions of neuron!
110 
112  worldSizeX = 1.0*fNeuronLoadParamz->GetdiagnlLength()*um;
113 
114  if (!worldSizeX)
115  {
116  worldSizeX = 10.*cm;
117  }
118 
119  G4double worldSizeY = worldSizeX;
120  G4double worldSizeZ = worldSizeX;
121  G4cout << " Side length of word volume is calculated : "
122  << worldSizeX/um <<" um"<< G4endl;
123  G4VSolid* worldS = new G4Box("World", //its name
124  worldSizeX/2, worldSizeY/2, worldSizeZ/2); //its size
125 
126  G4LogicalVolume* worldLV = new G4LogicalVolume(worldS, //its solid
127  fpDefaultMaterial, //its material
128  "World"); //its name
129 
130  // Visualization attributes
131  G4VisAttributes* worldVisAtt =
132  new G4VisAttributes(G4Colour(0.5,0.5,0.5,0.1)); //Gray
133  //worldVisAtt->SetForceSolid(true);
134  worldVisAtt->SetVisibility(true);
135  worldLV->SetVisAttributes(worldVisAtt);
136 
137 
138  G4VPhysicalVolume* worldPV = new G4PVPlacement(0, //no rotation
139  G4ThreeVector(), //at (0,0,0)
140  "World", //its name
141  worldLV, //its logical volume
142  0, //its mother volume
143  false, //no boolean operation
144  0, //copy number
145  true); // checking overlaps forced to YES
146 
147  // ===============================================
148  // HOMOGENEOUS MEDIUM - LARGE SPHERE VOLUME
149  // ===============================================
150 
151  // Radius of water sphere calculated as overall dimensions of neuron.
154  G4double RadiusMedium = fNeuronLoadParamz->GetdiagnlLength()*um / 2.;
155  G4cout << " Radius of homogeneous medium is calculated : "
156  << RadiusMedium/um <<" um"<< G4endl;
157  G4VSolid* mediumS = new G4Orb("Medium", RadiusMedium);
158  //G4VSolid* mediumS = new G4Box("Medium", RadiusMedium*um,
159  // RadiusMedium*um,RadiusMedium*um);
160 
161  G4LogicalVolume* mediumLV =
162  new G4LogicalVolume(mediumS, fpWaterMaterial, "Medium");
163 
164  // Visualization attributes
165  G4VisAttributes* mediumVisAtt =
166  new G4VisAttributes(G4Colour(0.0,1.0,0.0,0.02)); //Green
167  //mediumVisAtt->SetForceSolid(true);
168  //mediumVisAtt->SetForceWireframe (true);
169  mediumVisAtt->SetForceLineSegmentsPerCircle(180);
170  mediumVisAtt->SetVisibility(true);
171  mediumLV->SetVisAttributes(mediumVisAtt);
172 
173  G4VPhysicalVolume* mediumPV = new G4PVPlacement(0,
174  G4ThreeVector(),
175  "Medium",
176  mediumLV,
177  worldPV,
178  false,
179  0,
181 
182  // ===============================================
183  // TARGET - BOUNDING SLICE including NEURON
184  // ===============================================
185 
186  // Dimensions of bounding slice volume defined as overall measure of neuron
187 
188  G4double TargetSizeX = fNeuronLoadParamz->GetwidthB()*um;
189  G4double TargetSizeY = fNeuronLoadParamz->GetheightB()*um;
190  G4double TargetSizeZ = fNeuronLoadParamz->GetdepthB()*um;
192  G4cout << " Overall dimensions (um) of neuron morphology : " << "\n"
193  << '\t'<< " width = " <<TargetSizeX/um<< " height = " <<
194  TargetSizeY/um
195  << " depth = " <<TargetSizeZ/um<<G4endl;
196 
197  G4cout << " Volume (um3), surface (um2) and mass (ug) of Bounding Slice are"
198  << " calculated : " << "\n"
199  << '\t'<<fNeuronLoadParamz->GetTotVolSlice()/std::pow(um,3)<<"; "<<'\t'
201  <<"; "<<'\t'<<fNeuronLoadParamz->GetTotMassSlice()*1e6/g<< "\n "<<G4endl;
202 
203  G4Box* boundingS = new G4Box("BoundingSlice",
204  TargetSizeX/2.,TargetSizeY/2.,TargetSizeZ/2.);
205 
206  G4LogicalVolume* boundingLV =
207  new G4LogicalVolume(boundingS,fpWaterMaterial, "BoundingSlice");
208 
209  // Visualization attributes with opacity!
210  G4VisAttributes* TargetVisAtt =
211  new G4VisAttributes(G4Colour(1.0,1.0,1.0,0.1));
212  TargetVisAtt->SetForceSolid(true);
213  TargetVisAtt->SetVisibility(true);
214  boundingLV->SetVisAttributes(TargetVisAtt);
215  //G4VPhysicalVolume* boundingPV =
216  new G4PVPlacement(0,
217  G4ThreeVector(),
218  "BoundingSlice",
219  boundingLV,
220  mediumPV,
221  false,
222  0,
223  fCheckOverlaps);
224 
225  // ===============================================
226  // NEURON MORPHOLOGY
227  // ===============================================
228 
229  G4cout << " Volume (um3), surface (um2) and mass(ug) of Neuron "
230  << "are calculated : "<< "\n"
231  << '\t'<<fNeuronLoadParamz->GetTotVolNeuron()/std::pow(um,3)<<"; "<<'\t'
233  <<"; "<<'\t'<<fNeuronLoadParamz->GetTotMassNeuron()*1e6/g<<G4endl;
235  G4cout << " Total number of compartments into Neuron : "
237  G4cout << " Shift values (um) for Neuron translation are calculated : "
238  << "\n"
239  << '\t' << " shiftX = " <<fNeuronLoadParamz->GetshiftX()<< " shiftY = "
241  << " shiftZ = " <<fNeuronLoadParamz->GetshiftZ()<< "\n"<< G4endl;
242 
243  // Soma in Violet with opacity // 0.85,0.44,0.84
245  fSomaColour->SetColour(G4Colour(G4Colour(22/255. , 200/255. , 30/255.)));
246  fSomaColour->SetForceSolid(true); // true
247  fSomaColour->SetVisibility(true);
248 
249  // Dendrites in Dark-Blue
251  fDendColour->SetColour(G4Colour(G4Colour(0.0, 0.0, 0.5)));
252  fDendColour->SetForceSolid(true);
253  //fDendColour->SetVisibility(true);
254 
255  // Axon in Maroon
257  fAxonColour->SetColour(G4Colour(G4Colour(0.5, 0.0, 0.0)));
258  fAxonColour->SetForceSolid(true);
259  fAxonColour->SetVisibility(true);
260 
261  // Spines in Dark-Green
263  fSpineColour->SetColour(G4Colour(G4Colour(0.0 , 100/255. , 0.0)));
265  fSpineColour->SetVisibility(true);
266 
267  // Whole neuron in semitransparent navy blue
269  fNeuronColour->SetColour(G4Colour(G4Colour(0.0,0.4,0.8,0.9)));
272 
273  // Placement volumes: G4examples/extended/parameterisations/gflash
274 
275  // =======================================================================
276  // Structure-1: Soma
277 
278  // Create Target G4Region and add logical volume
279  // Active Geant4-DNA processes in this region
280  fpRegion = new G4Region("Soma");
281  G4ProductionCuts* cuts = new G4ProductionCuts();
282  G4double defCut = 1*nanometer;
283  cuts->SetProductionCut(defCut,"gamma");
284  cuts->SetProductionCut(defCut,"e-");
285  cuts->SetProductionCut(defCut,"e+");
286  cuts->SetProductionCut(defCut,"proton");
287 
293  {
294  G4cout <<" ---- Soma not found! ---- "<< G4endl;
295  }
296  else
297  {
298  G4cout <<" ---- Soma for construction: ---- "<< G4endl;
299  G4cout << " Total number of compartments into Soma : "
301  for (G4int i=0; i<fNeuronLoadParamz->GetnbSomacomp() ; i++)
302  {
303  fsomaS [i] = new G4Orb("Soma", fNeuronLoadParamz->GetRadSomacomp(i)* um);
304  //fsomaS [i] = new G4Ellipsoid("Soma", Ra *um, Rb *um, Rc *um, 0,0) ;
305  // you can change parameters of Soma with a single compartment
306  fsomaLV[i] = new G4LogicalVolume(fsomaS[i], fpWaterMaterial, "Soma");
307  fsomaLV[i] ->SetVisAttributes(fSomaColour);
308  fsomaPV[i] = new G4PVPlacement(
309  0, // no rotation
314  fsomaLV[i],
315  "Soma",
316  boundingLV,
317  false,
318  i);
322  fpRegion->AddRootLogicalVolume(fsomaLV[i]);
323 
324  }
325  }
326 
327  // =======================================================================
328  // Structure-2: Dendrites
329 
330  // Active Geant4-DNA processes in this region
331  fpRegion = new G4Region("Dendrites");
332 
340  {
341  G4cout <<" ---- Dendrites not found! ---- "<< G4endl;
342  }
343  else
344  {
345  G4cout <<" ---- Dendrites for construction: ---- "<< G4endl;
346  G4cout << " Total number of compartments into Dendrites : "
348  for (G4int i=1; i<fNeuronLoadParamz->GetnbDendritecomp() ; i++)
349  {
350  fdendriteS [i] = new G4Tubs( "Dendrites",
353  0., 2.*pi );
355  "Dendrites");
356  fdendriteLV[i] ->SetVisAttributes(fDendColour);
357 
358  fdendritePV[i] = new G4PVPlacement(
359  // rot, // rotation checking with function ComputeTransformation!
361  GetRotDendcomp(i), // RotationMatrix with Inverse
366  fdendriteLV[i],
367  "Dendrites",
368  boundingLV,
369  false,
370  i);
376  fpRegion->AddRootLogicalVolume(fdendriteLV[i]);
377 
378  }
379  }
380 
381  // =======================================================================
382  // Structure-3: Axon
383 
384  // Active Geant4-DNA processes in this region
385  fpRegion = new G4Region("Axon");
386 
393  {
394  G4cout <<" ---- Axon not found! ---- "<< G4endl;
395  }
396  else
397  {
398  G4cout <<" ---- Axon for construction: ---- "<< G4endl;
399  G4cout << " Total number of compartments into Axon : "
401  for (G4int i=1; i< fNeuronLoadParamz->GetnbAxoncomp() ; i++)
402  {
403  faxonS [i] = new G4Tubs( "Axon",
406  0., 2.*pi );
407  faxonLV[i] = new G4LogicalVolume(faxonS[i], fpWaterMaterial, "Axon");
408  faxonLV[i] ->SetVisAttributes(fAxonColour);
410  fNeuronLoadParamz->GetRotAxoncomp(i), // RotationMatrix with Inverse
415  faxonLV[i],
416  "Axon",
417  boundingLV,
418  false,
419  i);
424  fpRegion->AddRootLogicalVolume(faxonLV[i]);
425 
426  }
427  }
428  // =======================================================================
429  // Structure-4: Spines
431  {
432  G4cout <<" ---- Spines not found! ---- "<< G4endl;
433  }
434  else
435  {
436  G4cout <<" ---- Spines for construction: ---- "<< G4endl;
437  G4cout << " Total number of compartments into Spines : "
439  }
440 
441  G4cout <<"\n ---- End of Neuron Construction! ---- "
442  << "\n ========================================================== \n"
443  << G4endl;
444 
445  // =======================================================================
446  // Active Geant4-DNA processes in BoundingSlice with whole neuron structure
447  //fpRegion = new G4Region("BoundingSlice");
448  //fpRegion->SetProductionCuts(cuts);
449  // fpRegion->AddRootLogicalVolume(boundingLV);
450 
451  return worldPV;
452 }
void AddRootLogicalVolume(G4LogicalVolume *lv)
Definition: G4Region.cc:290
void SetProductionCut(G4double cut, G4int index=-1)
CLHEP::Hep3Vector G4ThreeVector
G4double GetDistADendSoma(G4int i)
HepGeom::Transform3D G4Transform3D
Definition: G4Tubs.hh:85
#define G4endl
Definition: G4ios.hh:61
double z() const
G4RotationMatrix GetRotAxoncomp(G4int i)
G4double GetHeightAxoncomp(G4int i)
G4double GetMassSomacomp(G4int i)
void SetProductionCuts(G4ProductionCuts *cut)
G4double GetMassDendcomp(G4int i)
static constexpr double um
Definition: G4SIunits.hh:113
static constexpr double g
Definition: G4SIunits.hh:183
void SetForceLineSegmentsPerCircle(G4int nSegments)
double G4double
Definition: G4Types.hh:76
Definition: G4Box.hh:64
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
Definition: G4Orb.hh:62
void SetVisAttributes(const G4VisAttributes *pVA)
G4double GetDistBDendSoma(G4int i)
G4ThreeVector GetPosDendcomp(G4int i)
void SetForceSolid(G4bool=true)
G4double GetRadDendcomp(G4int i)
void SetVisibility(G4bool=true)
G4double GetRadSomacomp(G4int i)
int G4int
Definition: G4Types.hh:78
G4double GetDistAxonsoma(G4int i)
G4double GetRadAxoncomp(G4int i)
static constexpr double cm
Definition: G4SIunits.hh:119
G4GLOB_DLL std::ostream G4cout
double x() const
G4ThreeVector GetPosAxoncomp(G4int i)
void SetColour(const G4Colour &)
static constexpr double pi
Definition: G4SIunits.hh:75
G4double GetMassAxoncomp(G4int i)
double y() const
G4ThreeVector GetPosSomacomp(G4int i)
static constexpr double nanometer
Definition: G4SIunits.hh:101
static G4NistManager * Instance()
G4double GetHeightDendcomp(G4int i)