00001 #include "BDSGlobalConstants.hh"
00002 #include "G4UnionSolid.hh"
00003 #include "G4SubtractionSolid.hh"
00004 #include "G4EllipticalTube.hh"
00005 #include "G4Box.hh"
00006 #include "G4RotationMatrix.hh"
00007 #include "G4ThreeVector.hh"
00008 #include "G4String.hh"
00009
00010 #include "BDSPCLTube.hh"
00011
00012
00013 BDSPCLTube::BDSPCLTube(G4double sizeX, G4double sizeYUp, G4double sizeYDown, G4double sizeDy, G4double thickness, G4double length, G4String name){
00014 itsSizeX=sizeX;
00015 itsSizeYUp=sizeYUp;
00016 itsSizeYDown=sizeYDown;
00017 itsSizeDy=sizeDy;
00018 itsThickness=thickness;
00019 itsLength=length;
00020 itsName=name;
00021
00022 if (itsThickness<=0){
00023 Build();
00024 } else {
00025 BuildHollow();
00026 }
00027 }
00028
00029 void BDSPCLTube::BuildHollow(){
00030 #ifdef DEBUG
00031 G4cout << "BDSPCLTube itsSizeX: " << itsSizeX/m << " m" << G4endl;
00032 G4cout << "BDSPCLTube itsSizeYUp: " << itsSizeYUp/m << " m" << G4endl;
00033 G4cout << "BDSPCLTube itsSizeYDown: " << itsSizeYDown/m << " m" << G4endl;
00034 G4cout << "BDSPCLTube Dy: " << itsSizeDy/m << " m" << G4endl;
00035 #endif
00036
00037 G4RotationMatrix* nullrot = new G4RotationMatrix();
00038 G4ThreeVector threeVector1;
00039
00040 threeVector1.setX(0);
00041 threeVector1.setZ(0);
00042
00043
00044 threeVector1.setY(0);
00045 G4VSolid* tmp_solid_1 =new G4SubtractionSolid("tmp_solid_1",
00046 new G4EllipticalTube(itsName+"_tmp_solid_1_a",
00047 itsSizeX+itsThickness,
00048 itsSizeYUp+itsThickness,
00049 itsLength/2.0),
00050 new G4EllipticalTube(itsName+"_tmp_solid_1_b",
00051 itsSizeX,
00052 itsSizeYUp,
00053 itsLength),
00054 nullrot,
00055 threeVector1);
00056
00057
00058 threeVector1.setY(-1*(itsSizeYUp*2));
00059
00060 upper_solid = new G4SubtractionSolid("upper_solid",
00061 tmp_solid_1,
00062 new G4Box(itsName+"_upper_solid_a",
00063 itsSizeX*2.0,
00064 itsSizeYUp*2.0,
00065 itsLength),
00066 nullrot,
00067 threeVector1);
00068
00069 threeVector1.setY(0);
00070
00071 middle_solid =new G4SubtractionSolid(itsName+"middle_solid",
00072 new G4Box(itsName+"_middle_solid_a",
00073 itsSizeX+itsThickness,
00074 itsSizeDy/2.0+1*um,
00075 itsLength/2.0),
00076 new G4Box(itsName+"_middle_solid_b",
00077 itsSizeX,
00078 itsSizeDy*2.0,
00079 itsLength),
00080 nullrot,
00081 threeVector1);
00082
00083 threeVector1.setY(0);
00084 G4VSolid* tmp_solid_2 =new G4SubtractionSolid("tmp_solid_2",
00085 new G4EllipticalTube(itsName+"_tmp_solid_2_a",
00086 itsSizeX+itsThickness,
00087 itsSizeYDown+itsThickness,
00088 itsLength/2),
00089 new G4EllipticalTube(itsName+"_tmp_solid_2_b",
00090 itsSizeX,
00091 itsSizeYDown,
00092 itsLength),
00093 nullrot,
00094 threeVector1);
00095
00096 threeVector1.setY(itsSizeYDown*2);
00097 lower_solid =new G4SubtractionSolid("lower_solid",
00098 tmp_solid_2,
00099 new G4Box(itsName+"_lower_solid_a",
00100 itsSizeX*2.0,
00101 itsSizeYDown*2.0,
00102 itsLength),
00103 nullrot,
00104 threeVector1);
00105
00106
00107 threeVector1.setY(-itsSizeDy/2.0);
00108 temp_solid = new G4UnionSolid("temp_solid",
00109 upper_solid,
00110 middle_solid,
00111 nullrot,
00112 threeVector1
00113 );
00114
00115 threeVector1.setY(-itsSizeDy);
00116 solid = new G4UnionSolid("temp_solid",
00117 temp_solid,
00118 lower_solid,
00119 nullrot,
00120 threeVector1
00121 );
00122
00123 }
00124
00125 void BDSPCLTube::Build(){
00126
00127 #ifdef DEBUG
00128 G4cout << "BDSPCLTube itsSizeX: " << itsSizeX/m << " m" << G4endl;
00129 G4cout << "BDSPCLTube itsSizeYUp: " << itsSizeYUp/m << " m" << G4endl;
00130 G4cout << "BDSPCLTube itsSizeYDown: " << itsSizeYDown/m << " m" << G4endl;
00131 G4cout << "BDSPCLTube Dy: " << itsSizeDy/m << " m" << G4endl;
00132 #endif
00133
00134 G4RotationMatrix* nullrot = new G4RotationMatrix();
00135 G4ThreeVector threeVector1;
00136
00137 threeVector1.setX(0);
00138 threeVector1.setZ(0);
00139
00140
00141 threeVector1.setY(0);
00142 G4VSolid* tmp_solid_1 =new G4EllipticalTube("tmp_solid_1",
00143 itsSizeX,
00144 itsSizeYUp,
00145 itsLength/2);
00146 threeVector1.setY(-1*(itsSizeYUp*2));
00147
00148 upper_solid = new G4SubtractionSolid("upper_solid",
00149 tmp_solid_1,
00150 new G4Box(itsName+"_upper_solid_a",
00151 itsSizeX*2.0,
00152 itsSizeYUp*2.0,
00153 itsLength),
00154 nullrot,
00155 threeVector1);
00156
00157 threeVector1.setY(0);
00158
00159 middle_solid =new G4Box(itsName+"_middle_solid",
00160 itsSizeX,
00161 itsSizeDy/2.0+1*um,
00162 itsLength/2.0);
00163
00164 threeVector1.setY(0);
00165
00166 G4VSolid* tmp_solid_2 =new G4EllipticalTube(itsName+"_tmp_solid_2",
00167 itsSizeX,
00168 itsSizeYDown,
00169 itsLength/2);
00170
00171 threeVector1.setY(itsSizeYDown*2);
00172 lower_solid =new G4SubtractionSolid("lower_solid",
00173 tmp_solid_2,
00174 new G4Box(+"_lower_solid_a",
00175 itsSizeX*2.0,
00176 itsSizeYDown*2.0,
00177 itsLength),
00178 nullrot,
00179 threeVector1);
00180
00181
00182 threeVector1.setY(-itsSizeDy/2.0);
00183 temp_solid = new G4UnionSolid("temp_solid",
00184 upper_solid,
00185 middle_solid,
00186 nullrot,
00187 threeVector1
00188 );
00189
00190 threeVector1.setY(-itsSizeDy);
00191 solid = new G4UnionSolid("temp_solid",
00192 temp_solid,
00193 lower_solid,
00194 nullrot,
00195 threeVector1
00196 );
00197
00198 }
00199
00200 G4VSolid* BDSPCLTube::GetSolid(){
00201 #ifdef DEBUG
00202 G4cout << "Returning solid..." << G4endl;
00203 #endif
00204 return solid;
00205 }
00206
00207 BDSPCLTube::~BDSPCLTube()
00208 {
00209 }