00001 #include "BDSGlobalConstants.hh"
00002 #include "BDSDebug.hh"
00003
00004 #include "BDSSectorBend.hh"
00005
00006 #include "BDSBeamPipeFactory.hh"
00007 #include "BDSDipoleStepper.hh"
00008 #include "BDSMagnet.hh"
00009 #include "BDSMagnetOuterInfo.hh"
00010 #include "BDSMagnetType.hh"
00011 #include "BDSMaterials.hh"
00012 #include "BDSSbendMagField.hh"
00013 #include "BDSUtilities.hh"
00014
00015 #include "G4CutTubs.hh"
00016 #include "G4VisAttributes.hh"
00017 #include "G4LogicalVolume.hh"
00018 #include "G4Mag_UsualEqRhs.hh"
00019 #include "G4UserLimits.hh"
00020 #include "G4VPhysicalVolume.hh"
00021
00022 #include "globals.hh"
00023
00024 class BDSTiltOffset;
00025
00026 BDSSectorBend::BDSSectorBend(G4String name,
00027 G4double length,
00028 G4double angleIn,
00029 G4double bField,
00030 G4double bGrad,
00031 BDSBeamPipeInfo* beamPipeInfo,
00032 BDSMagnetOuterInfo magnetOuterInfo,
00033 BDSTiltOffset tiltOffset):
00034 BDSMagnet(BDSMagnetType::sectorbend, name, length,
00035 beamPipeInfo, magnetOuterInfo, tiltOffset),
00036 itsBField(bField),itsBGrad(bGrad)
00037 {
00038 angle = angleIn;
00039
00040
00041 orientation = BDS::CalculateOrientation(angleIn);
00042 G4double in_z = cos(0.5*fabs(angleIn));
00043 G4double in_x = sin(0.5*fabs(angleIn));
00044 inputface = G4ThreeVector(-orientation*in_x, 0.0, -1.0*in_z);
00045
00046 outputface = G4ThreeVector(-orientation*in_x, 0.0, in_z);
00047 }
00048
00049 void BDSSectorBend::Build()
00050 {
00051 #ifdef BDSDEBUG
00052 G4cout << __METHOD_NAME__ << G4endl;
00053 #endif
00054 BDSMagnet::Build();
00055
00056 if(BDSGlobalConstants::Instance()->GetIncludeIronMagFields())
00057 {
00058 G4double polePos[4];
00059 G4double Bfield[3];
00060
00061
00062 polePos[0]=0.;
00063 polePos[1]=BDSGlobalConstants::Instance()->GetMagnetPoleRadius();
00064 polePos[2]=0.;
00065 polePos[3]=-999.;
00066
00067 itsMagField->GetFieldValue(polePos,Bfield);
00068 G4double BFldIron=
00069 sqrt(Bfield[0]*Bfield[0]+Bfield[1]*Bfield[1])*
00070 BDSGlobalConstants::Instance()->GetMagnetPoleSize()/
00071 (BDSGlobalConstants::Instance()->GetComponentBoxSize()/2-
00072 BDSGlobalConstants::Instance()->GetMagnetPoleRadius());
00073
00074
00075 BFldIron/=2.;
00076
00077 BuildOuterFieldManager(2, BFldIron,CLHEP::halfpi);
00078 }
00079 }
00080
00081 void BDSSectorBend::BuildBPFieldAndStepper()
00082 {
00083
00084 G4ThreeVector Bfield(0.,-itsBField,0.);
00085
00086 itsMagField = new BDSSbendMagField(Bfield,arcLength,angle);
00087 itsEqRhs = new G4Mag_UsualEqRhs(itsMagField);
00088 BDSDipoleStepper* dipoleStepper = new BDSDipoleStepper(itsEqRhs);
00089
00090 dipoleStepper->SetBField(-itsBField);
00091 dipoleStepper->SetBGrad(itsBGrad);
00092 itsStepper = dipoleStepper;
00093 }
00094 void BDSSectorBend::BuildBeampipe()
00095 {
00096 #ifdef BDSDEBUG
00097 G4cout << __METHOD_NAME__ << "sector bend version " << G4endl;
00098 #endif
00099
00100 beampipe =
00101 BDSBeamPipeFactory::Instance()->CreateBeamPipeAngledInOut(beamPipeInfo->beamPipeType,
00102 name,
00103 chordLength,
00104 -angle*0.5,
00105 -angle*0.5,
00106 beamPipeInfo->aper1,
00107 beamPipeInfo->aper2,
00108 beamPipeInfo->aper3,
00109 beamPipeInfo->aper4,
00110 beamPipeInfo->vacuumMaterial,
00111 beamPipeInfo->beamPipeThickness,
00112 beamPipeInfo->beamPipeMaterial);
00113
00114 BeamPipeCommonTasks();
00115 }