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

00001 #include "BDSBeamPipeFactoryBase.hh"
00002 #include "BDSBeamPipeFactoryLHCDetailed.hh"
00003 #include "BDSBeamPipe.hh"
00004 
00005 #include "BDSDebug.hh"
00006 #include "BDSExecOptions.hh"
00007 #include "BDSGlobalConstants.hh"
00008 #include "BDSMaterials.hh"
00009 #include "BDSSDManager.hh"
00010 
00011 #include "globals.hh"                      // geant4 globals / types
00012 #include "G4Box.hh"
00013 #include "G4Colour.hh"
00014 #include "G4CutTubs.hh"
00015 #include "G4IntersectionSolid.hh"
00016 #include "G4LogicalVolume.hh"
00017 #include "G4Material.hh"
00018 #include "G4PVPlacement.hh"
00019 #include "G4SubtractionSolid.hh"
00020 #include "G4ThreeVector.hh"
00021 #include "G4Tubs.hh"
00022 #include "G4VisAttributes.hh"
00023 #include "G4VSolid.hh"
00024 
00025 #include <cmath>
00026 #include <utility>                         // for std::pair
00027 
00028 
00029 BDSBeamPipeFactoryLHCDetailed* BDSBeamPipeFactoryLHCDetailed::_instance = 0;
00030 
00031 BDSBeamPipeFactoryLHCDetailed* BDSBeamPipeFactoryLHCDetailed::Instance()
00032 {
00033   if (_instance == 0)
00034     {_instance = new BDSBeamPipeFactoryLHCDetailed();}
00035   return _instance;
00036 }
00037 
00038 BDSBeamPipeFactoryLHCDetailed::BDSBeamPipeFactoryLHCDetailed():BDSBeamPipeFactoryBase()
00039 {
00040   coldBoreThickness         = 1.5*CLHEP::mm;
00041   coolingPipeThickness      = 0.53*CLHEP::mm;
00042   coolingPipeRadius         = 3.7*CLHEP::mm*0.5; // will be overwritten if needs be to fit inside beampipe
00043   coolingPipeYOffset        = 0.0;  //initialised only
00044   copperSkinThickness       = 75*CLHEP::um;
00045   CleanUp();
00046 }
00047 
00048 BDSBeamPipeFactoryLHCDetailed::~BDSBeamPipeFactoryLHCDetailed()
00049 {
00050   _instance = 0;
00051 }
00052 
00053 void BDSBeamPipeFactoryLHCDetailed::CleanUp()
00054 {
00055   BDSBeamPipeFactoryBase::CleanUp();
00056   copperSkinSolid  = NULL; // the copper skin
00057   screenSolid      = NULL; // the beam screen (first bit of aperture)
00058   coolingPipeSolid = NULL; // small cooling pipe above and below beam screen
00059   copperSkinLV     = NULL;
00060   screenLV         = NULL;
00061   coolingPipeLV    = NULL;
00062   
00063   InitialiseGeometricalParameters();
00064 }
00065 
00066 void BDSBeamPipeFactoryLHCDetailed::InitialiseGeometricalParameters()
00067 {
00068   vacRadius = 0, vacBoxX = 0, vacBoxY = 0;
00069   
00070   cuInnerRadius = 0, cuInnerBoxX = 0, cuInnerBoxY = 0;
00071   cuOuterRadius = 0, cuOuterBoxX = 0, cuOuterBoxY = 0;
00072   
00073   bsInnerRadius = 0, bsInnerBoxX = 0, bsInnerBoxY = 0;
00074   bsOuterRadius = 0, bsOuterBoxX = 0, bsOuterBoxY = 0;
00075   
00076   cbInnerRadius = 0, cbOuterRadius = 0;
00077   
00078   containerRadius = 0;
00079   
00080   vacHalfLength = 0;
00081   halfLength = 0;
00082   
00083   coolingPipeYOffset = 0;
00084 }
00085 
00086 
00087 G4double BDSBeamPipeFactoryLHCDetailed::GetFullWidthOfCoolingPipe()
00088 {
00089   return coolingPipeRadius + coolingPipeThickness + 2*lengthSafety;
00090 }
00091 
00092 void BDSBeamPipeFactoryLHCDetailed::CalculateGeometricalParameters(G4double aper1,
00093                                                                    G4double aper2,
00094                                                                    G4double aper3,
00095                                                                    G4double beamPipeThickness,
00096                                                                    G4double length)
00097 {
00098   // vacuum volume
00099   vacRadius     = aper3;
00100   vacBoxX       = aper1;
00101   vacBoxY       = aper2;
00102   
00103   // copper skin geometrical parameters
00104   cuInnerRadius = vacRadius + 1*CLHEP::um;
00105   cuInnerBoxX   = vacBoxX   + 1*CLHEP::um;
00106   cuInnerBoxY   = vacBoxY   + 1*CLHEP::um;
00107   cuOuterRadius = cuInnerRadius + copperSkinThickness;
00108   cuOuterBoxX   = cuInnerBoxX   + copperSkinThickness;
00109   cuOuterBoxY   = cuInnerBoxY   + copperSkinThickness;
00110 
00111   // beam screen geometrical parameters
00112   bsInnerRadius = cuOuterRadius + 1*CLHEP::um;
00113   bsInnerBoxX   = cuOuterBoxX   + 1*CLHEP::um;
00114   bsInnerBoxY   = cuOuterBoxY   + 1*CLHEP::um;
00115   bsOuterRadius = bsInnerRadius + beamPipeThickness;
00116   bsOuterBoxX   = bsInnerBoxX   + beamPipeThickness;
00117   bsOuterBoxY   = bsInnerBoxY   + beamPipeThickness;
00118   
00119   // cold bore geometrical parameters
00120   cbInnerRadius = bsOuterRadius + 1*CLHEP::um;
00121   cbOuterRadius = cbInnerRadius + coldBoreThickness;
00122 
00123   // container geometrical parameters
00124   containerRadius = cbOuterRadius + 1*CLHEP::um;  
00125   
00126   // general length variable (to avoid mistakes)
00127   vacHalfLength   = length*0.5 - lengthSafety;
00128   halfLength      = length*0.5 - 1*CLHEP::um; 
00129 
00130   // cooling pipe geometrical parameters
00131   coolingPipeYOffset = bsOuterBoxY + coolingPipeRadius + coolingPipeThickness + 1*CLHEP::um;
00132 }
00133   
00134 
00135 BDSBeamPipe* BDSBeamPipeFactoryLHCDetailed::CreateBeamPipe(G4String    name,              // name
00136                                                            G4double    length,            // length [mm]
00137                                                            G4double    aper1,             // rect half width
00138                                                            G4double    aper2,             // rect half height
00139                                                            G4double    aper3,             // radius of circle
00140                                                            G4double    /*aper4*/,         // aperture parameter 4
00141                                                            G4Material* vacuumMaterial,    // vacuum material
00142                                                            G4double    beamPipeThickness, // beampipe thickness [mm]
00143                                                            G4Material* beamPipeMaterial   // beampipe material
00144                                                            )
00145 {
00146 #ifdef BDSDEBUG
00147   G4cout << __METHOD_NAME__ << G4endl;
00148 #endif
00149   // clean up after last usage
00150   CleanUp();
00151 
00152   // calculate geometrical parameters
00153   CalculateGeometricalParameters(aper1, aper2, aper3, beamPipeThickness, length);
00154   
00155   // test input parameters - set global options as default if not specified
00156   TestInputParameters(vacuumMaterial,beamPipeThickness,beamPipeMaterial,aper1,aper2,aper3);
00157 
00158   // build the solids
00159   //vacuum cylindrical solid (circular cross-section)
00160   G4VSolid* vacCylSolid = new G4Tubs(name + "_vacuum_cylinder", // name
00161                                      0,                           // inner radius
00162                                      vacRadius,                   // outer radius
00163                                      vacHalfLength,               // half length
00164                                      0,                           // rotation start angle
00165                                      CLHEP::twopi);               // rotation finish angle
00166   //vacuum box solid (rectangular cross-section)
00167   G4VSolid* vacRectSolid = new G4Box(name + "_vacuum_box", // name
00168                                      vacBoxX,                // x half width
00169                                      vacBoxY,                // y half width
00170                                      length); // z full width (long for unambiguous intersection)
00171   //intersection of both of these gives the desired shape
00172   vacuumSolid = new G4IntersectionSolid(name + "_vacuum_solid", // name
00173                                         vacCylSolid,              // solid 1
00174                                         vacRectSolid);            // solid 2
00175 
00176 
00177   //copper skin layer to beamscreen
00178   //copper skin inner edge for subtraction (actually just like vacuum + lengthSafety)
00179   G4VSolid* cuInnerCylSolid = new G4Tubs(name + "_cu_inner_cylinder", // name
00180                                          0,                             // inner radius
00181                                          cuInnerRadius,                 // outer radius
00182                                          1.5*length,  // length big for unambiguous subtraction (but < outerlength)
00183                                          0,                             // rotation start angle
00184                                          CLHEP::twopi);                 // rotation finish angle
00185   //screen inner edge box solid (rectangular cross-section)
00186   G4VSolid* cuInnerRectSolid = new G4Box(name + "_cu_inner_box", // name
00187                                          cuInnerBoxX,              // x half width
00188                                          cuInnerBoxY,              // y half width
00189                                          1.7*length); // z long for unambiguous intersection
00190   //screen inner intersection - 1.5*length long which is > half length for unambiguous subtraction later
00191   G4VSolid* cuInnerSolid = new G4IntersectionSolid(name + "_cu_inner_solid", // name
00192                                                    cuInnerCylSolid,            // solid 1
00193                                                    cuInnerRectSolid);          // solid 2
00194 
00195   //screen outer edge for subtraction (actually just like vacuum + lengthSafety)
00196   G4VSolid* cuOuterCylSolid = new G4Tubs(name + "_cu_outer_cylinder",    // name
00197                                          0,                                // inner radius (0 for unambiguous subtraction)
00198                                          cuOuterRadius,                    // outer radius
00199                                          halfLength,                       // half length
00200                                          0,                                // rotation start angle
00201                                          CLHEP::twopi);                    // rotation finish angle
00202   //screen outer edge box solid (rectangular cross-section)
00203   G4VSolid* cuOuterRectSolid = new G4Box(name + "_cu_outer_box", // name
00204                                          cuOuterBoxX,              // x half width
00205                                          cuOuterBoxY,              // y half width
00206                                          length); // z full width (long for unambiguous intersection)
00207   G4VSolid* cuOuterSolid = new G4IntersectionSolid(name + "_cu_outer_solid", // name
00208                                                    cuOuterCylSolid,            // solid 1
00209                                                    cuOuterRectSolid);          // solid 2
00210   copperSkinSolid = new G4SubtractionSolid(name + "_copper_skin_solid",// name
00211                                            cuOuterSolid,                 // this
00212                                            cuInnerSolid);                // minus this
00213   
00214   //beampipe cylindrical solid (circular cross-section)
00215   //beampipe inner edge for subtraction (actually just like vacuum + lengthSafety)
00216   //using large margin of 1um here to avoid misplacement errors with compound booleans in geant4 (empirical solution)
00217   G4VSolid* screenInnerCylSolid = new G4Tubs(name + "_screen_inner_cylinder", // name
00218                                              0,                                 // inner radius
00219                                              bsInnerRadius,                     // outer radius
00220                                              1.5*length, // length big for unambiguous subtraction (but < outerlength)
00221                                              0,                                 // rotation start angle
00222                                              CLHEP::twopi);                     // rotation finish angle
00223   //screen inner edge box solid (rectangular cross-section)
00224   //using large margin of 1um here to avoid misplacement errors with compound booleans in geant4 (empirical solution)
00225   G4VSolid* screenInnerRectSolid = new G4Box(name + "_screen_inner_box", // name
00226                                              bsInnerBoxX,                  // x half width
00227                                              bsInnerBoxY,                  // y half width
00228                                              1.7*length); // z long for unambiguous intersection
00229   //screen inner intersection - 1.5*length long which is > half length for unambiguous subtraction later
00230   G4VSolid* screenInnerSolid = new G4IntersectionSolid(name + "_screen_inner_solid", // name
00231                                                        screenInnerCylSolid,            // solid 1
00232                                                        screenInnerRectSolid);          // solid 2
00233 
00234   //screen outer edge for subtraction (actually just like vacuum + lengthSafety)x
00235   G4VSolid* screenOuterCylSolid = new G4Tubs(name + "_screen_outer_cylinder",// name
00236                                              0,                                // inner radius (0 for unambiguous subtraction)
00237                                              bsOuterRadius,                    // outer radius
00238                                              halfLength,                       // half length
00239                                              0,                                // rotation start angle
00240                                              CLHEP::twopi);                    // rotation finish angle
00241   //screen outer edge box solid (rectangular cross-section)
00242   G4VSolid* screenOuterRectSolid = new G4Box(name + "_screen_outer_box", // name
00243                                              bsOuterBoxX,                  // x half width
00244                                              bsOuterBoxY,                  // y half width
00245                                              length); // z full width (long for unambiguous intersection)
00246   G4VSolid* screenOuterSolid = new G4IntersectionSolid(name + "_screen__outersolid", // name
00247                                                        screenOuterCylSolid,            // solid 1
00248                                                        screenOuterRectSolid);          // solid 2
00249   screenSolid = new G4SubtractionSolid(name + "_screen_solid",// name
00250                                        screenOuterSolid,        // this
00251                                        screenInnerSolid);       // minus this
00252   
00253   coolingPipeSolid = new G4Tubs(name + "_cooling_pipe_solid",           // name
00254                                 coolingPipeRadius,                        // inner radius
00255                                 coolingPipeRadius + coolingPipeThickness, // outer radius
00256                                 halfLength,                               // half length
00257                                 0,                                        // rotation start angle
00258                                 CLHEP::twopi);                            // rotation finish angle
00259   
00260   // beampipe - ("coldbore") circular cross-section and sits outisde screen and cooling pipe
00261   beamPipeSolid = new G4Tubs(name + "_beampipe_solid",         // name
00262                              cbInnerRadius,                      // inner radius
00263                              cbOuterRadius,                      // outer radius
00264                              halfLength,                         // half length
00265                              0,                                  // rotation start angle
00266                              CLHEP::twopi);                      // rotation finish angle
00267   
00268   //container cylindrical solid (circular cross-section)
00269   containerSolid = new G4Tubs(name + "_container_cylinder", // name
00270                               0,                              // inner radius
00271                               containerRadius,                // outer radius
00272                               length*0.5,                     // half length
00273                               0,                              // rotation start angle
00274                               CLHEP::twopi);                  // rotation finish angle
00275 
00276   //container cylindrical solid (circular cross-section)
00277   containerSubtractionSolid = new G4Tubs(name + "_subtraction_cylinder", // name
00278                                          0,                                // inner radius
00279                                          containerRadius + lengthSafety,   // outer radius
00280                                          2*length,                         // long length for unambiguous subtraction
00281                                          0,                                // rotation start angle
00282                                          CLHEP::twopi);                    // rotation finish angle
00283   
00284   return CommonFinalConstruction(name, vacuumMaterial, beamPipeMaterial, length, containerRadius);
00285 }
00286 
00287 BDSBeamPipe* BDSBeamPipeFactoryLHCDetailed::CreateBeamPipeAngledInOut(G4String    name,              // name
00288                                                                       G4double    length,            // length [mm]
00289                                                                       G4double    angleIn,           // the normal angle of the input face
00290                                                                       G4double    angleOut,          // the normal angle of the input face
00291                                                                       G4double    aper1,             // aperture parameter 1
00292                                                                       G4double    aper2,             // aperture parameter 2
00293                                                                       G4double    aper3,             // aperture parameter 3
00294                                                                       G4double    /*aper4*/,         // aperture parameter 4
00295                                                                       G4Material* vacuumMaterial,    // vacuum material
00296                                                                       G4double    beamPipeThickness, // beampipe thickness [mm]
00297                                                                       G4Material* beamPipeMaterial   // beampipe material
00298                                                                       )
00299 {
00300 #ifdef BDSDEBUG
00301   G4cout << __METHOD_NAME__ << G4endl;
00302 #endif
00303   // clean up after last usage
00304   CleanUp();
00305 
00306   // calculate geometrical parameters
00307   CalculateGeometricalParameters(aper1, aper2, aper3, beamPipeThickness, length);
00308   
00309    // test input parameters - set global options as default if not specified
00310   TestInputParameters(vacuumMaterial,beamPipeThickness,beamPipeMaterial,aper1,aper2,aper3);
00311 
00312   std::pair<G4ThreeVector,G4ThreeVector> faces = CalculateFaces(angleIn, angleOut);
00313   G4ThreeVector inputface  = faces.first;
00314   G4ThreeVector outputface = faces.second;
00315   
00316   G4double containerRadius = CreateGeneralAngledSolids(name, length, inputface, outputface);
00317   
00318   return CommonFinalConstruction(name, vacuumMaterial, beamPipeMaterial, length, containerRadius);
00319 }
00320 
00322 
00324 void BDSBeamPipeFactoryLHCDetailed::TestInputParameters(G4Material*&  vacuumMaterial,   // reference to a pointer
00325                                                         G4double&     beamPipeThickness,
00326                                                         G4Material*&  beamPipeMaterial,
00327                                                         G4double&     aper1,
00328                                                         G4double&     aper2,
00329                                                         G4double&     aper3)
00330 {
00331   BDSBeamPipeFactoryBase::TestInputParameters(vacuumMaterial,beamPipeThickness,beamPipeMaterial);
00332 
00333   if (aper1 < 1e-10)
00334     {aper1 = BDSGlobalConstants::Instance()->GetBeamPipeRadius();}
00335 
00336   if (aper2 < 1e-10)
00337     {aper2 = BDSGlobalConstants::Instance()->GetAper2();}
00338 
00339   if (aper3 < 1e-10)
00340     {aper3 = BDSGlobalConstants::Instance()->GetAper3();}
00341 }
00342 
00345 BDSBeamPipe* BDSBeamPipeFactoryLHCDetailed::CommonFinalConstruction(G4String    name,
00346                                                                     G4Material* vacuumMaterial,
00347                                                                     G4Material* beamPipeMaterial,
00348                                                                     G4double    length,
00349                                                                     G4double    containerRadius)
00350 {
00351 #ifdef BDSDEBUG
00352   G4cout << __METHOD_NAME__ << G4endl;
00353 #endif
00354 
00355   BDSBeamPipeFactoryBase::CommonConstruction(name,
00356                                              vacuumMaterial,
00357                                              beamPipeMaterial,
00358                                              length);
00359                     
00360   // record extents
00361   std::pair<double,double> extX = std::make_pair(-containerRadius,containerRadius);
00362   std::pair<double,double> extY = std::make_pair(-containerRadius,containerRadius);
00363   std::pair<double,double> extZ = std::make_pair(-length*0.5,length*0.5);
00364   
00365   // build the BDSBeamPipe instance and return it
00366   BDSBeamPipe* aPipe = BuildBeamPipeAndRegisterVolumes(extX,extY,extZ,containerRadius);
00367 
00368   // REGISTER private lvs (only ones not done by base class)
00369   aPipe->RegisterLogicalVolume(screenLV);
00370   aPipe->RegisterLogicalVolume(coolingPipeLV);
00371   aPipe->RegisterLogicalVolume(copperSkinLV);
00372 
00373   // register sensitive volumes
00374   aPipe->RegisterSensitiveVolume(screenLV);
00375   aPipe->RegisterSensitiveVolume(coolingPipeLV);
00376   aPipe->RegisterSensitiveVolume(copperSkinLV);
00377   
00378   return aPipe;
00379 }
00380 
00381 void BDSBeamPipeFactoryLHCDetailed::BuildLogicalVolumes(G4String    name,
00382                                                         G4Material* vacuumMaterialIn,
00383                                                         G4Material* beamPipeMaterialIn)
00384 {
00385   BDSBeamPipeFactoryBase::BuildLogicalVolumes(name,vacuumMaterialIn,beamPipeMaterialIn);
00386 
00387   // get materials
00388   G4Material* copper = BDSMaterials::Instance()->GetMaterial("Copper");
00389 
00390 
00391   copperSkinLV  = new G4LogicalVolume(copperSkinSolid,
00392                                       copper,
00393                                       name + "_copper_lv");
00394   
00395   screenLV      = new G4LogicalVolume(screenSolid,
00396                                       beamPipeMaterialIn,
00397                                       name + "_screen_lv");
00398   
00399   coolingPipeLV = new G4LogicalVolume(coolingPipeSolid,
00400                                       beamPipeMaterialIn,
00401                                       name + "_cooling_pipe_lv");
00402 }
00403 
00404 void BDSBeamPipeFactoryLHCDetailed::SetVisAttributes()
00405 {
00406   BDSBeamPipeFactoryBase::SetVisAttributes();
00407 
00408   // copper skin
00409   G4VisAttributes* cuVisAttr   = new G4VisAttributes(G4Colour(0.722, 0.525, 0.043));
00410   cuVisAttr->SetForceLineSegmentsPerCircle(nSegmentsPerCircle);
00411   cuVisAttr->SetVisibility(true);
00412   
00413   // beampipe
00414   G4VisAttributes* pipeVisAttr = new G4VisAttributes(G4Colour(0.4,0.4,0.4));
00415   pipeVisAttr->SetVisibility(true);
00416   pipeVisAttr->SetForceLineSegmentsPerCircle(nSegmentsPerCircle);
00417 
00418   copperSkinLV->SetVisAttributes(cuVisAttr);
00419   screenLV->SetVisAttributes(pipeVisAttr);
00420   coolingPipeLV->SetVisAttributes(pipeVisAttr);
00421 }
00422 
00423 G4UserLimits* BDSBeamPipeFactoryLHCDetailed::SetUserLimits(G4double length) {
00424 
00425   G4UserLimits* beamPipeUserLimits = BDSBeamPipeFactoryBase::SetUserLimits(length);
00426   copperSkinLV->SetUserLimits(beamPipeUserLimits);
00427   screenLV->SetUserLimits(beamPipeUserLimits);
00428   coolingPipeLV->SetUserLimits(beamPipeUserLimits);
00429   
00430   return beamPipeUserLimits;
00431 }
00432 
00433 void BDSBeamPipeFactoryLHCDetailed::PlaceComponents(G4String name) {
00434   BDSBeamPipeFactoryBase::PlaceComponents(name);
00435 
00436   new G4PVPlacement((G4RotationMatrix*)0,         // no rotation
00437                     G4ThreeVector(0,0,0),         // position
00438                     copperSkinLV,                 // lv to be placed
00439                     name + "_copper_skin_pv",     // name
00440                     containerLV,                  // mother lv to be place in
00441                     false,                        // no boolean operation
00442                     0,                            // copy number
00443                     checkOverlaps);               // whether to check overlaps
00444   
00445   new G4PVPlacement((G4RotationMatrix*)0,         // no rotation
00446                     (G4ThreeVector)0,             // position
00447                     screenLV,                     // lv to be placed
00448                     name + "_screen_pv",          // name
00449                     containerLV,                  // mother lv to be place in
00450                     false,                        // no boolean operation
00451                     0,                            // copy number
00452                     checkOverlaps);               // whether to check overlaps
00453   
00454   G4ThreeVector* coolingPipeTopPosition    = new G4ThreeVector(0,coolingPipeYOffset,0);
00455   G4ThreeVector* coolingPipeBottomPosition = new G4ThreeVector(0,-coolingPipeYOffset,0);
00456   
00457   new G4PVPlacement((G4RotationMatrix*)0,         // no rotation
00458                     *coolingPipeTopPosition,      // position
00459                     coolingPipeLV,                // lv to be placed
00460                     name + "_cooling_pipe_top_pv",// name
00461                     containerLV,                  // mother lv to be place in
00462                     false,                        // no boolean operation
00463                     0,                            // copy number
00464                     checkOverlaps);               // whether to check overlaps
00465 
00466   new G4PVPlacement((G4RotationMatrix*)0,         // no rotation
00467                     *coolingPipeBottomPosition,   // position
00468                     coolingPipeLV,                // lv to be placed
00469                     name + "_cooling_pipe_bottom_pv", // name
00470                     containerLV,                  // mother lv to be place in
00471                     false,                        // no boolean operation
00472                     0,                            // copy number
00473                     checkOverlaps);               // whether to check overlaps
00474 }
00475   
00478 G4double BDSBeamPipeFactoryLHCDetailed::CreateGeneralAngledSolids(G4String      name,
00479                                                                   G4double      length,
00480                                                                   G4ThreeVector inputface,
00481                                                                   G4ThreeVector outputface)
00482 {
00483 #ifdef BDSDEBUG
00484   G4cout << __METHOD_NAME__ << G4endl;
00485 #endif
00486   
00487   // build the solids
00488   //vacuum cylindrical solid (circular cross-section)
00489   G4VSolid* vacCylSolid = new G4CutTubs(name + "_vacuum_cylinder",   // name
00490                                         0,                           // inner radius
00491                                         vacRadius,                   // outer radius
00492                                         vacHalfLength,               // half length
00493                                         0,                           // rotation start angle
00494                                         CLHEP::twopi,                // rotation finish angle
00495                                         inputface,                   // input face normal
00496                                         outputface);                 // output face normal
00497   //vacuum box solid (rectangular cross-section)
00498   G4VSolid* vacRectSolid = new G4Box(name + "_vacuum_box", // name
00499                                      vacBoxX,              // x half width
00500                                      vacBoxY,              // y half width
00501                                      length); // z full width (long for unambiguous intersection)
00502   //intersection of both of these gives the desired shape
00503   vacuumSolid = new G4IntersectionSolid(name + "_vacuum_solid", // name
00504                                         vacCylSolid,            // solid 1
00505                                         vacRectSolid);          // solid 2
00506 
00507 
00508   //copper skin layer to beamscreen
00509   //copper skin inner edge for subtraction (actually just like vacuum + lengthSafety)
00510   G4VSolid* cuInnerCylSolid = new G4CutTubs(name + "_cu_inner_cylinder",   // name
00511                                             0,                             // inner radius
00512                                             cuInnerRadius,                 // outer radius
00513                                             1.5*length, // length big for unambiguous subtraction (but < outerlength)
00514                                             0,                             // rotation start angle
00515                                             CLHEP::twopi,                  // rotation finish angle
00516                                             inputface,                     // input face normal
00517                                             outputface);                   // output face normal
00518   //screen inner edge box solid (rectangular cross-section)
00519   G4VSolid* cuInnerRectSolid = new G4Box(name + "_cu_inner_box", // name
00520                                          cuInnerBoxX,            // x half width
00521                                          cuInnerBoxY,            // y half width
00522                                          1.7*length);            // z long for unambiguous intersection
00523   //screen inner intersection - 1.5*length long which is > half length for unambiguous subtraction later
00524   G4VSolid* cuInnerSolid = new G4IntersectionSolid(name + "_cu_inner_solid", // name
00525                                                    cuInnerCylSolid,            // solid 1
00526                                                    cuInnerRectSolid);          // solid 2
00527 
00528   //screen outer edge for subtraction (actually just like vacuum + lengthSafety)x
00529   G4VSolid* cuOuterCylSolid = new G4CutTubs(name + "_cu_outer_cylinder",  // name
00530                                             0,                            // inner radius (0 for unambiguous subtraction)
00531                                             cuOuterRadius,                // outer radius
00532                                             halfLength,                   // half length
00533                                             0,                            // rotation start angle
00534                                             CLHEP::twopi,                 // rotation finish angle
00535                                             inputface,                    // input face normal
00536                                             outputface);                  // output face normal
00537   //screen outer edge box solid (rectangular cross-section)
00538   G4VSolid* cuOuterRectSolid = new G4Box(name + "_cu_outer_box", // name
00539                                          cuOuterBoxX,            // x half width
00540                                          cuOuterBoxY,            // y half width
00541                                          length); // z full width (long for unambiguous intersection)
00542   G4VSolid* cuOuterSolid = new G4IntersectionSolid(name + "_cu_outer_solid", // name
00543                                                    cuOuterCylSolid,          // solid 1
00544                                                    cuOuterRectSolid);        // solid 2
00545   copperSkinSolid = new G4SubtractionSolid(name + "_copper_skin_solid",// name
00546                                            cuOuterSolid,               // this
00547                                            cuInnerSolid);              // minus this
00548   
00549   //beampipe cylindrical solid (circular cross-section)
00550   //beampipe inner edge for subtraction (actually just like vacuum + lengthSafety)
00551   G4VSolid* screenInnerCylSolid = new G4CutTubs(name + "_screen_inner_cylinder", // name
00552                                                 0,                               // inner radius
00553                                                 bsInnerRadius,                   // outer radius
00554                                                 1.5*length, // length big for unambiguous subtraction (but < outerlength)
00555                                                 0,                               // rotation start angle
00556                                                 CLHEP::twopi,                    // rotation finish angle
00557                                                 inputface,                       // input face normal
00558                                                 outputface);                     // output face normal
00559   //screen inner edge box solid (rectangular cross-section)
00560   G4VSolid* screenInnerRectSolid = new G4Box(name + "_screen_inner_box", // name
00561                                              bsInnerBoxX,                // x half width
00562                                              bsInnerBoxY,                // y half width
00563                                              1.7*length); // z long for unambiguous intersection
00564   //screen inner intersection - 1.5*length long which is > half length for unambiguous subtraction later
00565   G4VSolid* screenInnerSolid = new G4IntersectionSolid(name + "_screen_inner_solid", // name
00566                                                        screenInnerCylSolid,          // solid 1
00567                                                        screenInnerRectSolid);        // solid 2
00568 
00569   //screen outer edge for subtraction (actually just like vacuum + lengthSafety)x
00570   G4VSolid* screenOuterCylSolid = new G4CutTubs(name + "_screen_outer_cylinder",// name
00571                                                 0,       // inner radius (0 for unambiguous subtraction)
00572                                                 bsOuterRadius,                  // outer radius
00573                                                 halfLength,                     // half length
00574                                                 0,                              // rotation start angle
00575                                                 CLHEP::twopi,                   // rotation finish angle
00576                                                 inputface,                      // input face normal
00577                                                 outputface);                    // output face normal
00578   //screen outer edge box solid (rectangular cross-section)
00579   G4VSolid* screenOuterRectSolid = new G4Box(name + "_screen_outer_box", // name
00580                                              bsOuterBoxX,                // x half width
00581                                              bsOuterBoxY,                // y half width
00582                                              length); // z full width (long for unambiguous intersection)
00583   G4VSolid* screenOuterSolid = new G4IntersectionSolid(name + "_pipe_outer_solid", // name
00584                                                        screenOuterCylSolid,        // solid 1
00585                                                        screenOuterRectSolid);      // solid 2
00586   
00587 
00588   screenSolid = new G4SubtractionSolid(name + "_screen_solid",// name
00589                                        screenOuterSolid,      // this
00590                                        screenInnerSolid);     // minus this
00591   
00592   coolingPipeSolid = new G4CutTubs(name + "_cooling_pipe_solid",             // name
00593                                    coolingPipeRadius,                        // inner radius
00594                                    coolingPipeRadius + coolingPipeThickness, // outer radius
00595                                    halfLength,                               // half length
00596                                    0,                                        // rotation start angle
00597                                    CLHEP::twopi,                             // rotation finish angle
00598                                    inputface,                                // input face normal
00599                                    outputface);                              // output face normal
00600   
00601   // beampipe - ("coldbore") circular cross-section and sits outisde screen and cooling pipe
00602   beamPipeSolid = new G4CutTubs(name + "_beampipe_solid", // name
00603                                 cbInnerRadius,            // inner radius
00604                                 cbOuterRadius,            // outer radius
00605                                 halfLength,               // half length
00606                                 0,                        // rotation start angle
00607                                 CLHEP::twopi,             // rotation finish angle
00608                                 inputface,                // input face normal
00609                                 outputface);              // output face normal
00610 
00611   //container cylindrical solid (circular cross-section)
00612   containerSolid = new G4CutTubs(name + "_container_cylinder", // name
00613                                  0,                            // inner radius
00614                                  containerRadius,              // outer radius
00615                                  length*0.5,                   // half length
00616                                  0,                            // rotation start angle
00617                                  CLHEP::twopi,                 // rotation finish angle
00618                                  inputface,                    // input face normal
00619                                  outputface);                  // output face normal
00620 
00621   //container cylindrical solid (circular cross-section)
00622   containerSubtractionSolid = new G4Tubs(name + "_subtraction_cylinder", // name
00623                                          0,                              // inner radius
00624                                          containerRadius + lengthSafety, // outer radius
00625                                          2*length,                       // long length for unambiguous subtraction
00626                                          0,                              // rotation start angle
00627                                          CLHEP::twopi);                  // rotation finish angle
00628 
00629   // return the container radius as everything is calculated in this function
00630   return containerRadius;
00631 }

Generated on 28 Jun 2015 for BDSIM by  doxygen 1.4.7