00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "BDSGlobalConstants.hh"
00010
00011 #include "BDSSkewSextupole.hh"
00012 #include "G4Box.hh"
00013 #include "G4Tubs.hh"
00014 #include "G4VisAttributes.hh"
00015 #include "G4LogicalVolume.hh"
00016 #include "G4VPhysicalVolume.hh"
00017 #include "G4UserLimits.hh"
00018 #include "G4TransportationManager.hh"
00019
00020 #include <map>
00021
00022
00023
00024 typedef std::map<G4String,int> LogVolCountMap;
00025 extern LogVolCountMap* LogVolCount;
00026
00027 typedef std::map<G4String,G4LogicalVolume*> LogVolMap;
00028 extern LogVolMap* LogVol;
00029
00030 extern BDSMaterials* theMaterials;
00031
00032
00033 BDSSkewSextupole::BDSSkewSextupole(G4String& aName,G4double aLength,
00034 G4double bpRad,G4double FeRad,
00035 G4double BDblPrime):
00036 BDSMultipole(aName,aLength, bpRad, FeRad,SetVisAttributes()),
00037 itsBDblPrime(BDblPrime)
00038 {
00039 if (!(*LogVolCount)[itsName])
00040 {
00041 BuildBPFieldAndStepper();
00042 BuildBPFieldMgr(itsStepper,itsMagField);
00043 BuildDefaultMarkerLogicalVolume();
00044
00045 BuildBeampipe(itsLength);
00046
00047 BuildDefaultOuterLogicalVolume(itsLength);
00048
00049 SetSensitiveVolume(itsBeampipeLogicalVolume);
00050
00051
00052 if(BDSGlobals->GetIncludeIronMagFields())
00053 {
00054 G4double polePos[4];
00055 G4double Bfield[3];
00056
00057 polePos[0]=-BDSGlobals->GetMagnetPoleRadius()*sin(pi/6);
00058 polePos[1]=BDSGlobals->GetMagnetPoleRadius()*cos(pi/6);
00059 polePos[2]=0.;
00060 polePos[3]=-999.;
00061
00062
00063 itsMagField->GetFieldValue(polePos,Bfield);
00064 G4double BFldIron=
00065 sqrt(Bfield[0]*Bfield[0]+Bfield[1]*Bfield[1])*
00066 BDSGlobals->GetMagnetPoleSize()/
00067 (BDSGlobals->GetComponentBoxSize()/2-
00068 BDSGlobals->GetMagnetPoleRadius());
00069
00070 BFldIron/=2.;
00071
00072 BuildOuterFieldManager(6, BFldIron,pi/6);
00073 }
00074
00075
00076 (*LogVolCount)[itsName]=1;
00077 (*LogVol)[itsName]=itsMarkerLogicalVolume;
00078 }
00079 else
00080 {
00081 (*LogVolCount)[itsName]++;
00082 if(BDSGlobals->GetSynchRadOn()&& BDSGlobals->GetSynchRescale())
00083 {
00084
00085
00086
00087 itsName+=BDSGlobals->StringFromInt((*LogVolCount)[itsName]);
00088 BuildBPFieldAndStepper();
00089 BuildBPFieldMgr(itsStepper,itsMagField);
00090 BuildDefaultMarkerLogicalVolume();
00091
00092 BuildBeampipe(itsLength);
00093 BuildDefaultOuterLogicalVolume(itsLength);
00094
00095 SetSensitiveVolume(itsBeampipeLogicalVolume);
00096
00097 (*LogVol)[itsName]=itsMarkerLogicalVolume;
00098 }
00099 else
00100 {
00101 itsMarkerLogicalVolume=(*LogVol)[itsName];
00102 }
00103 }
00104
00105 }
00106
00107
00108 G4VisAttributes* BDSSkewSextupole::SetVisAttributes()
00109 {
00110 itsVisAttributes=new G4VisAttributes(G4Colour(1,1,0));
00111 return itsVisAttributes;
00112 }
00113
00114
00115 void BDSSkewSextupole::BuildBPFieldAndStepper()
00116 {
00117
00118 itsMagField=new BDSSkewSextMagField(itsBDblPrime);
00119 itsEqRhs=new G4Mag_UsualEqRhs(itsMagField);
00120
00121 itsStepper=new BDSSkewSextStepper(itsEqRhs);
00122 itsStepper->SetBDblPrime(itsBDblPrime);
00123
00124 }
00125
00126 BDSSkewSextupole::~BDSSkewSextupole()
00127 {
00128 delete itsVisAttributes;
00129 delete itsMarkerLogicalVolume;
00130 delete itsOuterLogicalVolume;
00131 delete itsPhysiComp;
00132 delete itsMagField;
00133 delete itsEqRhs;
00134 delete itsStepper;
00135 }