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 //
29 
30 #include "DetectorConstruction.hh"
31 #include "ScreenSD.hh"
32 
33 #include "G4Material.hh"
34 #include "G4NistManager.hh"
35 #include "G4Box.hh"
36 #include "G4LogicalVolume.hh"
37 #include "G4PVPlacement.hh"
39 #include "G4SDManager.hh"
40 
41 #include "G4VisAttributes.hh"
42 #include "G4Colour.hh"
43 #include "G4SystemOfUnits.hh"
44 #include "G4AutoDelete.hh"
45 
46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
47 
50 
51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
52 
55 {}
56 
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58 
60 {}
61 
62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
63 
65 {
66  // Get nist material manager
67  G4NistManager* nistManager = G4NistManager::Instance();
68 
69  // Build materials
70  G4Material* air = nistManager->FindOrBuildMaterial("G4_AIR");
71  G4Material* csi = nistManager->FindOrBuildMaterial("G4_CESIUM_IODIDE");
72  // There is no need to test if materials were built/found
73  // as G4NistManager would issue an error otherwise
74  // Try the code with "XYZ".
75 
76  // Print all materials
78 
79  // Option to switch on/off checking of volumes overlaps
80  G4bool checkOverlaps = true;
81 
82  //
83  // World
84  //
85 
86  // The world dimensions
87  G4double worldHxyz = 2.*m;
88 
89  // world volume
90  G4Box* worldS = new G4Box("World", worldHxyz, worldHxyz, worldHxyz);
91 
92  G4LogicalVolume* worldLV = new G4LogicalVolume(worldS, air, "World");
93 
94  G4VPhysicalVolume* worldPV
95  = new G4PVPlacement(
96  0, G4ThreeVector(), worldLV, "World", 0, false, 0, checkOverlaps);
97 
98  //
99  // Box
100  //
101 
102  // The box dimensions
103  G4double boxHxy = 1.*m;
104  G4double boxHz = 10.*cm;
105 
106  // box volume
107  G4Box* boxS = new G4Box("World", boxHxy, boxHxy, boxHz);
108 
109  G4LogicalVolume* boxLV = new G4LogicalVolume(boxS, csi, "Box");
110 
111  // The box position
112  G4double posz = 0.*m;
113 
114  new G4PVPlacement(
115  0, G4ThreeVector(0, 0, posz),
116  boxLV, "Box", worldLV, false, 0, checkOverlaps);
117 
118  //
119  // Scoring screen
120  //
121  // The screen dimensions
122  G4double screenHxy = 1.999*m;
123  G4double screenHz = 1.*mm;
124 
125  // Screen volume
126  G4Box* screenS = new G4Box("World", screenHxy, screenHxy, screenHz);
127 
128  G4LogicalVolume* screenLV = new G4LogicalVolume(screenS, air, "Screen");
129 
130  // The screen position
131  posz += boxHz + screenHz;
132 
133  new G4PVPlacement(
134  0, G4ThreeVector(0, 0, posz),
135  screenLV, "Screen", worldLV, false, 0, checkOverlaps);
136 
137  //
138  // Visualization attributes
139  //
141 
142  auto simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0, 1.0, 1.0));
143  simpleBoxVisAtt->SetVisibility(true);
144  boxLV->SetVisAttributes(simpleBoxVisAtt);
145  screenLV->SetVisAttributes(simpleBoxVisAtt);
146 
147  //
148  // Always return the physical World
149  //
150  return worldPV;
151 }
152 
153 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
154 
156 {
157  // G4SDManager::GetSDMpointer()->SetVerboseLevel(1);
158 
159  //
160  // Sensitive detectors
161  //
162  auto screenSD = new ScreenSD("ScreenSD");
164  SetSensitiveDetector("Screen", screenSD);
165 
166  //
167  // Magnetic field
168  //
169  // Create global magnetic field messenger.
170  // Uniform magnetic field is then created automatically if
171  // the field value is not zero.
172  G4ThreeVector fieldValue;
175 
176  // Register the field messenger for deleting
178 }
179 
180 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......