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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 ]

  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 /// \file medical/dna/range/src/DetectorConstruction.cc
 27 /// \brief Implementation of the DetectorConstruction class
 28 //
 29 // $Id: DetectorConstruction.cc 78723 2014-01-20 10:32:17Z gcosmo $
 30 //
 31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 33 
 34 #include "DetectorConstruction.hh"
 35 
 36 #include "DetectorMessenger.hh"
 37 
 38 #include "G4Colour.hh"
 39 #include "G4GeometryManager.hh"
 40 #include "G4LogicalVolume.hh"
 41 #include "G4LogicalVolumeStore.hh"
 42 #include "G4MultiFunctionalDetector.hh"
 43 #include "G4NistManager.hh"
 44 #include "G4PSDoseDeposit.hh"
 45 #include "G4PSEnergyDeposit.hh"
 46 #include "G4PVParameterised.hh"
 47 #include "G4PVPlacement.hh"
 48 #include "G4PVReplica.hh"
 49 #include "G4PhysicalConstants.hh"
 50 #include "G4PhysicalVolumeStore.hh"
 51 #include "G4ProductionCuts.hh"
 52 #include "G4RunManager.hh"
 53 #include "G4SDManager.hh"
 54 #include "G4SolidStore.hh"
 55 #include "G4Sphere.hh"
 56 #include "G4SubtractionSolid.hh"
 57 #include "G4SystemOfUnits.hh"
 58 #include "G4Tubs.hh"
 59 #include "G4UnitsTable.hh"
 60 #include "G4UserLimits.hh"
 61 #include "G4VPhysicalVolume.hh"
 62 #include "G4VPrimitiveScorer.hh"
 63 #include "G4VSensitiveDetector.hh"
 64 #include "G4VisAttributes.hh"
 65 
 66 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 67 
 68 DetectorConstruction::DetectorConstruction()
 69   : G4VUserDetectorConstruction(),
 70     fNPRadius(0),
 71     fAbsRadius(0),
 72     fNPMaterial(0),
 73     fAbsMaterial(0),
 74     pWorld(0),
 75     fNP(0),
 76     fAbs(0),
 77     fDetectorMessenger(0),
 78     fRegion(0)
 79 {
 80   // default tracking cut
 81   fTrackingCut = 10.0 * eV;
 82 
 83   // default parameter values
 84   fNPRadius = 50 * nm;
 85   fAbsRadius = 100000 * nm + fNPRadius;
 86 
 87   fNreplicaR = 1000;
 88   fNreplicaAzm = 360;
 89 
 90   DefineMaterials();
 91   SetNPMaterial("G4_Au");
 92   SetAbsMaterial("G4_WATER");
 93 
 94   // create commands for interactive definition of the detector
 95   fDetectorMessenger = new DetectorMessenger(this);
 96 }
 97 
 98 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 99 
