Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:57:56

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // class G4AuxiliaryNavServices Inline implementation
0027 //
0028 // --------------------------------------------------------------------
0029 
0030 inline G4bool
0031 G4AuxiliaryNavServices::
0032 CheckPointOnSurface( const G4VSolid* sampleSolid, 
0033                      const G4ThreeVector& localPoint, 
0034                      const G4ThreeVector* globalDirection, 
0035                      const G4AffineTransform& sampleTransform,
0036                      const G4bool locatedOnEdge)
0037 {
0038   G4ThreeVector localDirection, sampleNormal;
0039   G4bool enter = false;
0040 
0041   EInside insideSolid = sampleSolid->Inside(localPoint); 
0042   if ( insideSolid!=kOutside ) 
0043   {
0044     G4bool checkDirection = locatedOnEdge && (globalDirection!=nullptr);
0045     if( (insideSolid==kSurface) && checkDirection)
0046     {
0047       // We are probably located on an edge.
0048       //
0049       localDirection = sampleTransform.TransformAxis(*globalDirection); 
0050 
0051       // Check whether we enter the volume
0052       // 
0053       sampleNormal = sampleSolid->SurfaceNormal(localPoint);
0054 
0055       G4double dotProd = sampleNormal.dot(localDirection);
0056       
0057 #ifdef G4DEBUG_AUX_NAVIGATION
0058       G4cout << " dir.norm= " << dotProd // sampleNormal.dot(localDirection) 
0059              << " localDirection= " << localDirection
0060              << " sampleNormal= " << sampleNormal;
0061       if( dotProd == 0.0 )
0062       {
0063         G4cout << " distanceToIn = " 
0064                << sampleSolid->DistanceToIn( localPoint, localDirection );
0065       }
0066 #endif
0067 
0068       if ( dotProd <= 0.0 )         
0069       {
0070         if( dotProd == 0.0 )
0071         {
0072           // We can't decide yet, let's make sure we're entering the solid.
0073           // If by a confusion we entered the next solid we find out now
0074           // whether to leave or to enter.
0075           // This happens when we're on the surface or edge shared by two
0076           // solids
0077           //
0078           G4double distanceToIn =
0079                    sampleSolid->DistanceToIn( localPoint, localDirection );
0080           if( distanceToIn != kInfinity )
0081           {
0082             enter = true;
0083           } 
0084         }
0085         else
0086         {
0087           enter = true;
0088         }
0089       }
0090     }
0091     else
0092     {
0093       enter = true;
0094     }
0095   }
0096 #ifdef G4DEBUG_AUX_NAVIGATION  
0097   G4cout << " enter = " << (enter ? "true" : "false" ) << G4endl;
0098 #endif
0099   
0100   return enter;
0101 }
0102 
0103 // --------------------------------------------------------------------
0104 
0105 inline G4bool
0106 G4AuxiliaryNavServices::
0107 CheckPointExiting( const G4VSolid* sampleSolid, 
0108                    const G4ThreeVector& localPoint, 
0109                    const G4ThreeVector* globalDirection, 
0110                    const G4AffineTransform& sampleTransform )
0111 {
0112   if( globalDirection == nullptr )  { return false; }
0113 
0114   G4ThreeVector localDirection, sampleNormal;
0115   G4bool exiting = false;
0116 
0117   EInside insideSolid = sampleSolid->Inside(localPoint); 
0118   if( insideSolid==kSurface )
0119   {
0120     localDirection = sampleTransform.TransformAxis(*globalDirection); 
0121 
0122     // Check whether we are exiting the volume
0123     // 
0124     sampleNormal = sampleSolid->SurfaceNormal(localPoint);
0125     if ( sampleNormal.dot(localDirection) >= 0 )
0126     {
0127       if( sampleNormal.dot(localDirection) == 0 )
0128       {
0129         // We can't decide yet, let's make sure we're entering the solid.
0130         // If by a confusion we entered the next solid we find out now
0131         // whether to leave or to exiting.
0132         // This happens when we're on the surface or edge shared by two
0133         // solids
0134         //
0135         G4double distanceToIn =
0136                  sampleSolid->DistanceToIn( localPoint, localDirection );
0137         if( distanceToIn != kInfinity )
0138         {
0139           exiting = true;
0140         } 
0141       }
0142       else
0143       {
0144         exiting = true;
0145       }
0146     }
0147   }
0148   return exiting;
0149 }