Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
examples/advanced/microdosimetry/src/DetectorConstruction.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 
33 #include "DetectorConstruction.hh"
34 #include "G4SystemOfUnits.hh"
35 #include "G4Region.hh"
36 #include "G4ProductionCuts.hh"
37 
38 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
39 
41 :fPhysiWorld(NULL), fLogicWorld(NULL), fSolidWorld(NULL)
42 {}
43 
44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
45 
47 {}
48 
49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
50 
52 
53 {
54  DefineMaterials();
55  return ConstructDetector();
56 }
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
59 
60 void DetectorConstruction::DefineMaterials()
61 {
62 
63  // Water is defined from NIST material database
65  G4Material * H2O = man->FindOrBuildMaterial("G4_WATER");
66 
67  // Default materials in setup.
68  fWaterMaterial = H2O;
69 
70 }
71 
72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
73 G4VPhysicalVolume* DetectorConstruction::ConstructDetector()
74 {
75 
76 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
77 
78  // WORLD VOLUME
79 
80  fWorldSizeX = 1*mm;
81  fWorldSizeY = 1*mm;
82  fWorldSizeZ = 1*mm;
83 
84  fSolidWorld = new G4Box("World", //its name
85  fWorldSizeX/2,fWorldSizeY/2,fWorldSizeZ/2); //its size
86 
87 
88  fLogicWorld = new G4LogicalVolume(fSolidWorld, //its solid
89  fWaterMaterial, //its material
90  "World"); //its name
91 
92  fPhysiWorld = new G4PVPlacement(0, //no rotation
93  G4ThreeVector(), //at (0,0,0)
94  "World", //its name
95  fLogicWorld, //its logical volume
96  0, //its mother volume
97  false, //no boolean operation
98  0); //copy number
99 
100  G4double TargetSizeZ = fWorldSizeZ*0.05;
101 
102  G4Box* targetSolid = new G4Box("Target", //its name
103  fWorldSizeX/2,fWorldSizeY/2,TargetSizeZ/2); //its size
104 
105 
106  G4LogicalVolume* logicTarget = new G4LogicalVolume(targetSolid, //its solid
107  fWaterMaterial, //its material
108  "Target"); //its name
109 
110  new G4PVPlacement(0, //no rotation
111  G4ThreeVector(), //at (0,0,0)
112  "Target", //its name
113  logicTarget, //its logical volume
114  fPhysiWorld, //its mother volume
115  false, //no boolean operation
116  0); //copy number
117 
118  // Visualization attributes
119  G4VisAttributes* worldVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0)); //White
120  worldVisAtt->SetVisibility(true);
121  fLogicWorld->SetVisAttributes(worldVisAtt);
122 
123  G4VisAttributes* worldVisAtt1 = new G4VisAttributes(G4Colour(1.0,0.0,0.0));
124  worldVisAtt1->SetVisibility(true);
125  logicTarget->SetVisAttributes(worldVisAtt1);
126 
127  // Create Target G4Region and add logical volume
128 
129  fRegion = new G4Region("Target");
130 
131  G4ProductionCuts* cuts = new G4ProductionCuts();
132 
133  G4double defCut = 1*nanometer;
134  cuts->SetProductionCut(defCut,"gamma");
135  cuts->SetProductionCut(defCut,"e-");
136  cuts->SetProductionCut(defCut,"e+");
137  cuts->SetProductionCut(defCut,"proton");
138 
139  fRegion->SetProductionCuts(cuts);
140  fRegion->AddRootLogicalVolume(logicTarget);
141 
142  return fPhysiWorld;
143 }
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
CLHEP::Hep3Vector G4ThreeVector
void AddRootLogicalVolume(G4LogicalVolume *lv)
Definition: G4Region.cc:254
Definition: G4Box.hh:63
void SetVisibility(G4bool)
void SetProductionCut(G4double cut, G4int index=-1)
static G4NistManager * Instance()
int nanometer
Definition: hepunit.py:35
void SetProductionCuts(G4ProductionCuts *cut)
double G4double
Definition: G4Types.hh:76
void SetVisAttributes(const G4VisAttributes *pVA)