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 // G4ParameterisationCons[Rho/Phi/Z] implement 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 "G4ParameterisationCons.hh" 34 35 #include <iomanip> 36 #include "G4ThreeVector.hh" 37 #include "G4RotationMatrix.hh" 38 #include "G4VPhysicalVolume.hh" 39 #include "G4LogicalVolume.hh" 40 #include "G4ReflectedSolid.hh" 41 #include "G4Cons.hh" 42 43 //-------------------------------------------- 44 G4VParameterisationCons:: 45 G4VParameterisationCons( EAxis axis, G4int nDi 46 G4double offset, G4VSo 47 DivisionType divType ) 48 : G4VDivisionParameterisation( axis, nDiv, 49 { 50 auto msol = (G4Cons*)(msolid); 51 if (msolid->GetEntityType() == "G4ReflectedS 52 { 53 // Get constituent solid 54 G4VSolid* mConstituentSolid 55 = ((G4ReflectedSolid*)msolid)->GetConst 56 msol = (G4Cons*)(mConstituentSolid); 57 58 // Create a new solid with inversed parame 59 auto newSolid 60 = new G4Cons(msol->GetName(), 61 msol->GetInnerRadiusPlusZ() 62 msol->GetInnerRadiusMinusZ( 63 msol->GetZHalfLength(), 64 msol->GetStartPhiAngle(), m 65 msol = newSolid; 66 fmotherSolid = newSolid; 67 fReflectedSolid = true; 68 fDeleteSolid = true; 69 } 70 } 71 72 //-------------------------------------------- 73 G4VParameterisationCons::~G4VParameterisationC 74 75 //-------------------------------------------- 76 G4ParameterisationConsRho:: 77 G4ParameterisationConsRho( EAxis axis, G4int n 78 G4double width, G4d 79 G4VSolid* msolid, D 80 : G4VParameterisationCons( axis, nDiv, widt 81 { 82 CheckParametersValidity(); 83 SetType( "DivisionConsRho" ); 84 85 auto msol = (G4Cons*)(fmotherSolid); 86 if( msol->GetInnerRadiusPlusZ() == 0. ) 87 { 88 std::ostringstream message; 89 message << "OuterRadiusMinusZ = 0" << G4en 90 << "Width is calculated as that of 91 G4Exception("G4ParameterisationConsRho::G4 92 "GeomDiv1001", JustWarning, me 93 } 94 95 if( divType == DivWIDTH ) 96 { 97 fnDiv = CalculateNDiv( msol->GetOuterRadiu 98 - msol->GetInnerRadiu 99 } 100 else if( divType == DivNDIV ) 101 { 102 auto mconsol = (G4Cons*)(msolid); 103 fwidth = CalculateWidth( mconsol->GetOuter 104 - mconsol->GetInner 105 } 106 107 #ifdef G4DIVDEBUG 108 if( verbose >= 1 ) 109 { 110 G4cout << " G4ParameterisationConsRho - no 111 << nDiv << G4endl 112 << " Offset " << foffset << " = " < 113 << " - Width " << fwidth << " = " < 114 } 115 #endif 116 } 117 118 //-------------------------------------------- 119 G4ParameterisationConsRho::~G4Parameterisation 120 121 //-------------------------------------------- 122 G4double G4ParameterisationConsRho::GetMaxPara 123 { 124 auto msol = (G4Cons*)(fmotherSolid); 125 return msol->GetOuterRadiusMinusZ() - msol-> 126 } 127 128 //-------------------------------------------- 129 void 130 G4ParameterisationConsRho:: 131 ComputeTransformation( const G4int, G4VPhysica 132 { 133 //----- translation 134 G4ThreeVector origin(0.,0.,0.); 135 //----- set translation 136 physVol->SetTranslation( origin ); 137 138 //----- calculate rotation matrix: unit 139 140 #ifdef G4DIVDEBUG 141 if( verbose >= 2 ) 142 { 143 G4cout << " G4ParameterisationConsRho " < 144 << " Offset: " << foffset 145 << " - Width: " << fwidth << G4endl 146 } 147 #endif 148 149 ChangeRotMatrix( physVol ); 150 151 #ifdef G4DIVDEBUG 152 if( verbose >= 2 ) 153 { 154 G4cout << std::setprecision(8) << " G4Para 155 << " Position: " << origin << " - W 156 << " - Axis: " << faxis << G4endl; 157 } 158 #endif 159 } 160 161 //-------------------------------------------- 162 void 163 G4ParameterisationConsRho:: 164 ComputeDimensions( G4Cons& cons, const G4int c 165 const G4VPhysicalVolume* ) 166 { 167 auto msol = (G4Cons*)(fmotherSolid); 168 169 G4double pRMin1 = msol->GetInnerRadiusMinusZ 170 G4double pRMax1 = msol->GetInnerRadiusMinusZ 171 172 //width at Z Plus 173 //- G4double fwidthPlus = 174 // fwidth * ( msol->GetOuterRadiusPlusZ()/ 175 //- / ( msol->GetOuterRadiusMinusZ() 176 G4double fwidthPlus = CalculateWidth( msol-> 177 - msol->GetInnerRad 178 G4double pRMin2 = msol->GetInnerRadiusPlusZ( 179 + foffset + fwidthPlus * cop 180 G4double pRMax2 = msol->GetInnerRadiusPlusZ( 181 + foffset + fwidthPlus * (co 182 G4double pDz = msol->GetZHalfLength(); 183 184 G4double d_half_gap = fhgap * pRMax2 / pRMax 185 //- already rotated double pSR = foffset + 186 G4double pSPhi = msol->GetStartPhiAngle(); 187 G4double pDPhi = msol->GetDeltaPhiAngle();; 188 189 cons.SetInnerRadiusMinusZ( pRMin1 + fhgap ); 190 cons.SetOuterRadiusMinusZ( pRMax1 - fhgap ); 191 cons.SetInnerRadiusPlusZ( pRMin2 + d_half_ga 192 cons.SetOuterRadiusPlusZ( pRMax2 - d_half_ga 193 cons.SetZHalfLength( pDz ); 194 cons.SetStartPhiAngle( pSPhi, false ); 195 cons.SetDeltaPhiAngle( pDPhi ); 196 197 #ifdef G4DIVDEBUG 198 if( verbose >= 2 ) 199 { 200 G4cout << " G4ParameterisationConsRho::Com 201 << " pRMin: " << pRMin1 << " - pRMa 202 if( verbose >= 4 ) cons.DumpInfo(); 203 } 204 #endif 205 } 206 207 //-------------------------------------------- 208 G4ParameterisationConsPhi:: 209 G4ParameterisationConsPhi( EAxis axis, G4int n 210 G4double width, G4d 211 G4VSolid* msolid, D 212 : G4VParameterisationCons( axis, nDiv, widt 213 { 214 CheckParametersValidity(); 215 SetType( "DivisionConsPhi" ); 216 217 auto msol = (G4Cons*)(fmotherSolid); 218 if( divType == DivWIDTH ) 219 { 220 fnDiv = CalculateNDiv( msol->GetDeltaPhiAn 221 } 222 else if( divType == DivNDIV ) 223 { 224 fwidth = CalculateWidth( msol->GetDeltaPhi 225 } 226 227 #ifdef G4DIVDEBUG 228 if( verbose >= 1 ) 229 { 230 G4cout << " G4ParameterisationConsPhi no d 231 << nDiv << G4endl 232 << " Offset " << foffset << " = " < 233 << " Width " << fwidth << " = " << 234 } 235 #endif 236 } 237 238 //-------------------------------------------- 239 G4ParameterisationConsPhi::~G4Parameterisation 240 241 //-------------------------------------------- 242 G4double G4ParameterisationConsPhi::GetMaxPara 243 { 244 auto msol = (G4Cons*)(fmotherSolid); 245 return msol->GetDeltaPhiAngle(); 246 } 247 248 //-------------------------------------------- 249 void 250 G4ParameterisationConsPhi:: 251 ComputeTransformation( const G4int copyNo, G4V 252 { 253 //----- translation 254 G4ThreeVector origin(0.,0.,0.); 255 //----- set translation 256 physVol->SetTranslation( origin ); 257 258 //----- calculate rotation matrix (so that a 259 G4double posi = foffset + copyNo*fwidth; 260 261 #ifdef G4DIVDEBUG 262 if( verbose >= 2 ) 263 { 264 G4cout << " G4ParameterisationConsPhi - po 265 << " Origin: " << origin << " copyN 266 << " - foffset: " << foffset/CLHEP: 267 << " - fwidth: " << fwidth/CLHEP::d 268 << " - Axis: " << faxis << G4endl; 269 } 270 #endif 271 272 ChangeRotMatrix( physVol, -posi ); 273 } 274 275 //-------------------------------------------- 276 void 277 G4ParameterisationConsPhi:: 278 ComputeDimensions( G4Cons& cons, const G4int, 279 const G4VPhysicalVolume* ) 280 { 281 auto msol = (G4Cons*)(fmotherSolid); 282 283 G4double pRMin1 = msol->GetInnerRadiusMinusZ 284 G4double pRMax1 = msol->GetOuterRadiusMinusZ 285 G4double pRMin2 = msol->GetInnerRadiusPlusZ( 286 G4double pRMax2 = msol->GetOuterRadiusPlusZ( 287 G4double pDz = msol->GetZHalfLength(); 288 289 //- already rotated double pSPhi = foffset 290 G4double pSPhi = foffset + msol->GetStartPhi 291 G4double pDPhi = fwidth - 2.*fhgap; 292 293 cons.SetInnerRadiusMinusZ( pRMin1 ); 294 cons.SetOuterRadiusMinusZ( pRMax1 ); 295 cons.SetInnerRadiusPlusZ( pRMin2 ); 296 cons.SetOuterRadiusPlusZ( pRMax2 ); 297 cons.SetZHalfLength( pDz ); 298 cons.SetStartPhiAngle( pSPhi, false ); 299 cons.SetDeltaPhiAngle( pDPhi ); 300 301 #ifdef G4DIVDEBUG 302 if( verbose >= 2 ) 303 { 304 G4cout << " G4ParameterisationConsPhi::Com 305 << " pSPhi: " << pSPhi << " - pDPhi 306 if( verbose >= 4 ) cons.DumpInfo(); 307 } 308 #endif 309 } 310 311 //-------------------------------------------- 312 G4ParameterisationConsZ:: 313 G4ParameterisationConsZ( EAxis axis, G4int nDi 314 G4double width, G4dou 315 G4VSolid* msolid, Div 316 : G4VParameterisationCons( axis, nDiv, widt 317 { 318 CheckParametersValidity(); 319 SetType( "DivisionConsZ" ); 320 321 auto msol = (G4Cons*)(fmotherSolid); 322 if( divType == DivWIDTH ) 323 { 324 fnDiv = CalculateNDiv( 2*msol->GetZHalfLen 325 } 326 else if( divType == DivNDIV ) 327 { 328 fwidth = CalculateWidth( 2*msol->GetZHalfL 329 } 330 331 #ifdef G4DIVDEBUG 332 if( verbose >= 1 ) 333 { 334 G4cout << " G4ParameterisationConsZ: # div 335 << nDiv << G4endl 336 << " Offset " << foffset << " = " < 337 << " Width " << fwidth << " = " << 338 << " - Axis: " << faxis << G4endl; 339 } 340 #endif 341 } 342 343 //-------------------------------------------- 344 G4ParameterisationConsZ::~G4ParameterisationCo 345 346 //-------------------------------------------- 347 G4double G4ParameterisationConsZ::GetMaxParame 348 { 349 auto msol = (G4Cons*)(fmotherSolid); 350 return 2*msol->GetZHalfLength(); 351 } 352 353 //-------------------------------------------- 354 void 355 G4ParameterisationConsZ:: 356 ComputeTransformation( const G4int copyNo, G4V 357 { 358 //----- set translation: along Z axis 359 auto motherCons = (G4Cons*)(GetMotherSolid() 360 G4double posi = - motherCons->GetZHalfLength 361 + fwidth/2 + copyNo*fwidth; 362 G4ThreeVector origin(0.,0.,posi); 363 physVol->SetTranslation( origin ); 364 365 //----- calculate rotation matrix: unit 366 367 #ifdef G4DIVDEBUG 368 if( verbose >= 2 ) 369 { 370 G4cout << " G4ParameterisationConsZ::Compu 371 << " Origin: " << origin << " - cop 372 << " foffset: " << foffset << " - f 373 << G4endl; 374 } 375 #endif 376 377 ChangeRotMatrix( physVol ); 378 } 379 380 381 //-------------------------------------------- 382 void 383 G4ParameterisationConsZ:: 384 ComputeDimensions( G4Cons& cons, const G4int c 385 const G4VPhysicalVolume* ) 386 { 387 auto msol = (G4Cons*)(fmotherSolid); 388 389 G4double mHalfLength = msol->GetZHalfLength( 390 G4double aRInner = (msol->GetInnerRadiusPlus 391 - msol->GetInnerRadiusMinus 392 G4double bRInner = (msol->GetInnerRadiusPlus 393 + msol->GetInnerRadiusMinus 394 G4double aROuter = (msol->GetOuterRadiusPlus 395 - msol->GetOuterRadiusMinus 396 G4double bROuter = (msol->GetOuterRadiusPlus 397 + msol->GetOuterRadiusMinus 398 G4double xMinusZ = -mHalfLength + OffsetZ() 399 G4double xPlusZ = -mHalfLength + OffsetZ() 400 cons.SetInnerRadiusMinusZ( aRInner * xMinusZ 401 cons.SetOuterRadiusMinusZ( aROuter * xMinusZ 402 cons.SetInnerRadiusPlusZ( aRInner * xPlusZ + 403 cons.SetOuterRadiusPlusZ( aROuter * xPlusZ + 404 405 G4double pDz = fwidth / 2. - fhgap; 406 G4double pSPhi = msol->GetStartPhiAngle(); 407 G4double pDPhi = msol->GetDeltaPhiAngle(); 408 409 cons.SetZHalfLength( pDz ); 410 cons.SetStartPhiAngle( pSPhi, false ); 411 cons.SetDeltaPhiAngle( pDPhi ); 412 413 #ifdef G4DIVDEBUG 414 if( verbose >= 2 ) 415 { 416 G4cout << " G4ParameterisationConsZ::Compu 417 << " pDz: " << pDz << G4endl; 418 if( verbose >= 4 ) cons.DumpInfo(); 419 } 420 #endif 421 422 } 423