// // ******************************************************************** // * License and Disclaimer * // * * // * The Geant4 software is copyright of the Copyright Holders of * // * the Geant4 Collaboration. It is provided under the terms and * // * conditions of the Geant4 Software License, included in the file * // * LICENSE and available at http://cern.ch/geant4/license . These * // * include a list of copyright holders. * // * * // * Neither the authors of this software system, nor their employing * // * institutes,nor the agencies providing financial support for this * // * work make any representation or warranty, express or implied, * // * regarding this software system or assume any liability for its * // * use. Please see the license in the file LICENSE and URL above * // * for the full disclaimer and the limitation of liability. * // * * // * This code implementation is the result of the scientific and * // * technical work of the GEANT4 collaboration. * // * By using, copying, modifying or distributing the software (or * // * any work based on the software) you agree to acknowledge its * // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the Geant4 Software license. * // ******************************************************************** // #include #include #include "globals.hh" #include "geomdefs.hh" #include "ApproxEqual.hh" #include "G4ThreeVector.hh" #include "G4RotationMatrix.hh" #include "G4AffineTransform.hh" #include "G4VoxelLimits.hh" #include "G4Box.hh" #include "G4Cons.hh" #include "G4Para.hh" #include "G4Sphere.hh" #include "G4Torus.hh" #include "G4Trap.hh" #include "G4Trd.hh" #include "G4Tubs.hh" #include "G4UnionSolid.hh" // #include "G4DisplacedSolid.hh" /////////////////////////////////////////////////////////////////// // // Dave's auxiliary function const G4String OutputInside(const EInside a) { switch(a) { case kInside: return "Inside"; case kOutside: return "Outside"; case kSurface: return "Surface"; } return "????"; } int main() { G4ThreeVector pzero(0,0,0); G4ThreeVector ponxside(20,0,0),ponyside(0,30,0),ponzside(0,0,40), ponb2x(10,0,0),ponb2y(0,10,0),ponb2z(0,0,10), ponb2mx(-10,0,0),ponb2my(0,-10,0),ponb2mz(0,0,-10); G4ThreeVector ponmxside(-20,0,0),ponmyside(0,-30,0),ponmzside(0,0,-40); G4ThreeVector ponzsidey(0,25,40),ponmzsidey(0,25,-40), ponb2zy(0,5,10),ponb2mzy(0,5,-10) ; G4ThreeVector pbigx(100,0,0),pbigy(0,100,0),pbigz(0,0,100); G4ThreeVector pbigmx(-100,0,0),pbigmy(0,-100,0),pbigmz(0,0,-100); G4ThreeVector vx(1,0,0),vy(0,1,0),vz(0,0,1); G4ThreeVector vmx(-1,0,0),vmy(0,-1,0),vmz(0,0,-1); G4ThreeVector vxy(1/std::sqrt(2.0),1/std::sqrt(2.0),0); G4ThreeVector vmxy(-1/std::sqrt(2.0),1/std::sqrt(2.0),0); G4ThreeVector vmxmy(-1/std::sqrt(2.0),-1/std::sqrt(2.0),0); G4ThreeVector vxmy(1/std::sqrt(2.0),-1/std::sqrt(2.0),0); G4ThreeVector vxz(1/std::sqrt(2.0),0,1/std::sqrt(2.0)); G4ThreeVector vxmz(1/std::sqrt(2.0),0,-1/std::sqrt(2.0)); G4ThreeVector vmxz(-1/std::sqrt(2.0),0,1/std::sqrt(2.0)); G4ThreeVector vmxmz(-1/std::sqrt(2.0),0,-1/std::sqrt(2.0)); G4double dist, vol, volCheck, diff; G4ThreeVector *pNorm,norm; G4bool *pgoodNorm,goodNorm,calcNorm=true; pNorm=&norm; pgoodNorm=&goodNorm; G4RotationMatrix identity, xRot ; // NOTE: xRot = rotation such that x axis->-x axis & y axis->-y axis xRot.rotateZ(-pi) ; G4Transform3D transform(xRot,G4ThreeVector(0,40,0)) ; G4Box b1("Test Box #1",20,30,40); G4Box b2("Test Box #2",10,10,10); G4Box b3("Test Box #3",10,20,50); G4Box* b4 = new G4Box("b4",50,50,50) ; G4Box* b5 = new G4Box("b5",10,10,60) ; G4Tubs t1("Solid Tube #1",0,50,50,0,360); G4Tubs t2("Hole Tube #2",45,50,50,0,360); G4Tubs t3("disk",0,50,5,0,360); G4Tubs t4("t4",0,45,50,0,360); G4Cons c1("Hollow Full Tube",50,100,50,100,50,0,2*pi), c2("Full Cone",0,50,0,100,50,0,2*pi) ; G4UnionSolid b1Ub2("b1Unionb2",&b1,&b2), t1Ub2("t1Unionb2",&t1,&b2), c2Ub2("c2Unionb2",&c2,&b2); G4UnionSolid b4Ub5("b4Ub5",b4,b5); G4UnionSolid t2Ut4("t2Ut4",&t2,&t4); // With placement G4UnionSolid b1Ub3("b1Unionb3",&b1,&b3,transform); G4UnionSolid t1Ub3("t1Unionb3",&t1,&b3,transform); G4UnionSolid t2Ut1Trans("t2Ut1Trans",&t2,&t1, &identity,G4ThreeVector(0,0,110)); G4UnionSolid t2Ut1Ut1("t2Ut1Ut1",&t2Ut1Trans,&t1, &identity,G4ThreeVector(0,0,-110)); G4UnionSolid t2Ut3("t2Ut3",&t2,&t3, &identity,G4ThreeVector(0,0,50)) ; G4UnionSolid t2Ut3Ut3("t2Ut3Ut3",&t2Ut3,&t3, &identity,G4ThreeVector(0,0,-50)) ; G4UnionSolid t3Ut3("t3Ut3",&t3,&t3, &identity,G4ThreeVector(0,0,10)) ; G4UnionSolid t3Ut3Ut3("t3Ut3Ut3",&t3Ut3,&t3, &identity,G4ThreeVector(0,0,-10)) ; G4UnionSolid b4Ub4xtouch("b4Ub4xtouch",b4,b4,&identity,G4ThreeVector(100.,0,0)); G4Box * box1 = new G4Box("Box1",1092.500000,240.103374,92.000000); G4Box * box2 = new G4Box("Box2",540.103374,792.500000,92.000000); G4double L1 = 1104; G4UnionSolid envelope("ECShapeBoxes", box1, box2, 0, G4ThreeVector(-L1/2., L1/2., 0.) ); G4ThreeVector pPrePre(-301.4252442474112,903.7985455093324,3013.122572566068-2924); G4ThreeVector pPre(-301.5459060972926,904.1596390942879,3014.325585765819-2924); G4ThreeVector pPos(-301.7139066520877,904.6621760944698,3016-2924); // Vacuum Cross G4double startPhi = 0.*deg; G4double deltaPhi = 360.*deg; G4double minRadius = 0.*cm; //Sample changer (carbon-fiber cross) //G4double minRadiusTUV = 3.9*cm; // Vertical carbon fiber tube //G4double maxRadiusTUV = 4.1*cm; //G4double halfLengthTUV = 47.5*cm; G4double maxRadiusVACTUV = 3.9*cm; G4double halfLengthVACTUV = 47.5*cm; //G4double minRadiusTUH = 2.5*cm; // ??? Horizontal carbon fiber tube //G4double maxRadiusTUH = 2.7*cm; //G4double halfLengthTUH = 44.0*cm; G4double maxRadiusVACTUH = 2.5*cm; G4double halfLengthVACTUH = 44.0*cm; G4RotationMatrix rmVacCross; rmVacCross.rotateX(90.*deg); G4RotationMatrix rmVACTUV; rmVACTUV.rotateX(90.*deg); G4Tubs* solidVACTUH = new G4Tubs("VACTUH",minRadius,maxRadiusVACTUH, halfLengthVACTUH,startPhi,deltaPhi); G4Tubs* solidVACTUV = new G4Tubs("VACTUV",minRadius,maxRadiusVACTUV, halfLengthVACTUV,startPhi,deltaPhi); G4UnionSolid* solidVacCross = new G4UnionSolid("VacCross",solidVACTUH,solidVACTUV, &rmVacCross,G4ThreeVector()); // check cubic volume vol = b1Ub2.GetCubicVolume(); volCheck = 8.*20.*30.*40.; // G4cout<<"vol = "<Inside(G4ThreeVector( 2.3391... = " <Inside(point1)==kInside) { // G4cout<<"Test point "<DistanceToOut(point1,direction); // G4cout<<"Distance is "<Inside(point2)==kInside) { // G4cout<<"Test point "<DistanceToOut(point2,direction); // G4cout<<"Distance is "<