Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:45

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 // G4NormalNavigation Inline Implementation
0027 //
0028 // --------------------------------------------------------------------
0029 
0030 // ********************************************************************
0031 // LevelLocate
0032 // ********************************************************************
0033 //
0034 inline
0035 G4bool
0036 G4NormalNavigation::LevelLocate( G4NavigationHistory& history,
0037                            const G4VPhysicalVolume* blockedVol,
0038                            const G4int,
0039                            const G4ThreeVector& globalPoint,
0040                            const G4ThreeVector* globalDirection,
0041                            const G4bool  pLocatedOnEdge, 
0042                                  G4ThreeVector &localPoint )
0043 {
0044   G4VPhysicalVolume *targetPhysical, *samplePhysical;
0045   G4LogicalVolume *targetLogical;
0046   G4VSolid *sampleSolid;
0047   G4ThreeVector samplePoint;
0048   G4int targetNoDaughters;
0049   
0050   targetPhysical = history.GetTopVolume();
0051   targetLogical = targetPhysical->GetLogicalVolume();
0052   targetNoDaughters = G4int(targetLogical->GetNoDaughters());
0053   
0054   G4bool found = false;
0055 
0056   if ( targetNoDaughters!=0 )
0057   {
0058     //
0059     // Search daughters in volume
0060     //
0061     for ( auto sampleNo=targetNoDaughters-1; sampleNo>=0; sampleNo-- )
0062     {
0063       samplePhysical = targetLogical->GetDaughter(sampleNo);
0064       if ( samplePhysical!=blockedVol )
0065       {
0066         // Setup history
0067         //
0068         history.NewLevel(samplePhysical, kNormal, samplePhysical->GetCopyNo());
0069         sampleSolid = samplePhysical->GetLogicalVolume()->GetSolid();
0070         samplePoint = history.GetTopTransform().TransformPoint(globalPoint);
0071         if( G4AuxiliaryNavServices::
0072             CheckPointOnSurface(sampleSolid, samplePoint, globalDirection, 
0073                                 history.GetTopTransform(), pLocatedOnEdge) )
0074         {
0075           // Enter this daughter
0076           //
0077           localPoint = samplePoint;
0078           found = true;
0079           break;
0080         }
0081         history.BackLevel();
0082       }
0083     }
0084   }
0085   return found;
0086 }