/scratch0/jsnuveri/BDSIM/BDSIMgit/bdsim/src/BDSMagnetOuterFactoryPolesFacet.cc

00001 #include "BDSMagnetOuterFactoryPolesFacet.hh"
00002 
00003 #include "globals.hh"  // geant4 globals / types
00004 
00005 #include "G4Box.hh"
00006 #include "G4Polyhedra.hh"
00007 #include "G4SubtractionSolid.hh"
00008 #include "G4ThreeVector.hh"
00009 #include "G4Tubs.hh"
00010 #include "G4VSolid.hh"
00011 
00012 BDSMagnetOuterFactoryPolesFacet* BDSMagnetOuterFactoryPolesFacet::_instance = 0;
00013 
00014 BDSMagnetOuterFactoryPolesFacet* BDSMagnetOuterFactoryPolesFacet::Instance()
00015 {
00016   if (_instance == 0)
00017     {_instance = new BDSMagnetOuterFactoryPolesFacet();}
00018   return _instance;
00019 }
00020 
00021 BDSMagnetOuterFactoryPolesFacet::~BDSMagnetOuterFactoryPolesFacet()
00022 {
00023   _instance = 0;
00024 }
00025 
00026 void BDSMagnetOuterFactoryPolesFacet::CreatePoleSolid(G4String     name,
00027                                                       G4double     length,
00028                                                       G4int        order)
00029 {
00030   // use base class to do all the work, then modify the pole by cropping
00031   // it with a box to get the right shape
00032   
00033   // set pole length to be longer so we have unambiguous subtraction
00034   G4double tempPoleFinishRadius = poleFinishRadius; // copy to set back later
00035   poleFinishRadius = 2*poleFinishRadius;
00036   
00037   // base class method will use poleFinishRadius
00038   BDSMagnetOuterFactoryPolesBase::CreatePoleSolid(name,length,order);
00039   
00040   poleFinishRadius = tempPoleFinishRadius; // set it back to what it was
00041 
00042   G4VSolid* baseClassPoleSolid = poleSolid;
00043 
00044   // for box sizes we need something roughly adaptive to the component size
00045   // but just needs to be big - don't want to hard code anything so use
00046   // poleFinishRadius - a bigger component will entail bigger poleFinishRadius
00047   G4VSolid* subtractionBox = new G4Box(name + "_subtraction_box",  // name
00048                                        poleFinishRadius,           // x half width
00049                                        poleFinishRadius,           // y half width
00050                                        length);                    // z half width
00051   // z half width is full length for unambiguous subtraction
00052 
00053   // note translation is to centre of box which is nominal poleFinishRadius + half width
00054   // of box which is poleFinishRadius also - so tranlation is 2*poleFinishRadius
00055   G4ThreeVector boxTranslation(2*poleFinishRadius,0,0);
00056   poleSolid = new G4SubtractionSolid(name + "_pole_solid",        // name
00057                                      baseClassPoleSolid,          // solid 1
00058                                      subtractionBox,              // solid 2 - subtract this one
00059                                      0,                           // rotation
00060                                      boxTranslation);
00061                                      
00062 }
00063 
00064 void BDSMagnetOuterFactoryPolesFacet::CreateYokeAndContainerSolid(G4String      name,
00065                                                                   G4double      length,
00066                                                                   G4int         order)
00067 {
00068   G4double segmentAngle = CLHEP::twopi / (2*order);
00069   
00070   G4double zPlanes[2] = {-length*0.5, length*0.5};
00071   std::vector<G4double> innerRadii;
00072   std::vector<G4double> outerRadii;
00073   for (G4int i = 0; i < order*2; ++i)
00074     {
00075       innerRadii.push_back(yokeStartRadius);
00076       outerRadii.push_back(yokeFinishRadius);
00077     }
00078   
00079   yokeSolid = new G4Polyhedra(name + "_yoke_solid",    // name
00080                               CLHEP::pi*0.5,    // start angle
00081                               CLHEP::twopi,            // sweep angle
00082                               2*order,                 // number of sides
00083                               2,                       // number of z planes
00084                               zPlanes,                 // z plane z coordinates
00085                               innerRadii.data(),
00086                               outerRadii.data());
00087 
00088   // note container must have hole in it for the beampipe to fit in!
00089   // poled geometry doesn't fit tightly to beampipe so can alays use a circular aperture
00090   G4double yokeExtent   = yokeFinishRadius / cos(segmentAngle*0.5);
00091   containerSolid = new G4Tubs(name + "_container_solid",       // name
00092                               poleStartRadius,                 // start radius
00093                               yokeExtent + lengthSafety,       // finish radius
00094                               length*0.5,                      // z half length
00095                               0,                               // start angle
00096                               CLHEP::twopi);                   // sweep angle
00097 
00098 
00099 }

Generated on 28 Jun 2015 for BDSIM by  doxygen 1.4.7