G4ParameterisationTubs.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: G4ParameterisationTubs.cc 69784 2013-05-15 09:16:06Z gcosmo $
00028 //
00029 // class G4ParameterisationTubs 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 "G4ParameterisationTubs.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 "G4Tubs.hh"
00045 
00046 //--------------------------------------------------------------------------
00047 G4VParameterisationTubs::
00048 G4VParameterisationTubs( EAxis axis, G4int nDiv, G4double width,
00049                         G4double offset, G4VSolid* msolid,
00050                         DivisionType divType )
00051   :  G4VDivisionParameterisation( axis, nDiv, width, offset, divType, msolid )
00052 {
00053   G4Tubs* msol = (G4Tubs*)(msolid);
00054   if (msolid->GetEntityType() == "G4ReflectedSolid")
00055   {
00056     //----- get constituent solid  
00057     G4VSolid* mConstituentSolid 
00058        = ((G4ReflectedSolid*)msolid)->GetConstituentMovedSolid();
00059     msol = (G4Tubs*)(mConstituentSolid);
00060     fmotherSolid = msol;
00061     fReflectedSolid = true;
00062   }    
00063 }
00064 
00065 //------------------------------------------------------------------------
00066 G4VParameterisationTubs::~G4VParameterisationTubs()
00067 {
00068 }
00069 
00070 //--------------------------------------------------------------------------
00071 G4ParameterisationTubsRho::
00072 G4ParameterisationTubsRho( EAxis axis, G4int nDiv,
00073                            G4double width, G4double offset,
00074                            G4VSolid* msolid, DivisionType divType )
00075   :  G4VParameterisationTubs( axis, nDiv, width, offset, msolid, divType )
00076 {
00077   CheckParametersValidity();
00078   SetType( "DivisionTubsRho" );
00079 
00080   G4Tubs* msol = (G4Tubs*)(fmotherSolid);
00081   if( divType == DivWIDTH )
00082   {
00083     fnDiv = CalculateNDiv( msol->GetOuterRadius() - msol->GetInnerRadius(),
00084                            width, offset );
00085   }
00086   else if( divType == DivNDIV )
00087   {
00088     fwidth = CalculateWidth( msol->GetOuterRadius() - msol->GetInnerRadius(),
00089                              nDiv, offset );
00090   }
00091 
00092 #ifdef G4DIVDEBUG
00093   if( verbose >= 1 )
00094   {
00095     G4cout << " G4ParameterisationTubsRho - no divisions " << fnDiv << " = "
00096            << nDiv << G4endl
00097            << " Offset " << foffset << " = " << offset << G4endl
00098            << " Width " << fwidth << " = " << width << G4endl
00099            << " DivType " << divType << G4endl;
00100   }
00101 #endif
00102 }
00103 
00104 //--------------------------------------------------------------------------
00105 G4ParameterisationTubsRho::~G4ParameterisationTubsRho()
00106 {
00107 }
00108 
00109 //------------------------------------------------------------------------
00110 G4double G4ParameterisationTubsRho::GetMaxParameter() const
00111 {
00112   G4Tubs* msol = (G4Tubs*)(fmotherSolid);
00113   return msol->GetOuterRadius() - msol->GetInnerRadius();
00114 }
00115 
00116 
00117 //--------------------------------------------------------------------------
00118 void
00119 G4ParameterisationTubsRho::
00120 ComputeTransformation(const G4int, G4VPhysicalVolume* physVol) const
00121 {
00122   //----- translation 
00123   G4ThreeVector origin(0.,0.,0.); 
00124   //----- set translation 
00125   physVol->SetTranslation( origin );
00126 
00127   //----- calculate rotation matrix: unit
00128 
00129 #ifdef G4DIVDEBUG
00130   if( verbose >= 2 )
00131   {
00132     G4cout << " G4ParameterisationTubsRho " << G4endl
00133            << " Offset: " << foffset/deg
00134            << " - Width: " << fwidth/deg << G4endl;
00135   }
00136 #endif
00137 
00138   ChangeRotMatrix( physVol );
00139 
00140 #ifdef G4DIVDEBUG
00141   if( verbose >= 2 )
00142   {
00143     G4cout << std::setprecision(8) << " G4ParameterisationTubsRho " << G4endl
00144            << " Position: " << origin << " - Width: " << fwidth
00145            << " - Axis " << faxis  << G4endl;
00146   }
00147 #endif
00148 }
00149 
00150 //--------------------------------------------------------------------------
00151 void
00152 G4ParameterisationTubsRho::
00153 ComputeDimensions( G4Tubs& tubs, const G4int copyNo,
00154                    const G4VPhysicalVolume* ) const
00155 {
00156   G4Tubs* msol = (G4Tubs*)(fmotherSolid);
00157 
00158   G4double pRMin = msol->GetInnerRadius() + foffset + fwidth * copyNo + fhgap;
00159   G4double pRMax = msol->GetInnerRadius() + foffset + fwidth * (copyNo+1) - fhgap;
00160   G4double pDz = msol->GetZHalfLength();
00161   //- already rotated  G4double pSR = foffset + copyNo*fwidth;
00162   G4double pSPhi = msol->GetStartPhiAngle();
00163   G4double pDPhi = msol->GetDeltaPhiAngle();;
00164 
00165   tubs.SetInnerRadius( pRMin );
00166   tubs.SetOuterRadius( pRMax );
00167   tubs.SetZHalfLength( pDz );
00168   tubs.SetStartPhiAngle( pSPhi, false );
00169   tubs.SetDeltaPhiAngle( pDPhi );
00170 
00171 #ifdef G4DIVDEBUG
00172   if( verbose >= 2 )
00173   {
00174     G4cout << " G4ParameterisationTubsRho::ComputeDimensions()" << G4endl
00175            << " pRMin: " << pRMin << " - pRMax: " << pRMax << G4endl;
00176     tubs.DumpInfo();
00177   }
00178 #endif
00179 }
00180 
00181 //--------------------------------------------------------------------------
00182 G4ParameterisationTubsPhi::
00183 G4ParameterisationTubsPhi( EAxis axis, G4int nDiv,
00184                            G4double width, G4double offset,
00185                            G4VSolid* msolid, DivisionType divType )
00186   :  G4VParameterisationTubs( axis, nDiv, width, offset, msolid, divType )
00187 { 
00188   CheckParametersValidity();
00189   SetType( "DivisionTubsPhi" );
00190 
00191   G4Tubs* msol = (G4Tubs*)(fmotherSolid);
00192   if( divType == DivWIDTH )
00193   {
00194     fnDiv = CalculateNDiv( msol->GetDeltaPhiAngle(), width, offset );
00195   }
00196   else if( divType == DivNDIV )
00197   {
00198     fwidth = CalculateWidth( msol->GetDeltaPhiAngle(), nDiv, offset );
00199   }
00200 
00201 #ifdef G4DIVDEBUG
00202   if( verbose >= 1 )
00203   {
00204     G4cout << " G4ParameterisationTubsPhi no divisions " << fnDiv << " = "
00205            << nDiv << G4endl
00206            << " Offset " << foffset << " = " << offset << G4endl
00207            << " Width " << fwidth << " = " << width << G4endl;
00208   }
00209 #endif
00210 }
00211 
00212 //--------------------------------------------------------------------------
00213 G4ParameterisationTubsPhi::~G4ParameterisationTubsPhi()
00214 {
00215 }
00216 
00217 //------------------------------------------------------------------------
00218 G4double G4ParameterisationTubsPhi::GetMaxParameter() const
00219 {
00220   G4Tubs* msol = (G4Tubs*)(fmotherSolid);
00221   return msol->GetDeltaPhiAngle();
00222 }
00223 
00224 //--------------------------------------------------------------------------
00225 void
00226 G4ParameterisationTubsPhi::
00227 ComputeTransformation(const G4int copyNo, G4VPhysicalVolume *physVol) const
00228 {
00229   //----- translation 
00230   G4ThreeVector origin(0.,0.,0.); 
00231   //----- set translation 
00232   physVol->SetTranslation( origin );
00233 
00234   //----- calculate rotation matrix (so that all volumes point to the centre)
00235   G4double posi = foffset  + copyNo*fwidth;
00236 
00237 #ifdef G4DIVDEBUG
00238   if( verbose >= 2 )
00239   {
00240     G4cout << " G4ParameterisationTubsPhi - position: " << posi/deg << G4endl
00241            << " copyNo: " << copyNo << " - foffset: " << foffset/deg
00242            << " - fwidth: " << fwidth/deg << G4endl;
00243   }
00244 #endif
00245 
00246   ChangeRotMatrix( physVol, -posi );
00247 
00248 #ifdef G4DIVDEBUG
00249   if( verbose >= 2 )
00250   {
00251     G4cout << std::setprecision(8) << " G4ParameterisationTubsPhi " << copyNo
00252            << G4endl
00253            << " Position: " << origin << " - Width: " << fwidth
00254            << " - Axis: " << faxis  << G4endl;
00255   }
00256 #endif
00257 }
00258 
00259 //--------------------------------------------------------------------------
00260 void
00261 G4ParameterisationTubsPhi::
00262 ComputeDimensions( G4Tubs& tubs, const G4int,
00263                    const G4VPhysicalVolume* ) const
00264 {
00265   G4Tubs* msol = (G4Tubs*)(fmotherSolid);
00266 
00267   G4double pRMin = msol->GetInnerRadius();
00268   G4double pRMax = msol->GetOuterRadius();
00269   G4double pDz = msol->GetZHalfLength();
00270   //----- already rotated in 'ComputeTransformation'
00271   G4double pSPhi = msol->GetStartPhiAngle() + fhgap;
00272   G4double pDPhi = fwidth - 2.*fhgap;
00273 
00274   tubs.SetInnerRadius( pRMin );
00275   tubs.SetOuterRadius( pRMax );
00276   tubs.SetZHalfLength( pDz );
00277   tubs.SetStartPhiAngle( pSPhi, false );
00278   tubs.SetDeltaPhiAngle( pDPhi );
00279 
00280 #ifdef G4DIVDEBUG
00281   if( verbose >= 2 )
00282   {
00283     G4cout << " G4ParameterisationTubsPhi::ComputeDimensions" << G4endl
00284            << " pSPhi: " << pSPhi << " - pDPhi: " << pDPhi << G4endl;
00285     tubs.DumpInfo();
00286   }
00287 #endif
00288 }
00289 
00290 //--------------------------------------------------------------------------
00291 G4ParameterisationTubsZ::
00292 G4ParameterisationTubsZ( EAxis axis, G4int nDiv,
00293                          G4double width, G4double offset,
00294                          G4VSolid* msolid, DivisionType divType )
00295   : G4VParameterisationTubs( axis, nDiv, width, offset, msolid, divType )
00296 { 
00297   CheckParametersValidity();
00298   SetType( "DivisionTubsZ" );
00299 
00300   G4Tubs* msol = (G4Tubs*)(fmotherSolid);
00301   if( divType == DivWIDTH )
00302   {
00303     fnDiv = CalculateNDiv( 2*msol->GetZHalfLength(), width, offset );
00304   }
00305   else if( divType == DivNDIV )
00306   {
00307     fwidth = CalculateWidth( 2*msol->GetZHalfLength(), nDiv, offset );
00308   }
00309 
00310 #ifdef G4DIVDEBUG
00311   if( verbose >= 1 )
00312   {
00313     G4cout << " G4ParameterisationTubsZ: # divisions " << fnDiv << " = "
00314            << nDiv << G4endl
00315            << " Offset " << foffset << " = " << offset << G4endl
00316            << " Width " << fwidth << " = " << width << G4endl;
00317   }
00318 #endif
00319 }
00320 
00321 //--------------------------------------------------------------------------
00322 G4ParameterisationTubsZ::~G4ParameterisationTubsZ()
00323 {
00324 }
00325 
00326 //------------------------------------------------------------------------
00327 G4double G4ParameterisationTubsZ::GetMaxParameter() const
00328 {
00329   G4Tubs* msol = (G4Tubs*)(fmotherSolid);
00330   return 2*msol->GetZHalfLength();
00331 }
00332 
00333 //--------------------------------------------------------------------------
00334 void
00335 G4ParameterisationTubsZ::
00336 ComputeTransformation(const G4int copyNo, G4VPhysicalVolume *physVol) const
00337 {
00338   //----- set translation: along Z axis
00339   G4Tubs* motherTubs = (G4Tubs*)(fmotherSolid);
00340   G4double posi = - motherTubs->GetZHalfLength() + OffsetZ() 
00341                   + fwidth/2 + copyNo*fwidth;
00342   G4ThreeVector origin(0.,0.,posi); 
00343   physVol->SetTranslation( origin );
00344 
00345   //----- calculate rotation matrix: unit
00346 
00347 #ifdef G4DIVDEBUG
00348   if( verbose >= 2 )
00349   {
00350     G4cout << " G4ParameterisationTubsZ::ComputeTransformation()" << G4endl
00351            << " Position: " << posi << " - copyNo: " << copyNo << G4endl
00352            << " foffset " << foffset/deg << " - fwidth " << fwidth/deg
00353            << G4endl;
00354   }
00355 #endif
00356 
00357   ChangeRotMatrix( physVol );
00358 
00359 #ifdef G4DIVDEBUG
00360   if( verbose >= 2 )
00361   {
00362     G4cout << std::setprecision(8) << " G4ParameterisationTubsZ " << copyNo
00363            << G4endl
00364            << " Position: " << origin << " - Width: " << fwidth
00365            << " - Axis: " << faxis  << G4endl; 
00366   }
00367 #endif
00368 }
00369 
00370 //--------------------------------------------------------------------------
00371 void
00372 G4ParameterisationTubsZ::
00373 ComputeDimensions( G4Tubs& tubs, const G4int,
00374                    const G4VPhysicalVolume* ) const
00375 {
00376   G4Tubs* msol = (G4Tubs*)(fmotherSolid);
00377 
00378   G4double pRMin = msol->GetInnerRadius();
00379   G4double pRMax = msol->GetOuterRadius();
00380   //  G4double pDz = msol->GetZHalfLength() / GetNoDiv();
00381   G4double pDz = fwidth/2. - fhgap;
00382   G4double pSPhi = msol->GetStartPhiAngle();
00383   G4double pDPhi = msol->GetDeltaPhiAngle();
00384 
00385   tubs.SetInnerRadius( pRMin );
00386   tubs.SetOuterRadius( pRMax );
00387   tubs.SetZHalfLength( pDz );
00388   tubs.SetStartPhiAngle( pSPhi, false );
00389   tubs.SetDeltaPhiAngle( pDPhi );
00390 
00391 #ifdef G4DIVDEBUG
00392   if( verbose >= 2 )
00393   {
00394     G4cout << " G4ParameterisationTubsZ::ComputeDimensions()" << G4endl
00395            << " pDz: " << pDz << G4endl;
00396     tubs.DumpInfo();
00397   }
00398 #endif
00399 }

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