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 // 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 // $Id: DetectorConstruction.cc 87359 2014-12-01 16:04:27Z gcosmo $
33 //
36 
37 #include "DetectorConstruction.hh"
38 #include "G4SDManager.hh"
39 #include "TrackerSD.hh"
40 
41 #include "G4Material.hh"
42 #include "G4NistManager.hh"
43 
44 #include "G4Box.hh"
45 #include "G4PVPlacement.hh"
46 
47 #include "G4GeometryTolerance.hh"
48 #include "G4GeometryManager.hh"
49 
50 #include "G4SystemOfUnits.hh"
51 
52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53 
56 {
57 }
58 
59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
60 
62 {
63 }
64 
65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
66 
68 {
69  // Define materials
70  DefineMaterials();
71 
72  // Define volumes
73  return DefineVolumes();
74 }
75 
76 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
77 
78 void DetectorConstruction::DefineMaterials()
79 {
80  // Water is defined from NIST material database
82 
83  G4Material * H2O = man->FindOrBuildMaterial("G4_WATER");
84 
85  fpWaterMaterial = H2O;
86 
87  // Print materials
89 }
90 
91 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
92 
93 G4VPhysicalVolume* DetectorConstruction::DefineVolumes()
94 {
95  G4double worldLength = 200*um;
96 
97  // World
98 
100 
101  G4cout << "Computed tolerance = "
103  << " nm" << G4endl;
104 
105  G4Box* worldS
106  = new G4Box("world", //its name
107  worldLength/2,worldLength/2,worldLength/2); //its size
108 
109  G4LogicalVolume* worldLV
110  = new G4LogicalVolume(
111  worldS, //its solid
112  fpWaterMaterial, //its material
113  "World_LV"); //its name
114 
115  G4VPhysicalVolume* worldPV
116  = new G4PVPlacement(
117  0, // no rotation
118  G4ThreeVector(), // at (0,0,0)
119  worldLV, // its logical volume
120  "World", // its name
121  0, // its mother volume
122  false, // no boolean operations
123  0, // copy number
124  false); // checking overlaps
125 
126  return worldPV;
127 }
128 
129 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
130 
132 {
133  // Sensitive detectors
134 
135  G4String trackerChamberSDname = "TrackerChamberSD";
136 
137  TrackerSD* aTrackerSD = new TrackerSD(trackerChamberSDname,
138  "TrackerHitsCollection");
140  // Setting aTrackerSD to all logical volumes with the same name
141  // of "Chamber_LV".
142  SetSensitiveDetector("World_LV", aTrackerSD, true);
143 
144 }
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
Definition of the TrackerSD class.
CLHEP::Hep3Vector G4ThreeVector
Definition: G4Box.hh:64
G4VPhysicalVolume * Construct()
G4double GetSurfaceTolerance() const
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:587
void SetWorldMaximumExtent(G4double worldExtent)
static G4NistManager * Instance()
virtual void ConstructSDandField()
G4GLOB_DLL std::ostream G4cout
static constexpr double um
Definition: G4SIunits.hh:113
static G4GeometryManager * GetInstance()
void SetSensitiveDetector(const G4String &logVolName, G4VSensitiveDetector *aSD, G4bool multi=false)
void AddNewDetector(G4VSensitiveDetector *aSD)
Definition: G4SDManager.cc:71
static constexpr double nm
Definition: G4SIunits.hh:112
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
static G4GeometryTolerance * GetInstance()