G4ReplicaNavigation.icc

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$
00028 //
00029 // 
00030 // class G4ReplicaNavigation Inline implementation
00031 //
00032 // --------------------------------------------------------------------
00033 
00034 // ********************************************************************
00035 // VoxelLocate
00036 // ********************************************************************
00037 //
00038 inline
00039 G4int
00040 G4ReplicaNavigation::VoxelLocate( const G4SmartVoxelHeader* pHead,
00041                                   const G4ThreeVector& localPoint,
00042                                   const G4int blocked ) const
00043 {
00044   EAxis targetHeaderAxis;
00045   G4double coord=0.;
00046   G4double targetHeaderMin, targetHeaderMax;
00047   G4double targetHeaderNodeWidth, targetNodePos;
00048   G4int targetHeaderNoSlices, targetNodeNo;
00049   
00050   targetHeaderAxis = pHead->GetAxis();
00051   targetHeaderNoSlices = pHead->GetNoSlices();
00052   targetHeaderMin = pHead->GetMinExtent();
00053   targetHeaderMax = pHead->GetMaxExtent();
00054   targetHeaderNodeWidth = ( targetHeaderMax-targetHeaderMin )
00055                           / targetHeaderNoSlices;
00056 
00057   switch (targetHeaderAxis)
00058   {
00059     case kXAxis:
00060       coord = localPoint.x();
00061       break;
00062     case kYAxis:
00063       coord = localPoint.y();
00064       break;
00065     case kZAxis:
00066       coord = localPoint.z();
00067       break;
00068     case kRho:
00069       coord = localPoint.perp();
00070       break;
00071     case kPhi:
00072       coord = localPoint.phi();
00073       if ( (coord<0) && (coord<targetHeaderMin) ) coord += CLHEP::twopi;
00074       break;
00075     case kRadial3D:
00076     default:
00077       break;
00078   }
00079   targetNodePos = (coord-targetHeaderMin)/targetHeaderNodeWidth;
00080   targetNodeNo = (G4int) targetNodePos;
00081 
00082   if ( targetNodeNo==blocked )
00083   {
00084     targetNodeNo = (targetNodePos-targetNodeNo<0.5)
00085                    ? targetNodeNo-1 : targetNodeNo+1;
00086       
00087     // Do not need to check range: If on outer edge of zeroth
00088     // voxel & it is blocked => should have exited mother
00089     // (or similar)       P.Kent
00090     // assert(targetNodeNo>=0&&targetNodeNo<targetHeaderNoSlices);
00091 
00092     if( (targetNodeNo<0) || (targetNodeNo>=targetHeaderNoSlices) )
00093     {
00094 
00095 #ifdef G4DEBUG_NAVIGATION
00096       G4cerr << " WARNING: assert in G4ReplicaNavigation::VoxelLocate " 
00097              << " has failed : " << G4endl
00098              << " (targetNodeNo>=0&&targetNodeNo<targetHeaderNoSlices) " 
00099              << " targetNodeNo= " << targetNodeNo 
00100              << " Number of Slices =  " << targetHeaderNoSlices << G4endl;
00101 #endif
00102       // In the case of rotational symmetry and an extent over the
00103       // whole 360 degrees, the above is not true and you can go from
00104       // the last voxel to the zeroth and vice versa
00105       //                                        H.Boie, April 30, 2001  
00106       if ( (targetHeaderAxis==kPhi)
00107            && (targetHeaderMin==0) && (targetHeaderMax==CLHEP::twopi) )
00108       {
00109         if ( targetNodeNo<0 ) 
00110           targetNodeNo = targetHeaderNoSlices-1;
00111         else if ( targetNodeNo>=targetHeaderNoSlices )
00112           targetNodeNo = 0;
00113       }
00114       else 
00115       {
00116         if( targetNodeNo<0 )
00117           targetNodeNo = 0;
00118         else if ( targetNodeNo>=targetHeaderNoSlices )
00119           targetNodeNo = targetHeaderNoSlices-1;
00120       }
00121     }
00122   }
00123   else
00124   {
00125     // Rounding protection
00126     //
00127     if ( targetNodeNo<0 )
00128     {
00129       targetNodeNo = 0;
00130     }
00131     else if ( targetNodeNo>=targetHeaderNoSlices )
00132     {
00133       targetNodeNo = targetHeaderNoSlices-1;
00134     }
00135   }
00136   return targetNodeNo;
00137 }
00138 
00139 // ********************************************************************
00140 // LevelLocate
00141 // ********************************************************************
00142 //
00143 inline
00144 G4bool
00145 G4ReplicaNavigation::LevelLocate( G4NavigationHistory& history,
00146                             const G4VPhysicalVolume* blockedVol,
00147                             const G4int              blockedNum,
00148                             const G4ThreeVector&,     // globalPoint
00149                             const G4ThreeVector*,     // globalDirection
00150                             const G4bool,             // pLocatedOnEdge
00151                                   G4ThreeVector& localPoint )
00152 {
00153   G4VPhysicalVolume *motherPhysical, *pPhysical;
00154   G4LogicalVolume *motherLogical;
00155   G4SmartVoxelHeader *motherVoxelHeader;
00156   G4int nodeNo;
00157 
00158   motherPhysical = history.GetTopVolume();
00159   motherLogical = motherPhysical->GetLogicalVolume();
00160   motherVoxelHeader = motherLogical->GetVoxelHeader();
00161   pPhysical = motherLogical->GetDaughter(0);
00162 
00163   if ( blockedVol==pPhysical )
00164   {
00165     nodeNo = VoxelLocate(motherVoxelHeader, localPoint, blockedNum);
00166   }
00167   else
00168   {
00169     nodeNo = VoxelLocate(motherVoxelHeader, localPoint);
00170   }
00171 
00172   ComputeTransformation(nodeNo, pPhysical, localPoint);
00173   history.NewLevel(pPhysical, kReplica, nodeNo);
00174   pPhysical->SetCopyNo(nodeNo); 
00175 
00176   return true;
00177 }
00178 
00179 // ********************************************************************
00180 // SetPhiTransformation
00181 // ********************************************************************
00182 //
00183 inline
00184 void
00185 G4ReplicaNavigation::SetPhiTransformation( const G4double ang,
00186                                                  G4VPhysicalVolume* pVol ) const
00187 {
00188   G4RotationMatrix rm;
00189   rm.rotateZ(ang);
00190   if ( pVol )
00191     *pVol->GetRotation() = rm;
00192 }
00193 
00194 // ********************************************************************
00195 // GetVerboseLevel
00196 // ********************************************************************
00197 //
00198 inline
00199 G4int G4ReplicaNavigation::GetVerboseLevel() const
00200 {
00201   return fVerbose;
00202 }
00203 
00204 // ********************************************************************
00205 // SetVerboseLevel
00206 // ********************************************************************
00207 //
00208 inline
00209 void  G4ReplicaNavigation::SetVerboseLevel(G4int level)
00210 {
00211   fVerbose = level;
00212 }
00213 
00214 // ********************************************************************
00215 // CheckMode
00216 // ********************************************************************
00217 //
00218 inline
00219 void  G4ReplicaNavigation::CheckMode(G4bool mode)
00220 {
00221   fCheck = mode;
00222 }

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