33#include "G4AutoDelete.hh"
36#include "G4GeometryManager.hh"
37#include "G4GlobalMagFieldMessenger.hh"
38#include "G4LogicalVolume.hh"
39#include "G4LogicalVolumeStore.hh"
40#include "G4Material.hh"
41#include "G4NistManager.hh"
42#include "G4PVPlacement.hh"
43#include "G4PVReplica.hh"
44#include "G4PhysicalConstants.hh"
45#include "G4PhysicalVolumeStore.hh"
46#include "G4RunManager.hh"
47#include "G4SolidStore.hh"
48#include "G4SystemOfUnits.hh"
50#include "G4VisAttributes.hh"
57 : G4VUserDetectorConstruction() {
64 delete fGarfieldMessenger;
74 return DefineVolumes();
79void GarfieldDetectorConstruction::DefineMaterials() {
80 G4bool isotopes =
false;
81 G4String name, symbol;
82 G4int ncomponents, natoms;
83 G4double density, fractionmass;
86 G4NistManager* nistManager = G4NistManager::Instance();
88 nistManager->FindOrBuildMaterial(
"G4_Pb");
89 nistManager->FindOrBuildMaterial(
"G4_Cu");
90 nistManager->FindOrBuildMaterial(
"G4_Al");
91 nistManager->FindOrBuildMaterial(
"G4_Au");
92 nistManager->FindOrBuildMaterial(
"G4_W");
94 nistManager->FindOrBuildMaterial(
"G4_AIR");
96 G4Element* H = nistManager->FindOrBuildElement(
"H", isotopes);
97 G4Element* N = nistManager->FindOrBuildElement(
"N", isotopes);
98 G4Element* C = nistManager->FindOrBuildElement(
"C", isotopes);
99 G4Element* O = nistManager->FindOrBuildElement(
"O", isotopes);
100 G4Element* Ar = nistManager->FindOrBuildElement(
"Ar", isotopes);
102 G4Material* CO2 =
new G4Material(
103 "CO2", density = 1.977 * CLHEP::mg / CLHEP::cm3, ncomponents = 2);
104 CO2->AddElement(C, natoms = 1);
105 CO2->AddElement(O, natoms = 2);
107 G4Material* ArCO2_70_30 =
108 new G4Material(
"ArCO2_70_30", density = 1.8223 * CLHEP::mg / CLHEP::cm3,
109 ncomponents = 2, kStateGas);
110 ArCO2_70_30->AddElement(Ar, fractionmass = 0.70);
111 ArCO2_70_30->AddMaterial(CO2, fractionmass = 0.30);
113 density = 1.413 * CLHEP::g / CLHEP::cm3;
115 new G4Material(name =
"Kapton", density, ncomponents = 4);
116 Kapton->AddElement(O, 5);
117 Kapton->AddElement(C, 22);
118 Kapton->AddElement(N, 2);
119 Kapton->AddElement(H, 10);
122 G4cout << *(G4Material::GetMaterialTable()) << G4endl;
127G4VPhysicalVolume* GarfieldDetectorConstruction::DefineVolumes() {
129 G4double worldSizeXYZ = 1000 * mm;
130 G4double absorberThicknessZ = 10. * mm;
131 G4double absorberThicknessXY = 100. * mm;
132 G4double wireRadius = 0.025 * mm;
133 G4double tubeRadius = 15 * mm;
134 G4double tubeHalfLength = 100 * mm;
135 G4double tubeThickness = 500 * um;
138 G4Material* defaultMaterial = G4Material::GetMaterial(
"G4_AIR");
139 fAbsorberMaterial = G4Material::GetMaterial(
"G4_Pb");
141 G4Material* gasMaterial = G4Material::GetMaterial(
"ArCO2_70_30");
142 G4Material* cathodeMaterial = G4Material::GetMaterial(
"G4_Al");
143 G4Material* wireMaterial = G4Material::GetMaterial(
"G4_W");
145 if (!defaultMaterial || !fAbsorberMaterial || !gasMaterial ||
146 !cathodeMaterial || !wireMaterial) {
147 G4ExceptionDescription msg;
148 msg <<
"Cannot retrieve materials already defined.";
149 G4Exception(
"GarfieldDetectorConstruction::DefineVolumes()",
150 "exampleGarfield", FatalException, msg);
156 G4VSolid* worldS =
new G4Box(
"World",
157 0.5 * worldSizeXYZ, 0.5 * worldSizeXYZ,
160 G4LogicalVolume* worldLV =
161 new G4LogicalVolume(worldS,
165 G4VPhysicalVolume* worldPV =
177 G4VSolid* absorberS =
178 new G4Box(
"Absorber",
179 0.5 * absorberThicknessXY, 0.5 * absorberThicknessXY,
180 0.5 * absorberThicknessZ);
182 fAbsorberLV =
new G4LogicalVolume(absorberS,
186 fAbsorberPV =
new G4PVPlacement(
188 G4ThreeVector(0., 0., absorberThicknessZ / 2),
199 G4VSolid* tubeS =
new G4Tubs(
"Tube",
200 0, tubeRadius, tubeHalfLength + tubeThickness, 0,
203 G4LogicalVolume* tubeLV =
204 new G4LogicalVolume(tubeS,
208 G4RotationMatrix* rotY =
new G4RotationMatrix();
209 rotY->rotateY(90. * CLHEP::degree);
211 fTubePV =
new G4PVPlacement(
213 G4ThreeVector(0., -0.2 * tubeRadius,
214 absorberThicknessZ + tubeRadius),
225 G4VSolid* gasS =
new G4Tubs(
"Gas",
226 wireRadius, tubeRadius - tubeThickness,
227 tubeHalfLength, 0, 2 * pi);
229 G4LogicalVolume* gasLV =
new G4LogicalVolume(gasS,
233 fGasPV =
new G4PVPlacement(0,
234 G4ThreeVector(0., 0., 0.),
247 0, wireRadius, tubeHalfLength, 0, 2 * pi);
249 G4LogicalVolume* wireLV =
new G4LogicalVolume(wireS,
253 fWirePV =
new G4PVPlacement(0,
254 G4ThreeVector(0., 0., 0.),
265 worldLV->SetVisAttributes(G4VisAttributes::Invisible);
267 G4VisAttributes* VisAttBlue =
new G4VisAttributes(G4Colour(0.0, 0.0, 1.0));
268 G4VisAttributes* VisAttGreen =
new G4VisAttributes(G4Colour(0.0, 1.0, 0.0));
269 G4VisAttributes* VisAttRed =
new G4VisAttributes(G4Colour(1.0, 0.0, 0.0));
270 G4VisAttributes* VisAttWhite =
new G4VisAttributes(G4Colour(1.0, 1.0, 1.0));
272 wireLV->SetVisAttributes(VisAttRed);
273 tubeLV->SetVisAttributes(VisAttGreen);
274 gasLV->SetVisAttributes(VisAttWhite);
275 fAbsorberLV->SetVisAttributes(VisAttBlue);
277 G4Region* regionGarfield =
new G4Region(
"RegionGarfield");
278 regionGarfield->AddRootLogicalVolume(gasLV);
280 G4Region* regionWire =
new G4Region(
"RegionWire");
281 regionWire->AddRootLogicalVolume(wireLV);
284 "GarfieldG4FastSimulationModel", regionGarfield);
297 G4String name, G4String symbol, G4double density, G4int Z, G4int A) {
301 G4double abundance, massfraction;
303 G4Isotope* isotope =
new G4Isotope(symbol, Z, A);
305 G4Element* element =
new G4Element(name, symbol, ncomponents = 1);
306 element->AddIsotope(isotope, abundance = 100. * perCent);
308 G4Material* material =
new G4Material(name, density, ncomponents = 1);
309 material->AddElement(element, massfraction = 100. * perCent);
317 G4String materialChoice) {
319 G4Material* newMaterial =
320 G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
323 if (fAbsorberMaterial != newMaterial) {
324 fAbsorberMaterial = newMaterial;
326 fAbsorberLV->SetMaterial(fAbsorberMaterial);
328 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
331 G4cout <<
"\n--> warning from GarfieldDetectorConstruction::SetMaterial : "
332 << materialChoice <<
" not found" << G4endl;
Definition of the GarfieldDetectorConstruction class.
Definition of the GarfieldMessenger class.
GarfieldDetectorConstruction()
void SetAbsorberMaterial(G4String materialChoice)
G4Material * AbsorberMaterialWithSingleIsotope(G4String name, G4String symbol, G4double density, G4int Z, G4int A)
virtual ~GarfieldDetectorConstruction()
virtual G4VPhysicalVolume * Construct() override
void WriteGeometryToGDML(G4VPhysicalVolume *physicalVolume)