34#include "G4Material.hh"
35#include "G4NistManager.hh"
39#include "G4LogicalVolume.hh"
40#include "G4PVPlacement.hh"
41#include "G4PVReplica.hh"
42#include "G4GlobalMagFieldMessenger.hh"
43#include "G4AutoDelete.hh"
45#include "G4GeometryManager.hh"
46#include "G4PhysicalVolumeStore.hh"
47#include "G4LogicalVolumeStore.hh"
48#include "G4SolidStore.hh"
50#include "G4VisAttributes.hh"
53#include "G4PhysicalConstants.hh"
54#include "G4SystemOfUnits.hh"
55#include "G4RunManager.hh"
60 G4VUserDetectorConstruction(), fAbsorberPV(0), fTubePV(0), fGasPV(0), fWirePV(
61 0), fAbsorberMaterial(0), fAbsorberLV(0), fCheckOverlaps(true), fGarfieldG4FastSimulationModel(
62 0), fGarfieldMessenger(0) {
69 delete fGarfieldMessenger;
79 return DefineVolumes();
84void GarfieldDetectorConstruction::DefineMaterials() {
85 G4bool isotopes =
false;
86 G4String name, symbol;
87 G4int ncomponents, natoms;
88 G4double density, fractionmass;
91 G4NistManager* nistManager = G4NistManager::Instance();
93 nistManager->FindOrBuildMaterial(
"G4_Pb");
94 nistManager->FindOrBuildMaterial(
"G4_Cu");
95 nistManager->FindOrBuildMaterial(
"G4_Al");
96 nistManager->FindOrBuildMaterial(
"G4_Au");
97 nistManager->FindOrBuildMaterial(
"G4_W");
99 nistManager->FindOrBuildMaterial(
"G4_AIR");
101 G4Element* H = nistManager->FindOrBuildElement(
"H", isotopes);
102 G4Element* N = nistManager->FindOrBuildElement(
"N", isotopes);
103 G4Element* C = nistManager->FindOrBuildElement(
"C", isotopes);
104 G4Element* O = nistManager->FindOrBuildElement(
"O", isotopes);
105 G4Element* Ar = nistManager->FindOrBuildElement(
"Ar", isotopes);
107 G4Material* CO2 =
new G4Material(
"CO2",
108 density = 1.977 * CLHEP::mg / CLHEP::cm3, ncomponents = 2);
109 CO2->AddElement(C, natoms = 1);
110 CO2->AddElement(O, natoms = 2);
112 G4Material* ArCO2_70_30 =
new G4Material(
"ArCO2_70_30",
113 density = 1.8223 * CLHEP::mg / CLHEP::cm3, ncomponents = 2,
116 ArCO2_70_30->AddElement(Ar, fractionmass = 0.70);
117 ArCO2_70_30->AddMaterial(CO2, fractionmass = 0.30);
119 G4Material* ArCO2_93_7 =
new G4Material(
"ArCO2_93_7",
120 density = 1.8223 * CLHEP::mg / CLHEP::cm3, ncomponents = 2);
121 ArCO2_93_7->AddElement(Ar, fractionmass = 0.93);
122 ArCO2_93_7->AddMaterial(CO2, fractionmass = 0.07);
124 density = 1.413 * CLHEP::g / CLHEP::cm3;
125 G4Material* Kapton =
new G4Material(name =
"Kapton", density, ncomponents =
127 Kapton->AddElement(O, 5);
128 Kapton->AddElement(C, 22);
129 Kapton->AddElement(N, 2);
130 Kapton->AddElement(H, 10);
133 G4cout << *(G4Material::GetMaterialTable()) << G4endl;
138G4VPhysicalVolume* GarfieldDetectorConstruction::DefineVolumes() {
140 G4double worldSizeXYZ = 1000 * mm;
141 G4double absorberThicknessZ = 10. * mm;
142 G4double absorberThicknessXY = 100. * mm;
143 G4double wireRadius = 0.025 * mm;
144 G4double tubeRadius = 15 * mm;
145 G4double tubeHalfLength = 100 * mm;
146 G4double tubeThickness = 500 * um;
149 G4Material* defaultMaterial = G4Material::GetMaterial(
"G4_AIR");
150 fAbsorberMaterial = G4Material::GetMaterial(
"G4_Pb");
152 G4Material* gasMaterial = G4Material::GetMaterial(
"ArCO2_70_30");
153 G4Material* cathodeMaterial = G4Material::GetMaterial(
"G4_Al");
154 G4Material* wireMaterial = G4Material::GetMaterial(
"G4_W");
156 if (!defaultMaterial || !fAbsorberMaterial || !gasMaterial
157 || !cathodeMaterial || !wireMaterial) {
158 G4ExceptionDescription msg;
159 msg <<
"Cannot retrieve materials already defined.";
160 G4Exception(
"GarfieldDetectorConstruction::DefineVolumes()",
161 "exampleGarfield", FatalException, msg);
167 G4VSolid* worldS =
new G4Box(
"World",
168 0.5 * worldSizeXYZ, 0.5 * worldSizeXYZ, 0.5 * worldSizeXYZ);
170 G4LogicalVolume* worldLV =
new G4LogicalVolume(worldS,
174 G4VPhysicalVolume* worldPV =
new G4PVPlacement(0,
185 G4VSolid* absorberS =
new G4Box(
187 0.5 * absorberThicknessXY, 0.5 * absorberThicknessXY,
188 0.5 * absorberThicknessZ);
190 fAbsorberLV =
new G4LogicalVolume(absorberS,
194 fAbsorberPV =
new G4PVPlacement(0,
195 G4ThreeVector(0., 0., absorberThicknessZ / 2),
206 G4VSolid* tubeS =
new G4Tubs(
"Tube",
207 0, tubeRadius, tubeHalfLength + tubeThickness, 0, 2 * pi);
209 G4LogicalVolume* tubeLV =
new G4LogicalVolume(tubeS,
213 G4RotationMatrix* rotY =
new G4RotationMatrix();
214 rotY->rotateY(90. * CLHEP::degree);
216 fTubePV =
new G4PVPlacement(rotY,
217 G4ThreeVector(0., -0.2 * tubeRadius,
218 absorberThicknessZ + tubeRadius),
229 G4VSolid* gasS =
new G4Tubs(
"Gas",
230 wireRadius, tubeRadius - tubeThickness, tubeHalfLength, 0, 2 * pi);
232 G4LogicalVolume* gasLV =
new G4LogicalVolume(gasS,
236 fGasPV =
new G4PVPlacement(0,
237 G4ThreeVector(0., 0., 0.),
248 G4VSolid* wireS =
new G4Tubs(
"Wire",
249 0, wireRadius, tubeHalfLength, 0, 2 * pi);
251 G4LogicalVolume* wireLV =
new G4LogicalVolume(wireS,
255 fWirePV =
new G4PVPlacement(0,
256 G4ThreeVector(0., 0., 0.),
267 worldLV->SetVisAttributes(G4VisAttributes::Invisible);
269 G4VisAttributes* VisAttBlue =
new G4VisAttributes(G4Colour(0.0, 0.0, 1.0));
270 G4VisAttributes* VisAttGreen =
new G4VisAttributes(G4Colour(0.0, 1.0, 0.0));
271 G4VisAttributes* VisAttRed =
new G4VisAttributes(G4Colour(1.0, 0.0, 0.0));
272 G4VisAttributes* VisAttWhite =
new G4VisAttributes(G4Colour(1.0, 1.0, 1.0));
274 wireLV->SetVisAttributes(VisAttRed);
275 tubeLV->SetVisAttributes(VisAttGreen);
276 gasLV->SetVisAttributes(VisAttWhite);
277 fAbsorberLV->SetVisAttributes(VisAttBlue);
279 G4Region* regionGarfield =
new G4Region(
"RegionGarfield");
280 regionGarfield->AddRootLogicalVolume(gasLV);
282 G4Region* regionWire =
new G4Region(
"RegionWire");
283 regionWire->AddRootLogicalVolume(wireLV);
286 "GarfieldG4FastSimulationModel", regionGarfield);
299 G4String name, G4String symbol, G4double density, G4int Z, G4int A) {
303 G4double abundance, massfraction;
305 G4Isotope* isotope =
new G4Isotope(symbol, Z, A);
307 G4Element* element =
new G4Element(name, symbol, ncomponents = 1);
308 element->AddIsotope(isotope, abundance = 100. * perCent);
310 G4Material* material =
new G4Material(name, density, ncomponents = 1);
311 material->AddElement(element, massfraction = 100. * perCent);
319 G4String materialChoice) {
321 G4Material* newMaterial = G4NistManager::Instance()->FindOrBuildMaterial(
325 if (fAbsorberMaterial != newMaterial) {
326 fAbsorberMaterial = newMaterial;
328 fAbsorberLV->SetMaterial(fAbsorberMaterial);
330 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
334 <<
"\n--> warning from GarfieldDetectorConstruction::SetMaterial : "
335 << 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 G4VPhysicalVolume * Construct()
virtual ~GarfieldDetectorConstruction()
void WriteGeometryToGDML(G4VPhysicalVolume *physicalVolume)