G4ParameterisationCons.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id: G4ParameterisationCons.cc 69784 2013-05-15 09:16:06Z gcosmo $
00028 //
00029 // class G4ParameterisationCons Implementation file
00030 //
00031 // 26.05.03 - P.Arce, Initial version
00032 // 08.04.04 - I.Hrivnacova, Implemented reflection
00033 // 21.04.10 - M.Asai, Added gaps
00034 // --------------------------------------------------------------------
00035 
00036 #include "G4ParameterisationCons.hh"
00037 
00038 #include <iomanip>
00039 #include "G4ThreeVector.hh"
00040 #include "G4RotationMatrix.hh"
00041 #include "G4VPhysicalVolume.hh"
00042 #include "G4LogicalVolume.hh"
00043 #include "G4ReflectedSolid.hh"
00044 #include "G4Cons.hh"
00045 
00046 //--------------------------------------------------------------------------
00047 G4VParameterisationCons::
00048 G4VParameterisationCons( EAxis axis, G4int nDiv, G4double width,
00049                         G4double offset, G4VSolid* msolid,
00050                         DivisionType divType )
00051   :  G4VDivisionParameterisation( axis, nDiv, width, offset, divType, msolid )
00052 {
00053   G4Cons* msol = (G4Cons*)(msolid);
00054   if (msolid->GetEntityType() == "G4ReflectedSolid")
00055   {
00056     // Get constituent solid  
00057     G4VSolid* mConstituentSolid 
00058        = ((G4ReflectedSolid*)msolid)->GetConstituentMovedSolid();
00059     msol = (G4Cons*)(mConstituentSolid);
00060   
00061     // Create a new solid with inversed parameters
00062     G4Cons* newSolid
00063       = new G4Cons(msol->GetName(),
00064                    msol->GetInnerRadiusPlusZ(), msol->GetOuterRadiusPlusZ(),
00065                    msol->GetInnerRadiusMinusZ(), msol->GetOuterRadiusMinusZ(),
00066                    msol->GetZHalfLength(),
00067                    msol->GetStartPhiAngle(), msol->GetDeltaPhiAngle());
00068     msol = newSolid;
00069     fmotherSolid = newSolid;
00070     fReflectedSolid = true;
00071     fDeleteSolid = true;
00072   }    
00073 }
00074 
00075 //------------------------------------------------------------------------
00076 G4VParameterisationCons::~G4VParameterisationCons()
00077 {
00078 }
00079 
00080 //--------------------------------------------------------------------------
00081 G4ParameterisationConsRho::
00082 G4ParameterisationConsRho( EAxis axis, G4int nDiv,
00083                            G4double width, G4double offset,
00084                            G4VSolid* msolid, DivisionType divType )
00085   :  G4VParameterisationCons( axis, nDiv, width, offset, msolid, divType )
00086 {
00087   CheckParametersValidity();
00088   SetType( "DivisionConsRho" );
00089 
00090   G4Cons* msol = (G4Cons*)(fmotherSolid);
00091   if( msol->GetInnerRadiusPlusZ() == 0. )
00092   {
00093     std::ostringstream message;
00094     message << "OuterRadiusMinusZ = 0" << G4endl 
00095             << "Width is calculated as that of OuterRadiusMinusZ !";
00096     G4Exception("G4ParameterisationConsRho::G4ParameterisationConsRho()",
00097                 "GeomDiv1001", JustWarning, message);
00098   } 
00099 
00100   if( divType == DivWIDTH )
00101   {
00102     fnDiv = CalculateNDiv( msol->GetOuterRadiusMinusZ()
00103                          - msol->GetInnerRadiusMinusZ(), width, offset );
00104   }
00105   else if( divType == DivNDIV )
00106   {
00107     G4Cons* mconsol = (G4Cons*)(msolid);
00108     fwidth = CalculateWidth( mconsol->GetOuterRadiusMinusZ()
00109                            - mconsol->GetInnerRadiusMinusZ(), nDiv, offset );
00110   }
00111 
00112 #ifdef G4DIVDEBUG
00113   if( verbose >= 1 )
00114   {
00115     G4cout << " G4ParameterisationConsRho - no divisions " << fnDiv << " = "
00116            << nDiv << G4endl
00117            << " Offset " << foffset << " = " << offset
00118            << " - Width " << fwidth << " = " << width << G4endl;
00119   }
00120 #endif
00121 }
00122 
00123 //--------------------------------------------------------------------------
00124 G4ParameterisationConsRho::~G4ParameterisationConsRho()
00125 {
00126 }
00127 
00128 //------------------------------------------------------------------------
00129 G4double G4ParameterisationConsRho::GetMaxParameter() const
00130 {
00131   G4Cons* msol = (G4Cons*)(fmotherSolid);
00132   return msol->GetOuterRadiusMinusZ() - msol->GetInnerRadiusMinusZ();
00133 }
00134 
00135 //--------------------------------------------------------------------------
00136 void
00137 G4ParameterisationConsRho::
00138 ComputeTransformation( const G4int, G4VPhysicalVolume *physVol ) const
00139 {
00140   //----- translation 
00141   G4ThreeVector origin(0.,0.,0.); 
00142   //----- set translation 
00143   physVol->SetTranslation( origin );
00144 
00145   //----- calculate rotation matrix: unit
00146 
00147 #ifdef G4DIVDEBUG
00148   if( verbose >= 2 )
00149   {
00150     G4cout <<  " G4ParameterisationConsRho " << G4endl
00151            << " Offset: " << foffset
00152            << " - Width: " << fwidth << G4endl;
00153   }
00154 #endif
00155 
00156   ChangeRotMatrix( physVol );
00157 
00158 #ifdef G4DIVDEBUG
00159   if( verbose >= 2 )
00160   {
00161     G4cout << std::setprecision(8) << " G4ParameterisationConsRho" << G4endl
00162            << " Position: " << origin << " - Width: " << fwidth
00163            << " - Axis: " << faxis  << G4endl;
00164   }
00165 #endif
00166 }
00167 
00168 //--------------------------------------------------------------------------
00169 void
00170 G4ParameterisationConsRho::
00171 ComputeDimensions( G4Cons& cons, const G4int copyNo,
00172                    const G4VPhysicalVolume* ) const
00173 {
00174   G4Cons* msol = (G4Cons*)(fmotherSolid);
00175 
00176   G4double pRMin1 = msol->GetInnerRadiusMinusZ() + foffset + fwidth * copyNo;
00177   G4double pRMax1 = msol->GetInnerRadiusMinusZ() + foffset + fwidth * (copyNo+1);
00178  
00179   //width at Z Plus
00180   //- G4double fwidthPlus =
00181   //   fwidth * ( msol->GetOuterRadiusPlusZ()/ msol->GetInnerRadiusPlusZ())
00182   //-         / ( msol->GetOuterRadiusMinusZ() - msol->GetInnerRadiusMinusZ());
00183   G4double fwidthPlus = CalculateWidth( msol->GetOuterRadiusPlusZ()
00184                            - msol->GetInnerRadiusPlusZ(), fnDiv, foffset );
00185   G4double pRMin2 = msol->GetInnerRadiusPlusZ()
00186                   + foffset + fwidthPlus * copyNo;
00187   G4double pRMax2 = msol->GetInnerRadiusPlusZ()
00188                   + foffset + fwidthPlus * (copyNo+1);
00189   G4double pDz = msol->GetZHalfLength();
00190 
00191   G4double d_half_gap = fhgap * pRMax2 / pRMax1;
00192   //- already rotated  double pSR = foffset + copyNo*fwidth;
00193   G4double pSPhi = msol->GetStartPhiAngle();
00194   G4double pDPhi = msol->GetDeltaPhiAngle();;
00195 
00196   cons.SetInnerRadiusMinusZ( pRMin1 + fhgap );
00197   cons.SetOuterRadiusMinusZ( pRMax1 - fhgap );
00198   cons.SetInnerRadiusPlusZ( pRMin2 + d_half_gap );
00199   cons.SetOuterRadiusPlusZ( pRMax2 - d_half_gap );
00200   cons.SetZHalfLength( pDz );
00201   cons.SetStartPhiAngle( pSPhi, false );
00202   cons.SetDeltaPhiAngle( pDPhi );
00203 
00204 #ifdef G4DIVDEBUG
00205   if( verbose >= 2 )
00206   {
00207     G4cout << " G4ParameterisationConsRho::ComputeDimensions()" << G4endl
00208            << " pRMin: " << pRMin1 << " - pRMax: " << pRMax1 << G4endl;
00209     if( verbose >= 4 ) cons.DumpInfo();
00210   }
00211 #endif
00212 }
00213 
00214 //--------------------------------------------------------------------------
00215 G4ParameterisationConsPhi::
00216 G4ParameterisationConsPhi( EAxis axis, G4int nDiv,
00217                            G4double width, G4double offset,
00218                            G4VSolid* msolid, DivisionType divType )
00219   :  G4VParameterisationCons( axis, nDiv, width, offset, msolid, divType )
00220 { 
00221   CheckParametersValidity();
00222   SetType( "DivisionConsPhi" );
00223 
00224   G4Cons* msol = (G4Cons*)(fmotherSolid);
00225   if( divType == DivWIDTH )
00226   {
00227     fnDiv = CalculateNDiv( msol->GetDeltaPhiAngle(), width, offset );
00228   }
00229   else if( divType == DivNDIV )
00230   {
00231     fwidth = CalculateWidth( msol->GetDeltaPhiAngle(), nDiv, offset );
00232   }
00233 
00234 #ifdef G4DIVDEBUG
00235   if( verbose >= 1 )
00236   {
00237     G4cout << " G4ParameterisationConsPhi no divisions " << fnDiv << " = "
00238            << nDiv << G4endl
00239            << " Offset " << foffset << " = " << offset << G4endl
00240            << " Width " << fwidth << " = " << width << G4endl;
00241   }
00242 #endif
00243 }
00244 
00245 //--------------------------------------------------------------------------
00246 G4ParameterisationConsPhi::~G4ParameterisationConsPhi()
00247 {
00248 }
00249 
00250 //------------------------------------------------------------------------
00251 G4double G4ParameterisationConsPhi::GetMaxParameter() const
00252 {
00253   G4Cons* msol = (G4Cons*)(fmotherSolid);
00254   return msol->GetDeltaPhiAngle();
00255 }
00256 
00257 //--------------------------------------------------------------------------
00258 void
00259 G4ParameterisationConsPhi::
00260 ComputeTransformation( const G4int copyNo, G4VPhysicalVolume *physVol ) const
00261 {
00262   //----- translation 
00263   G4ThreeVector origin(0.,0.,0.); 
00264   //----- set translation 
00265   physVol->SetTranslation( origin );
00266 
00267   //----- calculate rotation matrix (so that all volumes point to the centre)
00268   G4double posi = foffset  + copyNo*fwidth;
00269 
00270 #ifdef G4DIVDEBUG
00271   if( verbose >= 2 )
00272   {
00273     G4cout << " G4ParameterisationConsPhi - position: " << posi/deg << G4endl
00274            << " Origin: " << origin << " copyNo: " << copyNo
00275            << " - foffset: " << foffset/deg
00276            << " - fwidth: " << fwidth/deg << G4endl
00277            << " - Axis: " << faxis << G4endl;
00278   }
00279 #endif
00280 
00281   ChangeRotMatrix( physVol, -posi );
00282 }
00283 
00284 //--------------------------------------------------------------------------
00285 void
00286 G4ParameterisationConsPhi::
00287 ComputeDimensions( G4Cons& cons, const G4int,
00288                    const G4VPhysicalVolume* ) const
00289 {
00290   G4Cons* msol = (G4Cons*)(fmotherSolid);
00291 
00292   G4double pRMin1 = msol->GetInnerRadiusMinusZ();
00293   G4double pRMax1 = msol->GetOuterRadiusMinusZ();
00294   G4double pRMin2 = msol->GetInnerRadiusPlusZ();
00295   G4double pRMax2 = msol->GetOuterRadiusPlusZ();
00296   G4double pDz = msol->GetZHalfLength();
00297 
00298   //- already rotated  double pSPhi = foffset + copyNo*fwidth;
00299   G4double pSPhi = foffset + msol->GetStartPhiAngle() + fhgap;
00300   G4double pDPhi = fwidth - 2.*fhgap;
00301 
00302   cons.SetInnerRadiusMinusZ( pRMin1 );
00303   cons.SetOuterRadiusMinusZ( pRMax1 );
00304   cons.SetInnerRadiusPlusZ( pRMin2 );
00305   cons.SetOuterRadiusPlusZ( pRMax2 );
00306   cons.SetZHalfLength( pDz );
00307   cons.SetStartPhiAngle( pSPhi, false );
00308   cons.SetDeltaPhiAngle( pDPhi );
00309 
00310 #ifdef G4DIVDEBUG
00311   if( verbose >= 2 )
00312   {
00313     G4cout << " G4ParameterisationConsPhi::ComputeDimensions" << G4endl
00314            << " pSPhi: " << pSPhi << " - pDPhi: " << pDPhi << G4endl;
00315     if( verbose >= 4 ) cons.DumpInfo();
00316   }
00317 #endif
00318 }
00319 
00320 //--------------------------------------------------------------------------
00321 G4ParameterisationConsZ::
00322 G4ParameterisationConsZ( EAxis axis, G4int nDiv,
00323                          G4double width, G4double offset,
00324                          G4VSolid* msolid, DivisionType divType )
00325   :  G4VParameterisationCons( axis, nDiv, width, offset, msolid, divType )
00326 { 
00327   CheckParametersValidity();
00328   SetType( "DivisionConsZ" );
00329 
00330   G4Cons* msol = (G4Cons*)(fmotherSolid);
00331   if( divType == DivWIDTH )
00332   {
00333     fnDiv = CalculateNDiv( 2*msol->GetZHalfLength(), width, offset );
00334   }
00335   else if( divType == DivNDIV )
00336   {
00337     fwidth = CalculateWidth( 2*msol->GetZHalfLength(), nDiv, offset );
00338   }
00339 
00340 #ifdef G4DIVDEBUG
00341   if( verbose >= 1 )
00342   {
00343     G4cout << " G4ParameterisationConsZ: # divisions " << fnDiv << " = "
00344            << nDiv << G4endl
00345            << " Offset " << foffset << " = " << offset << G4endl
00346            << " Width " << fwidth << " = " << width << G4endl
00347            << " - Axis: " << faxis << G4endl;
00348   }
00349 #endif
00350 }
00351 
00352 //--------------------------------------------------------------------------
00353 G4ParameterisationConsZ::~G4ParameterisationConsZ()
00354 {
00355 }
00356 
00357 //------------------------------------------------------------------------
00358 G4double G4ParameterisationConsZ::GetMaxParameter() const
00359 {
00360   G4Cons* msol = (G4Cons*)(fmotherSolid);
00361   return 2*msol->GetZHalfLength();
00362 }
00363 
00364 //--------------------------------------------------------------------------
00365 void
00366 G4ParameterisationConsZ::
00367 ComputeTransformation( const G4int copyNo, G4VPhysicalVolume* physVol ) const
00368 {
00369   //----- set translation: along Z axis
00370   G4Cons* motherCons = (G4Cons*)(GetMotherSolid());
00371   G4double posi = - motherCons->GetZHalfLength() + OffsetZ()
00372                   + fwidth/2 + copyNo*fwidth;
00373   G4ThreeVector origin(0.,0.,posi); 
00374   physVol->SetTranslation( origin );
00375 
00376   //----- calculate rotation matrix: unit
00377 
00378 #ifdef G4DIVDEBUG
00379   if( verbose >= 2 )
00380   {
00381     G4cout << " G4ParameterisationConsZ::ComputeTransformation()" << G4endl
00382            << " Origin: " << origin << " - copyNo: " << copyNo << G4endl
00383            << " foffset: " << foffset << " - fwidth: " << fwidth
00384            << G4endl;
00385   }
00386 #endif
00387 
00388   ChangeRotMatrix( physVol );
00389 }
00390 
00391 
00392 //--------------------------------------------------------------------------
00393 void
00394 G4ParameterisationConsZ::
00395 ComputeDimensions( G4Cons& cons, const G4int copyNo,
00396                    const G4VPhysicalVolume* ) const
00397 {
00398   G4Cons* msol = (G4Cons*)(fmotherSolid);
00399 
00400   G4double mHalfLength = msol->GetZHalfLength() - fhgap;
00401   G4double aRInner = (msol->GetInnerRadiusPlusZ()
00402                    - msol->GetInnerRadiusMinusZ()) / (2*mHalfLength);
00403   G4double bRInner = (msol->GetInnerRadiusPlusZ()
00404                    + msol->GetInnerRadiusMinusZ()) / 2;
00405   G4double aROuter = (msol->GetOuterRadiusPlusZ()
00406                    - msol->GetOuterRadiusMinusZ()) / (2*mHalfLength);
00407   G4double bROuter = (msol->GetOuterRadiusPlusZ()
00408                    + msol->GetOuterRadiusMinusZ()) / 2;
00409   G4double xMinusZ = -mHalfLength + OffsetZ() + fwidth*copyNo + fhgap;
00410   G4double xPlusZ  = -mHalfLength + OffsetZ() + fwidth*(copyNo+1) - fhgap;
00411   cons.SetInnerRadiusMinusZ( aRInner * xMinusZ + bRInner );
00412   cons.SetOuterRadiusMinusZ( aROuter * xMinusZ + bROuter );
00413   cons.SetInnerRadiusPlusZ( aRInner * xPlusZ + bRInner );
00414   cons.SetOuterRadiusPlusZ( aROuter * xPlusZ + bROuter );
00415  
00416   G4double pDz = fwidth / 2. - fhgap;
00417   G4double pSPhi = msol->GetStartPhiAngle();
00418   G4double pDPhi = msol->GetDeltaPhiAngle();
00419 
00420   cons.SetZHalfLength( pDz );
00421   cons.SetStartPhiAngle( pSPhi, false );
00422   cons.SetDeltaPhiAngle( pDPhi );
00423 
00424 #ifdef G4DIVDEBUG
00425   if( verbose >= 2 )
00426   {
00427     G4cout << " G4ParameterisationConsZ::ComputeDimensions()" << G4endl
00428            << " pDz: " << pDz << G4endl;
00429     if( verbose >= 4 ) cons.DumpInfo();
00430   }
00431 #endif
00432 
00433 }

Generated on Mon May 27 17:49:14 2013 for Geant4 by  doxygen 1.4.7