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

00001 //  
00002 //   BDSIM, (C) 2001-2006 
00003 //   
00004 //   version 0.3
00005 //  
00006 //
00007 //
00008 //   Quadrupole class
00009 //
00010 //   History
00011 //
00012 //     21 Nov 2006 by Agapov,  v.0.3
00013 //     22 Mar 2005 by Agapov, Carter,  v.0.2
00014 //     x  x   2002 by Blair
00015 //
00016 //
00017 
00018 #include "BDSBeamPipeInfo.hh"
00019 #include "BDSDebug.hh"
00020 #include "BDSGlobalConstants.hh" 
00021 #include "BDSMagnetType.hh"
00022 #include "BDSMagnetOuterInfo.hh"
00023 #include "BDSQuadrupole.hh"
00024 #include "BDSQuadMagField.hh"
00025 #include "BDSQuadStepper.hh"
00026 #include "BDSEnergyCounterSD.hh"
00027 
00028 #include "G4FieldManager.hh"
00029 #include "G4LogicalVolume.hh"
00030 #include "G4Tubs.hh"
00031 #include "G4UserLimits.hh"
00032 #include "G4VisAttributes.hh"
00033 #include "G4VPhysicalVolume.hh"
00034 
00035 class BDSTiltOffset;
00036 
00037 BDSQuadrupole::BDSQuadrupole(G4String           name,
00038                              G4double           length,
00039                              G4double           bGrad,
00040                              BDSBeamPipeInfo*   beamPipeInfo,
00041                              BDSMagnetOuterInfo magnetOuterInfo,
00042                              BDSTiltOffset      tiltOffset):
00043   BDSMagnet(BDSMagnetType::quadrupole, name, length,
00044             beamPipeInfo, magnetOuterInfo, tiltOffset),
00045   itsBGrad(bGrad)
00046 {;}
00047 
00048 void BDSQuadrupole::Build() 
00049 {
00050 #ifdef BDSDEBUG
00051   G4cout << __METHOD_NAME__ << G4endl;
00052 #endif
00053   BDSMagnet::Build();
00054   
00055   if(BDSGlobalConstants::Instance()->GetIncludeIronMagFields())
00056     {
00057       G4double polePos[4];
00058       G4double Bfield[3];
00059       
00060       //coordinate in GetFieldValue
00061       polePos[0]=-BDSGlobalConstants::Instance()->GetMagnetPoleRadius()*sin(CLHEP::pi/4);
00062       polePos[1]=BDSGlobalConstants::Instance()->GetMagnetPoleRadius()*cos(CLHEP::pi/4);
00063       polePos[2]=0.;
00064       polePos[3]=-999.;//flag to use polePos rather than local track
00065       
00066       itsMagField->GetFieldValue(polePos,Bfield);
00067       G4double BFldIron=
00068         sqrt(Bfield[0]*Bfield[0]+Bfield[1]*Bfield[1])*
00069         BDSGlobalConstants::Instance()->GetMagnetPoleSize()/
00070         (BDSGlobalConstants::Instance()->GetComponentBoxSize()/2-
00071          BDSGlobalConstants::Instance()->GetMagnetPoleRadius());
00072       
00073       // Magnetic flux from a pole is divided in two directions
00074       BFldIron/=2.;
00075       
00076       BuildOuterFieldManager(4, BFldIron,CLHEP::pi/4);
00077     }
00078 }
00079 
00080 void BDSQuadrupole::BuildBPFieldAndStepper()
00081 {
00082   // set up the magnetic field and stepper
00083   itsMagField = new BDSQuadMagField(1*itsBGrad); //L Deacon checking sign of field 4/7/12
00084   itsEqRhs    = new G4Mag_UsualEqRhs(itsMagField);
00085   BDSQuadStepper* quadStepper = new BDSQuadStepper(itsEqRhs);
00086   quadStepper->SetBGrad(itsBGrad);
00087   itsStepper = quadStepper;
00088 }

Generated on 28 Jun 2015 for BDSIM by  doxygen 1.4.7