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 //
28 //
29 //
30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 
33 #include "DetectorConstruction.hh"
34 #include "DetectorMessenger.hh"
35 
36 #include "G4Material.hh"
37 #include "G4Box.hh"
38 #include "G4LogicalVolume.hh"
39 #include "G4PVPlacement.hh"
40 
41 #include "G4GeometryManager.hh"
42 #include "G4PhysicalVolumeStore.hh"
43 #include "G4LogicalVolumeStore.hh"
44 #include "G4SolidStore.hh"
45 
46 #include "G4UnitsTable.hh"
47 
48 #include "G4PolarizationManager.hh"
49 #include "G4NistManager.hh"
50 #include "G4SystemOfUnits.hh"
51 
52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53 
56  fWorld(0), fBox(0), fTargetMaterial(0), fWorldMaterial(0)
57 {
58  fBoxSizeXY = 50*mm;
59  fBoxSizeZ = 5*mm;
60  fWorldSize = 1.*m;
61  SetTargetMaterial("G4_Fe");
62  SetWorldMaterial("G4_Galactic");
63  fMessenger = new DetectorMessenger(this);
64 }
65 
66 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
67 
69 {
70  delete fMessenger;
71 }
72 
73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
74 
76 {
77  // Cleanup old geometry
82 
84 
85  // World
86  //
87  G4Box*
88  sWorld = new G4Box("World", //name
89  fWorldSize/2,fWorldSize/2,fWorldSize/2); //dimensions
90 
92  lWorld = new G4LogicalVolume(sWorld, //shape
93  fWorldMaterial, //material
94  "World"); //name
95 
96  fWorld = new G4PVPlacement(0, //no rotation
97  G4ThreeVector(), //at (0,0,0)
98  lWorld, //logical volume
99  "World", //name
100  0, //mother volume
101  false, //no boolean operation
102  0); //copy number
103 
104  // Box
105  //
106  G4Box*
107  sBox = new G4Box("Container", //its name
108  fBoxSizeXY/2.,fBoxSizeXY/2.,fBoxSizeZ/2.);//its dimensions
109 
111  lBox = new G4LogicalVolume(sBox, //its shape
112  fTargetMaterial, //its material
113  "theBox"); //its name
114 
115  fBox = new G4PVPlacement(0, //no rotation
116  G4ThreeVector(), //at (0,0,0)
117  lBox, //its logical volume
118  fTargetMaterial->GetName(), //its name
119  lWorld, //its mother volume
120  false, //no boolean operation
121  0); //copy number
122 
123  // register logical Volume in PolarizationManager with zero polarization
125  polMgr->SetVolumePolarization(lBox,G4ThreeVector(0.,0.,0.));
126 
127  PrintParameters();
128 
129  //always return the root volume
130  //
131  return fWorld;
132 }
133 
134 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
135 
137 {
138  G4cout << "\n The Box is " << G4BestUnit(fBoxSizeXY,"Length")
139  << " x " << G4BestUnit(fBoxSizeXY,"Length")
140  << " x " << G4BestUnit(fBoxSizeZ,"Length")
141  << " of " << fTargetMaterial->GetName() << G4endl;
142 }
143 
144 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
145 
147 {
148  // search the material by its name
149  G4Material* mat =
150  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
151  if (mat != fTargetMaterial) {
152  if(mat) {
154  UpdateGeometry();
155  } else {
156  G4cout << "### Warning! Target material: <"
157  << materialChoice << "> not found" << G4endl;
158  }
159  }
160 }
161 
162 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
163 
165 {
166  // search the material by its name
167  G4Material* mat =
168  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
169  if (mat != fWorldMaterial) {
170  if(mat) {
172  UpdateGeometry();
173  } else {
174  G4cout << "### Warning! World material: <"
175  << materialChoice << "> not found" << G4endl;
176  }
177  }
178 }
179 
180 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
181 
183 {
184  fBoxSizeXY = value;
186  UpdateGeometry();
187 }
188 
190 {
191  fBoxSizeZ = value;
193  UpdateGeometry();
194 }
195 
196 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
197 
198 #include "G4RunManager.hh"
199 
201 {
202  if (fWorld)
204 }
205 
206 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......