ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DetectorConstruction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DetectorConstruction.cc
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 publications:
29 // Med. Phys. 45 (2018) e722-e739
30 // Phys. Med. 31 (2015) 861-874
31 // Med. Phys. 37 (2010) 4692-4708
32 // Int. J. Model. Simul. Sci. Comput. 1 (2010) 157\u2013178
33 //
34 // The Geant4-DNA web site is available at http://geant4-dna.org
35 //
38 
39 #include "DetectorConstruction.hh"
40 #include "DetectorMessenger.hh"
41 #include "TrackerSD.hh"
42 
43 #include "G4Material.hh"
44 #include "G4NistManager.hh"
45 
46 #include "G4Box.hh"
47 #include "G4PVPlacement.hh"
48 
49 #include "G4GeometryTolerance.hh"
50 #include "G4GeometryManager.hh"
51 
52 #include "G4SystemOfUnits.hh"
53 #include "G4UserLimits.hh"
54 #include "G4UnitsTable.hh"
55 
56 #include "G4SDManager.hh"
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 
62 fDetectorMessenger(0)
63 {
64  // Default tracking cut
65  fTrackingCut = 9*eV;
66 
67  // Create commands for interactive definition of the detector
69 
70 }
71 
72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
73 
75 {
76  delete fDetectorMessenger;
77 }
78 
79 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
80 
82 {
83  // Define materials
85 
86  // Define volumes
87  return DefineVolumes();
88 }
89 
90 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
91 
93 {
94  // Water is defined from NIST material database
96 
97  G4Material * H2O = man->FindOrBuildMaterial("G4_WATER");
98 
99  fWaterMaterial = H2O;
100 
101  // Print materials
103 }
104 
105 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
106 
108 {
109  G4double worldLength = 1*km;
110 
111  // World
112 
114 
115  G4cout << "Computed tolerance = "
117  << " nm" << G4endl;
118 
119  G4Box* worldS
120  = new G4Box("world", //its name
121  worldLength/2,worldLength/2,worldLength/2); //its size
122 
123  G4LogicalVolume* worldLV
124  = new G4LogicalVolume(
125  worldS, //its solid
126  fWaterMaterial, //its material
127  "World_LV"); //its name
128 
129  G4VPhysicalVolume* worldPV
130  = new G4PVPlacement(
131  0, // no rotation
132  G4ThreeVector(), // at (0,0,0)
133  worldLV, // its logical volume
134  "World", // its name
135  0, // its mother volume
136  false, // no boolean operations
137  0, // copy number
138  false); // checking overlaps
139 
141  fTrackingCut));
142 
143  PrintParameters();
144 
145  return worldPV;
146 }
147 
148 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
149 
151 {
152  // Sensitive detectors
153 
154  G4String trackerChamberSDname = "TrackerChamberSD";
155 
156  TrackerSD* aTrackerSD = new TrackerSD(trackerChamberSDname,
157  "TrackerHitsCollection");
158 
160 
161  // Setting aTrackerSD to all logical volumes with the same name
162  // of "Chamber_LV".
163  SetSensitiveDetector("World_LV", aTrackerSD, true);
164 
165 }
166 
167 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
168 
170 {
172 }
173 
174 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
175 
177 {
178  G4cout << "\n---------------------------------------------------------\n";
179  G4cout << "---> The tracking cut is set to "
180  << G4BestUnit(fTrackingCut,"Energy") << G4endl;
181  G4cout << "\n---------------------------------------------------------\n";
182 }
183 
184 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
185