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 // class G4ParameterisationPara[X,Y,Z] impleme 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 "G4ParameterisationPara.hh" 34 35 #include <iomanip> 36 37 #include "G4PhysicalConstants.hh" 38 #include "G4ThreeVector.hh" 39 #include "G4Transform3D.hh" 40 #include "G4RotationMatrix.hh" 41 #include "G4VPhysicalVolume.hh" 42 #include "G4ReflectedSolid.hh" 43 #include "G4Para.hh" 44 45 //-------------------------------------------- 46 G4VParameterisationPara:: 47 G4VParameterisationPara( EAxis axis, G4int nDi 48 G4double offset, G4VS 49 DivisionType divType 50 : G4VDivisionParameterisation( axis, nDiv, 51 { 52 auto msol = (G4Para*)(msolid); 53 if (msolid->GetEntityType() == "G4ReflectedS 54 { 55 // Get constituent solid 56 G4VSolid* mConstituentSolid 57 = ((G4ReflectedSolid*)msolid)->GetConst 58 msol = (G4Para*)(mConstituentSolid); 59 fmotherSolid = msol; 60 61 // Create a new solid with inversed parame 62 auto newSolid 63 = new G4Para(msol->GetName(), 64 msol->GetXHalfLength(), 65 msol->GetYHalfLength(), 66 msol->GetZHalfLength(), 67 std::atan(msol->GetTanAlpha 68 pi - msol->GetSymAxis().the 69 msol->GetSymAxis().phi()); 70 71 msol = newSolid; 72 fmotherSolid = newSolid; 73 fReflectedSolid = true; 74 fDeleteSolid = true; 75 } 76 } 77 78 //-------------------------------------------- 79 G4VParameterisationPara::~G4VParameterisationP 80 81 //-------------------------------------------- 82 G4ParameterisationParaX:: 83 G4ParameterisationParaX( EAxis axis, G4int nDi 84 G4double width, G4dou 85 G4VSolid* msolid, Div 86 : G4VParameterisationPara( axis, nDiv, widt 87 { 88 CheckParametersValidity(); 89 SetType( "DivisionParaX" ); 90 91 auto mpara = (G4Para*)(fmotherSolid); 92 if( divType == DivWIDTH ) 93 { 94 fnDiv = CalculateNDiv( 2*mpara->GetXHalfLe 95 } 96 else if( divType == DivNDIV ) 97 { 98 fwidth = CalculateWidth( 2*mpara->GetXHalf 99 } 100 101 #ifdef G4DIVDEBUG 102 if( verbose >= 1 ) 103 { 104 G4cout << " G4ParameterisationParaX - # di 105 << " = " << nDiv << G4endl 106 << " Offset " << foffset << " = " < 107 << " Width " << fwidth << " = " << 108 } 109 #endif 110 } 111 112 //-------------------------------------------- 113 G4double G4ParameterisationParaX::GetMaxParame 114 { 115 auto msol = (G4Para*)(fmotherSolid); 116 return 2*msol->GetXHalfLength(); 117 } 118 119 //-------------------------------------------- 120 G4ParameterisationParaX::~G4ParameterisationPa 121 122 //-------------------------------------------- 123 void 124 G4ParameterisationParaX:: 125 ComputeTransformation( const G4int copyNo, G4V 126 { 127 auto msol = (G4Para*)(fmotherSolid ); 128 G4double mdx = msol->GetXHalfLength( ); 129 130 //----- translation 131 G4ThreeVector origin(0.,0.,0.); 132 G4double posi = -mdx + foffset+(copyNo+0.5)* 133 origin.setX( posi ); 134 135 #ifdef G4DIVDEBUG 136 if( verbose >= 2 ) 137 { 138 G4cout << std::setprecision(8) << " G4Para 139 << copyNo << G4endl 140 << " Position: " << origin << " - A 141 } 142 #endif 143 144 //----- set translation 145 physVol->SetTranslation( origin ); 146 } 147 148 //-------------------------------------------- 149 void 150 G4ParameterisationParaX:: 151 ComputeDimensions(G4Para& para, const G4int, 152 const G4VPhysicalVolume*) co 153 { 154 //---- The division along X of a Para will r 155 auto msol = (G4Para*)(fmotherSolid); 156 157 //---- Get 158 G4double pDx = fwidth/2. - fhgap; 159 G4double pDy = msol->GetYHalfLength(); 160 G4double pDz = msol->GetZHalfLength(); 161 G4double pAlpha = std::atan(msol->GetTanAlph 162 G4double pTheta = msol->GetSymAxis().theta() 163 G4double pPhi = msol->GetSymAxis().phi(); 164 165 para.SetAllParameters ( pDx, pDy, pDz, pAlph 166 167 #ifdef G4DIVDEBUG 168 if( verbose >= 1 ) 169 { 170 G4cout << " G4ParameterisationParaX::Compu 171 << " - Mother PARA " << G4endl; 172 msol->DumpInfo(); 173 G4cout << " - Parameterised PARA: " << G4e 174 para.DumpInfo(); 175 } 176 #endif 177 } 178 179 //-------------------------------------------- 180 G4ParameterisationParaY:: 181 G4ParameterisationParaY( EAxis axis, G4int nDi 182 G4double width, G4dou 183 G4VSolid* msolid, Div 184 : G4VParameterisationPara( axis, nDiv, widt 185 { 186 CheckParametersValidity(); 187 SetType( "DivisionParaY" ); 188 189 auto mpara = (G4Para*)(fmotherSolid); 190 if( divType == DivWIDTH ) 191 { 192 fnDiv = CalculateNDiv( 2*mpara->GetYHalfLe 193 } 194 else if( divType == DivNDIV ) 195 { 196 fwidth = CalculateWidth( 2*mpara->GetYHalf 197 } 198 199 #ifdef G4DIVDEBUG 200 if( verbose >= 1 ) 201 { 202 G4cout << " G4ParameterisationParaY - # di 203 << " = " << nDiv << G4endl 204 << " Offset " << foffset << " = " < 205 << " Width " << fwidth << " = " << 206 } 207 #endif 208 } 209 210 //-------------------------------------------- 211 G4ParameterisationParaY::~G4ParameterisationPa 212 213 //-------------------------------------------- 214 G4double G4ParameterisationParaY::GetMaxParame 215 { 216 auto msol = (G4Para*)(fmotherSolid); 217 return 2*msol->GetYHalfLength(); 218 } 219 220 //-------------------------------------------- 221 void 222 G4ParameterisationParaY:: 223 ComputeTransformation( const G4int copyNo, G4V 224 { 225 auto msol = (G4Para*)(fmotherSolid ); 226 G4double mdy = msol->GetYHalfLength( ); 227 228 //----- translation 229 G4ThreeVector origin(0.,0.,0.); 230 G4double posiY = -mdy + foffset+(copyNo+0.5) 231 origin.setY( posiY ); 232 G4double posiX = posiY * msol->GetTanAlpha() 233 origin.setX( posiX ); 234 235 #ifdef G4DIVDEBUG 236 if( verbose >= 2 ) 237 { 238 G4cout << std::setprecision(8) << " G4Para 239 << copyNo << G4endl 240 << " Position: " << origin << " - A 241 } 242 #endif 243 244 //----- set translation 245 physVol->SetTranslation( origin ); 246 } 247 248 //-------------------------------------------- 249 void 250 G4ParameterisationParaY:: 251 ComputeDimensions(G4Para& para, const G4int, 252 const G4VPhysicalVolume*) co 253 { 254 //---- The division along Y of a Para will r 255 auto msol = (G4Para*)(fmotherSolid); 256 257 //---- Get 258 G4double pDx = msol->GetXHalfLength(); 259 G4double pDy = fwidth/2. - fhgap; 260 G4double pDz = msol->GetZHalfLength(); 261 G4double pAlpha = std::atan(msol->GetTanAlph 262 G4double pTheta = msol->GetSymAxis().theta() 263 G4double pPhi = msol->GetSymAxis().phi(); 264 265 para.SetAllParameters ( pDx, pDy, pDz, pAlph 266 267 #ifdef G4DIVDEBUG 268 if( verbose >= -1 ) 269 { 270 G4cout << " G4ParameterisationParaY::Compu 271 << " - Mother PARA " << G4endl; 272 msol->DumpInfo(); 273 G4cout << " - Parameterised PARA: " << G4e 274 para.DumpInfo(); 275 } 276 #endif 277 } 278 279 //-------------------------------------------- 280 G4ParameterisationParaZ:: 281 G4ParameterisationParaZ( EAxis axis, G4int nDi 282 G4double width, G4dou 283 G4VSolid* msolid, Div 284 : G4VParameterisationPara( axis, nDiv, widt 285 { 286 CheckParametersValidity(); 287 SetType( "DivisionParaZ" ); 288 289 auto mpara = (G4Para*)(fmotherSolid); 290 if( divType == DivWIDTH ) 291 { 292 fnDiv = CalculateNDiv( 2*mpara->GetZHalfLe 293 } 294 else if( divType == DivNDIV ) 295 { 296 fwidth = CalculateWidth( 2*mpara->GetZHalf 297 } 298 299 #ifdef G4DIVDEBUG 300 if( verbose >= -1 ) 301 { 302 G4cout << " G4ParameterisationParaZ - # di 303 << " = " << nDiv << G4endl 304 << " Offset " << foffset << " = " < 305 << " Width " << fwidth << " = " << 306 } 307 #endif 308 } 309 310 //-------------------------------------------- 311 G4ParameterisationParaZ::~G4ParameterisationPa 312 313 //-------------------------------------------- 314 G4double G4ParameterisationParaZ::GetMaxParame 315 { 316 auto msol = (G4Para*)(fmotherSolid); 317 return 2*msol->GetZHalfLength(); 318 } 319 320 //-------------------------------------------- 321 void 322 G4ParameterisationParaZ:: 323 ComputeTransformation( const G4int copyNo, G4V 324 { 325 auto msol = (G4Para*)(fmotherSolid ); 326 G4double mdz = msol->GetZHalfLength( ); 327 328 //----- translation 329 G4double posi = -mdz + OffsetZ() + (copyNo+0 330 G4ThreeVector symAxis = msol->GetSymAxis(); 331 G4ThreeVector origin( symAxis * posi / symAx 332 333 #ifdef G4DIVDEBUG 334 if( verbose >= 2 ) 335 { 336 G4cout << std::setprecision(8) << " G4Para 337 << copyNo << G4endl 338 << " Position: " << origin << " - A 339 } 340 #endif 341 342 //----- set translation 343 physVol->SetTranslation( origin ); 344 } 345 346 //-------------------------------------------- 347 void 348 G4ParameterisationParaZ:: 349 ComputeDimensions(G4Para& para, const G4int, 350 const G4VPhysicalVolume*) co 351 { 352 //---- The division along Z of a Para will r 353 auto msol = (G4Para*)(fmotherSolid); 354 355 //---- Get 356 G4double pDx = msol->GetXHalfLength(); 357 G4double pDy = msol->GetYHalfLength(); 358 G4double pDz = fwidth/2. - fhgap; 359 G4double pAlpha = std::atan(msol->GetTanAlph 360 G4double pTheta = msol->GetSymAxis().theta() 361 G4double pPhi = msol->GetSymAxis().phi(); 362 363 para.SetAllParameters ( pDx, pDy, pDz, pAlph 364 365 #ifdef G4DIVDEBUG 366 if( verbose >= -1 ) 367 { 368 G4cout << " G4ParameterisationParaZ::Compu 369 << " - Mother PARA " << G4endl; 370 msol->DumpInfo(); 371 G4cout << " - Parameterised PARA: " << G4e 372 para.DumpInfo(); 373 } 374 #endif 375 } 376