| [831] | 1 | //
|
|---|
| 2 | // ********************************************************************
|
|---|
| 3 | // * License and Disclaimer *
|
|---|
| 4 | // * *
|
|---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of *
|
|---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and *
|
|---|
| 7 | // * conditions of the Geant4 Software License, included in the file *
|
|---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These *
|
|---|
| 9 | // * include a list of copyright holders. *
|
|---|
| 10 | // * *
|
|---|
| 11 | // * Neither the authors of this software system, nor their employing *
|
|---|
| 12 | // * institutes,nor the agencies providing financial support for this *
|
|---|
| 13 | // * work make any representation or warranty, express or implied, *
|
|---|
| 14 | // * regarding this software system or assume any liability for its *
|
|---|
| 15 | // * use. Please see the license in the file LICENSE and URL above *
|
|---|
| 16 | // * for the full disclaimer and the limitation of liability. *
|
|---|
| 17 | // * *
|
|---|
| 18 | // * This code implementation is the result of the scientific and *
|
|---|
| 19 | // * technical work of the GEANT4 collaboration. *
|
|---|
| 20 | // * By using, copying, modifying or distributing the software (or *
|
|---|
| 21 | // * any work based on the software) you agree to acknowledge its *
|
|---|
| 22 | // * use in resulting scientific publications, and indicate your *
|
|---|
| 23 | // * acceptance of all terms of the Geant4 Software license. *
|
|---|
| 24 | // ********************************************************************
|
|---|
| 25 | //
|
|---|
| 26 | //
|
|---|
| 27 | // $Id: G4ParameterisationPara.cc,v 1.11 2006/06/29 18:18:42 gunter Exp $
|
|---|
| [1010] | 28 | // GEANT4 tag $Name: geant4-09-02-ref-02 $
|
|---|
| [831] | 29 | //
|
|---|
| 30 | // class G4ParameterisationPara Implementation file
|
|---|
| 31 | //
|
|---|
| 32 | // 26.05.03 - P.Arce, Initial version
|
|---|
| 33 | // 08.04.04 - I.Hrivnacova, Implemented reflection
|
|---|
| 34 | // --------------------------------------------------------------------
|
|---|
| 35 |
|
|---|
| 36 | #include "G4ParameterisationPara.hh"
|
|---|
| 37 |
|
|---|
| 38 | #include <iomanip>
|
|---|
| 39 |
|
|---|
| 40 | #include "G4ThreeVector.hh"
|
|---|
| 41 | #include "G4Transform3D.hh"
|
|---|
| 42 | #include "G4RotationMatrix.hh"
|
|---|
| 43 | #include "G4VPhysicalVolume.hh"
|
|---|
| 44 | #include "G4ReflectedSolid.hh"
|
|---|
| 45 | #include "G4Para.hh"
|
|---|
| 46 |
|
|---|
| 47 | //--------------------------------------------------------------------------
|
|---|
| 48 | G4VParameterisationPara::
|
|---|
| 49 | G4VParameterisationPara( EAxis axis, G4int nDiv, G4double width,
|
|---|
| 50 | G4double offset, G4VSolid* msolid,
|
|---|
| 51 | DivisionType divType )
|
|---|
| 52 | : G4VDivisionParameterisation( axis, nDiv, width, offset, divType, msolid )
|
|---|
| 53 | {
|
|---|
| 54 | G4Para* msol = (G4Para*)(msolid);
|
|---|
| 55 | if (msolid->GetEntityType() == "G4ReflectedSolid")
|
|---|
| 56 | {
|
|---|
| 57 | // Get constituent solid
|
|---|
| 58 | G4VSolid* mConstituentSolid
|
|---|
| 59 | = ((G4ReflectedSolid*)msolid)->GetConstituentMovedSolid();
|
|---|
| 60 | msol = (G4Para*)(mConstituentSolid);
|
|---|
| 61 | fmotherSolid = msol;
|
|---|
| 62 |
|
|---|
| 63 | // Create a new solid with inversed parameters
|
|---|
| 64 | G4Para* newSolid
|
|---|
| 65 | = new G4Para(msol->GetName(),
|
|---|
| 66 | msol->GetXHalfLength(),
|
|---|
| 67 | msol->GetYHalfLength(),
|
|---|
| 68 | msol->GetZHalfLength(),
|
|---|
| 69 | std::atan(msol->GetTanAlpha()),
|
|---|
| 70 | pi - msol->GetSymAxis().theta(),
|
|---|
| 71 | msol->GetSymAxis().phi());
|
|---|
| 72 |
|
|---|
| 73 | msol = newSolid;
|
|---|
| 74 | fmotherSolid = newSolid;
|
|---|
| 75 | fReflectedSolid = true;
|
|---|
| 76 | fDeleteSolid = true;
|
|---|
| 77 | }
|
|---|
| 78 | }
|
|---|
| 79 |
|
|---|
| 80 | //------------------------------------------------------------------------
|
|---|
| 81 | G4VParameterisationPara::~G4VParameterisationPara()
|
|---|
| 82 | {
|
|---|
| 83 | }
|
|---|
| 84 |
|
|---|
| 85 | //------------------------------------------------------------------------
|
|---|
| 86 | G4ParameterisationParaX::
|
|---|
| 87 | G4ParameterisationParaX( EAxis axis, G4int nDiv,
|
|---|
| 88 | G4double width, G4double offset,
|
|---|
| 89 | G4VSolid* msolid, DivisionType divType )
|
|---|
| 90 | : G4VParameterisationPara( axis, nDiv, width, offset, msolid, divType )
|
|---|
| 91 | {
|
|---|
| 92 | CheckParametersValidity();
|
|---|
| 93 | SetType( "DivisionParaX" );
|
|---|
| 94 |
|
|---|
| 95 | G4Para* mpara = (G4Para*)(fmotherSolid);
|
|---|
| 96 | if( divType == DivWIDTH )
|
|---|
| 97 | {
|
|---|
| 98 | fnDiv = CalculateNDiv( 2*mpara->GetXHalfLength(), width, offset );
|
|---|
| 99 | }
|
|---|
| 100 | else if( divType == DivNDIV )
|
|---|
| 101 | {
|
|---|
| 102 | fwidth = CalculateWidth( 2*mpara->GetXHalfLength(), nDiv, offset );
|
|---|
| 103 | }
|
|---|
| 104 |
|
|---|
| 105 | #ifdef G4DIVDEBUG
|
|---|
| 106 | if( verbose >= 1 )
|
|---|
| 107 | {
|
|---|
| 108 | G4cout << " G4ParameterisationParaX - # divisions " << fnDiv
|
|---|
| 109 | << " = " << nDiv << G4endl
|
|---|
| 110 | << " Offset " << foffset << " = " << offset << G4endl
|
|---|
| 111 | << " Width " << fwidth << " = " << width << G4endl;
|
|---|
| 112 | }
|
|---|
| 113 | #endif
|
|---|
| 114 | }
|
|---|
| 115 |
|
|---|
| 116 | //------------------------------------------------------------------------
|
|---|
| 117 | G4double G4ParameterisationParaX::GetMaxParameter() const
|
|---|
| 118 | {
|
|---|
| 119 | G4Para* msol = (G4Para*)(fmotherSolid);
|
|---|
| 120 | return 2*msol->GetXHalfLength();
|
|---|
| 121 | }
|
|---|
| 122 |
|
|---|
| 123 | //------------------------------------------------------------------------
|
|---|
| 124 | G4ParameterisationParaX::~G4ParameterisationParaX()
|
|---|
| 125 | {
|
|---|
| 126 | }
|
|---|
| 127 |
|
|---|
| 128 | //------------------------------------------------------------------------
|
|---|
| 129 | void
|
|---|
| 130 | G4ParameterisationParaX::
|
|---|
| 131 | ComputeTransformation( const G4int copyNo, G4VPhysicalVolume *physVol ) const
|
|---|
| 132 | {
|
|---|
| 133 | G4Para* msol = (G4Para*)(fmotherSolid );
|
|---|
| 134 | G4double mdx = msol->GetXHalfLength( );
|
|---|
| 135 |
|
|---|
| 136 | //----- translation
|
|---|
| 137 | G4ThreeVector origin(0.,0.,0.);
|
|---|
| 138 | G4double posi = -mdx + foffset+(copyNo+0.5)*fwidth;
|
|---|
| 139 | origin.setX( posi );
|
|---|
| 140 |
|
|---|
| 141 | #ifdef G4DIVDEBUG
|
|---|
| 142 | if( verbose >= 2 )
|
|---|
| 143 | {
|
|---|
| 144 | G4cout << std::setprecision(8) << " G4ParameterisationParaX "
|
|---|
| 145 | << copyNo << G4endl
|
|---|
| 146 | << " Position: " << origin << " - Axis: " << faxis << G4endl;
|
|---|
| 147 | }
|
|---|
| 148 | #endif
|
|---|
| 149 |
|
|---|
| 150 | //----- set translation
|
|---|
| 151 | physVol->SetTranslation( origin );
|
|---|
| 152 | }
|
|---|
| 153 |
|
|---|
| 154 | //--------------------------------------------------------------------------
|
|---|
| 155 | void
|
|---|
| 156 | G4ParameterisationParaX::
|
|---|
| 157 | ComputeDimensions(G4Para& para, const G4int,
|
|---|
| 158 | const G4VPhysicalVolume*) const
|
|---|
| 159 | {
|
|---|
| 160 | //---- The division along X of a Para will result a Para
|
|---|
| 161 | G4Para* msol = (G4Para*)(fmotherSolid);
|
|---|
| 162 |
|
|---|
| 163 | //---- Get
|
|---|
| 164 | G4double pDx = fwidth/2.;
|
|---|
| 165 | G4double pDy = msol->GetYHalfLength();
|
|---|
| 166 | G4double pDz = msol->GetZHalfLength();
|
|---|
| 167 | G4double pAlpha = std::atan(msol->GetTanAlpha());
|
|---|
| 168 | G4double pTheta = msol->GetSymAxis().theta();
|
|---|
| 169 | G4double pPhi = msol->GetSymAxis().phi();
|
|---|
| 170 |
|
|---|
| 171 | para.SetAllParameters ( pDx, pDy, pDz, pAlpha, pTheta, pPhi );
|
|---|
| 172 |
|
|---|
| 173 | #ifdef G4DIVDEBUG
|
|---|
| 174 | if( verbose >= 1 )
|
|---|
| 175 | {
|
|---|
| 176 | G4cout << " G4ParameterisationParaX::ComputeDimensions()"
|
|---|
| 177 | << " - Mother PARA " << G4endl;
|
|---|
| 178 | msol->DumpInfo();
|
|---|
| 179 | G4cout << " - Parameterised PARA: " << G4endl;
|
|---|
| 180 | para.DumpInfo();
|
|---|
| 181 | }
|
|---|
| 182 | #endif
|
|---|
| 183 | }
|
|---|
| 184 |
|
|---|
| 185 | //------------------------------------------------------------------------
|
|---|
| 186 | G4ParameterisationParaY::
|
|---|
| 187 | G4ParameterisationParaY( EAxis axis, G4int nDiv,
|
|---|
| 188 | G4double width, G4double offset,
|
|---|
| 189 | G4VSolid* msolid, DivisionType divType )
|
|---|
| 190 | : G4VParameterisationPara( axis, nDiv, width, offset, msolid, divType )
|
|---|
| 191 | {
|
|---|
| 192 | CheckParametersValidity();
|
|---|
| 193 | SetType( "DivisionParaY" );
|
|---|
| 194 |
|
|---|
| 195 | G4Para* mpara = (G4Para*)(fmotherSolid);
|
|---|
| 196 | if( divType == DivWIDTH )
|
|---|
| 197 | {
|
|---|
| 198 | fnDiv = CalculateNDiv( 2*mpara->GetYHalfLength(), width, offset );
|
|---|
| 199 | }
|
|---|
| 200 | else if( divType == DivNDIV )
|
|---|
| 201 | {
|
|---|
| 202 | fwidth = CalculateWidth( 2*mpara->GetYHalfLength(), nDiv, offset );
|
|---|
| 203 | }
|
|---|
| 204 |
|
|---|
| 205 | #ifdef G4DIVDEBUG
|
|---|
| 206 | if( verbose >= 1 )
|
|---|
| 207 | {
|
|---|
| 208 | G4cout << " G4ParameterisationParaY - # divisions " << fnDiv
|
|---|
| 209 | << " = " << nDiv << G4endl
|
|---|
| 210 | << " Offset " << foffset << " = " << offset << G4endl
|
|---|
| 211 | << " Width " << fwidth << " = " << width << G4endl;
|
|---|
| 212 | }
|
|---|
| 213 | #endif
|
|---|
| 214 | }
|
|---|
| 215 |
|
|---|
| 216 | //------------------------------------------------------------------------
|
|---|
| 217 | G4ParameterisationParaY::~G4ParameterisationParaY()
|
|---|
| 218 | {
|
|---|
| 219 | }
|
|---|
| 220 |
|
|---|
| 221 | //------------------------------------------------------------------------
|
|---|
| 222 | G4double G4ParameterisationParaY::GetMaxParameter() const
|
|---|
| 223 | {
|
|---|
| 224 | G4Para* msol = (G4Para*)(fmotherSolid);
|
|---|
| 225 | return 2*msol->GetYHalfLength();
|
|---|
| 226 | }
|
|---|
| 227 |
|
|---|
| 228 | //------------------------------------------------------------------------
|
|---|
| 229 | void
|
|---|
| 230 | G4ParameterisationParaY::
|
|---|
| 231 | ComputeTransformation( const G4int copyNo, G4VPhysicalVolume *physVol ) const
|
|---|
| 232 | {
|
|---|
| 233 | G4Para* msol = (G4Para*)(fmotherSolid );
|
|---|
| 234 | G4double mdy = msol->GetYHalfLength( );
|
|---|
| 235 |
|
|---|
| 236 | //----- translation
|
|---|
| 237 | G4ThreeVector origin(0.,0.,0.);
|
|---|
| 238 | G4double posiY = -mdy + foffset+(copyNo+0.5)*fwidth;
|
|---|
| 239 | origin.setY( posiY );
|
|---|
| 240 | G4double posiX = posiY * msol->GetTanAlpha();
|
|---|
| 241 | origin.setX( posiX );
|
|---|
| 242 |
|
|---|
| 243 | #ifdef G4DIVDEBUG
|
|---|
| 244 | if( verbose >= 2 )
|
|---|
| 245 | {
|
|---|
| 246 | G4cout << std::setprecision(8) << " G4ParameterisationParaY "
|
|---|
| 247 | << copyNo << G4endl
|
|---|
| 248 | << " Position: " << origin << " - Axis: " << faxis << G4endl;
|
|---|
| 249 | }
|
|---|
| 250 | #endif
|
|---|
| 251 |
|
|---|
| 252 | //----- set translation
|
|---|
| 253 | physVol->SetTranslation( origin );
|
|---|
| 254 | }
|
|---|
| 255 |
|
|---|
| 256 | //--------------------------------------------------------------------------
|
|---|
| 257 | void
|
|---|
| 258 | G4ParameterisationParaY::
|
|---|
| 259 | ComputeDimensions(G4Para& para, const G4int,
|
|---|
| 260 | const G4VPhysicalVolume*) const
|
|---|
| 261 | {
|
|---|
| 262 | //---- The division along Y of a Para will result a Para
|
|---|
| 263 | G4Para* msol = (G4Para*)(fmotherSolid);
|
|---|
| 264 |
|
|---|
| 265 | //---- Get
|
|---|
| 266 | G4double pDx = msol->GetXHalfLength();
|
|---|
| 267 | G4double pDy = fwidth/2.;
|
|---|
| 268 | G4double pDz = msol->GetZHalfLength();
|
|---|
| 269 | G4double pAlpha = std::atan(msol->GetTanAlpha());
|
|---|
| 270 | G4double pTheta = msol->GetSymAxis().theta();
|
|---|
| 271 | G4double pPhi = msol->GetSymAxis().phi();
|
|---|
| 272 |
|
|---|
| 273 | para.SetAllParameters ( pDx, pDy, pDz, pAlpha, pTheta, pPhi );
|
|---|
| 274 |
|
|---|
| 275 | #ifdef G4DIVDEBUG
|
|---|
| 276 | if( verbose >= -1 )
|
|---|
| 277 | {
|
|---|
| 278 | G4cout << " G4ParameterisationParaY::ComputeDimensions()"
|
|---|
| 279 | << " - Mother PARA " << G4endl;
|
|---|
| 280 | msol->DumpInfo();
|
|---|
| 281 | G4cout << " - Parameterised PARA: " << G4endl;
|
|---|
| 282 | para.DumpInfo();
|
|---|
| 283 | }
|
|---|
| 284 | #endif
|
|---|
| 285 | }
|
|---|
| 286 |
|
|---|
| 287 | //------------------------------------------------------------------------
|
|---|
| 288 | G4ParameterisationParaZ::
|
|---|
| 289 | G4ParameterisationParaZ( EAxis axis, G4int nDiv,
|
|---|
| 290 | G4double width, G4double offset,
|
|---|
| 291 | G4VSolid* msolid, DivisionType divType )
|
|---|
| 292 | : G4VParameterisationPara( axis, nDiv, width, offset, msolid, divType )
|
|---|
| 293 | {
|
|---|
| 294 | CheckParametersValidity();
|
|---|
| 295 | SetType( "DivisionParaZ" );
|
|---|
| 296 |
|
|---|
| 297 | G4Para* mpara = (G4Para*)(fmotherSolid);
|
|---|
| 298 | if( divType == DivWIDTH )
|
|---|
| 299 | {
|
|---|
| 300 | fnDiv = CalculateNDiv( 2*mpara->GetZHalfLength(), width, offset );
|
|---|
| 301 | }
|
|---|
| 302 | else if( divType == DivNDIV )
|
|---|
| 303 | {
|
|---|
| 304 | fwidth = CalculateWidth( 2*mpara->GetZHalfLength(), nDiv, offset );
|
|---|
| 305 | }
|
|---|
| 306 |
|
|---|
| 307 | #ifdef G4DIVDEBUG
|
|---|
| 308 | if( verbose >= -1 )
|
|---|
| 309 | {
|
|---|
| 310 | G4cout << " G4ParameterisationParaZ - # divisions " << fnDiv
|
|---|
| 311 | << " = " << nDiv << G4endl
|
|---|
| 312 | << " Offset " << foffset << " = " << offset << G4endl
|
|---|
| 313 | << " Width " << fwidth << " = " << width << G4endl;
|
|---|
| 314 | }
|
|---|
| 315 | #endif
|
|---|
| 316 | }
|
|---|
| 317 |
|
|---|
| 318 | //------------------------------------------------------------------------
|
|---|
| 319 | G4ParameterisationParaZ::~G4ParameterisationParaZ()
|
|---|
| 320 | {
|
|---|
| 321 | }
|
|---|
| 322 |
|
|---|
| 323 | //------------------------------------------------------------------------
|
|---|
| 324 | G4double G4ParameterisationParaZ::GetMaxParameter() const
|
|---|
| 325 | {
|
|---|
| 326 | G4Para* msol = (G4Para*)(fmotherSolid);
|
|---|
| 327 | return 2*msol->GetZHalfLength();
|
|---|
| 328 | }
|
|---|
| 329 |
|
|---|
| 330 | //------------------------------------------------------------------------
|
|---|
| 331 | void
|
|---|
| 332 | G4ParameterisationParaZ::
|
|---|
| 333 | ComputeTransformation( const G4int copyNo, G4VPhysicalVolume *physVol ) const
|
|---|
| 334 | {
|
|---|
| 335 | G4Para* msol = (G4Para*)(fmotherSolid );
|
|---|
| 336 | G4double mdz = msol->GetZHalfLength( );
|
|---|
| 337 |
|
|---|
| 338 | //----- translation
|
|---|
| 339 | G4double posi = -mdz + OffsetZ() + (copyNo+0.5)*fwidth;
|
|---|
| 340 | G4ThreeVector symAxis = msol->GetSymAxis();
|
|---|
| 341 | G4ThreeVector origin( symAxis * posi / symAxis.z() );
|
|---|
| 342 |
|
|---|
| 343 | #ifdef G4DIVDEBUG
|
|---|
| 344 | if( verbose >= 2 )
|
|---|
| 345 | {
|
|---|
| 346 | G4cout << std::setprecision(8) << " G4ParameterisationParaZ "
|
|---|
| 347 | << copyNo << G4endl
|
|---|
| 348 | << " Position: " << origin << " - Axis: " << faxis << G4endl;
|
|---|
| 349 | }
|
|---|
| 350 | #endif
|
|---|
| 351 |
|
|---|
| 352 | //----- set translation
|
|---|
| 353 | physVol->SetTranslation( origin );
|
|---|
| 354 | }
|
|---|
| 355 |
|
|---|
| 356 | //--------------------------------------------------------------------------
|
|---|
| 357 | void
|
|---|
| 358 | G4ParameterisationParaZ::
|
|---|
| 359 | ComputeDimensions(G4Para& para, const G4int,
|
|---|
| 360 | const G4VPhysicalVolume*) const
|
|---|
| 361 | {
|
|---|
| 362 | //---- The division along Z of a Para will result a Para
|
|---|
| 363 | G4Para* msol = (G4Para*)(fmotherSolid);
|
|---|
| 364 |
|
|---|
| 365 | //---- Get
|
|---|
| 366 | G4double pDx = msol->GetXHalfLength();
|
|---|
| 367 | G4double pDy = msol->GetYHalfLength();
|
|---|
| 368 | G4double pAlpha = std::atan(msol->GetTanAlpha());
|
|---|
| 369 | G4double pTheta = msol->GetSymAxis().theta();
|
|---|
| 370 | G4double pPhi = msol->GetSymAxis().phi();
|
|---|
| 371 | G4double pDz = fwidth/2.;
|
|---|
| 372 |
|
|---|
| 373 | para.SetAllParameters ( pDx, pDy, pDz, pAlpha, pTheta, pPhi );
|
|---|
| 374 |
|
|---|
| 375 | #ifdef G4DIVDEBUG
|
|---|
| 376 | if( verbose >= -1 )
|
|---|
| 377 | {
|
|---|
| 378 | G4cout << " G4ParameterisationParaZ::ComputeDimensions()"
|
|---|
| 379 | << " - Mother PARA " << G4endl;
|
|---|
| 380 | msol->DumpInfo();
|
|---|
| 381 | G4cout << " - Parameterised PARA: " << G4endl;
|
|---|
| 382 | para.DumpInfo();
|
|---|
| 383 | }
|
|---|
| 384 | #endif
|
|---|
| 385 | }
|
|---|