Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 // G4ParameterisationBox[X/Y/Z] implementation 27 // 28 // 26.05.03 - P.Arce, Initial version 29 // 08.04.04 - I.Hrivnacova, Implemented reflec 30 // 21.04.10 - M.Asai, Added gaps 31 // ------------------------------------------- 32 33 #include "G4ParameterisationBox.hh" 34 35 #include <iomanip> 36 #include "G4ThreeVector.hh" 37 #include "G4Transform3D.hh" 38 #include "G4RotationMatrix.hh" 39 #include "G4VPhysicalVolume.hh" 40 #include "G4ReflectedSolid.hh" 41 #include "G4Box.hh" 42 43 //-------------------------------------------- 44 G4VParameterisationBox:: 45 G4VParameterisationBox( EAxis axis, G4int nDiv 46 G4double offset, G4VSo 47 DivisionType divType ) 48 : G4VDivisionParameterisation( axis, nDiv, 49 { 50 auto msol = (G4Box*)(msolid); 51 if (msolid->GetEntityType() == "G4ReflectedS 52 { 53 // Get constituent solid 54 G4VSolid* mConstituentSolid 55 = ((G4ReflectedSolid*)msolid)->GetConst 56 msol = (G4Box*)(mConstituentSolid); 57 fmotherSolid = msol; 58 fReflectedSolid = true; 59 } 60 } 61 62 //-------------------------------------------- 63 G4VParameterisationBox::~G4VParameterisationBo 64 65 //-------------------------------------------- 66 G4ParameterisationBoxX:: 67 G4ParameterisationBoxX( EAxis axis, G4int nDiv 68 G4double offset, G4VSo 69 DivisionType divType ) 70 : G4VParameterisationBox( axis, nDiv, width 71 { 72 CheckParametersValidity(); 73 SetType( "DivisionBoxX" ); 74 75 auto mbox = (G4Box*)(fmotherSolid); 76 if( divType == DivWIDTH ) 77 { 78 fnDiv = CalculateNDiv( 2*mbox->GetXHalfLen 79 } 80 else if( divType == DivNDIV ) 81 { 82 fwidth = CalculateWidth( 2*mbox->GetXHalfL 83 } 84 #ifdef G4DIVDEBUG 85 if( verbose >= 1 ) 86 { 87 G4cout << " G4ParameterisationBoxX - no di 88 << fnDiv << " = " << nDiv << G4endl 89 << " Offset " << foffset << " = " < 90 << " Width " << fwidth << " = " << 91 } 92 #endif 93 } 94 95 //-------------------------------------------- 96 G4ParameterisationBoxX::~G4ParameterisationBox 97 98 //-------------------------------------------- 99 G4double G4ParameterisationBoxX::GetMaxParamet 100 { 101 auto msol = (G4Box*)(fmotherSolid); 102 return 2*msol->GetXHalfLength(); 103 } 104 105 //-------------------------------------------- 106 void 107 G4ParameterisationBoxX:: 108 ComputeTransformation( const G4int copyNo, G4V 109 { 110 auto msol = (G4Box*)(fmotherSolid ); 111 G4double mdx = msol->GetXHalfLength( ); 112 113 //----- translation 114 G4ThreeVector origin(0.,0.,0.); 115 G4double posi = -mdx + foffset+(copyNo+0.5)* 116 117 if( faxis == kXAxis ) 118 { 119 origin.setX( posi ); 120 } 121 else 122 { 123 std::ostringstream message; 124 message << "Only axes along X are allowed 125 G4Exception("G4ParameterisationBoxX::Compu 126 "GeomDiv0002", FatalException, 127 } 128 #ifdef G4DIVDEBUG 129 if( verbose >= 2 ) 130 { 131 G4cout << std::setprecision(8) << " G4Para 132 << copyNo << G4endl 133 << " Position " << origin << " Axis 134 } 135 #endif 136 //----- set translation 137 physVol->SetTranslation( origin ); 138 } 139 140 //-------------------------------------------- 141 void 142 G4ParameterisationBoxX:: 143 ComputeDimensions( G4Box& box, const G4int, 144 const G4VPhysicalVolume* ) 145 { 146 auto msol = (G4Box*)(fmotherSolid); 147 148 G4double pDx = fwidth/2. - fhgap; 149 G4double pDy = msol->GetYHalfLength(); 150 G4double pDz = msol->GetZHalfLength(); 151 152 box.SetXHalfLength( pDx ); 153 box.SetYHalfLength( pDy ); 154 box.SetZHalfLength( pDz ); 155 156 #ifdef G4DIVDEBUG 157 if( verbose >= 2 ) 158 { 159 G4cout << " G4ParameterisationBoxX::Comput 160 << " pDx: " << pDz << G4endl; 161 box.DumpInfo(); 162 } 163 #endif 164 } 165 166 //-------------------------------------------- 167 G4ParameterisationBoxY:: 168 G4ParameterisationBoxY( EAxis axis, G4int nDiv 169 G4double offset, G4VSo 170 DivisionType divType) 171 : G4VParameterisationBox( axis, nDiv, width 172 { 173 CheckParametersValidity(); 174 SetType( "DivisionBoxY" ); 175 176 auto mbox = (G4Box*)(fmotherSolid); 177 if( divType == DivWIDTH ) 178 { 179 fnDiv = CalculateNDiv( 2*mbox->GetYHalfLen 180 } 181 else if( divType == DivNDIV ) 182 { 183 fwidth = CalculateWidth( 2*mbox->GetYHalfL 184 } 185 186 #ifdef G4DIVDEBUG 187 if( verbose >= 1 ) 188 { 189 G4cout << " G4ParameterisationBoxY - no di 190 << nDiv << ". Offset " << foffset < 191 << ". Width " << fwidth << " = " << 192 } 193 #endif 194 } 195 196 //-------------------------------------------- 197 G4ParameterisationBoxY::~G4ParameterisationBox 198 199 //-------------------------------------------- 200 G4double G4ParameterisationBoxY::GetMaxParamet 201 { 202 auto msol = (G4Box*)(fmotherSolid); 203 return 2*msol->GetYHalfLength(); 204 } 205 206 //-------------------------------------------- 207 void 208 G4ParameterisationBoxY:: 209 ComputeTransformation( const G4int copyNo, G4V 210 { 211 auto msol = (G4Box*)(fmotherSolid); 212 G4double mdy = msol->GetYHalfLength(); 213 214 //----- translation 215 G4ThreeVector origin(0.,0.,0.); 216 G4double posi = -mdy + foffset + (copyNo+0.5 217 if( faxis == kYAxis ) 218 { 219 origin.setY( posi ); 220 } 221 else 222 { 223 std::ostringstream message; 224 message << "Only axes along Y are allowed 225 G4Exception("G4ParameterisationBoxY::Compu 226 "GeomDiv0002", FatalException, 227 } 228 #ifdef G4DIVDEBUG 229 if( verbose >= 2 ) 230 { 231 G4cout << std::setprecision(8) << " G4Para 232 << copyNo << G4endl 233 << " Position " << origin << " Axis 234 } 235 #endif 236 //----- set translation 237 physVol->SetTranslation( origin ); 238 } 239 240 //-------------------------------------------- 241 void 242 G4ParameterisationBoxY:: 243 ComputeDimensions( G4Box& box, const G4int, 244 const G4VPhysicalVolume* ) 245 { 246 auto msol = (G4Box*)(fmotherSolid); 247 248 G4double pDx = msol->GetXHalfLength(); 249 G4double pDy = fwidth/2. - fhgap; 250 G4double pDz = msol->GetZHalfLength(); 251 252 box.SetXHalfLength( pDx ); 253 box.SetYHalfLength( pDy ); 254 box.SetZHalfLength( pDz ); 255 256 #ifdef G4DIVDEBUG 257 if( verbose >= 2 ) 258 { 259 G4cout << " G4ParameterisationBoxY::Comput 260 << " pDx: " << pDz << G4endl; 261 box.DumpInfo(); 262 } 263 #endif 264 } 265 266 //-------------------------------------------- 267 G4ParameterisationBoxZ:: 268 G4ParameterisationBoxZ( EAxis axis, G4int nDiv 269 G4double offset, G4VSo 270 DivisionType divType ) 271 : G4VParameterisationBox( axis, nDiv, width 272 { 273 CheckParametersValidity(); 274 SetType( "DivisionBoxZ" ); 275 276 auto mbox = (G4Box*)(fmotherSolid); 277 if( divType == DivWIDTH ) 278 { 279 fnDiv = CalculateNDiv( 2*mbox->GetZHalfLen 280 } 281 else if ( divType == DivNDIV ) 282 { 283 fwidth = CalculateWidth( 2*mbox->GetZHalfL 284 } 285 #ifdef G4DIVDEBUG 286 if( verbose >= 1 ) 287 { 288 G4cout << " G4ParameterisationBoxZ - no di 289 << nDiv << ". Offset " << foffset < 290 << ". Width " << fwidth << " = " << 291 } 292 #endif 293 } 294 295 //-------------------------------------------- 296 G4ParameterisationBoxZ::~G4ParameterisationBox 297 298 //-------------------------------------------- 299 G4double G4ParameterisationBoxZ::GetMaxParamet 300 { 301 auto msol = (G4Box*)(fmotherSolid); 302 return 2*msol->GetZHalfLength(); 303 } 304 305 //-------------------------------------------- 306 void 307 G4ParameterisationBoxZ:: 308 ComputeTransformation( const G4int copyNo, G4V 309 { 310 auto msol = (G4Box*)(fmotherSolid ); 311 G4double mdz = msol->GetZHalfLength(); 312 313 //----- translation 314 G4ThreeVector origin(0.,0.,0.); 315 G4double posi = -mdz + OffsetZ() + (copyNo+0 316 317 if( faxis == kZAxis ) 318 { 319 origin.setZ( posi ); 320 } 321 else 322 { 323 std::ostringstream message; 324 message << "Only axes along Z are allowed 325 G4Exception("G4ParameterisationBoxZ::Compu 326 "GeomDiv0002", FatalException, 327 } 328 #ifdef G4DIVDEBUG 329 if( verbose >= 2 ) 330 { 331 G4cout << std::setprecision(8) << " G4Para 332 << copyNo << G4endl 333 << " Position " << origin << " Axis 334 } 335 #endif 336 //----- set translation 337 physVol->SetTranslation( origin ); 338 } 339 340 //-------------------------------------------- 341 void 342 G4ParameterisationBoxZ:: 343 ComputeDimensions( G4Box& box, const G4int, 344 const G4VPhysicalVolume* ) 345 { 346 auto msol = (G4Box*)(fmotherSolid); 347 348 G4double pDx = msol->GetXHalfLength(); 349 G4double pDy = msol->GetYHalfLength(); 350 G4double pDz = fwidth/2. - fhgap; 351 352 box.SetXHalfLength( pDx ); 353 box.SetYHalfLength( pDy ); 354 box.SetZHalfLength( pDz ); 355 356 #ifdef G4DIVDEBUG 357 if( verbose >= 2 ) 358 { 359 G4cout << " G4ParameterisationBoxZ::Comput 360 << " pDx: " << pDz << G4endl; 361 box.DumpInfo(); 362 } 363 #endif 364 } 365