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