Geant4  10.03.p03
 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: DetectorConstruction.cc,v 1.1 2012-09-20 mraine Exp $
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 :fPhysiWorld(NULL), fLogicWorld(NULL), fSolidWorld(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  // Silicon is defined from NIST material database
62  G4Material * Si = man->FindOrBuildMaterial("G4_Si");
63 
64  // Default materials in setup.
65  fSiMaterial = Si;
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  fWorldSizeX = 1*um;
78  fWorldSizeY = 1*um;
79  fWorldSizeZ = 1*um;
80 
81  fSolidWorld = new G4Box("World", //its name
82  fWorldSizeX/2,fWorldSizeY/2,fWorldSizeZ/2); //its size
83 
84 
85  fLogicWorld = new G4LogicalVolume(fSolidWorld, //its solid
86  fSiMaterial, //its material
87  "World"); //its name
88 
89  fPhysiWorld = new G4PVPlacement(0, //no rotation
90  G4ThreeVector(), //at (0,0,0)
91  "World", //its name
92  fLogicWorld, //its logical volume
93  0, //its mother volume
94  false, //no boolean operation
95  0); //copy number
96 
97  G4double TargetSizeZ = 0.2*um;
98 
99  G4Box* targetSolid = new G4Box("Target", //its name
100  fWorldSizeX/2,fWorldSizeY/2,TargetSizeZ/2); //its size
101 
102 
103  G4LogicalVolume* logicTarget = new G4LogicalVolume(targetSolid, //its solid
104  fSiMaterial, //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  fPhysiWorld, //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  fLogicWorld->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 fPhysiWorld;
140 }
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
CLHEP::Hep3Vector G4ThreeVector
void AddRootLogicalVolume(G4LogicalVolume *lv)
Definition: G4Region.cc:290
Definition: G4Box.hh:64
G4VPhysicalVolume * Construct()
void SetProductionCut(G4double cut, G4int index=-1)
static constexpr double nanometer
Definition: G4SIunits.hh:101
static G4NistManager * Instance()
static constexpr double um
Definition: G4SIunits.hh:113
void SetVisibility(G4bool=true)
void SetProductionCuts(G4ProductionCuts *cut)
double G4double
Definition: G4Types.hh:76
void SetVisAttributes(const G4VisAttributes *pVA)