100 DetectorConstruction::~DetectorConstruction()
101 {
102   delete fDetectorMessenger;
103 }
104 
105 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
106 
107 G4VPhysicalVolume* DetectorConstruction::Construct()
108 {
109   return ConstructVolumes();
110 }
111 
112 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
113 
114 void DetectorConstruction::DefineMaterials()
115 {
116   G4NistManager* man = G4NistManager::Instance();
117 
118   man->FindOrBuildMaterial("G4_Au");
119   man->FindOrBuildMaterial("G4_WATER");
120 }
121 
122 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
123 
124 G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
125 {
126   const G4bool check_overlap = false;
127   G4GeometryManager::GetInstance()->OpenGeometry();
128   G4PhysicalVolumeStore::GetInstance()->Clean();
129   G4LogicalVolumeStore::GetInstance()->Clean();
130   G4SolidStore::GetInstance()->Clean();
131 
132   // World  ====================================================================
133   G4Material* Vacuum = new G4Material("Galactic", 1., 1.01 * g / mole, universe_mean_density,
134                                       kStateGas, 2.73 * kelvin, 3.e-18 * pascal);
135 
136   G4Sphere* sWorld = new G4Sphere("World", 0., fAbsRadius * 1.5, 0., 2 * pi * rad, 0., pi);
137   G4LogicalVolume* lWorld = new G4LogicalVolume(sWorld, Vacuum, "World");
138   pWorld = new G4PVPlacement(0, G4ThreeVector(), lWorld, "World", 0, false, 0);
139 
140   // Spherical NanoParticle ===================================================
141   G4Sphere* sNP = new G4Sphere("NanoParticle", 0., fNPRadius, 0., 2 * pi * rad, 0., pi);
142 
143   fLogicalNP = new G4LogicalVolume(sNP, fNPMaterial, "NanoParticle");
144 
145   fNP = new G4PVPlacement(0, G4ThreeVector(), fLogicalNP, "NanoParticle", lWorld, false, 0,
146                           check_overlap);
147 
148   // Sampling Plane ===========================================================
149 
150   // Spherical water absorber -------------------------------------------------
151   G4Sphere* sAbsorber0 = new G4Sphere("Absorber0", 0., fAbsRadius * 1.2, 0., 2 * pi * rad, 0., pi);
152   G4VSolid* sAbsorber = new G4SubtractionSolid("Absorber", sAbsorber0, sNP, 0, G4ThreeVector());
153 
154   fLogicalAbs = new G4LogicalVolume(sAbsorber, fAbsMaterial, "Absorber");
155   fAbs =
156     new G4PVPlacement(0, G4ThreeVector(), fLogicalAbs, "Absorber", lWorld, false, 0, check_overlap);
157 
158   // Set Visualization Setting#################################################
159   G4VisAttributes* visWorld = new G4VisAttributes(true, G4Colour::Gray());
160   G4VisAttributes* visNP = new G4VisAttributes(true, G4Colour::Yellow());
161   G4VisAttributes* visAbs = new G4VisAttributes(true, G4Colour::Cyan());
162 
163   lWorld->SetVisAttributes(visWorld);
164   fLogicalNP->SetVisAttributes(visNP);
165   fLogicalAbs->SetVisAttributes(visAbs);
166 
167   PrintParameters();
168 
169   G4double maxStep = fNPRadius / 2.;
170   fLogicalNP->SetUserLimits(new G4UserLimits(maxStep, DBL_MAX, DBL_MAX, fTrackingCut));
171 
172   fRegion = new G4Region("NP");
173 
174   G4ProductionCuts* cuts = new G4ProductionCuts();
175   G4double defCut = 0.1 * nm;
176   cuts->SetProductionCut(defCut, "gamma");
177   cuts->SetProductionCut(defCut, "e-");
178   cuts->SetProductionCut(defCut, "e+");
179   cuts->SetProductionCut(defCut, "proton");
180   fRegion->SetProductionCuts(cuts);
181   fRegion->AddRootLogicalVolume(fLogicalNP);
182 
183   return pWorld;
184 }
185 
186 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
187 
188 void DetectorConstruction::PrintParameters() const
189 {
190   G4cout << "\n=========================================================\n";
191   G4cout << "---> The tracking cut to all particles is set to "
192          << G4BestUnit(fTrackingCut, "Energy") << G4endl;
193   G4cout << "\n---------------------------------------------------------\n";
194   G4cout << "---> The Nano-Particle is a sphere of " << G4BestUnit(fNPRadius, "Length")
195          << " radius of " << fNPMaterial->GetName() << " made of"
196          << "\n \n"
197          << fNPMaterial << G4endl;
198   G4cout << "\n---------------------------------------------------------\n";
199   G4cout << "---> The Absorber is a sphere of " << G4BestUnit(fAbsRadius, "Length") << " radius of "
200          << fAbsMaterial->GetName() << " made of"
201          << "\n \n"
202          << fAbsMaterial << G4endl;
203   G4cout << "\n=========================================================\n";
204 }
205 
206 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
207 
208 void DetectorConstruction::SetTrackingCut(G4double value)
209 {
210   fTrackingCut = value;
211   G4RunManager::GetRunManager()->ReinitializeGeometry();
212 }
213 
214 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
215 
216 void DetectorConstruction::SetAbsRadius(G4double value)
217 {
218   fAbsRadius = value;
219   G4RunManager::GetRunManager()->ReinitializeGeometry();
220 }
221 
222 void DetectorConstruction::SetNPRadius(G4double value)
223 {
224   fNPRadius = value;
225   G4RunManager::GetRunManager()->ReinitializeGeometry();
226 }
227 
228 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
229 //
230 void DetectorConstruction::SetAbsMaterial(G4String materialChoice)
231 {
232   G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
233   if (pttoMaterial) fAbsMaterial = pttoMaterial;
234   G4RunManager::GetRunManager()->PhysicsHasBeenModified();
235 }
236 
237 void DetectorConstruction::SetNPMaterial(G4String materialChoice)
238 {
239   G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
240   if (pttoMaterial) fNPMaterial = pttoMaterial;
241   G4RunManager::GetRunManager()->PhysicsHasBeenModified();
242 }
243 
244 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
245 //
246 void DetectorConstruction::SetNReplicaR(G4int value)
247 {
248   fNreplicaR = value;
249   G4RunManager::GetRunManager()->ReinitializeGeometry();
250 }
251 void DetectorConstruction::SetNReplicaAzm(G4int value)
252 {
253   fNreplicaAzm = value;
254   G4RunManager::GetRunManager()->ReinitializeGeometry();
255 }
256