00001
00002
00003
00004
00005
00006
00007 #include "DetectorConstruction.hh"
00008 #include "DetectorMessenger.hh"
00009
00010 #include "G4Material.hh"
00011 #include "G4Box.hh"
00012 #include "G4Tubs.hh"
00013 #include "G4Trd.hh"
00014 #include "G4LogicalVolume.hh"
00015 #include "G4PVPlacement.hh"
00016 #include "G4RotationMatrix.hh"
00017
00018 #include "G4GeometryManager.hh"
00019 #include "G4PhysicalVolumeStore.hh"
00020 #include "G4LogicalVolumeStore.hh"
00021 #include "G4SolidStore.hh"
00022
00023 #include "G4VisAttributes.hh"
00024 #include "G4UnitsTable.hh"
00025
00026
00027
00028
00029 DetectorConstruction::DetectorConstruction()
00030 {
00031 DefineMaterials();
00032
00033
00034
00035 m_cabinRadius = 50*cm;
00036 m_cabinLength = 80*cm;
00037 m_spacecraftThickness = 2*cm;
00038
00039 m_floorThickness = 2*cm;
00040
00041 m_astronautHeight = 50*cm;
00042 m_astronautTopWidth = 40*cm;
00043 m_astronautBottomWidth = 60*cm;
00044
00045
00046 m_detectorMessenger = new DetectorMessenger(this);
00047 }
00048
00049
00050
00051 DetectorConstruction::~DetectorConstruction()
00052 {delete m_detectorMessenger; }
00053
00054
00055
00056 G4VPhysicalVolume* DetectorConstruction::Construct()
00057 {
00058 return ConstructVolumes();
00059 }
00060
00061
00062
00063 void DetectorConstruction::DefineMaterials()
00064 {
00065
00066
00067
00068 G4double Z,A,density;
00069
00070 G4Material* Al =
00071 new G4Material("Aluminium", Z=13., A=26.98*g/mole, density=2.700*g/cm3);
00072
00073
00074
00075
00076 G4Element* H = new G4Element("Hydrogen" ,"H" , Z=1., A= 1.01*g/mole);
00077 G4Element* N = new G4Element("Nitrogen" ,"N" , Z=7., A=14.01*g/mole);
00078 G4Element* O = new G4Element("Oxygen" ,"O" , Z=8., A=16.00*g/mole);
00079
00080 G4int ncomponents, natoms;
00081 G4double fractionmass;
00082
00083 G4Material* Air =
00084 new G4Material("Air", density= 1.290*mg/cm3, ncomponents=2);
00085 Air->AddElement(N, fractionmass=70.*perCent);
00086 Air->AddElement(O, fractionmass=30.*perCent);
00087
00088 G4Material* H2O =
00089 new G4Material("Water", density= 1.000*g/cm3, ncomponents=2);
00090 H2O->AddElement(H, natoms=2);
00091 H2O->AddElement(O, natoms=1);
00092
00093
00094
00095 G4Material* Vacuum =
00096 new G4Material("Galactic", Z=1., A=1.01*g/mole, density= 1.e-10*g/cm3,
00097 kStateGas, 2.73*kelvin, 3.e-18*pascal);
00098
00099
00100
00101 m_worldMaterial = Vacuum;
00102 m_spacecraftMaterial = m_floorMaterial = Al;
00103 m_cabinMaterial = Air;
00104 m_astronautMaterial = H2O;
00105
00106
00107
00108 G4cout << *(G4Material::GetMaterialTable()) << G4endl;
00109 }
00110
00111
00112
00113 G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
00114 {
00115
00116 G4GeometryManager::GetInstance()->OpenGeometry();
00117 G4PhysicalVolumeStore::GetInstance()->Clean();
00118 G4LogicalVolumeStore::GetInstance()->Clean();
00119 G4SolidStore::GetInstance()->Clean();
00120
00121
00122
00123 m_spacecraftRadius = m_cabinRadius + m_spacecraftThickness;
00124 m_spacecraftLength = m_cabinLength + 2*m_spacecraftThickness;
00125
00126 m_floorYcenter = - 0.5*m_cabinRadius;
00127 G4double floorYtop = m_floorYcenter + 0.5*m_floorThickness;
00128 G4double floorYbottom = m_floorYcenter - 0.5*m_floorThickness;
00129 m_floorWidth =
00130 2*std::sqrt(m_cabinRadius*m_cabinRadius - floorYbottom*floorYbottom);
00131 m_floorLength = m_cabinLength;
00132
00133 m_worldSizeXY = 2.2*m_spacecraftRadius;
00134 m_worldSizeZ = 1.1*m_spacecraftLength;
00135
00136 m_astronautPosition = floorYtop + 0.5*m_astronautHeight;
00137
00138
00139
00140
00141
00142 G4Box*
00143 solidWorld = new G4Box("World",
00144 m_worldSizeXY/2,m_worldSizeXY/2,m_worldSizeZ/2);
00145
00146 G4LogicalVolume*
00147 logicWorld = new G4LogicalVolume(solidWorld,
00148 m_worldMaterial,
00149 "World");
00150
00151 m_physiWorld = new G4PVPlacement(0,
00152 G4ThreeVector(),
00153 logicWorld,
00154 "World",
00155 0,
00156 false,
00157 0);
00158
00159
00160
00161 G4Tubs*
00162 solidSpacecraft = new G4Tubs("Spacecraft",
00163 0*cm, m_spacecraftRadius,
00164 0.5*m_spacecraftLength,
00165 0., twopi);
00166
00167 G4LogicalVolume*
00168 logicSpacecraft = new G4LogicalVolume(solidSpacecraft,
00169 m_spacecraftMaterial,
00170 "Spacecraft");
00171
00172 m_physiSpacecraft = new G4PVPlacement(0,
00173 G4ThreeVector(0,0,0),
00174 logicSpacecraft,
00175 "Spacecraft",
00176 logicWorld,
00177 false,
00178 0);
00179
00180
00181
00182 G4Tubs*
00183 solidCabin = new G4Tubs("Cabin",
00184 0*cm, m_cabinRadius,
00185 0.5*m_cabinLength,
00186 0., 360*deg);
00187
00188 G4LogicalVolume*
00189 logicCabin = new G4LogicalVolume(solidCabin,
00190 m_cabinMaterial,
00191 "Cabin");
00192
00193 m_physiCabin = new G4PVPlacement(0,
00194 G4ThreeVector(0,0,0),
00195 logicCabin,
00196 "Cabin",
00197 logicSpacecraft,
00198 false,
00199 0);
00200
00201
00202
00203
00204 G4Box*
00205 solidFloor = new G4Box("Floor",
00206 m_floorWidth/2,m_floorLength/2,m_floorThickness/2);
00207
00208 G4LogicalVolume*
00209 logicFloor = new G4LogicalVolume(solidFloor, m_floorMaterial, "Floor");
00210
00211
00212 G4RotationMatrix* rotm1 = new G4RotationMatrix();
00213 rotm1->rotateX(90*deg);
00214
00215 m_physiFloor = new G4PVPlacement(rotm1,
00216 G4ThreeVector(0,m_floorYcenter,0),
00217 logicFloor,
00218 "Floor",
00219 logicCabin,
00220 false,
00221 0);
00222
00223
00224
00225 G4Trd*
00226 solidAstronaut = new G4Trd("Astronaut",
00227 0.5 * m_astronautBottomWidth,
00228 0.5 * m_astronautTopWidth,
00229 0.5 * m_astronautBottomWidth,
00230 0.5 * m_astronautTopWidth,
00231 0.5 * m_astronautHeight);
00232
00233 G4LogicalVolume*
00234 logicAstronaut = new G4LogicalVolume(solidAstronaut,
00235 m_astronautMaterial,
00236 "Astronaut");
00237
00238
00239 G4RotationMatrix* rotm2 = new G4RotationMatrix();
00240 rotm2->rotateX(90*deg);
00241
00242
00243 G4ThreeVector position = G4ThreeVector(0.,m_astronautPosition,0.);
00244
00245 m_physiAstronaut = new G4PVPlacement(rotm2,
00246 position,
00247 logicAstronaut,
00248 "Astronaut",
00249 logicCabin,
00250 false,
00251 0);
00252
00253
00254
00255 G4VisAttributes* colourWhite= new G4VisAttributes(G4Colour(1.,1.,1.));
00256 colourWhite->SetVisibility(true);
00257 colourWhite->SetForceSolid(false);
00258
00259 G4VisAttributes* colourGrey= new G4VisAttributes(G4Colour(0.5,0.5,0.5));
00260 colourGrey->SetVisibility(true);
00261 colourGrey->SetForceSolid(false);
00262
00263 G4VisAttributes* colourCyan= new G4VisAttributes(G4Colour(0.,1.,1.));
00264 colourCyan->SetVisibility(true);
00265 colourCyan->SetForceSolid(false);
00266
00267 G4VisAttributes* colourMagenta= new G4VisAttributes(G4Colour(1.,0.,1.));
00268 colourMagenta->SetVisibility(true);
00269 colourMagenta->SetForceSolid(true);
00270
00271 G4VisAttributes* colourBlue= new G4VisAttributes(G4Colour(0.,0.,1.));
00272 colourBlue->SetVisibility(true);
00273 colourBlue->SetForceSolid(false);
00274
00275 logicWorld->SetVisAttributes(colourGrey);
00276 logicSpacecraft->SetVisAttributes(colourCyan);
00277 logicCabin->SetVisAttributes(colourCyan);
00278 logicFloor->SetVisAttributes(colourWhite);
00279 logicAstronaut->SetVisAttributes(colourBlue);
00280
00281
00282
00283 PrintParameters();
00284
00285
00286
00287 return m_physiWorld;
00288 }
00289
00290
00291
00292 void DetectorConstruction::PrintParameters()
00293 {
00294 G4cout << "\n---------------------------------------------------------\n";
00295 G4cout
00296 << "---> World : (" << m_worldSizeXY/m << " X " << m_worldSizeXY/m << " X "
00297 << m_worldSizeZ/m << ") m of "
00298 << m_worldMaterial->GetName() << G4endl;
00299 G4cout
00300 << "---> Spacecraft : radius = " << G4BestUnit(m_spacecraftRadius,"Length")
00301 << "\t length = " << G4BestUnit(m_spacecraftLength,"Length")
00302 << "\t thickness = " << G4BestUnit(m_spacecraftThickness,"Length")
00303 << "\t material : " << m_spacecraftMaterial->GetName() << G4endl;
00304 G4cout
00305 << "---> Cabin : radius = " << G4BestUnit(m_cabinRadius,"Length")
00306 << "\t length = " << G4BestUnit(m_cabinLength,"Length")
00307 << "\t material : " << m_cabinMaterial->GetName() << G4endl;
00308 G4cout
00309 << "---> Floor : thickness = " << G4BestUnit(m_floorThickness,"Length")
00310 << "\t width = " << G4BestUnit(m_floorWidth,"Length")
00311 << "\t length = " << G4BestUnit(m_floorLength,"Length")
00312 << "\t material : " << m_floorMaterial->GetName() << G4endl;
00313 G4cout
00314 << "---> Astronaut : height = " << G4BestUnit(m_astronautHeight,"Length")
00315 << "\t bottom width = " << G4BestUnit(m_astronautBottomWidth,"Length")
00316 << "\t top width = " << G4BestUnit(m_astronautTopWidth,"Length")
00317 << "\t material : " << m_astronautMaterial->GetName() << G4endl;
00318 G4cout << "\n---------------------------------------------------------\n";
00319 G4cout << G4endl;
00320 }
00321
00322
00323
00324 void DetectorConstruction::SetWorldMaterial(G4String materialChoice)
00325 {
00326
00327 G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
00328 if (pttoMaterial) m_worldMaterial = pttoMaterial;
00329 }
00330
00331
00332
00333 void DetectorConstruction::SetSpacecraftMaterial(G4String materialChoice)
00334 {
00335
00336 G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
00337 if (pttoMaterial) m_spacecraftMaterial = pttoMaterial;
00338 }
00339
00340
00341
00342 void DetectorConstruction::SetCabinMaterial(G4String materialChoice)
00343 {
00344
00345 G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
00346 if (pttoMaterial) m_cabinMaterial = pttoMaterial;
00347 }
00348
00349
00350
00351 void DetectorConstruction::SetFloorMaterial(G4String materialChoice)
00352 {
00353
00354 G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
00355 if (pttoMaterial) m_floorMaterial = pttoMaterial;
00356 }
00357
00358
00359
00360 void DetectorConstruction::SetAstronautMaterial(G4String materialChoice)
00361 {
00362
00363 G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
00364 if (pttoMaterial) m_astronautMaterial = pttoMaterial;
00365 }
00366
00367
00368
00369 #include "G4RunManager.hh"
00370
00371 void DetectorConstruction::UpdateGeometry()
00372 {
00373 G4RunManager::GetRunManager()->DefineWorldVolume(ConstructVolumes());
00374 }
00375
00376