00001
00002
00003
00004
00005
00006
00007 #include "DetectorConstruction.hh"
00008
00009 #include "G4Material.hh"
00010 #include "G4Box.hh"
00011 #include "G4Tubs.hh"
00012 #include "G4LogicalVolume.hh"
00013 #include "G4PVPlacement.hh"
00014 #include "G4RotationMatrix.hh"
00015
00016 #include "G4VisAttributes.hh"
00017
00018
00019
00020
00021 DetectorConstruction::DetectorConstruction()
00022 {
00023 DefineMaterials();
00024 }
00025
00026
00027
00028 DetectorConstruction::~DetectorConstruction()
00029 { }
00030
00031
00032
00033 G4VPhysicalVolume* DetectorConstruction::Construct()
00034 {
00035 return ConstructVolumes();
00036 }
00037
00038
00039
00040 void DetectorConstruction::DefineMaterials()
00041 {
00042
00043
00044
00045 G4double Z,A,density;
00046
00047 G4Material* Al =
00048 new G4Material("Aluminium", Z=13., A=26.98*g/mole, density=2.700*g/cm3);
00049
00050
00051
00052
00053 G4Element* N = new G4Element("Nitrogen" ,"N" , Z=7., A=14.01*g/mole);
00054 G4Element* O = new G4Element("Oxygen" ,"O" , Z=8., A=16.00*g/mole);
00055
00056 G4int ncomponents;
00057 G4double fractionmass;
00058
00059 G4Material* Air =
00060 new G4Material("Air", density= 1.290*mg/cm3, ncomponents=2);
00061 Air->AddElement(N, fractionmass=70.*perCent);
00062 Air->AddElement(O, fractionmass=30.*perCent);
00063
00064
00065
00066 G4Material* Vacuum =
00067 new G4Material("Galactic", Z=1., A=1.01*g/mole, density= 1.e-10*g/cm3,
00068 kStateGas, 2.73*kelvin, 3.e-18*pascal);
00069
00070
00071
00072 m_worldMaterial = Vacuum;
00073 m_spacecraftMaterial = m_floorMaterial = Al;
00074 m_cabinMaterial = Air;
00075
00076
00077
00078 G4cout << *(G4Material::GetMaterialTable()) << G4endl;
00079 }
00080
00081
00082
00083 G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
00084 {
00085
00086
00087 G4double cabinRadius = 50*cm;
00088 G4double cabinLength = 80*cm;
00089
00090 G4double spacecraftThickness = 2*cm;
00091 G4double spacecraftRadius = cabinRadius + spacecraftThickness;
00092 G4double spacecraftLength = cabinLength + 2*spacecraftThickness;
00093
00094 G4double floorThickness = 2*cm;
00095 G4double floorYcenter = - 0.5*cabinRadius;
00096
00097 G4double floorYbottom = floorYcenter - 0.5*floorThickness;
00098 G4double floorWidth =
00099 2*std::sqrt(cabinRadius*cabinRadius - floorYbottom*floorYbottom);
00100 G4double floorLength = cabinLength;
00101
00102 m_worldSizeXY = 2.2*spacecraftRadius;
00103 m_worldSizeZ = 1.1*spacecraftLength;
00104
00105
00106
00107
00108
00109 G4Box*
00110 solidWorld = new G4Box("World",
00111 m_worldSizeXY/2,m_worldSizeXY/2,m_worldSizeZ/2);
00112
00113 G4LogicalVolume*
00114 logicWorld = new G4LogicalVolume(solidWorld,
00115 m_worldMaterial,
00116 "World");
00117
00118 m_physiWorld = new G4PVPlacement(0,
00119 G4ThreeVector(),
00120 logicWorld,
00121 "World",
00122 0,
00123 false,
00124 0);
00125
00126
00127
00128 G4Tubs*
00129 solidSpacecraft = new G4Tubs("Spacecraft",
00130 0*cm, spacecraftRadius,
00131 0.5*spacecraftLength,
00132 0., twopi);
00133
00134 G4LogicalVolume*
00135 logicSpacecraft = new G4LogicalVolume(solidSpacecraft,
00136 m_spacecraftMaterial,
00137 "Spacecraft");
00138
00139 new G4PVPlacement(0,
00140 G4ThreeVector(0,0,0),
00141 logicSpacecraft,
00142 "Spacecraft",
00143 logicWorld,
00144 false,
00145 0);
00146
00147
00148
00149 G4Tubs*
00150 solidCabin = new G4Tubs("Cabin",
00151 0*cm, cabinRadius,
00152 0.5*cabinLength,
00153 0., 360*deg);
00154
00155 G4LogicalVolume*
00156 logicCabin = new G4LogicalVolume(solidCabin,
00157 m_cabinMaterial,
00158 "Cabin");
00159
00160 new G4PVPlacement(0,
00161 G4ThreeVector(0,0,0),
00162 logicCabin,
00163 "Cabin",
00164 logicSpacecraft,
00165 false,
00166 0);
00167
00168
00169
00170
00171 G4Box*
00172 solidFloor = new G4Box("Floor",
00173 floorWidth/2,floorLength/2,floorThickness/2);
00174
00175 G4LogicalVolume*
00176 logicFloor = new G4LogicalVolume(solidFloor, m_floorMaterial, "Floor");
00177
00178
00179 G4RotationMatrix* rotm = new G4RotationMatrix();
00180 rotm->rotateX(90*deg);
00181
00182 new G4PVPlacement(rotm,
00183 G4ThreeVector(0,floorYcenter,0),
00184 logicFloor,
00185 "Floor",
00186 logicCabin,
00187 false,
00188 0);
00189
00190
00191
00192
00193 G4VisAttributes* colourWhite= new G4VisAttributes(G4Colour(1.,1.,1.));
00194 colourWhite->SetVisibility(true);
00195 colourWhite->SetForceSolid(false);
00196
00197 G4VisAttributes* colourGrey= new G4VisAttributes(G4Colour(0.5,0.5,0.5));
00198 colourGrey->SetVisibility(true);
00199 colourGrey->SetForceSolid(false);
00200
00201 G4VisAttributes* colourCyan= new G4VisAttributes(G4Colour(0.,1.,1.));
00202 colourCyan->SetVisibility(true);
00203 colourCyan->SetForceSolid(false);
00204
00205 G4VisAttributes* colourMagenta= new G4VisAttributes(G4Colour(1.,0.,1.));
00206 colourMagenta->SetVisibility(true);
00207 colourMagenta->SetForceSolid(true);
00208
00209 G4VisAttributes* colourBlue= new G4VisAttributes(G4Colour(0.,0.,1.));
00210 colourBlue->SetVisibility(true);
00211 colourBlue->SetForceSolid(false);
00212
00213 logicWorld->SetVisAttributes(colourGrey);
00214 logicSpacecraft->SetVisAttributes(colourCyan);
00215 logicCabin->SetVisAttributes(colourCyan);
00216 logicFloor->SetVisAttributes(colourWhite);
00217
00218
00219
00220 PrintParameters();
00221
00222
00223
00224 return m_physiWorld;
00225 }
00226
00227
00228
00229 void DetectorConstruction::PrintParameters()
00230 {
00231 G4cout << "\n---------------------------------------------------------\n";
00232 G4cout
00233 << "---> The world is in " << m_worldMaterial->GetName() << "\n"
00234 << "---> The spacecraft is in " << m_spacecraftMaterial->GetName() << "\n"
00235 << "---> The cabin is in " << m_cabinMaterial->GetName() << "\n"
00236 << "---> The floor is in " << m_floorMaterial->GetName();
00237 G4cout << "\n---------------------------------------------------------\n";
00238 G4cout << G4endl;
00239 }
00240
00241