Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 // -------------------------------------------------------------------
27 // $Id$
28 // -------------------------------------------------------------------
29 
30 #include "DetectorConstruction.hh"
31 #include "G4SystemOfUnits.hh"
32 #include "G4Region.hh"
33 #include "G4ProductionCuts.hh"
34 
35 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
36 
38 :physiWorld(NULL), logicWorld(NULL), solidWorld(NULL)
39 {}
40 
41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
42 
44 {}
45 
46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
47 
49 
50 {
51  DefineMaterials();
52  return ConstructDetector();
53 }
54 
55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
56 
57 void DetectorConstruction::DefineMaterials()
58 {
59 
60  // Water is defined from NIST material database
62  G4Material * H2O = man->FindOrBuildMaterial("G4_WATER");
63 
64  // Default materials in setup.
65  waterMaterial = H2O;
66 
67 }
68 
69 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
70 G4VPhysicalVolume* DetectorConstruction::ConstructDetector()
71 {
72 
73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
74 
75  // WORLD VOLUME
76 
77  WorldSizeX = 1*mm;
78  WorldSizeY = 1*mm;
79  WorldSizeZ = 1*mm;
80 
81  solidWorld = new G4Box("World", //its name
82  WorldSizeX/2,WorldSizeY/2,WorldSizeZ/2); //its size
83 
84 
85  logicWorld = new G4LogicalVolume(solidWorld, //its solid
86  waterMaterial, //its material
87  "World"); //its name
88 
89  physiWorld = new G4PVPlacement(0, //no rotation
90  G4ThreeVector(), //at (0,0,0)
91  "World", //its name
92  logicWorld, //its logical volume
93  0, //its mother volume
94  false, //no boolean operation
95  0); //copy number
96 
97  G4double TargetSizeZ = WorldSizeZ*0.05;
98 
99  G4Box* targetSolid = new G4Box("Target", //its name
100  WorldSizeX/2,WorldSizeY/2,TargetSizeZ/2); //its size
101 
102 
103  G4LogicalVolume* logicTarget = new G4LogicalVolume(targetSolid, //its solid
104  waterMaterial, //its material
105  "Target"); //its name
106 
107  new G4PVPlacement(0, //no rotation
108  G4ThreeVector(), //at (0,0,0)
109  "Target", //its name
110  logicTarget, //its logical volume
111  physiWorld, //its mother volume
112  false, //no boolean operation
113  0); //copy number
114 
115  // Visualization attributes
116  G4VisAttributes* worldVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0)); //White
117  worldVisAtt->SetVisibility(true);
118  logicWorld->SetVisAttributes(worldVisAtt);
119 
120  G4VisAttributes* worldVisAtt1 = new G4VisAttributes(G4Colour(1.0,0.0,0.0));
121  worldVisAtt1->SetVisibility(true);
122  logicTarget->SetVisAttributes(worldVisAtt1);
123 
124  // Create Target G4Region and add logical volume
125 
126  fRegion = new G4Region("Target");
127 
128  G4ProductionCuts* cuts = new G4ProductionCuts();
129 
130  G4double defCut = 1*nanometer;
131  cuts->SetProductionCut(defCut,"gamma");
132  cuts->SetProductionCut(defCut,"e-");
133  cuts->SetProductionCut(defCut,"e+");
134  cuts->SetProductionCut(defCut,"proton");
135 
136  fRegion->SetProductionCuts(cuts);
137  fRegion->AddRootLogicalVolume(logicTarget);
138 
139  return physiWorld;
140 }