00001
00007
00008
00009
00010 #include "BDSGlobalConstants.hh"
00011
00012 #include "BDSTMultipole.hh"
00013 #include "G4Box.hh"
00014 #include "G4Tubs.hh"
00015 #include "G4VisAttributes.hh"
00016 #include "G4LogicalVolume.hh"
00017 #include "G4VPhysicalVolume.hh"
00018 #include "G4UserLimits.hh"
00019 #include "G4TransportationManager.hh"
00020
00021 #include <map>
00022
00023 const int DEBUG = 0;
00024
00025
00026
00027 typedef std::map<G4String,int> LogVolCountMap;
00028 extern LogVolCountMap* LogVolCount;
00029
00030 typedef std::map<G4String,G4LogicalVolume*> LogVolMap;
00031 extern LogVolMap* LogVol;
00032
00033 extern BDSMaterials* theMaterials;
00034
00035
00036 BDSTMultipole::BDSTMultipole(G4String aName,G4double aLength,
00037 G4double bpRad,G4double FeRad,G4double outR,
00038 list<G4double> knl, list<G4double> ksl,
00039 G4String aMaterial):
00040 BDSMultipole(aName,aLength, bpRad, FeRad,SetVisAttributes(),aMaterial)
00041 {
00042 SetOuterRadius(outR);
00043 itsType="multipole";
00044
00045 G4cout<<"Building Multipole of order "<<knl.size()<<G4endl;
00046
00047 if(knl.size() != ksl.size()) { G4cerr<<"ERROR : skew and normal multipole coeficiens must be of the same numbers"<<G4endl;}
00048 if(knl.size() < 1 ) { G4cerr<<"ERROR : multipole order must be greater than 0"<<G4endl; }
00049
00050 bnl = knl;
00051 bsl = ksl;
00052
00053 G4cout<<"M: bnl=";
00054 list<double>::iterator kit;
00055 for(kit=bnl.begin();kit!=bnl.end();kit++)
00056 {
00057 G4cout<<(*kit)<<" ";
00058 }
00059 G4cout<<G4endl;
00060
00061 itsOrder = bnl.size();
00062
00063
00064
00065 if (!(*LogVolCount)[itsName])
00066 {
00067
00068
00069
00070 BuildDefaultMarkerLogicalVolume();
00071
00072
00073
00074
00075 BuildBPFieldAndStepper();
00076 BuildBPFieldMgr(itsStepper,itsMagField);
00077 BuildBeampipe(itsLength);
00078
00079
00080
00081
00082 BuildDefaultOuterLogicalVolume(itsLength);
00083
00084
00085
00086
00087 SetMultipleSensitiveVolumes(itsBeampipeLogicalVolume);
00088 SetMultipleSensitiveVolumes(itsOuterLogicalVolume);
00089
00090
00091
00092
00093 itsVisAttributes=SetVisAttributes();
00094 itsVisAttributes->SetForceSolid(true);
00095 itsOuterLogicalVolume->SetVisAttributes(itsVisAttributes);
00096
00097
00098
00099
00100 (*LogVolCount)[itsName]=1;
00101 (*LogVol)[itsName]=itsMarkerLogicalVolume;
00102 }
00103 else
00104 {
00105 (*LogVolCount)[itsName]++;
00106
00107
00108
00109 itsMarkerLogicalVolume=(*LogVol)[itsName];
00110 }
00111 }
00112
00113 G4VisAttributes* BDSTMultipole::SetVisAttributes()
00114 {
00115 itsVisAttributes=new G4VisAttributes(G4Colour(0.1,0.4,0.2));
00116 return itsVisAttributes;
00117 }
00118
00119 void BDSTMultipole::BuildBPFieldAndStepper()
00120 {
00121
00122 itsMagField=new BDSMultipoleMagField(bnl,bsl);
00123 itsEqRhs=new G4Mag_UsualEqRhs(itsMagField);
00124
00125 itsStepper=new BDSRK4Stepper(itsEqRhs);
00126 itsStepper->SetVolLength(itsLength);
00127 }
00128
00129 BDSTMultipole::~BDSTMultipole()
00130 {
00131 delete itsVisAttributes;
00132 delete itsMarkerLogicalVolume;
00133 delete itsOuterLogicalVolume;
00134 delete itsPhysiComp;
00135 delete itsMagField;
00136 delete itsEqRhs;
00137 delete itsStepper;
00138 }