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 
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "DetectorConstruction.hh"
35 #include "DetectorMessenger.hh"
36 
37 #include "G4Material.hh"
38 #include "G4NistManager.hh"
39 #include "G4Box.hh"
40 #include "G4LogicalVolume.hh"
41 #include "G4PVPlacement.hh"
42 
43 #include "G4GeometryManager.hh"
44 #include "G4PhysicalVolumeStore.hh"
45 #include "G4LogicalVolumeStore.hh"
46 #include "G4SolidStore.hh"
47 
48 #include "G4UnitsTable.hh"
49 #include "G4SystemOfUnits.hh"
50 
51 #include "G4RunManager.hh"
52 
53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
54 
57  fPBox(0), fLBox(0), fMaterial(0), fDetectorMessenger(0)
58 {
59  fBoxSize = 10*m;
61  SetMaterial("Molybdenum98");
63 }
64 
65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
66 
68 { delete fDetectorMessenger;}
69 
70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
71 
73 {
74  return ConstructVolumes();
75 }
76 
77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
78 
80 {
81  // define a Material from isotopes
82  //
83  MaterialWithSingleIsotope("Molybdenum98", "Mo98", 10.28*g/cm3, 42, 98);
84 
85  //NE213
86  G4Element* H = new G4Element("Hydrogen" ,"H" , 1., 1.01*g/mole);
87  G4Element* C = new G4Element("Carbon" ,"C" , 6., 12.00*g/mole);
88  G4Material* ne213 =
89  new G4Material("NE213", 0.874*g/cm3, 2);
90  ne213->AddElement(H, 9.2*perCent);
91  ne213->AddElement(C, 90.8*perCent);
92 
93  G4Material* hydrogen =
94  new G4Material("hydrogen", 1.0*g/cm3, 1);
95  hydrogen->AddElement(H, 1);
96 
97  G4Material* carbon =
98  new G4Material("carbon", 1.0*g/cm3, 1);
99  carbon->AddElement(C, 1);
100 
101  G4Material* plastic =
102  new G4Material("plastic", 1.0*g/cm3, 2);
103  plastic->AddElement(H, 1);
104  plastic->AddElement(C, 1);
105 
106  // or use G4-NIST materials data base
107  //
109  man->FindOrBuildMaterial("G4_B");
110 
111  G4Element* O = man->FindOrBuildElement("O");
112  G4Element* Hf = man->FindOrBuildElement("Hf");
113 
114  G4Material* HfO2 = new G4Material("HfO2", 9.68*g/cm3, 2);
115  HfO2->AddElement(Hf, 1);
116  HfO2->AddElement(O , 2);
117 
119 }
120 
121 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
122 
124  G4String symbol, G4double density, G4int Z, G4int A)
125 {
126  // define a material from an isotope
127  //
128  G4int ncomponents;
129  G4double abundance, massfraction;
130 
131  G4Isotope* isotope = new G4Isotope(symbol, Z, A);
132 
133  G4Element* element = new G4Element(name, symbol, ncomponents=1);
134  element->AddIsotope(isotope, abundance= 100.*perCent);
135 
136  G4Material* material = new G4Material(name, density, ncomponents=1);
137  material->AddElement(element, massfraction=100.*perCent);
138 
139  return material;
140 }
141 
142 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
143 
145 {
146  // Cleanup old geometry
151 
152  G4Box*
153  sBox = new G4Box("Container", //its name
154  fBoxSize/2,fBoxSize/2,fBoxSize/2); //its dimensions
155 
156  fLBox = new G4LogicalVolume(sBox, //its shape
157  fMaterial, //its material
158  fMaterial->GetName()); //its name
159 
160  fPBox = new G4PVPlacement(0, //no rotation
161  G4ThreeVector(), //at (0,0,0)
162  fLBox, //its logical volume
163  fMaterial->GetName(), //its name
164  0, //its mother volume
165  false, //no boolean operation
166  0); //copy number
167 
168  PrintParameters();
169 
170  //always return the root volume
171  //
172  return fPBox;
173 }
174 
175 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
176 
178 {
179  G4cout << "\n The Box is " << G4BestUnit(fBoxSize,"Length")
180  << " of " << fMaterial->GetName()
181  << "\n \n" << fMaterial << G4endl;
182 }
183 
184 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
185 
186 void DetectorConstruction::SetMaterial(G4String materialChoice)
187 {
188  // search the material by its name
189  G4Material* pttoMaterial =
190  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
191 
192  if (pttoMaterial) {
193  if(fMaterial != pttoMaterial) {
194  fMaterial = pttoMaterial;
195  if(fLBox) { fLBox->SetMaterial(pttoMaterial); }
197  }
198  } else {
199  G4cout << "\n--> warning from DetectorConstruction::SetMaterial : "
200  << materialChoice << " not found" << G4endl;
201  }
202 }
203 
204 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
205 
207 {
208  fBoxSize = value;
210 }
211 
212 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......