[807] | 1 | // |
---|
| 2 | // ******************************************************************** |
---|
| 3 | // * License and Disclaimer * |
---|
| 4 | // * * |
---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
| 7 | // * conditions of the Geant4 Software License, included in the file * |
---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
| 9 | // * include a list of copyright holders. * |
---|
| 10 | // * * |
---|
| 11 | // * Neither the authors of this software system, nor their employing * |
---|
| 12 | // * institutes,nor the agencies providing financial support for this * |
---|
| 13 | // * work make any representation or warranty, express or implied, * |
---|
| 14 | // * regarding this software system or assume any liability for its * |
---|
| 15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
| 16 | // * for the full disclaimer and the limitation of liability. * |
---|
| 17 | // * * |
---|
| 18 | // * This code implementation is the result of the scientific and * |
---|
| 19 | // * technical work of the GEANT4 collaboration. * |
---|
| 20 | // * By using, copying, modifying or distributing the software (or * |
---|
| 21 | // * any work based on the software) you agree to acknowledge its * |
---|
| 22 | // * use in resulting scientific publications, and indicate your * |
---|
| 23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
| 24 | // ******************************************************************** |
---|
| 25 | // |
---|
| 26 | // |
---|
| 27 | // ************************************** |
---|
| 28 | // * * |
---|
| 29 | // * RemSimDetectorConstruction.cc * |
---|
| 30 | // * * |
---|
| 31 | // ************************************** |
---|
| 32 | // |
---|
| 33 | // $Id: RemSimDetectorConstruction.cc,v 1.17 2006/06/29 16:23:39 gunter Exp $ |
---|
| 34 | // GEANT4 tag $Name: $ |
---|
| 35 | // |
---|
| 36 | // Author:Susanna Guatelli, guatelli@ge.infn.it |
---|
| 37 | // |
---|
| 38 | #include "RemSimDetectorConstruction.hh" |
---|
| 39 | #include "RemSimMaterial.hh" |
---|
| 40 | #include "RemSimDetectorMessenger.hh" |
---|
| 41 | #include "G4Material.hh" |
---|
| 42 | #include "G4Box.hh" |
---|
| 43 | #include "G4Tubs.hh" |
---|
| 44 | #include "G4LogicalVolume.hh" |
---|
| 45 | #include "G4ThreeVector.hh" |
---|
| 46 | #include "G4PVPlacement.hh" |
---|
| 47 | #include "globals.hh" |
---|
| 48 | #include "G4RunManager.hh" |
---|
| 49 | #include "G4Colour.hh" |
---|
| 50 | #include "G4VisAttributes.hh" |
---|
| 51 | #include "G4UserLimits.hh" |
---|
| 52 | #include "RemSimVGeometryComponent.hh" |
---|
| 53 | #include "RemSimVehicle1.hh" |
---|
| 54 | #include "RemSimMoonHabitat.hh" |
---|
| 55 | #include "G4VisAttributes.hh" |
---|
| 56 | #include "RemSimSensitiveDetector.hh" |
---|
| 57 | #include "G4SDManager.hh" |
---|
| 58 | #include "RemSimROGeometry.hh" |
---|
| 59 | #include "RemSimDecorator.hh" |
---|
| 60 | #include "RemSimShieldingDecorator.hh" |
---|
| 61 | #include "RemSimShelterSPEDecorator.hh" |
---|
| 62 | #include "RemSimAstronautDecorator.hh" |
---|
| 63 | #include "RemSimRoofDecorator.hh" |
---|
| 64 | |
---|
| 65 | RemSimDetectorConstruction::RemSimDetectorConstruction() |
---|
| 66 | : experimentalHall_log(0), experimentalHall_phys(0), |
---|
| 67 | phantomPhys(0), detectorPhys(0), geometry(0) |
---|
| 68 | { |
---|
| 69 | pMaterial = new RemSimMaterial(); |
---|
| 70 | |
---|
| 71 | messenger = new RemSimDetectorMessenger(this); |
---|
| 72 | decoratorValue ="Nothing"; |
---|
| 73 | astronautValue ="On"; |
---|
| 74 | decorator = 0; //pointing to shielding |
---|
| 75 | decoratorSPE = 0; //pointing to SPE shelter |
---|
| 76 | decorator1 = 0; //pointing to the phantom/astronaut |
---|
| 77 | decoratorRoof = 0; //pointing to the roof of the Moon Habitat |
---|
| 78 | moon = false; // moon = true: moon configuration selected |
---|
| 79 | // moon = false: vehicle configuration selected |
---|
| 80 | flag = false; // flag = true : the geometry configuration (vehicle/moon) |
---|
| 81 | // has been chosen |
---|
| 82 | // flag = false : the geometry configuration (vehicle/moon) |
---|
| 83 | // has not been chosen} |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | RemSimDetectorConstruction::~RemSimDetectorConstruction() |
---|
| 87 | { |
---|
| 88 | delete decoratorRoof; |
---|
| 89 | delete decorator1; |
---|
| 90 | delete decoratorSPE; |
---|
| 91 | delete decorator; |
---|
| 92 | delete messenger; |
---|
| 93 | delete geometry; |
---|
| 94 | delete pMaterial; |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | G4VPhysicalVolume* RemSimDetectorConstruction::Construct() |
---|
| 98 | { |
---|
| 99 | pMaterial -> DefineMaterials(); |
---|
| 100 | G4Material* vacuum = pMaterial -> GetMaterial("Galactic"); |
---|
| 101 | |
---|
| 102 | // World definition |
---|
| 103 | |
---|
| 104 | G4double expHall_x = 30.0*m; |
---|
| 105 | G4double expHall_y = 30.0*m; |
---|
| 106 | G4double expHall_z = 30.0*m; |
---|
| 107 | |
---|
| 108 | G4Box* experimentalHall_box |
---|
| 109 | = new G4Box("world",expHall_x,expHall_y,expHall_z); |
---|
| 110 | experimentalHall_log = new G4LogicalVolume(experimentalHall_box, |
---|
| 111 | vacuum,"world",0,0,0); |
---|
| 112 | |
---|
| 113 | experimentalHall_phys = new G4PVPlacement(0,G4ThreeVector(),"world", |
---|
| 114 | experimentalHall_log,0, |
---|
| 115 | false,0); |
---|
| 116 | return experimentalHall_phys; |
---|
| 117 | } |
---|
| 118 | |
---|
| 119 | void RemSimDetectorConstruction::ConstructVolume() |
---|
| 120 | { |
---|
| 121 | if (moon == true) |
---|
| 122 | { |
---|
| 123 | |
---|
| 124 | geometry = new RemSimMoonHabitat(); |
---|
| 125 | geometry -> ConstructComponent(experimentalHall_phys); |
---|
| 126 | decorator1 = new RemSimAstronautDecorator(geometry, moon); |
---|
| 127 | decorator1 -> ConstructComponent(experimentalHall_phys); |
---|
| 128 | } |
---|
| 129 | else |
---|
| 130 | { |
---|
| 131 | geometry = new RemSimVehicle1(); |
---|
| 132 | geometry -> ConstructComponent(experimentalHall_phys); |
---|
| 133 | decorator1 = new RemSimAstronautDecorator(geometry, moon); |
---|
| 134 | decorator1 -> ConstructComponent(experimentalHall_phys); |
---|
| 135 | } |
---|
| 136 | } |
---|
| 137 | |
---|
| 138 | void RemSimDetectorConstruction::AddShielding(G4String value) |
---|
| 139 | { |
---|
| 140 | if (moon == false) |
---|
| 141 | { |
---|
| 142 | decoratorValue = value; |
---|
| 143 | |
---|
| 144 | if (decoratorValue == "On") |
---|
| 145 | { |
---|
| 146 | if (decorator == 0) |
---|
| 147 | { |
---|
| 148 | decorator = new RemSimShieldingDecorator(geometry); |
---|
| 149 | decorator -> ConstructComponent(experimentalHall_phys); |
---|
| 150 | G4RunManager::GetRunManager() -> DefineWorldVolume(experimentalHall_phys); |
---|
| 151 | } |
---|
| 152 | else G4cout<<" The shielding alread exists!"<<G4endl; |
---|
| 153 | } |
---|
| 154 | |
---|
| 155 | if (decoratorValue == "Off") |
---|
| 156 | { |
---|
| 157 | if (decorator != 0) |
---|
| 158 | { |
---|
| 159 | decorator -> DestroyComponent(); |
---|
| 160 | G4RunManager::GetRunManager() -> DefineWorldVolume(experimentalHall_phys); |
---|
| 161 | decorator = 0; |
---|
| 162 | } |
---|
| 163 | |
---|
| 164 | else G4cout<<" The shielding does not exist!"<<G4endl; |
---|
| 165 | } |
---|
| 166 | } |
---|
| 167 | else G4cout << " The shielding is not available in moon habitat configuration"<<G4endl; |
---|
| 168 | } |
---|
| 169 | |
---|
| 170 | void RemSimDetectorConstruction::AddShelterSPE(G4String value) |
---|
| 171 | { |
---|
| 172 | if (moon == false) |
---|
| 173 | { |
---|
| 174 | if (value == "On") |
---|
| 175 | { |
---|
| 176 | if (decoratorSPE == 0) |
---|
| 177 | { |
---|
| 178 | decoratorSPE = new RemSimShelterSPEDecorator(geometry); |
---|
| 179 | decoratorSPE -> ConstructComponent(experimentalHall_phys); |
---|
| 180 | G4RunManager::GetRunManager() -> DefineWorldVolume(experimentalHall_phys); |
---|
| 181 | } |
---|
| 182 | else G4cout<<" The SPE shelter alread exists!"<<G4endl; |
---|
| 183 | } |
---|
| 184 | |
---|
| 185 | if (value == "Off") |
---|
| 186 | { |
---|
| 187 | if (decoratorSPE != 0) |
---|
| 188 | { |
---|
| 189 | decoratorSPE -> DestroyComponent(); |
---|
| 190 | G4RunManager::GetRunManager() -> DefineWorldVolume(experimentalHall_phys); |
---|
| 191 | decoratorSPE = 0; |
---|
| 192 | } |
---|
| 193 | |
---|
| 194 | else G4cout<<" The SPE shelter does not exist!"<<G4endl; |
---|
| 195 | } |
---|
| 196 | } |
---|
| 197 | else G4cout<< " It is not possible to select SPE shelter in moon habitat configuration" << G4endl; |
---|
| 198 | } |
---|
| 199 | |
---|
| 200 | void RemSimDetectorConstruction::AddHabitatRoof(G4String value) |
---|
| 201 | { |
---|
| 202 | if (moon == true) |
---|
| 203 | { |
---|
| 204 | if (value == "On") |
---|
| 205 | { |
---|
| 206 | if (decoratorRoof == 0) |
---|
| 207 | { |
---|
| 208 | decoratorRoof = new RemSimRoofDecorator(geometry); |
---|
| 209 | decoratorRoof -> ConstructComponent(experimentalHall_phys); |
---|
| 210 | G4RunManager::GetRunManager() -> DefineWorldVolume(experimentalHall_phys); |
---|
| 211 | } |
---|
| 212 | else G4cout<<" The roof alread exists!"<<G4endl; |
---|
| 213 | } |
---|
| 214 | |
---|
| 215 | if (value == "Off") |
---|
| 216 | { |
---|
| 217 | if (decoratorRoof != 0) |
---|
| 218 | { |
---|
| 219 | decoratorRoof -> DestroyComponent(); |
---|
| 220 | G4RunManager::GetRunManager() -> DefineWorldVolume(experimentalHall_phys); |
---|
| 221 | decoratorRoof = 0; |
---|
| 222 | } |
---|
| 223 | |
---|
| 224 | else G4cout<<" The roof does not exist!"<<G4endl; |
---|
| 225 | } |
---|
| 226 | } |
---|
| 227 | else G4cout<< " It is not possible to select the roof in the vehicle configuration" << G4endl; |
---|
| 228 | } |
---|
| 229 | |
---|
| 230 | void RemSimDetectorConstruction::ChangeShieldingThickness(G4double thick) |
---|
| 231 | { |
---|
| 232 | if (moon == false) |
---|
| 233 | { |
---|
| 234 | if (decorator != 0) |
---|
| 235 | { |
---|
| 236 | decorator -> ChangeThickness(thick); |
---|
| 237 | G4RunManager::GetRunManager() -> DefineWorldVolume(experimentalHall_phys); |
---|
| 238 | } |
---|
| 239 | else G4cout<<" Define the shielding before!"<< G4endl; |
---|
| 240 | } |
---|
| 241 | } |
---|
| 242 | |
---|
| 243 | void RemSimDetectorConstruction::ChangeRoofThickness(G4double thick) |
---|
| 244 | { |
---|
| 245 | if (moon == true) |
---|
| 246 | { |
---|
| 247 | if (decoratorRoof != 0) |
---|
| 248 | { |
---|
| 249 | decoratorRoof -> ChangeThickness(thick); |
---|
| 250 | G4RunManager::GetRunManager() -> DefineWorldVolume(experimentalHall_phys); |
---|
| 251 | } |
---|
| 252 | else G4cout<<" Define the roof before!"<< G4endl; |
---|
| 253 | } |
---|
| 254 | |
---|
| 255 | else G4cout<<"The roof can be selected in moon habitat configuration"<<G4endl; |
---|
| 256 | } |
---|
| 257 | |
---|
| 258 | void RemSimDetectorConstruction:: ChooseConfiguration(G4String value) |
---|
| 259 | { |
---|
| 260 | if (flag == false) |
---|
| 261 | { |
---|
| 262 | if (value == "vehicle") ConstructVolume(); |
---|
| 263 | |
---|
| 264 | else if (value == "moon") |
---|
| 265 | { |
---|
| 266 | moon = true; |
---|
| 267 | ConstructVolume(); |
---|
| 268 | } |
---|
| 269 | G4RunManager::GetRunManager() -> DefineWorldVolume(experimentalHall_phys); |
---|
| 270 | flag = true; |
---|
| 271 | } |
---|
| 272 | else |
---|
| 273 | G4cout<< "The configurations vehicle/moon can not be switched" << G4endl; |
---|
| 274 | } |
---|
| 275 | |
---|