00001 #include "BDSGlobalConstants.hh"
00002
00003 #include "BDSBeamPipeInfo.hh"
00004 #include "BDSRfCavity.hh"
00005 #include "G4Tubs.hh"
00006 #include "G4VisAttributes.hh"
00007 #include "G4LogicalVolume.hh"
00008 #include "G4VPhysicalVolume.hh"
00009 #include "G4UserLimits.hh"
00010
00011 #include "G4MagIntegratorDriver.hh"
00012
00013 #include "G4ExplicitEuler.hh"
00014
00015 class BDSTiltOffset;
00016
00017 BDSRfCavity::BDSRfCavity(G4String name,
00018 G4double length,
00019 G4double grad,
00020 BDSBeamPipeInfo* beamPipeInfo,
00021 BDSMagnetOuterInfo magnetOuterInfo,
00022 BDSTiltOffset tiltOffset):
00023 BDSMagnet(BDSMagnetType::rfcavity, name, length,
00024 beamPipeInfo, magnetOuterInfo, tiltOffset),
00025 itsGrad(grad)
00026 {
00027 itsEField = NULL;
00028 fChordFinder = NULL;
00029 fStepper = NULL;
00030 fIntgrDriver = NULL;
00031 }
00032
00033 void BDSRfCavity::BuildBPFieldAndStepper()
00034 {
00035 G4int nvar = 8;
00036
00037
00038 G4ThreeVector Efield(0.,0.,itsGrad * CLHEP::megavolt / CLHEP::m);
00039 itsEField=new G4UniformElectricField(Efield);
00040
00041 G4EqMagElectricField* fEquation = new G4EqMagElectricField(itsEField);
00042
00043 itsBPFieldMgr = new G4FieldManager();
00044
00045 fStepper = new G4ExplicitEuler( fEquation, nvar );
00046
00047
00048 G4double fMinStep = BDSGlobalConstants::Instance()->GetChordStepMinimum();
00049
00050
00051 itsBPFieldMgr->SetDetectorField(itsEField );
00052
00053 delete fChordFinder;
00054
00055 fIntgrDriver = new G4MagInt_Driver(fMinStep,
00056 fStepper,
00057 fStepper->GetNumberOfVariables() );
00058
00059 fChordFinder = new G4ChordFinder(fIntgrDriver);
00060
00061 fChordFinder->SetDeltaChord(BDSGlobalConstants::Instance()->GetDeltaChord());
00062 itsBPFieldMgr->SetChordFinder( fChordFinder );
00063 }
00064