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