[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: G4ParameterisationBox.cc,v 1.10 2006/06/29 18:18:35 gunter Exp $ |
---|
[1010] | 28 | // GEANT4 tag $Name: geant4-09-02-ref-02 $ |
---|
[831] | 29 | // |
---|
| 30 | // class G4ParameterisationBox Implementation file |
---|
| 31 | // |
---|
| 32 | // 26.05.03 - P.Arce, Initial version |
---|
| 33 | // 08.04.04 - I.Hrivnacova, Implemented reflection |
---|
| 34 | // -------------------------------------------------------------------- |
---|
| 35 | |
---|
| 36 | #include "G4ParameterisationBox.hh" |
---|
| 37 | |
---|
| 38 | #include <iomanip> |
---|
| 39 | #include "G4ThreeVector.hh" |
---|
| 40 | #include "G4Transform3D.hh" |
---|
| 41 | #include "G4RotationMatrix.hh" |
---|
| 42 | #include "G4VPhysicalVolume.hh" |
---|
| 43 | #include "G4ReflectedSolid.hh" |
---|
| 44 | #include "G4Box.hh" |
---|
| 45 | |
---|
| 46 | //-------------------------------------------------------------------------- |
---|
| 47 | G4VParameterisationBox:: |
---|
| 48 | G4VParameterisationBox( EAxis axis, G4int nDiv, G4double width, |
---|
| 49 | G4double offset, G4VSolid* msolid, |
---|
| 50 | DivisionType divType ) |
---|
| 51 | : G4VDivisionParameterisation( axis, nDiv, width, offset, divType, msolid ) |
---|
| 52 | { |
---|
| 53 | G4Box* msol = (G4Box*)(msolid); |
---|
| 54 | if (msolid->GetEntityType() == "G4ReflectedSolid") |
---|
| 55 | { |
---|
| 56 | // Get constituent solid |
---|
| 57 | G4VSolid* mConstituentSolid |
---|
| 58 | = ((G4ReflectedSolid*)msolid)->GetConstituentMovedSolid(); |
---|
| 59 | msol = (G4Box*)(mConstituentSolid); |
---|
| 60 | fmotherSolid = msol; |
---|
| 61 | fReflectedSolid = true; |
---|
| 62 | } |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | //-------------------------------------------------------------------------- |
---|
| 66 | G4VParameterisationBox::~G4VParameterisationBox() |
---|
| 67 | { |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | //-------------------------------------------------------------------------- |
---|
| 71 | G4ParameterisationBoxX:: |
---|
| 72 | G4ParameterisationBoxX( EAxis axis, G4int nDiv, G4double width, |
---|
| 73 | G4double offset, G4VSolid* msolid, |
---|
| 74 | DivisionType divType ) |
---|
| 75 | : G4VParameterisationBox( axis, nDiv, width, offset, msolid, divType ) |
---|
| 76 | { |
---|
| 77 | CheckParametersValidity(); |
---|
| 78 | SetType( "DivisionBoxX" ); |
---|
| 79 | |
---|
| 80 | G4Box* mbox = (G4Box*)(fmotherSolid); |
---|
| 81 | if( divType == DivWIDTH ) |
---|
| 82 | { |
---|
| 83 | fnDiv = CalculateNDiv( 2*mbox->GetXHalfLength(), width, offset ); |
---|
| 84 | } |
---|
| 85 | else if( divType == DivNDIV ) |
---|
| 86 | { |
---|
| 87 | fwidth = CalculateWidth( 2*mbox->GetXHalfLength(), nDiv, offset ); |
---|
| 88 | } |
---|
| 89 | #ifdef G4DIVDEBUG |
---|
| 90 | if( verbose >= 1 ) |
---|
| 91 | { |
---|
| 92 | G4cout << " G4ParameterisationBoxX - no divisions " |
---|
| 93 | << fnDiv << " = " << nDiv << G4endl |
---|
| 94 | << " Offset " << foffset << " = " << offset << G4endl |
---|
| 95 | << " Width " << fwidth << " = " << width << G4endl; |
---|
| 96 | } |
---|
| 97 | #endif |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | //------------------------------------------------------------------------ |
---|
| 101 | G4ParameterisationBoxX::~G4ParameterisationBoxX() |
---|
| 102 | { |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | //------------------------------------------------------------------------ |
---|
| 106 | G4double G4ParameterisationBoxX::GetMaxParameter() const |
---|
| 107 | { |
---|
| 108 | G4Box* msol = (G4Box*)(fmotherSolid); |
---|
| 109 | return 2*msol->GetXHalfLength(); |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | //------------------------------------------------------------------------ |
---|
| 113 | void |
---|
| 114 | G4ParameterisationBoxX:: |
---|
| 115 | ComputeTransformation( const G4int copyNo, G4VPhysicalVolume* physVol ) const |
---|
| 116 | { |
---|
| 117 | G4Box* msol = (G4Box*)(fmotherSolid ); |
---|
| 118 | G4double mdx = msol->GetXHalfLength( ); |
---|
| 119 | |
---|
| 120 | //----- translation |
---|
| 121 | G4ThreeVector origin(0.,0.,0.); |
---|
| 122 | G4double posi = -mdx + foffset+(copyNo+0.5)*fwidth; |
---|
| 123 | |
---|
| 124 | if( faxis == kXAxis ) |
---|
| 125 | { |
---|
| 126 | origin.setX( posi ); |
---|
| 127 | } |
---|
| 128 | else |
---|
| 129 | { |
---|
| 130 | G4Exception("G4ParameterisationBoxX::ComputeTransformation()", |
---|
| 131 | "IllegalConstruct", FatalException, |
---|
| 132 | "Only axes along X are allowed ! Axis: "+faxis); |
---|
| 133 | } |
---|
| 134 | #ifdef G4DIVDEBUG |
---|
| 135 | if( verbose >= 2 ) |
---|
| 136 | { |
---|
| 137 | G4cout << std::setprecision(8) << " G4ParameterisationBoxX: " |
---|
| 138 | << copyNo << G4endl |
---|
| 139 | << " Position " << origin << " Axis " << faxis << G4endl; |
---|
| 140 | } |
---|
| 141 | #endif |
---|
| 142 | //----- set translation |
---|
| 143 | physVol->SetTranslation( origin ); |
---|
| 144 | } |
---|
| 145 | |
---|
| 146 | //------------------------------------------------------------------------ |
---|
| 147 | void |
---|
| 148 | G4ParameterisationBoxX:: |
---|
| 149 | ComputeDimensions( G4Box& box, const G4int, |
---|
| 150 | const G4VPhysicalVolume* ) const |
---|
| 151 | { |
---|
| 152 | G4Box* msol = (G4Box*)(fmotherSolid); |
---|
| 153 | |
---|
| 154 | G4double pDx = fwidth/2.; |
---|
| 155 | G4double pDy = msol->GetYHalfLength(); |
---|
| 156 | G4double pDz = msol->GetZHalfLength(); |
---|
| 157 | |
---|
| 158 | box.SetXHalfLength( pDx ); |
---|
| 159 | box.SetYHalfLength( pDy ); |
---|
| 160 | box.SetZHalfLength( pDz ); |
---|
| 161 | |
---|
| 162 | #ifdef G4DIVDEBUG |
---|
| 163 | if( verbose >= 2 ) |
---|
| 164 | { |
---|
| 165 | G4cout << " G4ParameterisationBoxX::ComputeDimensions()" << G4endl |
---|
| 166 | << " pDx: " << pDz << G4endl; |
---|
| 167 | box.DumpInfo(); |
---|
| 168 | } |
---|
| 169 | #endif |
---|
| 170 | } |
---|
| 171 | |
---|
| 172 | //------------------------------------------------------------------------ |
---|
| 173 | G4ParameterisationBoxY:: |
---|
| 174 | G4ParameterisationBoxY( EAxis axis, G4int nDiv, G4double width, |
---|
| 175 | G4double offset, G4VSolid* msolid, |
---|
| 176 | DivisionType divType) |
---|
| 177 | : G4VParameterisationBox( axis, nDiv, width, offset, msolid, divType ) |
---|
| 178 | { |
---|
| 179 | CheckParametersValidity(); |
---|
| 180 | SetType( "DivisionBoxY" ); |
---|
| 181 | |
---|
| 182 | G4Box* mbox = (G4Box*)(fmotherSolid); |
---|
| 183 | if( divType == DivWIDTH ) |
---|
| 184 | { |
---|
| 185 | fnDiv = CalculateNDiv( 2*mbox->GetYHalfLength(), width, offset ); |
---|
| 186 | } |
---|
| 187 | else if( divType == DivNDIV ) |
---|
| 188 | { |
---|
| 189 | fwidth = CalculateWidth( 2*mbox->GetYHalfLength(), nDiv, offset ); |
---|
| 190 | } |
---|
| 191 | |
---|
| 192 | #ifdef G4DIVDEBUG |
---|
| 193 | if( verbose >= 1 ) |
---|
| 194 | { |
---|
| 195 | G4cout << " G4ParameterisationBoxY - no divisions " << fnDiv << " = " |
---|
| 196 | << nDiv << ". Offset " << foffset << " = " << offset |
---|
| 197 | << ". Width " << fwidth << " = " << width << G4endl; |
---|
| 198 | } |
---|
| 199 | #endif |
---|
| 200 | } |
---|
| 201 | |
---|
| 202 | //------------------------------------------------------------------------ |
---|
| 203 | G4ParameterisationBoxY::~G4ParameterisationBoxY() |
---|
| 204 | { |
---|
| 205 | } |
---|
| 206 | |
---|
| 207 | //------------------------------------------------------------------------ |
---|
| 208 | G4double G4ParameterisationBoxY::GetMaxParameter() const |
---|
| 209 | { |
---|
| 210 | G4Box* msol = (G4Box*)(fmotherSolid); |
---|
| 211 | return 2*msol->GetYHalfLength(); |
---|
| 212 | } |
---|
| 213 | |
---|
| 214 | //------------------------------------------------------------------------ |
---|
| 215 | void |
---|
| 216 | G4ParameterisationBoxY:: |
---|
| 217 | ComputeTransformation( const G4int copyNo, G4VPhysicalVolume* physVol ) const |
---|
| 218 | { |
---|
| 219 | G4Box* msol = (G4Box*)(fmotherSolid); |
---|
| 220 | G4double mdy = msol->GetYHalfLength(); |
---|
| 221 | |
---|
| 222 | //----- translation |
---|
| 223 | G4ThreeVector origin(0.,0.,0.); |
---|
| 224 | G4double posi = -mdy + foffset + (copyNo+0.5)*fwidth; |
---|
| 225 | if( faxis == kYAxis ) |
---|
| 226 | { |
---|
| 227 | origin.setY( posi ); |
---|
| 228 | } |
---|
| 229 | else |
---|
| 230 | { |
---|
| 231 | G4Exception("G4ParameterisationBoxY::ComputeTransformation()", |
---|
| 232 | "IllegalConstruct", FatalException, |
---|
| 233 | "Only axes along Y are allowed ! Axis: "+faxis); |
---|
| 234 | } |
---|
| 235 | #ifdef G4DIVDEBUG |
---|
| 236 | if( verbose >= 2 ) |
---|
| 237 | { |
---|
| 238 | G4cout << std::setprecision(8) << " G4ParameterisationBoxY: " |
---|
| 239 | << copyNo << G4endl |
---|
| 240 | << " Position " << origin << " Axis " << faxis << G4endl; |
---|
| 241 | } |
---|
| 242 | #endif |
---|
| 243 | //----- set translation |
---|
| 244 | physVol->SetTranslation( origin ); |
---|
| 245 | } |
---|
| 246 | |
---|
| 247 | //------------------------------------------------------------------------ |
---|
| 248 | void |
---|
| 249 | G4ParameterisationBoxY:: |
---|
| 250 | ComputeDimensions( G4Box& box, const G4int, |
---|
| 251 | const G4VPhysicalVolume* ) const |
---|
| 252 | { |
---|
| 253 | G4Box* msol = (G4Box*)(fmotherSolid); |
---|
| 254 | |
---|
| 255 | G4double pDx = msol->GetXHalfLength(); |
---|
| 256 | G4double pDy = fwidth/2.; |
---|
| 257 | G4double pDz = msol->GetZHalfLength(); |
---|
| 258 | |
---|
| 259 | box.SetXHalfLength( pDx ); |
---|
| 260 | box.SetYHalfLength( pDy ); |
---|
| 261 | box.SetZHalfLength( pDz ); |
---|
| 262 | |
---|
| 263 | #ifdef G4DIVDEBUG |
---|
| 264 | if( verbose >= 2 ) |
---|
| 265 | { |
---|
| 266 | G4cout << " G4ParameterisationBoxY::ComputeDimensions()" << G4endl |
---|
| 267 | << " pDx: " << pDz << G4endl; |
---|
| 268 | box.DumpInfo(); |
---|
| 269 | } |
---|
| 270 | #endif |
---|
| 271 | } |
---|
| 272 | |
---|
| 273 | //------------------------------------------------------------------------ |
---|
| 274 | G4ParameterisationBoxZ:: |
---|
| 275 | G4ParameterisationBoxZ( EAxis axis, G4int nDiv, G4double width, |
---|
| 276 | G4double offset, G4VSolid* msolid, |
---|
| 277 | DivisionType divType ) |
---|
| 278 | : G4VParameterisationBox( axis, nDiv, width, offset, msolid, divType ) |
---|
| 279 | { |
---|
| 280 | CheckParametersValidity(); |
---|
| 281 | SetType( "DivisionBoxZ" ); |
---|
| 282 | |
---|
| 283 | G4Box* mbox = (G4Box*)(fmotherSolid); |
---|
| 284 | if( divType == DivWIDTH ) |
---|
| 285 | { |
---|
| 286 | fnDiv = CalculateNDiv( 2*mbox->GetZHalfLength(), width, offset ); |
---|
| 287 | } |
---|
| 288 | else if ( divType == DivNDIV ) |
---|
| 289 | { |
---|
| 290 | fwidth = CalculateWidth( 2*mbox->GetZHalfLength(), nDiv, offset ); |
---|
| 291 | } |
---|
| 292 | #ifdef G4DIVDEBUG |
---|
| 293 | if( verbose >= 1 ) |
---|
| 294 | { |
---|
| 295 | G4cout << " G4ParameterisationBoxZ - no divisions " << fnDiv << " = " |
---|
| 296 | << nDiv << ". Offset " << foffset << " = " << offset |
---|
| 297 | << ". Width " << fwidth << " = " << width << G4endl; |
---|
| 298 | } |
---|
| 299 | #endif |
---|
| 300 | } |
---|
| 301 | |
---|
| 302 | //------------------------------------------------------------------------ |
---|
| 303 | G4ParameterisationBoxZ::~G4ParameterisationBoxZ() |
---|
| 304 | { |
---|
| 305 | } |
---|
| 306 | |
---|
| 307 | //------------------------------------------------------------------------ |
---|
| 308 | G4double G4ParameterisationBoxZ::GetMaxParameter() const |
---|
| 309 | { |
---|
| 310 | G4Box* msol = (G4Box*)(fmotherSolid); |
---|
| 311 | return 2*msol->GetZHalfLength(); |
---|
| 312 | } |
---|
| 313 | |
---|
| 314 | //------------------------------------------------------------------------ |
---|
| 315 | void |
---|
| 316 | G4ParameterisationBoxZ:: |
---|
| 317 | ComputeTransformation( const G4int copyNo, G4VPhysicalVolume *physVol ) const |
---|
| 318 | { |
---|
| 319 | G4Box* msol = (G4Box*)(fmotherSolid ); |
---|
| 320 | G4double mdz = msol->GetZHalfLength(); |
---|
| 321 | |
---|
| 322 | //----- translation |
---|
| 323 | G4ThreeVector origin(0.,0.,0.); |
---|
| 324 | G4double posi = -mdz + OffsetZ() + (copyNo+0.5)*fwidth; |
---|
| 325 | |
---|
| 326 | if( faxis == kZAxis ) |
---|
| 327 | { |
---|
| 328 | origin.setZ( posi ); |
---|
| 329 | } |
---|
| 330 | else |
---|
| 331 | { |
---|
| 332 | G4Exception("G4ParameterisationBoxZ::ComputeTransformation()", |
---|
| 333 | "IllegalConstruct", FatalException, |
---|
| 334 | "Only axes along Z are allowed ! Axis: "+faxis); |
---|
| 335 | } |
---|
| 336 | #ifdef G4DIVDEBUG |
---|
| 337 | if( verbose >= 2 ) |
---|
| 338 | { |
---|
| 339 | G4cout << std::setprecision(8) << " G4ParameterisationBoxZ: " |
---|
| 340 | << copyNo << G4endl |
---|
| 341 | << " Position " << origin << " Axis " << faxis << G4endl; |
---|
| 342 | } |
---|
| 343 | #endif |
---|
| 344 | //----- set translation |
---|
| 345 | physVol->SetTranslation( origin ); |
---|
| 346 | } |
---|
| 347 | |
---|
| 348 | //------------------------------------------------------------------------ |
---|
| 349 | void |
---|
| 350 | G4ParameterisationBoxZ:: |
---|
| 351 | ComputeDimensions( G4Box& box, const G4int, |
---|
| 352 | const G4VPhysicalVolume* ) const |
---|
| 353 | { |
---|
| 354 | G4Box* msol = (G4Box*)(fmotherSolid); |
---|
| 355 | |
---|
| 356 | G4double pDx = msol->GetXHalfLength(); |
---|
| 357 | G4double pDy = msol->GetYHalfLength(); |
---|
| 358 | G4double pDz = fwidth/2.; |
---|
| 359 | |
---|
| 360 | box.SetXHalfLength( pDx ); |
---|
| 361 | box.SetYHalfLength( pDy ); |
---|
| 362 | box.SetZHalfLength( pDz ); |
---|
| 363 | |
---|
| 364 | #ifdef G4DIVDEBUG |
---|
| 365 | if( verbose >= 2 ) |
---|
| 366 | { |
---|
| 367 | G4cout << " G4ParameterisationBoxZ::ComputeDimensions()" << G4endl |
---|
| 368 | << " pDx: " << pDz << G4endl; |
---|
| 369 | box.DumpInfo(); |
---|
| 370 | } |
---|
| 371 | #endif |
---|
| 372 | } |
---|
| 373 | |
---|