00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "Toroid_Magnet.h"
00020
00021
00022
00023 #include "G4VPhysicalVolume.hh"
00024 #include "G4LogicalVolume.hh"
00025 #include "G4PVPlacement.hh"
00026 #include "G4UnionSolid.hh"
00027 #include "G4Box.hh"
00028 #include "G4Tubs.hh"
00029 #include "G4Material.hh"
00030 #include "G4ThreeVector.hh"
00031 #include "G4RotationMatrix.hh"
00032 #include "G4VisAttributes.hh"
00033 #include "G4Colour.hh"
00034
00035
00036
00037 using namespace std;
00038
00039
00040
00041
00042
00043 Toroid_Magnet::Toroid_Magnet() {}
00044
00045
00046
00047 Toroid_Magnet::~Toroid_Magnet() {}
00048
00049
00050
00051 void Toroid_Magnet::Build( G4VPhysicalVolume * World_phys ) {
00052
00053
00054
00055
00056
00057 G4double Width = 53.34 * cm / 2.0;
00058
00059
00060
00061 G4double Thick = 8.89 * cm / 2.0;
00062
00063
00064
00065 G4double R1 = 25.50 * cm;
00066 G4double R2 = 43.00 * cm;
00067 G4double R3 = 53.19 * cm;
00068 G4double R4 = 53.80 * cm;
00069
00070
00071
00072 G4double R1X = 128.84 * cm;
00073
00074 G4double R3X = 121.55 * cm;
00075 G4double R4X = -3.85 * cm;
00076
00077 G4double R1Z = -63.63 * cm;
00078 G4double R2Z = 193.85 * cm;
00079 G4double R3Z = 149.10 * cm;
00080 G4double R4Z = 49.10 * cm;
00081
00082
00083
00084 G4double Arc = atan( ( R3Z - R4Z ) / ( R3X - R4X ) );
00085
00086
00087
00088 G4cout << "Building the Toroid Magnets.\n" << flush;
00089
00090
00091
00092 G4Box * Str1 = new G4Box( "Str1", ( R2Z - R1Z ) / 2.0, Width, Thick );
00093
00094 G4Box * Str2 = new G4Box( "Str2", ( R2Z - R3Z ) / 2.0, Width, Thick );
00095
00096 G4Box * Str3 = new G4Box( "Str3", ( R4Z - R1Z ) / 2.0, Width, Thick );
00097
00098 G4Tubs * Crv1 = new G4Tubs( "Crv1", R1, R1 + 2.0 * Width, Thick,
00099 90.0 * degree, 180.0 * degree );
00100
00101 G4Tubs * Crv2 = new G4Tubs( "Crv2", R2, R2 + 2.0 * Width, Thick,
00102 -90.0 * degree, 180.0 * degree );
00103
00104 G4Tubs * Crv3 = new G4Tubs( "Crv3", R3, R3 + 2.0 * Width, Thick,
00105 270.0 * degree - Arc, Arc );
00106
00107 G4Tubs * Crv4 = new G4Tubs( "Crv4", R4, R4 + 2.0 * Width, Thick,
00108 90.0 * degree - Arc, Arc );
00109
00110
00111
00112 G4UnionSolid * U1 = new
00113 G4UnionSolid( "U1", Str1, Str2, 0,
00114 G4ThreeVector( ( R3Z - R1Z ) / 2.0,
00115 -2.0 * ( Width + R2 ), 0.0 ) );
00116
00117 G4UnionSolid * U2 = new
00118 G4UnionSolid( "U2", U1, Str3, 0,
00119 G4ThreeVector( ( R4Z - R2Z ) / 2.0,
00120 -2.0 * ( Width + R1 ), 0.0 ) );
00121
00122 G4UnionSolid * U3 = new
00123 G4UnionSolid( "U3", U2, Crv1, 0,
00124 G4ThreeVector( ( R1Z - R2Z ) / 2.0 ,
00125 -( Width + R1 ), 0.0 ) );
00126
00127 G4UnionSolid * U4 = new
00128 G4UnionSolid( "U4", U3, Crv2, 0,
00129 G4ThreeVector( ( R2Z - R1Z ) / 2.0,
00130 -( Width + R2 ), 0.0 ) );
00131
00132 G4UnionSolid * U5 = new
00133 G4UnionSolid( "U5", U4, Crv3, 0,
00134 G4ThreeVector( R3Z - ( R2Z + R1Z ) / 2.0,
00135 R3 - ( Width + 2.0 * R2 ), 0.0 ) );
00136
00137 G4UnionSolid * Toroid_solid = new
00138 G4UnionSolid( "Toroid_solid", U5, Crv4, 0,
00139 G4ThreeVector( R4Z - ( R2Z + R1Z ) / 2.0,
00140 -( Width * 3.0 + 2.0 * R1 + R4 ), 0.0 ) );
00141
00142
00143
00144 G4LogicalVolume * Toroid_log = new
00145 G4LogicalVolume( Toroid_solid, G4Material::GetMaterial( "G4_Cu" ),
00146 "Toroid_log", 0, 0, 0, false );
00147
00148 Toroid_log->SetVisAttributes(
00149 G4VisAttributes( true, G4Color( 0.2, 0.3, 0.4 ) ) );
00150
00151
00152
00153 G4RotationMatrix * Rot[8];
00154 G4double rho = Width + R1 + R1X;
00155
00156 for( int i = 0; i < 8; ++i ) {
00157
00158 Rot[i] = new G4RotationMatrix;
00159
00160 Rot[i]->rotateY( 90.0 * degree );
00161 Rot[i]->rotateX( ( 67.5 - 45.0 * i ) * degree );
00162
00163 G4double phi = ( 22.5 + 45.0 * i ) * degree;
00164
00165
00166
00167 new G4PVPlacement( Rot[i], G4ThreeVector( rho * cos( phi ),
00168 rho * sin( phi ),
00169 ( R1Z + R2Z ) / 2.0 ),
00170 "Toroid_phys", Toroid_log, World_phys,
00171 false, i, true );
00172 }
00173
00174 G4cout << " done.\n" << G4endl << flush;
00175
00176
00177
00178 return;
00179
00180 }