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 // 25 // 26 // 26 // 27 /// \file DetectorConstruction.cc 27 /// \file DetectorConstruction.cc 28 /// \brief Implementation of the DetectorConst 28 /// \brief Implementation of the DetectorConstruction class 29 29 30 #include "DetectorConstruction.hh" 30 #include "DetectorConstruction.hh" 31 << 32 #include "DetectorMessenger.hh" 31 #include "DetectorMessenger.hh" 33 32 34 #include "G4GeometryManager.hh" << 35 #include "G4LogicalVolume.hh" << 36 #include "G4LogicalVolumeStore.hh" << 37 #include "G4Material.hh" 33 #include "G4Material.hh" 38 #include "G4NistManager.hh" 34 #include "G4NistManager.hh" >> 35 #include "G4Tubs.hh" >> 36 #include "G4Trd.hh" >> 37 #include "G4LogicalVolume.hh" 39 #include "G4PVPlacement.hh" 38 #include "G4PVPlacement.hh" 40 #include "G4PhysicalConstants.hh" << 39 #include "G4Transform3D.hh" 41 #include "G4PhysicalVolumeStore.hh" << 42 #include "G4ReflectionFactory.hh" << 43 #include "G4RotationMatrix.hh" 40 #include "G4RotationMatrix.hh" >> 41 #include "G4ReflectionFactory.hh" >> 42 >> 43 #include "G4GeometryManager.hh" >> 44 #include "G4PhysicalVolumeStore.hh" >> 45 #include "G4LogicalVolumeStore.hh" 44 #include "G4SolidStore.hh" 46 #include "G4SolidStore.hh" >> 47 #include "G4PhysicalConstants.hh" 45 #include "G4SystemOfUnits.hh" 48 #include "G4SystemOfUnits.hh" 46 #include "G4Transform3D.hh" << 47 #include "G4Trd.hh" << 48 #include "G4Tubs.hh" << 49 49 50 //....oooOO0OOooo........oooOO0OOooo........oo 50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 51 51 52 DetectorConstruction::DetectorConstruction() 52 DetectorConstruction::DetectorConstruction() >> 53 : G4VUserDetectorConstruction(), >> 54 fMessenger(0), >> 55 fMethod(kWithDirectMatrix), >> 56 fWorldVolume(0), >> 57 fTrdVolume(0) >> 58 53 { 59 { 54 fMessenger = new DetectorMessenger(this); 60 fMessenger = new DetectorMessenger(this); 55 } 61 } 56 62 57 //....oooOO0OOooo........oooOO0OOooo........oo 63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 58 64 59 DetectorConstruction::~DetectorConstruction() 65 DetectorConstruction::~DetectorConstruction() 60 { << 66 { 61 delete fMessenger; 67 delete fMessenger; 62 } 68 } 63 69 64 //....oooOO0OOooo........oooOO0OOooo........oo 70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 65 71 66 G4VPhysicalVolume* DetectorConstruction::Const 72 G4VPhysicalVolume* DetectorConstruction::Construct() 67 { 73 { 68 // Materials 74 // Materials 69 G4NistManager* nist = G4NistManager::Instanc 75 G4NistManager* nist = G4NistManager::Instance(); 70 G4Material* material = nist->FindOrBuildMate 76 G4Material* material = nist->FindOrBuildMaterial("G4_AIR"); 71 << 77 72 // Clean old geometry, if any 78 // Clean old geometry, if any 73 // 79 // 74 G4GeometryManager::GetInstance()->OpenGeomet 80 G4GeometryManager::GetInstance()->OpenGeometry(); 75 G4PhysicalVolumeStore::GetInstance()->Clean( 81 G4PhysicalVolumeStore::GetInstance()->Clean(); 76 G4LogicalVolumeStore::GetInstance()->Clean() 82 G4LogicalVolumeStore::GetInstance()->Clean(); 77 G4SolidStore::GetInstance()->Clean(); 83 G4SolidStore::GetInstance()->Clean(); 78 G4ReflectionFactory::Instance()->Clean(); << 84 79 << 80 // World 85 // World 81 // << 86 // 82 G4double rmin = 0.; 87 G4double rmin = 0.; 83 G4double rmax = 5 * cm; << 88 G4double rmax = 5*cm; 84 G4double hz = 5 * cm; << 89 G4double hz = 5*cm; 85 G4double phiMin = 0.; 90 G4double phiMin = 0.; 86 G4double deltaPhi = 360 * degree; << 91 G4double deltaPhi = 360*degree; 87 << 92 88 auto solidWorld = new G4Tubs("World", // na << 93 G4Tubs* solidWorld 89 rmin, rmax, hz, << 94 = new G4Tubs("World", //name 90 << 95 rmin, rmax, hz, phiMin, deltaPhi); //size 91 fWorldVolume = new G4LogicalVolume(solidWorl << 96 92 material, << 97 fWorldVolume 93 "World"); << 98 = new G4LogicalVolume(solidWorld, //solid 94 << 99 material, //material 95 G4VPhysicalVolume* physiWorld = new G4PVPlac << 100 "World"); //name 96 << 101 97 << 102 G4VPhysicalVolume* physiWorld 98 << 103 = new G4PVPlacement(0, //no rotation 99 << 104 G4ThreeVector(), //at (0,0,0) 100 << 105 fWorldVolume, //logical volume 101 << 106 "World", //name 102 << 107 0, //mother volume 103 // Trd volume << 108 false, //no boolean operation 104 // << 109 0); //copy number 105 G4double dX1 = 1 * cm; << 110 106 G4double dX2 = 1 * cm; << 111 // Trd volume 107 G4double dY1 = 1 * cm; << 112 // 108 G4double dY2 = 2 * cm; << 113 G4double dX1 = 1*cm; 109 G4double dZ = 3 * cm; << 114 G4double dX2 = 1*cm; 110 << 115 G4double dY1 = 1*cm; 111 auto solidTrd = new G4Trd("trd", // name << 116 G4double dY2 = 2*cm; 112 dX1 / 2, dX2 / 2, << 117 G4double dZ = 3*cm; 113 << 118 114 fTrdVolume = new G4LogicalVolume(solidTrd, << 119 G4Trd* solidTrd 115 material, << 120 = new G4Trd("trd", //name 116 "trd"); // << 121 dX1/2, dX2/2, dY1/2, dY2/2, dZ/2); //size >> 122 >> 123 fTrdVolume >> 124 = new G4LogicalVolume(solidTrd, //solid >> 125 material, //material >> 126 "trd"); //name >> 127 117 128 118 // Place Volume1 and Volume2 according to se 129 // Place Volume1 and Volume2 according to selected methods 119 // << 130 // 120 switch (fMethod) { << 131 switch ( fMethod ) { 121 case kWithDirectMatrix: << 132 case kWithDirectMatrix: PlaceWithDirectMatrix(); break; 122 PlaceWithDirectMatrix(); << 133 case kWithInverseMatrix: PlaceWithInverseMatrix(); break; 123 break; << 134 case kWithAxialRotations: PlaceWithAxialRotations(); break; 124 case kWithInverseMatrix: << 135 case kWithEulerAngles: PlaceWithEulerAngles(); break; 125 PlaceWithInverseMatrix(); << 136 case kWithReflections: PlaceWithReflections(); break; 126 break; << 137 default: ;; 127 case kWithAxialRotations: << 128 PlaceWithAxialRotations(); << 129 break; << 130 case kWithEulerAngles: << 131 PlaceWithEulerAngles(); << 132 break; << 133 case kWithReflections: << 134 PlaceWithReflections(); << 135 break; << 136 default:; << 137 ; << 138 } 138 } 139 139 140 // Return the root volume 140 // Return the root volume 141 // 141 // 142 return physiWorld; 142 return physiWorld; 143 } 143 } 144 144 145 //....oooOO0OOooo........oooOO0OOooo........oo 145 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 146 146 147 void DetectorConstruction::PlaceWithDirectMatr 147 void DetectorConstruction::PlaceWithDirectMatrix() 148 { 148 { 149 G4double og = 3 * cm; << 149 G4double og = 3*cm; 150 150 151 // 1st position << 151 // 1st position 152 // 152 // 153 G4double phi = 30 * deg; << 153 G4double phi = 30*deg; 154 // u, v, w are the daughter axes, projected 154 // u, v, w are the daughter axes, projected on the mother frame 155 G4ThreeVector u = G4ThreeVector(0, 0, -1); 155 G4ThreeVector u = G4ThreeVector(0, 0, -1); 156 G4ThreeVector v = G4ThreeVector(-std::sin(ph << 156 G4ThreeVector v = G4ThreeVector(-std::sin(phi), std::cos(phi),0.); 157 G4ThreeVector w = G4ThreeVector(std::cos(phi << 157 G4ThreeVector w = G4ThreeVector( std::cos(phi), std::sin(phi),0.); 158 G4RotationMatrix rotm1 = G4RotationMatrix(u, << 158 G4RotationMatrix rotm1 = G4RotationMatrix(u, v, w); 159 G4cout << "\n --> phi = " << phi / deg << " << 159 G4cout << "\n --> phi = " << phi/deg << " deg; direct rotation matrix : "; 160 rotm1.print(G4cout); << 160 rotm1.print(G4cout); 161 G4ThreeVector position1 = og * w; << 161 G4ThreeVector position1 = og*w; 162 G4Transform3D transform1 = G4Transform3D(rot << 162 G4Transform3D transform1 = G4Transform3D(rotm1,position1); 163 << 163 164 new G4PVPlacement(transform1, // position, << 164 new G4PVPlacement(transform1, //position, rotation 165 fTrdVolume, // logical vo << 165 fTrdVolume, //logical volume 166 "Trd", // name << 166 "Trd", //name 167 fWorldVolume, // mother v << 167 fWorldVolume, //mother volume 168 false, // no boolean oper << 168 false, //no boolean operation 169 1); // copy number << 169 1); //copy number 170 << 170 171 // 2nd position << 171 // 2nd position 172 // << 172 // 173 phi = phi + 90 * deg; << 173 phi = phi + 90*deg; 174 v = G4ThreeVector(-std::sin(phi), std::cos(p << 174 v = G4ThreeVector(-std::sin(phi), std::cos(phi),0.); 175 w = G4ThreeVector(std::cos(phi), std::sin(ph << 175 w = G4ThreeVector( std::cos(phi), std::sin(phi),0.); 176 G4RotationMatrix rotm2 = G4RotationMatrix(u, << 176 G4RotationMatrix rotm2 = G4RotationMatrix(u, v, w); 177 G4ThreeVector position2 = og * w; << 177 G4ThreeVector position2 = og*w; 178 G4Transform3D transform2 = G4Transform3D(rot << 178 G4Transform3D transform2 = G4Transform3D(rotm2,position2); 179 new G4PVPlacement(transform2, // position, << 179 new G4PVPlacement(transform2, //position, rotation 180 fTrdVolume, // logical vo << 180 fTrdVolume, //logical volume 181 "Trd", // name << 181 "Trd", //name 182 fWorldVolume, // mother v << 182 fWorldVolume, //mother volume 183 false, // no boolean oper << 183 false, //no boolean operation 184 2); // copy number << 184 2); //copy number 185 } 185 } 186 186 187 //....oooOO0OOooo........oooOO0OOooo........oo 187 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 188 188 189 void DetectorConstruction::PlaceWithInverseMat 189 void DetectorConstruction::PlaceWithInverseMatrix() 190 { 190 { 191 G4double og = 3 * cm; << 191 G4double og = 3*cm; 192 192 193 // 1st position 193 // 1st position 194 // 194 // 195 G4double phi = 30 * deg; << 195 G4double phi = 30*deg; 196 // u, v, w are the daughter axes, projected << 196 // u, v, w are the daughter axes, projected on the mother frame 197 G4ThreeVector u = G4ThreeVector(0, 0, -1); 197 G4ThreeVector u = G4ThreeVector(0, 0, -1); 198 G4ThreeVector v = G4ThreeVector(-std::sin(ph << 198 G4ThreeVector v = G4ThreeVector(-std::sin(phi), std::cos(phi),0.); 199 G4ThreeVector w = G4ThreeVector(std::cos(phi << 199 G4ThreeVector w = G4ThreeVector( std::cos(phi), std::sin(phi),0.); 200 G4RotationMatrix rotm1 = G4RotationMatrix(u, << 200 G4RotationMatrix rotm1 = G4RotationMatrix(u, v, w); 201 auto rotm1Inv = new G4RotationMatrix(rotm1.i << 201 G4RotationMatrix* rotm1Inv = new G4RotationMatrix(rotm1.inverse()); 202 G4cout << "\n --> phi = " << phi / deg << " << 202 G4cout << "\n --> phi = " << phi/deg << " deg; inverse rotation matrix : "; 203 rotm1Inv->print(G4cout); << 203 rotm1Inv->print(G4cout); 204 G4ThreeVector position1 = og * w; << 204 G4ThreeVector position1 = og*w; 205 << 205 206 new G4PVPlacement(rotm1Inv, position1, << 206 new G4PVPlacement(rotm1Inv, 207 fTrdVolume, // logical vo << 207 position1, 208 "Trd", // name << 208 fTrdVolume, //logical volume 209 fWorldVolume, // mother v << 209 "Trd", //name 210 false, // no boolean oper << 210 fWorldVolume, //mother volume 211 1); // copy number << 211 false, //no boolean operation >> 212 1); //copy number 212 213 213 // 2nd position 214 // 2nd position 214 // 215 // 215 phi = phi + 90 * deg; << 216 phi = phi + 90*deg; 216 v = G4ThreeVector(-std::sin(phi), std::cos(p << 217 v = G4ThreeVector(-std::sin(phi), std::cos(phi),0.); 217 w = G4ThreeVector(std::cos(phi), std::sin(ph << 218 w = G4ThreeVector( std::cos(phi), std::sin(phi),0.); 218 G4RotationMatrix rotm2 = G4RotationMatrix(u, << 219 G4RotationMatrix rotm2 = G4RotationMatrix(u, v, w); 219 auto rotm2Inv = new G4RotationMatrix(rotm2.i << 220 G4RotationMatrix* rotm2Inv = new G4RotationMatrix(rotm2.inverse()); 220 G4ThreeVector position2 = og * w; << 221 G4ThreeVector position2 = og*w; 221 << 222 222 new G4PVPlacement(rotm2Inv, // rotation << 223 new G4PVPlacement(rotm2Inv, //rotation 223 position2, // position << 224 position2, //position 224 fTrdVolume, // logical vo << 225 fTrdVolume, //logical volume 225 "Trd", // name << 226 "Trd", //name 226 fWorldVolume, // mother v << 227 fWorldVolume, //mother volume 227 false, // no boolean oper << 228 false, //no boolean operation 228 2); // copy number << 229 2); //copy number 229 } 230 } 230 231 231 //....oooOO0OOooo........oooOO0OOooo........oo 232 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 232 233 233 void DetectorConstruction::PlaceWithAxialRotat 234 void DetectorConstruction::PlaceWithAxialRotations() 234 { 235 { 235 G4double og = 3 * cm; << 236 G4double og = 3*cm; 236 237 237 // 1st position (with first G4PVPlacement co 238 // 1st position (with first G4PVPlacement constructor) 238 // 239 // 239 G4double phi = 30 * deg, theta = 90 * deg; << 240 G4double phi = 30*deg, theta = 90*deg; 240 G4ThreeVector rotAxis = G4ThreeVector(std::s << 241 G4ThreeVector rotAxis = >> 242 G4ThreeVector(std::sin(theta-pi/2), 0., std::cos(theta-pi/2)); 241 G4RotationMatrix rotm1 = G4RotationMatrix(); 243 G4RotationMatrix rotm1 = G4RotationMatrix(); 242 rotm1.rotateY(theta); 244 rotm1.rotateY(theta); 243 rotm1.rotate(phi, rotAxis); << 245 rotm1.rotate (phi, rotAxis); 244 G4cout << "\n --> direct rotation matrix : " 246 G4cout << "\n --> direct rotation matrix : " 245 << " theta = " << theta / deg << " de << 247 << " theta = " << theta/deg << " deg;" 246 << " phi = " << phi / deg << " deg;" << 248 << " phi = " << phi/deg << " deg;"; 247 rotm1.print(G4cout); << 249 rotm1.print(G4cout); 248 G4ThreeVector w = << 250 G4ThreeVector w = G4ThreeVector( std::sin(theta)*std::cos(phi), 249 G4ThreeVector(std::sin(theta) * std::cos(p << 251 std::sin(phi), std::cos(theta)*std::cos(phi)); 250 G4ThreeVector position1 = og * w; << 252 G4ThreeVector position1 = og*w; 251 G4Transform3D transform1(rotm1, position1); << 253 G4Transform3D transform1(rotm1,position1); 252 << 254 253 new G4PVPlacement(transform1, // rotation,p << 255 new G4PVPlacement(transform1, //rotation,position 254 fTrdVolume, // logical vo << 256 fTrdVolume, //logical volume 255 "Trd", // name << 257 "Trd", //name 256 fWorldVolume, // mother v << 258 fWorldVolume, //mother volume 257 false, // no boolean oper << 259 false, //no boolean operation 258 1); // copy number << 260 1); //copy number 259 261 260 // 2nd position (with second G4PVPlacement c 262 // 2nd position (with second G4PVPlacement constructor) 261 // 263 // 262 phi = phi + 90 * deg; << 264 phi = phi + 90*deg; 263 // rotm2Inv could be calculated with rotm2.i << 265 //rotm2Inv could be calculated with rotm2.inverse() 264 // but also by the following : << 266 //but also by the following : 265 auto rotm2Inv = new G4RotationMatrix(); << 267 G4RotationMatrix* rotm2Inv = new G4RotationMatrix(); 266 rotm2Inv->rotate(-phi, rotAxis); << 268 rotm2Inv->rotate (-phi, rotAxis); 267 rotm2Inv->rotateY(-theta); 269 rotm2Inv->rotateY(-theta); 268 w = << 270 w = G4ThreeVector( std::sin(theta)*std::cos(phi), 269 G4ThreeVector(std::sin(theta) * std::cos(p << 271 std::sin(phi), std::cos(theta)*std::cos(phi)); 270 G4ThreeVector position2 = og * w; << 272 G4ThreeVector position2 = og*w; 271 << 273 272 new G4PVPlacement(rotm2Inv, // rotation << 274 new G4PVPlacement(rotm2Inv, //rotation 273 position2, // position << 275 position2, //position 274 fTrdVolume, // logical vo << 276 fTrdVolume, //logical volume 275 "Trd", // name << 277 "Trd", //name 276 fWorldVolume, // mother v << 278 fWorldVolume, //mother volume 277 false, // no boolean oper << 279 false, //no boolean operation 278 2); // copy number << 280 2); //copy number 279 } 281 } 280 282 281 //....oooOO0OOooo........oooOO0OOooo........oo 283 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 282 284 283 void DetectorConstruction::PlaceWithEulerAngle 285 void DetectorConstruction::PlaceWithEulerAngles() 284 { 286 { 285 // definitions : mother frame = {x,y,z} ; da << 287 //definitions : mother frame = {x,y,z} ; daughter frame = {u,v,w} 286 // n = node line = intercept of xy and uv p << 288 // n = node line = intercept of xy and uv planes 287 // phi_euler = (x,n) : precession << 289 // phi_euler = (x,n) : precession 288 // theta_euler = (z,w) : nutation << 290 // theta_euler = (z,w) : nutation 289 // psi_euler = (n,u) : proper rotation << 291 // psi_euler = (n,u) : proper rotation 290 << 292 291 G4double og = 3 * cm; << 293 G4double og = 3*cm; 292 294 293 // 1st position (with first G4PVPlacement co 295 // 1st position (with first G4PVPlacement constructor) 294 // 296 // 295 G4double phi = 30 * deg; << 297 G4double phi = 30*deg; 296 G4double phi_euler = phi + pi / 2; << 298 G4double phi_euler = phi + pi/2; 297 G4double theta_euler = 90 * deg; << 299 G4double theta_euler = 90*deg; 298 G4double psi_euler = -90 * deg; << 300 G4double psi_euler = -90*deg; 299 // attention : clhep Euler constructor build << 301 //attention : clhep Euler constructor build inverse matrix ! 300 G4RotationMatrix rotm1Inv = G4RotationMatrix << 302 G4RotationMatrix rotm1Inv = G4RotationMatrix(phi_euler,theta_euler,psi_euler); 301 G4RotationMatrix rotm1 = rotm1Inv.inverse(); 303 G4RotationMatrix rotm1 = rotm1Inv.inverse(); 302 // remark : could be built as rotm1 = G4Rota << 304 //remark : could be built as rotm1 = G4RotationMatrix(-psi, -theta, -phi) 303 G4cout << "\n --> phi = " << phi / deg << " << 305 G4cout << "\n --> phi = " << phi/deg << " deg; direct rotation matrix : "; 304 rotm1.print(G4cout); << 306 rotm1.print(G4cout); 305 G4ThreeVector w = G4ThreeVector(std::cos(phi << 307 G4ThreeVector w = G4ThreeVector(std::cos(phi), std::sin(phi),0.); 306 G4ThreeVector position1 = og * w; << 308 G4ThreeVector position1 = og*w; 307 G4Transform3D transform1 = G4Transform3D(rot << 309 G4Transform3D transform1 = G4Transform3D(rotm1,position1); 308 << 310 309 new G4PVPlacement(transform1, // position, << 311 new G4PVPlacement(transform1, //position, rotation 310 fTrdVolume, // logical vo << 312 fTrdVolume, //logical volume 311 "Trd", // name << 313 "Trd", //name 312 fWorldVolume, // mother v << 314 fWorldVolume, //mother volume 313 false, // no boolean oper << 315 false, //no boolean operation 314 1); // copy number << 316 1); //copy number 315 317 316 // 2nd position (with second G4PVPlacement c 318 // 2nd position (with second G4PVPlacement constructor) 317 // 319 // 318 phi = phi + 90 * deg; << 320 phi = phi + 90*deg; 319 << 321 320 phi_euler = phi + pi / 2; << 322 phi_euler = phi + pi/2; 321 auto rotm2Inv = new G4RotationMatrix(phi_eul << 323 G4RotationMatrix* rotm2Inv 322 w = G4ThreeVector(std::cos(phi), std::sin(ph << 324 = new G4RotationMatrix(phi_euler,theta_euler,psi_euler); 323 G4ThreeVector position2 = og * w; << 325 w = G4ThreeVector(std::cos(phi), std::sin(phi),0.); 324 << 326 G4ThreeVector position2 = og*w; 325 new G4PVPlacement(rotm2Inv, // rotation << 327 326 position2, // position << 328 new G4PVPlacement(rotm2Inv, //rotation 327 fTrdVolume, // logical vo << 329 position2, //position 328 "Trd", // name << 330 fTrdVolume, //logical volume 329 fWorldVolume, // mother v << 331 "Trd", //name 330 false, // no boolean oper << 332 fWorldVolume, //mother volume 331 2); // copy number << 333 false, //no boolean operation >> 334 2); //copy number 332 } 335 } 333 336 334 //....oooOO0OOooo........oooOO0OOooo........oo 337 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 335 338 336 void DetectorConstruction::PlaceWithReflection 339 void DetectorConstruction::PlaceWithReflections() 337 { 340 { 338 /// Placement with reflections. << 341 /// Placement with reflections. 339 /// In order to better show the reflection s << 342 /// In order to better show the reflection symmetry we do not apply 340 /// the rotation along Y axis. << 343 /// the rotation along Y axis. 341 344 342 G4double og = 3 * cm; << 345 G4double og = 3*cm; 343 346 344 // Place first two positionz in z = + 3cm << 347 // Place first two positionz in z = - 3cm 345 // 348 // 346 349 347 // 1st position 350 // 1st position 348 G4double phi = 30 * deg; << 351 G4double phi = 30*deg; 349 G4RotationMatrix rotm1; 352 G4RotationMatrix rotm1; 350 // rotm1.rotateY(90*deg); << 353 //rotm1.rotateY(90*deg); 351 rotm1.rotateZ(phi); << 354 rotm1.rotateZ(phi); 352 G4ThreeVector uz = G4ThreeVector(std::cos(ph << 355 G4ThreeVector uz = G4ThreeVector(std::cos(phi), std::sin(phi), 0); 353 G4ThreeVector position = og * uz; << 356 G4ThreeVector position = og*uz; 354 G4Transform3D transform1(rotm1, position); << 357 G4Transform3D transform1(rotm1,position); 355 G4Transform3D translateZ = HepGeom::Translat << 358 G4Transform3D translateZ = HepGeom::Translate3D(0, 0, -3.*cm); 356 << 359 357 new G4PVPlacement(translateZ * transform1, << 360 new G4PVPlacement(translateZ * transform1, //rotation,position 358 fTrdVolume, // logical vo << 361 fTrdVolume, //logical volume 359 "Trd", // name << 362 "Trd", //name 360 fWorldVolume, // mother v << 363 fWorldVolume, //mother volume 361 false, // no boolean oper << 364 false, //no boolean operation 362 1); // copy number << 365 1); //copy number 363 366 364 // 2nd position 367 // 2nd position 365 phi = phi + pi / 2; << 368 phi = phi + pi/2 ; 366 G4RotationMatrix rotm2; 369 G4RotationMatrix rotm2; 367 // rotm2.rotateY(90*deg); << 370 //rotm2.rotateY(90*deg); 368 rotm2.rotateZ(phi); << 371 rotm2.rotateZ(phi); 369 uz = G4ThreeVector(std::cos(phi), std::sin(p << 372 uz = G4ThreeVector(std::cos(phi), std::sin(phi), 0.); 370 position = og * uz; << 373 position = og*uz; 371 G4Transform3D transform2 = G4Transform3D(rot 374 G4Transform3D transform2 = G4Transform3D(rotm2, position); >> 375 >> 376 new G4PVPlacement(translateZ * transform2, //rotation, position >> 377 fTrdVolume, //logical volume >> 378 "Trd", //name >> 379 fWorldVolume, //mother volume >> 380 false, //no boolean operation >> 381 2); //copy number 372 382 373 new G4PVPlacement(translateZ * transform2, << 374 fTrdVolume, // logical vo << 375 "Trd", // name << 376 fWorldVolume, // mother v << 377 false, // no boolean oper << 378 2); // copy number << 379 383 380 // Place next two positionz in z = - 3cm wit << 384 // Place next two positionz in z = + 3cm with reflection 381 // 385 // 382 386 383 // 3rd position 387 // 3rd position 384 translateZ = HepGeom::Translate3D(0, 0, -3. << 388 translateZ = HepGeom::Translate3D(0, 0, +3.*cm); 385 G4Transform3D reflect3D = HepGeom::ReflectZ3 389 G4Transform3D reflect3D = HepGeom::ReflectZ3D(); 386 390 387 G4ReflectionFactory::Instance()->Place(trans << 391 G4ReflectionFactory::Instance() 388 "Trd" << 392 ->Place(translateZ * transform1 * reflect3D, //rotation,position 389 fTrdV << 393 "Trd", //name 390 fWorl << 394 fTrdVolume, //logical volume 391 false << 395 fWorldVolume, //mother volume 392 3); << 396 false, //no boolean operation >> 397 3); //copy number 393 398 394 // 4rd position 399 // 4rd position 395 G4ReflectionFactory::Instance()->Place(trans << 400 G4ReflectionFactory::Instance() 396 "Trd" << 401 ->Place( translateZ * transform2 * reflect3D,//rotation,position 397 fTrdV << 402 "Trd", //name 398 fWorl << 403 fTrdVolume, //logical volume 399 false << 404 fWorldVolume, //mother volume 400 4); << 405 false, //no boolean operation >> 406 4); //copy number 401 } 407 } 402 408 403 //....oooOO0OOooo........oooOO0OOooo........oo 409 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 404 410 405 #include "G4RunManager.hh" 411 #include "G4RunManager.hh" 406 412 407 void DetectorConstruction::SetMethod(EMethod m << 413 void DetectorConstruction::SetMethod(EMethod method) { 408 { << 409 fMethod = method; 414 fMethod = method; 410 G4RunManager::GetRunManager()->DefineWorldVo << 415 G4RunManager::GetRunManager()->DefineWorldVolume(Construct()); 411 } << 416 } 412 417 413 //....oooOO0OOooo........oooOO0OOooo........oo 418 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 414 419