Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // g << 25 //g 26 /// \file persistency/gdml/G02/src/G02Detector 26 /// \file persistency/gdml/G02/src/G02DetectorConstruction.cc 27 /// \brief Implementation of the G02DetectorCo 27 /// \brief Implementation of the G02DetectorConstruction class 28 // 28 // 29 // 29 // >> 30 // $Id: G02DetectorConstruction.cc 68025 2013-03-13 13:43:46Z gcosmo $ 30 // 31 // 31 // Class G02DetectorConstruction implementatio 32 // Class G02DetectorConstruction implementation 32 // 33 // 33 // ------------------------------------------- 34 // ---------------------------------------------------------------------------- 34 35 35 #include "G02DetectorConstruction.hh" 36 #include "G02DetectorConstruction.hh" 36 37 37 // Geant4 includes 38 // Geant4 includes 38 // 39 // >> 40 #include "globals.hh" 39 #include "G4GeometryManager.hh" 41 #include "G4GeometryManager.hh" 40 #include "G4VisAttributes.hh" 42 #include "G4VisAttributes.hh" 41 #include "globals.hh" << 42 43 43 // Materials 44 // Materials 44 // 45 // 45 #include "G4Material.hh" 46 #include "G4Material.hh" 46 47 47 // Geometry includes 48 // Geometry includes 48 // 49 // 49 #include "G4Box.hh" << 50 #include "G4LogicalVolume.hh" 50 #include "G4LogicalVolume.hh" >> 51 #include "G4VPhysicalVolume.hh" 51 #include "G4PVParameterised.hh" 52 #include "G4PVParameterised.hh" 52 #include "G4PVPlacement.hh" 53 #include "G4PVPlacement.hh" >> 54 #include "G4Box.hh" 53 #include "G4Tubs.hh" 55 #include "G4Tubs.hh" 54 #include "G4VPhysicalVolume.hh" << 55 56 56 // Reflected solids 57 // Reflected solids 57 // 58 // 58 #include "G4AffineTransform.hh" << 59 #include "G4DisplacedSolid.hh" << 60 #include "G4ReflectedSolid.hh" 59 #include "G4ReflectedSolid.hh" >> 60 #include "G4DisplacedSolid.hh" 61 #include "G4ReflectionFactory.hh" 61 #include "G4ReflectionFactory.hh" 62 #include "G4RotationMatrix.hh" 62 #include "G4RotationMatrix.hh" >> 63 #include "G4AffineTransform.hh" 63 #include "G4Transform3D.hh" 64 #include "G4Transform3D.hh" 64 65 65 // Assembly volumes 66 // Assembly volumes 66 // 67 // 67 #include "G4AssemblyVolume.hh" 68 #include "G4AssemblyVolume.hh" 68 69 69 // Volume parameterisations 70 // Volume parameterisations 70 // 71 // 71 #include "G02ChamberParameterisation.hh" 72 #include "G02ChamberParameterisation.hh" 72 73 73 // Messenger 74 // Messenger 74 // 75 // 75 #include "G02DetectorMessenger.hh" 76 #include "G02DetectorMessenger.hh" 76 77 77 // GDML parser include 78 // GDML parser include 78 // 79 // 79 #include "G4GDMLParser.hh" 80 #include "G4GDMLParser.hh" >> 81 80 #include "G4PhysicalConstants.hh" 82 #include "G4PhysicalConstants.hh" 81 #include "G4SystemOfUnits.hh" 83 #include "G4SystemOfUnits.hh" 82 84 83 //....oooOO0OOooo........oooOO0OOooo........oo 85 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 84 // 86 // 85 // Constructor 87 // Constructor 86 // 88 // 87 G02DetectorConstruction::G02DetectorConstructi 89 G02DetectorConstruction::G02DetectorConstruction() 88 : G4VUserDetectorConstruction(), fAir(0), fA << 90 : G4VUserDetectorConstruction(), 89 { << 91 fAir(0), fAluminum(0), fPb(0), fXenon(0), 90 fExpHall_x = 5. * m; << 92 fDetectorMessenger(0) 91 << 93 { 92 fReadFile = "test.gdml"; << 94 fExpHall_x=5.*m; 93 fWriteFile = "wtest.gdml"; << 95 94 fStepFile = "mbb"; << 96 fReadFile ="test.gdml"; 95 fWritingChoice = 1; << 97 fWriteFile="wtest.gdml"; 96 << 98 fStepFile ="mbb"; 97 fDetectorMessenger = new G02DetectorMessenge << 99 fWritingChoice=1; >> 100 >> 101 fDetectorMessenger = new G02DetectorMessenger( this ); 98 } 102 } 99 103 100 //....oooOO0OOooo........oooOO0OOooo........oo 104 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 101 // 105 // 102 // Destructor 106 // Destructor 103 // 107 // 104 G02DetectorConstruction::~G02DetectorConstruct 108 G02DetectorConstruction::~G02DetectorConstruction() 105 { 109 { 106 if (fDetectorMessenger) delete fDetectorMess << 110 if(fDetectorMessenger) delete fDetectorMessenger; 107 } 111 } 108 112 109 //....oooOO0OOooo........oooOO0OOooo........oo 113 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 110 // 114 // 111 // Constructs geometries and materials 115 // Constructs geometries and materials 112 // 116 // 113 G4VPhysicalVolume* G02DetectorConstruction::Co 117 G4VPhysicalVolume* G02DetectorConstruction::Construct() 114 { << 118 { 115 // Writing or Reading of Geometry using G4GD 119 // Writing or Reading of Geometry using G4GDML 116 120 117 G4VPhysicalVolume* fWorldPhysVol; 121 G4VPhysicalVolume* fWorldPhysVol; 118 122 119 if (fWritingChoice == 0) { << 123 if(fWritingChoice==0) >> 124 { 120 // **** LOOK HERE*** FOR READING GDML FILE 125 // **** LOOK HERE*** FOR READING GDML FILES 121 // 126 // 122 << 127 123 // ACTIVATING OVERLAP CHECK when read volu 128 // ACTIVATING OVERLAP CHECK when read volumes are placed. 124 // Can take long time in case of complex g 129 // Can take long time in case of complex geometries 125 // 130 // 126 // fParser.SetOverlapCheck(true); 131 // fParser.SetOverlapCheck(true); 127 132 128 fParser.Read(fReadFile); 133 fParser.Read(fReadFile); 129 134 130 // READING GDML FILES OPTION: 2nd Boolean 135 // READING GDML FILES OPTION: 2nd Boolean argument "Validate". 131 // Flag to "false" disables check with the 136 // Flag to "false" disables check with the Schema when reading GDML file. 132 // See the GDML Documentation for more inf 137 // See the GDML Documentation for more information. 133 // 138 // 134 // fParser.Read(fReadFile,false); 139 // fParser.Read(fReadFile,false); 135 << 140 136 // Prints the material information 141 // Prints the material information 137 // 142 // 138 G4cout << *(G4Material::GetMaterialTable() << 143 G4cout << *(G4Material::GetMaterialTable() ) << G4endl; 139 << 144 140 // Giving World Physical Volume from GDML 145 // Giving World Physical Volume from GDML Parser 141 // 146 // 142 fWorldPhysVol = fParser.GetWorldVolume(); << 147 fWorldPhysVol = fParser.GetWorldVolume(); 143 } 148 } 144 else if (fWritingChoice == 1) { << 149 else if(fWritingChoice==1) >> 150 { 145 // **** LOOK HERE*** FOR WRITING GDML FILE 151 // **** LOOK HERE*** FOR WRITING GDML FILES 146 // Detector Construction and WRITING to GD 152 // Detector Construction and WRITING to GDML 147 // 153 // 148 ListOfMaterials(); 154 ListOfMaterials(); 149 fWorldPhysVol = ConstructDetector(); 155 fWorldPhysVol = ConstructDetector(); 150 156 151 // OPTION: TO ADD MODULE AT DEPTH LEVEL .. 157 // OPTION: TO ADD MODULE AT DEPTH LEVEL ... 152 // 158 // 153 // Can be a integer or a pointer to the to 159 // Can be a integer or a pointer to the top Physical Volume: 154 // 160 // 155 // G4int depth=1; 161 // G4int depth=1; 156 // fParser.AddModule(depth); << 162 // parser.AddModule(depth); 157 << 163 158 // OPTION: SETTING ADDITION OF POINTER TO 164 // OPTION: SETTING ADDITION OF POINTER TO NAME TO FALSE 159 // 165 // 160 // By default, written names in GDML consi 166 // By default, written names in GDML consist of the given name with 161 // appended the pointer reference to it, i 167 // appended the pointer reference to it, in order to make it unique. 162 // Naming policy can be changed by using t 168 // Naming policy can be changed by using the following method, or 163 // calling Write with additional Boolean a 169 // calling Write with additional Boolean argument to "false". 164 // NOTE: you have to be sure not to have d 170 // NOTE: you have to be sure not to have duplication of names in your 165 // Geometry Setup. 171 // Geometry Setup. 166 // << 172 // 167 // fParser.SetAddPointerToName(false); << 173 // parser.SetAddPointerToName(false); 168 // 174 // 169 // or 175 // or 170 // 176 // 171 // fParser.Write(fWriteFile, fWorldPhysVol 177 // fParser.Write(fWriteFile, fWorldPhysVol, false); 172 << 178 173 // OPTION: SET MAXIMUM LEVEL TO EXPORT (RE << 174 // << 175 // Can be a integer greater than zero: << 176 // << 177 // G4int maxlevel=3; << 178 // fParser.SetMaxExportLevel(maxlevel); << 179 << 180 // Writing Geometry to GDML File 179 // Writing Geometry to GDML File 181 // 180 // 182 fParser.Write(fWriteFile, fWorldPhysVol); 181 fParser.Write(fWriteFile, fWorldPhysVol); 183 << 182 184 // OPTION: SPECIFYING THE SCHEMA LOCATION 183 // OPTION: SPECIFYING THE SCHEMA LOCATION 185 // 184 // 186 // When writing GDML file the default the 185 // When writing GDML file the default the Schema Location from the 187 // GDML web site will be used: 186 // GDML web site will be used: 188 // "http://cern.ch/service-spi/app/release << 187 // "http://cern.ch/service-spi/app/releases/GDML/GDML_2_10_0/src/GDMLSchema/gdml.xsd" 189 // 188 // 190 // NOTE: GDML Schema is distributed in Gea 189 // NOTE: GDML Schema is distributed in Geant4 in the directory: 191 // $G4INSTALL/source/persistency/gdml/s 190 // $G4INSTALL/source/persistency/gdml/schema 192 // 191 // 193 // You can change the Schema path by addin 192 // You can change the Schema path by adding a parameter to the Write 194 // command, as follows: 193 // command, as follows: 195 // 194 // 196 // fParser.Write(fWriteFile, fWorldPhysVol 195 // fParser.Write(fWriteFile, fWorldPhysVol, "your-path-to-schema/gdml.xsd"); 197 } 196 } 198 else // Demonstration how to Read STEP file << 197 else // Demonstration how to Read STEP files using GDML 199 { 198 { 200 // Some printout... << 199 // Some printout... 201 // << 200 // 202 ListOfMaterials(); << 201 ListOfMaterials(); 203 << 202 204 // Arbitrary values that should enclose an << 203 // Arbitrary values that should enclose any reasonable geometry 205 // << 204 // 206 const G4double expHall_y = fExpHall_x / 50 << 205 const G4double expHall_y = fExpHall_x/50.; 207 const G4double expHall_z = fExpHall_x / 50 << 206 const G4double expHall_z = fExpHall_x/50.; 208 << 207 209 // Create the hall << 208 // Create the hall 210 // << 209 // 211 G4Box* experimentalHallBox = new G4Box("Ex << 210 G4Box * experimentalHallBox 212 G4LogicalVolume* experimentalHallLV = << 211 = new G4Box("ExpHallBox",fExpHall_x/50.,expHall_y,expHall_z); 213 new G4LogicalVolume(experimentalHallBox, << 212 G4LogicalVolume * experimentalHallLV 214 fWorldPhysVol = new G4PVPlacement(0, G4Thr << 213 = new G4LogicalVolume(experimentalHallBox, fAir,"ExpHallLV"); 215 "ExpHall << 214 fWorldPhysVol 216 << 215 = new G4PVPlacement(0, G4ThreeVector(0.0,0.0,0.0), 217 // G02DetectorConstruction via reading STE << 216 experimentalHallLV, "ExpHallPhys", 0, false, 0); 218 // << 217 219 G4LogicalVolume* LogicalVolST = fParser.Pa << 218 // G02DetectorConstruction via reading STEP File 220 << 219 // 221 // Placement inside of the hall << 220 G4LogicalVolume* LogicalVolST 222 // << 221 = fParser.ParseST(fStepFile,fAir,fAluminum); 223 new G4PVPlacement(0, G4ThreeVector(10.0, 0 << 222 224 experimentalHallLV, fals << 223 // Placement inside of the hall >> 224 // >> 225 new G4PVPlacement(0, G4ThreeVector(10.0,0.0,0.0), LogicalVolST, >> 226 "StepPhys", experimentalHallLV, false, 0); 225 } 227 } 226 228 227 // Set Visualization attributes to world 229 // Set Visualization attributes to world 228 // 230 // 229 G4VisAttributes* BoxVisAtt = new G4VisAttrib << 231 G4VisAttributes* BoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0)); 230 fWorldPhysVol->GetLogicalVolume()->SetVisAtt << 232 fWorldPhysVol->GetLogicalVolume()->SetVisAttributes(BoxVisAtt); 231 233 232 return fWorldPhysVol; 234 return fWorldPhysVol; 233 } 235 } 234 236 235 //....oooOO0OOooo........oooOO0OOooo........oo 237 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 236 // 238 // 237 // Utility to build and list necessary materia 239 // Utility to build and list necessary materials 238 // 240 // 239 void G02DetectorConstruction::ListOfMaterials( 241 void G02DetectorConstruction::ListOfMaterials() 240 { 242 { 241 G4double a; // atomic mass 243 G4double a; // atomic mass 242 G4double z; // atomic number 244 G4double z; // atomic number 243 G4double density, temperature, pressure; << 245 G4double density,temperature,pressure; 244 G4double fractionmass; 246 G4double fractionmass; 245 G4String name, symbol; 247 G4String name, symbol; 246 G4int ncomponents; 248 G4int ncomponents; 247 249 248 // Elements needed for the materials 250 // Elements needed for the materials 249 251 250 a = 14.01 * g / mole; << 252 a = 14.01*g/mole; 251 G4Element* elN = new G4Element(name = "Nitro << 253 G4Element* elN = new G4Element(name="Nitrogen", symbol="N", z=7., a); 252 << 253 a = 16.00 * g / mole; << 254 G4Element* elO = new G4Element(name = "Oxyge << 255 << 256 a = 26.98 * g / mole; << 257 G4Element* elAl = new G4Element(name = "Alum << 258 254 >> 255 a = 16.00*g/mole; >> 256 G4Element* elO = new G4Element(name="Oxygen", symbol="O", z=8., a); >> 257 >> 258 a = 26.98*g/mole; >> 259 G4Element* elAl = new G4Element(name="Aluminum", symbol="Al", z=13., a); >> 260 259 // Print the Element information 261 // Print the Element information 260 // 262 // 261 G4cout << *(G4Element::GetElementTable()) << 263 G4cout << *(G4Element::GetElementTable()) << G4endl; 262 264 263 // Air 265 // Air 264 // 266 // 265 density = 1.29 * mg / cm3; << 267 density = 1.29*mg/cm3; 266 fAir = new G4Material(name = "Air", density, << 268 fAir = new G4Material(name="Air", density, ncomponents=2); 267 fAir->AddElement(elN, fractionmass = 0.7); << 269 fAir->AddElement(elN, fractionmass=0.7); 268 fAir->AddElement(elO, fractionmass = 0.3); << 270 fAir->AddElement(elO, fractionmass=0.3); 269 271 270 // Aluminum 272 // Aluminum 271 // 273 // 272 density = 2.70 * g / cm3; << 274 density = 2.70*g/cm3; 273 fAluminum = new G4Material(name = "Aluminum" << 275 fAluminum = new G4Material(name="Aluminum", density, ncomponents=1); 274 fAluminum->AddElement(elAl, fractionmass = 1 << 276 fAluminum->AddElement(elAl, fractionmass=1.0); 275 277 276 // Lead 278 // Lead 277 // 279 // 278 fPb = new G4Material("Lead", z = 82., a = 20 << 280 fPb = new G4Material("Lead", z=82., a= 207.19*g/mole, density= 11.35*g/cm3); 279 281 280 // Xenon gas 282 // Xenon gas 281 // 283 // 282 fXenon = new G4Material("XenonGas", z = 54., << 284 fXenon = new G4Material("XenonGas", z=54., a=131.29*g/mole, 283 kStateGas, temperatu << 285 density= 5.458*mg/cm3, kStateGas, >> 286 temperature= 293.15*kelvin, pressure= 1*atmosphere); 284 287 285 // Prints the material information 288 // Prints the material information 286 // 289 // 287 G4cout << *(G4Material::GetMaterialTable()) << 290 G4cout << *(G4Material::GetMaterialTable() ) << G4endl; 288 } 291 } 289 292 290 //....oooOO0OOooo........oooOO0OOooo........oo 293 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 291 // 294 // 292 // Detector Construction 295 // Detector Construction 293 // 296 // 294 // Detector consist from DetectorBox, Conrol R 297 // Detector consist from DetectorBox, Conrol Room and 4 SubDetectors 295 // SubDetectors1 and 2 show how to use Reflect 298 // SubDetectors1 and 2 show how to use Reflection Factory and Assembly 296 // SubDetectors 3 and 4 show how to use Parame 299 // SubDetectors 3 and 4 show how to use Parameterisation 297 // 300 // 298 G4VPhysicalVolume* G02DetectorConstruction::Co 301 G4VPhysicalVolume* G02DetectorConstruction::ConstructDetector() 299 { 302 { 300 // Arbitary values that should enclose any r 303 // Arbitary values that should enclose any reasonable geometry 301 // 304 // 302 const G4double expHall_y = fExpHall_x; 305 const G4double expHall_y = fExpHall_x; 303 const G4double expHall_z = fExpHall_x; 306 const G4double expHall_z = fExpHall_x; 304 307 305 // Create the hall 308 // Create the hall 306 // 309 // 307 G4Box* experimentalHallBox = new G4Box("ExpH << 310 G4Box * experimentalHallBox = 308 G4LogicalVolume* experimentalHallLV = new G4 << 311 new G4Box("ExpHallBox", fExpHall_x, expHall_y, expHall_z); 309 G4PVPlacement* experimentalHallPhys = new G4 << 312 G4LogicalVolume * experimentalHallLV = 310 0, G4ThreeVector(0.0, 0.0, 0.0), experimen << 313 new G4LogicalVolume(experimentalHallBox, fAir, "ExpHallLV"); >> 314 G4PVPlacement * experimentalHallPhys = >> 315 new G4PVPlacement(0, G4ThreeVector(0.0,0.0,0.0), experimentalHallLV, >> 316 "ExpHallPhys", 0, false, 0); 311 317 312 // G02DetectorConstruction 318 // G02DetectorConstruction 313 319 314 const G4double det_x = fExpHall_x * 0.8; << 320 const G4double det_x = fExpHall_x*0.8; 315 const G4double det_y = fExpHall_x * 0.7; << 321 const G4double det_y = fExpHall_x*0.7; 316 const G4double det_z = det_y; 322 const G4double det_z = det_y; 317 323 318 // Create the detector box 324 // Create the detector box 319 // 325 // 320 G4Box* detectorBox = new G4Box("detectorBox" << 326 G4Box * detectorBox = 321 G4LogicalVolume* detectorLV = new G4LogicalV << 327 new G4Box("detectorBox", det_x, det_y, det_z); 322 // G4PVPlacement * detectorPhys = << 328 G4LogicalVolume * detectorLV = 323 new G4PVPlacement(0, G4ThreeVector(0.0, 0.0, << 329 new G4LogicalVolume(detectorBox, fAir, "detLV"); 324 false, 0); << 330 // G4PVPlacement * detectorPhys = >> 331 new G4PVPlacement(0, G4ThreeVector(0.0,0.0,0.0), detectorLV, >> 332 "detPhys", experimentalHallLV, false, 0); 325 333 326 // Create the Control room box 334 // Create the Control room box 327 // 335 // 328 const G4double room_x = fExpHall_x / 20.; << 336 const G4double room_x = fExpHall_x/20.; 329 const G4double room_y = room_x; 337 const G4double room_y = room_x; 330 const G4double room_z = room_x; 338 const G4double room_z = room_x; 331 339 332 G4Box* roomBox = new G4Box("roomBox", room_x << 340 G4Box * roomBox = 333 G4LogicalVolume* roomLV = new G4LogicalVolum << 341 new G4Box("roomBox", room_x, room_y, room_z); >> 342 G4LogicalVolume * roomLV = >> 343 new G4LogicalVolume(roomBox, fAir, "roomLV"); 334 // G4PVPlacement * roomPhys = 344 // G4PVPlacement * roomPhys = 335 new G4PVPlacement(0, G4ThreeVector(fExpHall_ << 345 new G4PVPlacement(0, G4ThreeVector(fExpHall_x-room_x-10.,0.0,0.0), roomLV, 336 experimentalHallLV, false, << 346 "roomPhys", experimentalHallLV, false, 0); 337 << 347 338 // SubDetector1 348 // SubDetector1 339 // 349 // 340 const G4double bigL = fExpHall_x / 5. + 50.; << 350 const G4double bigL=fExpHall_x/5.+50.; 341 G4LogicalVolume* subDetectorLV1 = ConstructS 351 G4LogicalVolume* subDetectorLV1 = ConstructSubDetector1(); 342 // G4PVPlacement * detPhys1 = 352 // G4PVPlacement * detPhys1 = 343 new G4PVPlacement(0, G4ThreeVector(bigL, 0.0 << 353 new G4PVPlacement(0, G4ThreeVector(bigL,0.0,0.0), subDetectorLV1, 344 detectorLV, false, 0); << 354 "PhysSubDetector1", detectorLV, false, 0); 345 << 355 346 // 356 // 347 // LOOK HERE FOR REFLECTIONS 357 // LOOK HERE FOR REFLECTIONS 348 // << 358 // 349 359 350 // SubDetector2 360 // SubDetector2 351 // << 361 // 352 G4Translate3D translation(-bigL, 0., 0.); 362 G4Translate3D translation(-bigL, 0., 0.); 353 G4RotationMatrix* rotD3 = new G4RotationMatr 363 G4RotationMatrix* rotD3 = new G4RotationMatrix(); 354 G4Transform3D rotation = G4Rotate3D(*rotD3); 364 G4Transform3D rotation = G4Rotate3D(*rotD3); 355 G4ReflectX3D reflection; << 365 G4ReflectX3D reflection; 356 G4Transform3D transform = translation * rota << 366 G4Transform3D transform = translation*rotation*reflection; 357 367 358 // Place the reflected part using G4Reflecti 368 // Place the reflected part using G4ReflectionFactory 359 // 369 // 360 G4ReflectionFactory::Instance()->Place(trans << 370 G4ReflectionFactory::Instance()->Place(transform, "reflSubDetector", 361 false << 371 subDetectorLV1, detectorLV, false, 0); 362 372 363 // SubDetector3 373 // SubDetector3 364 // 374 // 365 G4LogicalVolume* subDetectorLV3 = ConstructS 375 G4LogicalVolume* subDetectorLV3 = ConstructSubDetector2(); 366 // G4PVPlacement * detPhys3 = 376 // G4PVPlacement * detPhys3 = 367 new G4PVPlacement(0, G4ThreeVector(0.0, bigL << 377 new G4PVPlacement(0, G4ThreeVector(0.0,bigL,0.0), subDetectorLV3, 368 detectorLV, false, 0); << 378 "PhysSubDetectorFirst3", detectorLV, false, 0); 369 << 379 370 // SubDetector4, placement of parameterised 380 // SubDetector4, placement of parameterised chambers 371 // 381 // 372 G4LogicalVolume* subDetectorLV4 = ConstructS 382 G4LogicalVolume* subDetectorLV4 = ConstructSubDetector2(); 373 G4LogicalVolume* subChamberLV = ConstructPar << 383 G4LogicalVolume* subChamberLV = ConstructParametrisationChamber(); 374 // G4PVPlacement * detChamb = 384 // G4PVPlacement * detChamb = 375 new G4PVPlacement(0, G4ThreeVector(0, 0.0, 0 << 385 new G4PVPlacement(0, G4ThreeVector(0,0.0,0.0), subChamberLV, 376 false, 0); << 386 "AssemblyPhys", subDetectorLV4, false, 0); 377 // G4PVPlacement * detPhys4 = 387 // G4PVPlacement * detPhys4 = 378 new G4PVPlacement(0, G4ThreeVector(0.0, -big << 388 new G4PVPlacement(0, G4ThreeVector(0.0,-bigL,0.0), subDetectorLV4, 379 detectorLV, false, 0); << 389 "PhysSubDetectorSecond3", detectorLV, false, 0); 380 390 381 return experimentalHallPhys; 391 return experimentalHallPhys; 382 } 392 } 383 393 384 //....oooOO0OOooo........oooOO0OOooo........oo 394 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 385 // 395 // 386 // SubDetector1 396 // SubDetector1 387 // 397 // 388 G4LogicalVolume* G02DetectorConstruction::Cons 398 G4LogicalVolume* G02DetectorConstruction::ConstructSubDetector1() 389 { << 399 { 390 const G4double sub_x = fExpHall_x / 5.; << 400 const G4double sub_x = fExpHall_x/5.; 391 const G4double sub_y = sub_x; 401 const G4double sub_y = sub_x; 392 402 393 // Create the hall 403 // Create the hall 394 // 404 // 395 G4Tubs* subTub = new G4Tubs("subTub", 0., su << 405 G4Tubs * subTub = 396 G4LogicalVolume* subTubLV = new G4LogicalVol << 406 new G4Tubs("subTub", 0., sub_x, sub_y, -90.*deg, 180*deg); 397 G4LogicalVolume* AssemblyLV = ConstructAssem << 407 G4LogicalVolume * subTubLV = >> 408 new G4LogicalVolume(subTub, fPb, "tubLV"); >> 409 G4LogicalVolume *AssemblyLV = ConstructAssembly(); 398 // G4PVPlacement * detAss = 410 // G4PVPlacement * detAss = 399 new G4PVPlacement(0, G4ThreeVector(sub_x / 3 << 411 new G4PVPlacement(0, G4ThreeVector(sub_x/3,0.0,0.0), AssemblyLV, 400 false, 0); << 412 "AssemblyPhys", subTubLV, false, 0); 401 return subTubLV; << 413 return subTubLV; 402 } << 414 } 403 415 404 //....oooOO0OOooo........oooOO0OOooo........oo 416 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 405 // 417 // 406 // SubDetector2 418 // SubDetector2 407 // 419 // 408 G4LogicalVolume* G02DetectorConstruction::Cons 420 G4LogicalVolume* G02DetectorConstruction::ConstructSubDetector2() 409 { << 421 { 410 const G4double sub_x = fExpHall_x / 10.; << 422 const G4double sub_x = fExpHall_x/10.; 411 const G4double sub_y = sub_x * 2.; << 423 const G4double sub_y = sub_x*2.; 412 const G4double sub_z = sub_x; 424 const G4double sub_z = sub_x; 413 425 414 // Create the hall 426 // Create the hall 415 // 427 // 416 G4Box* detHallBox = new G4Box("detHallBox", << 428 G4Box * detHallBox = 417 G4LogicalVolume* detHallLV = new G4LogicalVo << 429 new G4Box("detHallBox", sub_x, sub_y, sub_z); >> 430 G4LogicalVolume * detHallLV = >> 431 new G4LogicalVolume(detHallBox, fAluminum, "detHallLV"); 418 432 419 return detHallLV; << 433 return detHallLV; 420 } << 434 } 421 435 422 //....oooOO0OOooo........oooOO0OOooo........oo 436 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 423 // 437 // 424 // Assembly 438 // Assembly 425 // 439 // 426 G4LogicalVolume* G02DetectorConstruction::Cons 440 G4LogicalVolume* G02DetectorConstruction::ConstructAssembly() 427 { << 441 { 428 const G4double big_x = fExpHall_x / 17; << 442 const G4double big_x = fExpHall_x/17; 429 const G4double big_y = big_x; 443 const G4double big_y = big_x; 430 const G4double big_z = big_x; 444 const G4double big_z = big_x; 431 445 432 // Create the Box 446 // Create the Box 433 // 447 // 434 G4Box* OuterBox = new G4Box("OuterBox", big_ << 448 G4Box * OuterBox = 435 G4LogicalVolume* OuterBoxLV = new G4LogicalV << 449 new G4Box("OuterBox", big_x, big_y, big_z); 436 // G4PVPlacement * OuterBoxPhys = << 450 G4LogicalVolume * OuterBoxLV = 437 new G4PVPlacement(0, G4ThreeVector(0.0, 0.0, << 451 new G4LogicalVolume(OuterBox, fAir, "OuterBoxLV"); >> 452 // G4PVPlacement * OuterBoxPhys = >> 453 new G4PVPlacement(0, G4ThreeVector(0.0,0.0,0.0), OuterBoxLV, >> 454 "OuterBoxPhys", 0, false, 0); 438 455 439 // The aluminum object's logical volume 456 // The aluminum object's logical volume 440 // 457 // 441 const G4double bigL = big_x / 2.5; << 458 const G4double bigL=big_x/2.5; 442 const G4double medL = big_x / 8; << 459 const G4double medL=big_x/8; 443 const G4double smalL = big_x / 12; << 460 const G4double smalL=big_x/12; 444 << 461 445 G4Box* BigBox = new G4Box("BBox", bigL, bigL << 462 G4Box * BigBox = 446 G4LogicalVolume* BigBoxLV = new G4LogicalVol << 463 new G4Box("BBox", bigL, bigL, bigL); 447 G4Box* MedBox = new G4Box("MBox", medL, medL << 464 G4LogicalVolume * BigBoxLV = 448 G4LogicalVolume* MedBoxLV1 = new G4LogicalVo << 465 new G4LogicalVolume(BigBox, fAluminum, "AlBigBoxLV"); 449 G4Box* SmallBox = new G4Box("SBox", smalL, s << 466 G4Box * MedBox = 450 G4LogicalVolume* SmallBoxLV = new G4LogicalV << 467 new G4Box("MBox", medL, medL, medL); 451 << 468 G4LogicalVolume * MedBoxLV1 = 452 const G4double bigPlace = bigL + 10.; << 469 new G4LogicalVolume(MedBox, fAluminum, "AlMedBoxLV1"); 453 const G4double medPlace = medL + 10.; << 470 G4Box * SmallBox = 454 // G4PVPlacement * BigBoxPhys = << 471 new G4Box("SBox", smalL, smalL, smalL); 455 new G4PVPlacement(0, G4ThreeVector(bigPlace, << 472 G4LogicalVolume * SmallBoxLV = 456 0); << 473 new G4LogicalVolume(SmallBox, fAluminum, "AlSmaBoxLV"); >> 474 >> 475 const G4double bigPlace=bigL+10.; >> 476 const G4double medPlace=medL+10.; >> 477 // G4PVPlacement * BigBoxPhys = >> 478 new G4PVPlacement(0, G4ThreeVector(bigPlace,0.0,0.0), BigBoxLV, >> 479 "AlPhysBig", OuterBoxLV, false, 0); 457 480 458 // Construction of Tub << 481 // Construction of Tub 459 // 482 // 460 G4Tubs* BigTube = new G4Tubs("BTube", 0, sma << 483 G4Tubs * BigTube = >> 484 new G4Tubs("BTube",0,smalL,smalL,-pi/2.,pi); 461 485 462 // Construction of Reflection of Tub 486 // Construction of Reflection of Tub 463 // 487 // 464 G4ReflectX3D Xreflection; << 488 G4ReflectX3D Xreflection; 465 G4Translate3D translation(-bigPlace, 0., 0.) 489 G4Translate3D translation(-bigPlace, 0., 0.); 466 G4Transform3D transform = Xreflection; << 490 G4Transform3D transform =Xreflection; 467 491 468 G4ReflectedSolid* ReflBig = new G4ReflectedS << 492 G4ReflectedSolid * ReflBig = 469 G4LogicalVolume* ReflBigLV = new G4LogicalVo << 493 new G4ReflectedSolid("Refll_Big", BigTube, transform); 470 new G4PVPlacement(0, G4ThreeVector(0., 0.0, << 494 G4LogicalVolume * ReflBigLV = 471 0); << 495 new G4LogicalVolume(ReflBig, fXenon, "ReflBigAl"); >> 496 new G4PVPlacement(0, G4ThreeVector(0.,0.0,0.0), ReflBigLV, >> 497 "AlPhysBigTube", SmallBoxLV, false, 0); 472 // 498 // 473 // LOOK HERE FOR ASSEMBLY << 499 // LOOK HERE FOR ASSEMBLY 474 // 500 // 475 501 476 // create Assembly of Boxes and Tubs 502 // create Assembly of Boxes and Tubs 477 // 503 // 478 G4AssemblyVolume* assembly = new G4AssemblyV 504 G4AssemblyVolume* assembly = new G4AssemblyVolume(); 479 G4RotationMatrix* rot = new G4RotationMatrix 505 G4RotationMatrix* rot = new G4RotationMatrix(); 480 G4ThreeVector posBig(-bigPlace, 0, 0); 506 G4ThreeVector posBig(-bigPlace, 0, 0); 481 G4ThreeVector posBig0(bigPlace / 4, 0, 0); << 507 G4ThreeVector posBig0(bigPlace/4, 0, 0); 482 G4ThreeVector posMed(-medPlace, 0, 0); 508 G4ThreeVector posMed(-medPlace, 0, 0); 483 G4ThreeVector posMed0(medPlace, 0, 0); 509 G4ThreeVector posMed0(medPlace, 0, 0); 484 G4ThreeVector position(0., 0., 0.); 510 G4ThreeVector position(0., 0., 0.); 485 511 486 // Add to Assembly the MediumBox1 512 // Add to Assembly the MediumBox1 487 // 513 // 488 assembly->AddPlacedVolume(MedBoxLV1, posMed0 514 assembly->AddPlacedVolume(MedBoxLV1, posMed0, rot); 489 515 490 // Add to Assembly the Small Box 516 // Add to Assembly the Small Box 491 // 517 // 492 assembly->AddPlacedVolume(SmallBoxLV, posMed 518 assembly->AddPlacedVolume(SmallBoxLV, posMed, rot); 493 << 519 494 // Place the Assembly 520 // Place the Assembly 495 // 521 // 496 assembly->MakeImprint(BigBoxLV, posBig0, rot 522 assembly->MakeImprint(BigBoxLV, posBig0, rot, 0); 497 523 498 // 524 // 499 // LOOK HERE FOR ASSEMBLY with REFLECTION << 525 // LOOK HERE FOR ASSEMBLY with REFLECTION 500 // << 526 // 501 527 502 G4Translate3D translation1(-bigPlace, 0., 0. 528 G4Translate3D translation1(-bigPlace, 0., 0.); 503 G4RotationMatrix* rotD3 = new G4RotationMatr 529 G4RotationMatrix* rotD3 = new G4RotationMatrix(); 504 G4Transform3D rotation = G4Rotate3D(*rotD3); 530 G4Transform3D rotation = G4Rotate3D(*rotD3); 505 G4ReflectX3D reflection; << 531 G4ReflectX3D reflection; 506 G4Transform3D transform1 = translation1 * ro << 532 G4Transform3D transform1 = translation1*rotation*reflection; 507 533 508 assembly->MakeImprint(OuterBoxLV, transform1 534 assembly->MakeImprint(OuterBoxLV, transform1, 0, 0); 509 535 510 return OuterBoxLV; << 536 return OuterBoxLV; 511 } 537 } 512 538 513 //....oooOO0OOooo........oooOO0OOooo........oo 539 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 514 // 540 // 515 // Parameterised Chamber 541 // Parameterised Chamber 516 // 542 // 517 G4LogicalVolume* G02DetectorConstruction::Cons 543 G4LogicalVolume* G02DetectorConstruction::ConstructParametrisationChamber() 518 { << 544 { 519 const G4double chamber_x = fExpHall_x / 12.; << 545 const G4double chamber_x = fExpHall_x/12.; 520 const G4double chamber_y = chamber_x; 546 const G4double chamber_y = chamber_x; 521 const G4double chamber_z = chamber_x; 547 const G4double chamber_z = chamber_x; 522 548 523 // Create the hall 549 // Create the hall 524 // 550 // 525 G4Box* paramChamberBox = new G4Box("ChamberB << 551 G4Box * paramChamberBox = 526 G4LogicalVolume* paramChamberLV = new G4Logi << 552 new G4Box("ChamberBox", chamber_x, chamber_y, chamber_z); >> 553 G4LogicalVolume * paramChamberLV = >> 554 new G4LogicalVolume(paramChamberBox, fAir, "ChamberLV"); 527 555 528 // Parametrisation Chamber (taken from N02 n 556 // Parametrisation Chamber (taken from N02 novice example) 529 // 557 // 530 G4int NbOfChambers = 5; 558 G4int NbOfChambers = 5; 531 G4double ChamberWidth = 2 * cm; << 559 G4double ChamberWidth = 2*cm; 532 G4double ChamberSpacing = 8 * cm; << 560 G4double ChamberSpacing = 8*cm; 533 G4double fTrackerLength = (NbOfChambers + 1) << 561 G4double fTrackerLength = (NbOfChambers+1)*ChamberSpacing; // Full length 534 G4double trackerSize = 0.5 * fTrackerLength; << 562 G4double trackerSize = 0.5*fTrackerLength; 535 563 536 // An example of parameterised volume 564 // An example of parameterised volume 537 // dummy values for G4Box -- modified by par 565 // dummy values for G4Box -- modified by parameterised volume 538 // 566 // 539 G4Box* solidChamber = new G4Box("chamber", 1 << 567 G4Box *solidChamber = 540 G4LogicalVolume* logicChamber = new G4Logica << 568 new G4Box("chamber", 10*cm, 10*cm, 1*cm); 541 << 569 G4LogicalVolume* logicChamber = 542 G4double firstPosition = -trackerSize + 0.5 << 570 new G4LogicalVolume(solidChamber, fAluminum, "Chamber", 0, 0, 0); 543 G4double firstLength = fTrackerLength / 10; << 571 544 G4double lastLength = fTrackerLength; << 572 G4double firstPosition = -trackerSize + 0.5*ChamberWidth; >> 573 G4double firstLength = fTrackerLength/10; >> 574 G4double lastLength = fTrackerLength; 545 575 546 G4VPVParameterisation* chamberParam = 576 G4VPVParameterisation* chamberParam = 547 new G02ChamberParameterisation(NbOfChamber << 577 new G02ChamberParameterisation( NbOfChambers, // NoChambers 548 firstPositi << 578 firstPosition, // Z of center of first 549 ChamberSpac << 579 ChamberSpacing, // Z spacing of centers 550 ChamberWidt << 580 ChamberWidth, // Width Chamber 551 firstLength << 581 firstLength, // lengthInitial 552 lastLength) << 582 lastLength); // lengthFinal 553 // G4VPhysicalVolume* physiChamber = << 583 // G4VPhysicalVolume* physiChamber = 554 new G4PVParameterised("Chamber", // their n << 584 new G4PVParameterised( "Chamber", // their name 555 logicChamber, // thei << 585 logicChamber, // their logical volume 556 paramChamberLV, // mo << 586 paramChamberLV, // mother logical volume 557 kZAxis, // Are placed << 587 kZAxis, // Are placed along this axis 558 NbOfChambers, // Numb << 588 NbOfChambers, // Number of chambers 559 chamberParam); // The << 589 chamberParam); // The parametrisation 560 return paramChamberLV; 590 return paramChamberLV; 561 } << 591 } 562 592 563 //....oooOO0OOooo........oooOO0OOooo........oo 593 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 564 // 594 // 565 // SetReadFile 595 // SetReadFile 566 // 596 // 567 void G02DetectorConstruction::SetReadFile(cons << 597 void G02DetectorConstruction::SetReadFile( const G4String& File ) 568 { 598 { 569 fReadFile = File; << 599 fReadFile=File; 570 fWritingChoice = 0; << 600 fWritingChoice=0; 571 } 601 } 572 602 573 //....oooOO0OOooo........oooOO0OOooo........oo 603 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 574 // 604 // 575 // SetWriteFile 605 // SetWriteFile 576 // 606 // 577 void G02DetectorConstruction::SetWriteFile(con << 607 void G02DetectorConstruction::SetWriteFile( const G4String& File ) 578 { 608 { 579 fWriteFile = File; << 609 fWriteFile=File; 580 fWritingChoice = 1; << 610 fWritingChoice=1; 581 } 611 } 582 612 583 //....oooOO0OOooo........oooOO0OOooo........oo 613 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 584 // 614 // 585 // SetStepFile 615 // SetStepFile 586 // 616 // 587 void G02DetectorConstruction::SetStepFile(cons << 617 void G02DetectorConstruction::SetStepFile( const G4String& File ) 588 { 618 { 589 fStepFile = File; << 619 fStepFile=File; 590 fWritingChoice = 3; << 620 fWritingChoice=3; 591 } 621 } 592 622