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[ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/extended/medical/dna/neuron/src/DetectorConstruction.cc (Version 11.3.0) and /examples/extended/medical/dna/neuron/src/DetectorConstruction.cc (Version 9.6)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26 // This example is provided by the Geant4-DNA     
 27 // Any report or published results obtained us    
 28 // shall cite the following Geant4-DNA collabo    
 29 // Med. Phys. 37 (2010) 4692-4708                 
 30 // and papers                                     
 31 // M. Batmunkh et al. J Radiat Res Appl Sci 8     
 32 // O. Belov et al. Physica Medica 32 (2016) 15    
 33 // The Geant4-DNA web site is available at htt    
 34 //                                                
 35 // -------------------------------------------    
 36 // November 2016                                  
 37 // -------------------------------------------    
 38 //                                                
 39 /// \file DetectorConstruction.cc                 
 40 /// \brief Implementation of the DetectorConst    
 41                                                   
 42 #include "DetectorConstruction.hh"                
 43                                                   
 44 #include "G4Colour.hh"                            
 45 #include "G4PhysicalConstants.hh"                 
 46 #include "G4ProductionCuts.hh"                    
 47 #include "G4Region.hh"                            
 48 #include "G4RotationMatrix.hh"                    
 49 #include "G4SystemOfUnits.hh"                     
 50 #include "G4VisAttributes.hh"                     
 51                                                   
 52 #include <algorithm>                              
 53 #include <iostream>                               
 54                                                   
 55 //....oooOO0OOooo........oooOO0OOooo........oo    
 56                                                   
 57 DetectorConstruction::DetectorConstruction()      
 58 {                                                 
 59   fNeuronLoadParamz = new NeuronLoadDataFile()    
 60   DefineMaterials();                              
 61 }                                                 
 62                                                   
 63 //....oooOO0OOooo........oooOO0OOooo........oo    
 64                                                   
 65 DetectorConstruction::~DetectorConstruction()     
 66 {                                                 
 67   delete fNeuronLoadParamz;                       
 68 }                                                 
 69                                                   
 70 //....oooOO0OOooo........oooOO0OOooo........oo    
 71                                                   
 72 void DetectorConstruction::DefineMaterials()      
 73 {                                                 
 74   // Water is defined from NIST material datab    
 75   G4NistManager* man = G4NistManager::Instance    
 76   fpWaterMaterial = man->FindOrBuildMaterial("    
 77   fpWorldMaterial = man->FindOrBuildMaterial("    
 78 }                                                 
 79                                                   
 80 //....oooOO0OOooo........oooOO0OOooo........oo    
 81                                                   
 82 G4VPhysicalVolume* DetectorConstruction::Const    
 83 {                                                 
 84   G4cout << " ---- Begin of Neuron Constructio    
 85          << "\n"                                  
 86          << " ================================    
 87                                                   
 88   // =========================================    
 89   // WORLD VOLUME - filled by default material    
 90   // =========================================    
 91                                                   
 92   // Dimensions of world volume are calculated    
 93                                                   
 94   G4double worldSizeX;                            
 95   worldSizeX = fNeuronLoadParamz->GetdiagnlLen    
 96                                                   
 97   if (worldSizeX <= 0.0) {                        
 98     worldSizeX = 10. * cm;                        
 99   }                                               
100                                                   
101   G4double worldSizeY = worldSizeX;               
102   G4double worldSizeZ = worldSizeX;               
103   G4cout << " Side length of word volume is ca    
104   G4VSolid* worldS = new G4Box("World", worldS    
105                                                   
106   G4LogicalVolume* worldLV = new G4LogicalVolu    
107                                                   
108   // Visualization attributes                     
109   G4VisAttributes* worldVisAtt = new G4VisAttr    
110   worldVisAtt->SetVisibility(true);               
111   worldLV->SetVisAttributes(worldVisAtt);         
112                                                   
113   G4VPhysicalVolume* worldPV = new G4PVPlaceme    
114                                                   
115                                                   
116                                                   
117                                                   
118                                                   
119                                                   
120                                                   
121                                                   
122   // =========================================    
123   // HOMOGENEOUS MEDIUM - LARGE SPHERE VOLUME     
124   // =========================================    
125                                                   
126   // Radius of water sphere calculated as over    
127   fTotMassMedium = fNeuronLoadParamz->GetTotMa    
128   fTotSurfMedium = fNeuronLoadParamz->GetTotSu    
129   G4double RadiusMedium = fNeuronLoadParamz->G    
130   G4cout << " Radius of homogeneous medium is     
131          << G4endl;                               
132   G4VSolid* mediumS = new G4Orb("Medium", Radi    
133                                                   
134   G4LogicalVolume* mediumLV = new G4LogicalVol    
135                                                   
136   // Visualization attributes                     
137   G4VisAttributes* mediumVisAtt = new G4VisAtt    
138   // mediumVisAtt->SetForceSolid(true);           
139   // mediumVisAtt->SetForceWireframe (true);      
140   mediumVisAtt->SetForceLineSegmentsPerCircle(    
141   mediumVisAtt->SetVisibility(true);              
142   mediumLV->SetVisAttributes(mediumVisAtt);       
143                                                   
144   G4VPhysicalVolume* mediumPV =                   
145     new G4PVPlacement(0, G4ThreeVector(), "Med    
146                                                   
147   // =========================================    
148   // TARGET - BOUNDING SLICE including NEURON     
149   // =========================================    
150                                                   
151   // Dimensions of bounding slice volume defin    
152                                                   
153   G4double TargetSizeX = fNeuronLoadParamz->Ge    
154   G4double TargetSizeY = fNeuronLoadParamz->Ge    
155   G4double TargetSizeZ = fNeuronLoadParamz->Ge    
156   fTotMassSlice = fNeuronLoadParamz->GetTotMas    
157   G4cout << " Overall dimensions (um) of neuro    
158          << "\n"                                  
159          << '\t' << " width = " << TargetSizeX    
160          << " depth = " << TargetSizeZ / um <<    
161                                                   
162   G4cout << " Volume (um3), surface (um2) and     
163          << " calculated : "                      
164          << "\n"                                  
165          << '\t' << fNeuronLoadParamz->GetTotV    
166          << fNeuronLoadParamz->GetTotSurfSlice    
167          << fNeuronLoadParamz->GetTotMassSlice    
168                                                   
169   G4Box* boundingS =                              
170     new G4Box("BoundingSlice", TargetSizeX / 2    
171                                                   
172   G4LogicalVolume* boundingLV = new G4LogicalV    
173                                                   
174   // Visualization attributes with opacity!       
175   G4VisAttributes* TargetVisAtt = new G4VisAtt    
176   TargetVisAtt->SetForceSolid(true);              
177   TargetVisAtt->SetVisibility(true);              
178   boundingLV->SetVisAttributes(TargetVisAtt);     
179   new G4PVPlacement(0, G4ThreeVector(), "Bound    
180                     fCheckOverlaps);              
181                                                   
182   // =========================================    
183   // NEURON MORPHOLOGY                            
184   // =========================================    
185                                                   
186   G4cout << " Volume (um3), surface (um2) and     
187          << "are calculated : "                   
188          << "\n"                                  
189          << '\t' << fNeuronLoadParamz->GetTotV    
190          << fNeuronLoadParamz->GetTotSurfNeuro    
191          << fNeuronLoadParamz->GetTotMassNeuro    
192   fTotMassNeuron = fNeuronLoadParamz->GetTotMa    
193   G4cout << " Total number of compartments int    
194          << G4endl;                               
195   G4cout << " Shift values (um) for Neuron tra    
196          << "\n"                                  
197          << '\t' << " shiftX = " << fNeuronLoa    
198          << " shiftY = " << fNeuronLoadParamz-    
199          << " shiftZ = " << fNeuronLoadParamz-    
200                                                   
201   // Soma in Violet with opacity   // 0.85,0.4    
202   fSomaColour = new G4VisAttributes;              
203   fSomaColour->SetColour(G4Colour(G4Colour(22     
204   fSomaColour->SetForceSolid(true);  // true      
205   fSomaColour->SetVisibility(true);               
206                                                   
207   // Dendrites in Dark-Blue                       
208   fDendColour = new G4VisAttributes;              
209   fDendColour->SetColour(G4Colour(G4Colour(0.0    
210   fDendColour->SetForceSolid(true);               
211   // fDendColour->SetVisibility(true);            
212                                                   
213   // Axon in Maroon                               
214   fAxonColour = new G4VisAttributes;              
215   fAxonColour->SetColour(G4Colour(G4Colour(0.5    
216   fAxonColour->SetForceSolid(true);               
217   fAxonColour->SetVisibility(true);               
218                                                   
219   // Spines in Dark-Green                         
220   fSpineColour = new G4VisAttributes;             
221   fSpineColour->SetColour(G4Colour(G4Colour(0.    
222   fSpineColour->SetForceSolid(true);              
223   fSpineColour->SetVisibility(true);              
224                                                   
225   // Whole neuron in semitransparent navy blue    
226   fNeuronColour = new G4VisAttributes;            
227   fNeuronColour->SetColour(G4Colour(G4Colour(0    
228   fNeuronColour->SetForceSolid(true);             
229   fNeuronColour->SetVisibility(true);             
230                                                   
231   // Placement volumes: G4examples/extended/pa    
232                                                   
233   // =========================================    
234   // Structure-1: Soma                            
235                                                   
236   // Create Target G4Region and add logical vo    
237   // Active Geant4-DNA processes in this regio    
238   fpRegion = new G4Region("Soma");                
239   G4ProductionCuts* cuts = new G4ProductionCut    
240   G4double defCut = 1 * nanometer;                
241   cuts->SetProductionCut(defCut, "gamma");        
242   cuts->SetProductionCut(defCut, "e-");           
243   cuts->SetProductionCut(defCut, "e+");           
244   cuts->SetProductionCut(defCut, "proton");       
245   fpRegion->SetProductionCuts(cuts);              
246   G4ThreeVector shift(fNeuronLoadParamz->Getsh    
247                       fNeuronLoadParamz->Getsh    
248                                                   
249   G4int n = fNeuronLoadParamz->GetnbSomacomp()    
250   if (n <= 0) {                                   
251     G4cout << " ---- Soma not found! ---- " <<    
252   }                                               
253   else {                                          
254     G4cout << " ---- Soma for construction: --    
255     G4cout << " Total number of compartments i    
256     fnbSomacomp = n;                              
257     fMassSomaTot = fNeuronLoadParamz->GetMassS    
258     fMassSomacomp.resize(n, 0.0);                 
259     fPosSomacomp.resize(n);                       
260     fsomaS.resize(n, nullptr);                    
261     fsomaLV.resize(n, nullptr);                   
262     fsomaPV.resize(n, nullptr);                   
263                                                   
264     for (G4int i = 0; i < n; ++i) {               
265       fsomaS[i] = new G4Orb("Soma", fNeuronLoa    
266       // you can change parameters of Soma wit    
267       G4ThreeVector pos = (fNeuronLoadParamz->    
268       fsomaLV[i] = new G4LogicalVolume(fsomaS[    
269       fsomaLV[i]->SetVisAttributes(fSomaColour    
270       fsomaPV[i] = new G4PVPlacement(0,  // no    
271                                      pos, fsom    
272       fMassSomacomp[i] = fNeuronLoadParamz->Ge    
273       fPosSomacomp[i] = fNeuronLoadParamz->Get    
274       fpRegion->AddRootLogicalVolume(fsomaLV[i    
275     }                                             
276   }                                               
277                                                   
278   // =========================================    
279   // Structure-2: Dendrites                       
280                                                   
281   n = fNeuronLoadParamz->GetnbDendritecomp();     
282   if (n <= 0) {                                   
283     G4cout << " ---- Dendrites not found! ----    
284   }                                               
285   else {                                          
286     fnbDendritecomp = n;                          
287     G4cout << " ---- Dendrites for constructio    
288     G4cout << " Total number of compartments i    
289                                                   
290     // Active Geant4-DNA processes in this reg    
291     auto region = new G4Region("Dendrites");      
292     region->SetProductionCuts(cuts);              
293                                                   
294     fMassDendTot = fNeuronLoadParamz->GetMassD    
295     fMassDendcomp.resize(n, 0.0);                 
296     fDistADendSoma.resize(n, 0.0);                
297     fDistBDendSoma.resize(n, 0.0);                
298     fPosDendcomp.resize(n);                       
299     fdendriteS.resize(n, nullptr);                
300     fdendriteLV.resize(n, nullptr);               
301     fdendritePV.resize(n, nullptr);               
302     for (G4int i = 1; i < n; ++i) {               
303       fdendriteS[i] = new G4Tubs("Dendrites",     
304                                  fNeuronLoadPa    
305       fdendriteLV[i] = new G4LogicalVolume(fde    
306       fdendriteLV[i]->SetVisAttributes(fDendCo    
307                                                   
308       G4ThreeVector pos = (fNeuronLoadParamz->    
309       // rotation checking with function Compu    
310       // RotationMatrix with Inverse              
311       fdendritePV[i] = new G4PVPlacement(G4Tra    
312                                          fdend    
313       fMassDendcomp[i] = fNeuronLoadParamz->Ge    
314       fPosDendcomp[i] = fNeuronLoadParamz->Get    
315       fDistADendSoma[i] = fNeuronLoadParamz->G    
316       fDistBDendSoma[i] = fNeuronLoadParamz->G    
317       region->AddRootLogicalVolume(fdendriteLV    
318     }                                             
319   }                                               
320                                                   
321   // =========================================    
322   // Structure-3: Axon                            
323                                                   
324   n = fNeuronLoadParamz->GetnbAxoncomp();         
325   if (n <= 0) {                                   
326     G4cout << " ---- Axon not found! ---- " <<    
327   }                                               
328   else {                                          
329     G4cout << " ---- Axon for construction: --    
330     G4cout << " Total number of compartments i    
331     // Active Geant4-DNA processes in this reg    
332     auto region = new G4Region("Axon");           
333     region->SetProductionCuts(cuts);              
334                                                   
335     fnbAxoncomp = n;                              
336     fMassAxonTot = fNeuronLoadParamz->GetMassA    
337     fMassAxoncomp.resize(n, 0.0);                 
338     fDistAxonsoma.resize(n, 0.0);                 
339     fPosAxoncomp.resize(n);                       
340     faxonS.resize(n, nullptr);                    
341     faxonLV.resize(n, nullptr);                   
342     faxonPV.resize(n, nullptr);                   
343                                                   
344     for (G4int i = 1; i < n; ++i) {               
345       faxonS[i] = new G4Tubs("Axon", 0., fNeur    
346                              fNeuronLoadParamz    
347       faxonLV[i] = new G4LogicalVolume(faxonS[    
348       faxonLV[i]->SetVisAttributes(fAxonColour    
349       // RotationMatrix with Inverse              
350       G4ThreeVector pos = (fNeuronLoadParamz->    
351       faxonPV[i] = new G4PVPlacement(G4Transfo    
352                                      faxonLV[i    
353       fMassAxoncomp[i] = fNeuronLoadParamz->Ge    
354       fPosAxoncomp[i] = fNeuronLoadParamz->Get    
355       fDistAxonsoma[i] = fNeuronLoadParamz->Ge    
356       region->AddRootLogicalVolume(faxonLV[i])    
357     }                                             
358   }                                               
359   // =========================================    
360   // Structure-4: Spines                          
361   if (fNeuronLoadParamz->GetnbSpinecomp() == 0    
362     G4cout << " ---- Spines not found! ---- "     
363   }                                               
364   else {                                          
365     G4cout << " ---- Spines for construction:     
366     G4cout << " Total number of compartments i    
367            << G4endl;                             
368   }                                               
369                                                   
370   G4cout << "\n ---- End of Neuron Constructio    
371          << "\n ==============================    
372          << G4endl;                               
373                                                   
374   // =========================================    
375   // Active Geant4-DNA processes in BoundingSl    
376   // fpRegion = new G4Region("BoundingSlice");    
377   // fpRegion->SetProductionCuts(cuts);           
378   // fpRegion->AddRootLogicalVolume(boundingLV    
379                                                   
380   return worldPV;                                 
381 }                                                 
382