G4ErrorPropagationNavigator.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$
00028 //
00029 //
00030 // --------------------------------------------------------------------
00031 //      GEANT 4 class implementation file
00032 // --------------------------------------------------------------------
00033 
00034 #include "G4ErrorPropagationNavigator.hh"
00035 
00036 #include "globals.hh"
00037 #include "G4ThreeVector.hh"
00038 #include "G4ErrorPropagatorData.hh"
00039 #include "G4ErrorSurfaceTarget.hh"
00040 
00041 //-------------------------------------------------------------------
00042 
00043 G4ErrorPropagationNavigator::G4ErrorPropagationNavigator()
00044   : G4Navigator()
00045 {
00046 }
00047 
00048 //-------------------------------------------------------------------
00049 
00050 G4ErrorPropagationNavigator::~G4ErrorPropagationNavigator()
00051 {
00052 }
00053 
00054 //-------------------------------------------------------------------
00055 
00056 G4double G4ErrorPropagationNavigator::
00057 ComputeStep ( const G4ThreeVector &pGlobalPoint,
00058               const G4ThreeVector &pDirection,
00059               const G4double pCurrentProposedStepLength,
00060                     G4double &pNewSafety )
00061 {
00062   G4double Step = G4Navigator::ComputeStep(pGlobalPoint, pDirection,
00063                                            pCurrentProposedStepLength,
00064                                            pNewSafety);
00065   
00066   G4ErrorPropagatorData * g4edata
00067     = G4ErrorPropagatorData::GetErrorPropagatorData();
00068 
00069   if (g4edata !=0)
00070   {
00071     const G4ErrorTarget* target = g4edata->GetTarget();
00072     if( target != 0 )
00073     {
00074       G4double StepPlane= target->GetDistanceFromPoint(pGlobalPoint,pDirection);
00075 
00076       if( StepPlane < 0. ) // Negative means target is crossed, will not be found
00077       {
00078         StepPlane = DBL_MAX; 
00079       }
00080 #ifdef G4VERBOSE
00081       if( G4ErrorPropagatorData::verbose() >= 4 )
00082       {
00083         G4cout << "G4ErrorPropagationNavigator::ComputeStep()" << G4endl
00084                << "  Target step: " << StepPlane
00085                << ", Transportation step: " << Step << G4endl;
00086         target->Dump( "G4ErrorPropagationNavigator::ComputeStep Target " );
00087       }
00088 #endif
00089 
00090       if(StepPlane<Step)
00091       {
00092 #ifdef G4VERBOSE
00093         if( G4ErrorPropagatorData::verbose() >= 2 )
00094         {
00095           G4cout << "G4ErrorPropagationNavigator::ComputeStep()" << G4endl
00096                  << "  TargetCloserThanBoundary: " << StepPlane << " < "
00097                  << Step << G4endl;
00098         }
00099 #endif
00100         Step = StepPlane;
00101         g4edata->SetState(G4ErrorState_TargetCloserThanBoundary);
00102       }
00103       else
00104       {
00105         g4edata->SetState(G4ErrorState_Propagating);
00106       }
00107     }
00108   }
00109   pNewSafety = ComputeSafety(pGlobalPoint, pCurrentProposedStepLength);
00110 
00111 #ifdef G4VERBOSE
00112   if( G4ErrorPropagatorData::verbose() >= 3 )
00113   {
00114     G4cout << "G4ErrorPropagationNavigator::ComputeStep()" << G4endl
00115            << "  Step: " << Step << ", ComputeSafety: " << pNewSafety
00116            << G4endl;
00117   }
00118 #endif
00119 
00120   return Step;
00121 }
00122 
00123 //-------------------------------------------------------------------
00124 
00125 G4double G4ErrorPropagationNavigator::
00126 ComputeSafety( const G4ThreeVector &pGlobalpoint,
00127                const G4double pMaxLength,
00128                const G4bool keepState )
00129 {
00130   G4double newSafety = G4Navigator::ComputeSafety(pGlobalpoint,
00131                                                   pMaxLength, keepState);
00132 
00133   G4ErrorPropagatorData *g4edata
00134     = G4ErrorPropagatorData::GetErrorPropagatorData();
00135 
00136   if (g4edata !=0)
00137   {
00138     const G4ErrorTarget* target = g4edata->GetTarget();
00139     if( target != 0 )
00140     {
00141       G4double distance = target->GetDistanceFromPoint(pGlobalpoint);
00142       
00143       if(distance<newSafety)
00144       {
00145         newSafety = distance;
00146       }
00147     }
00148   }
00149   return newSafety;
00150 } 

Generated on Mon May 27 17:48:11 2013 for Geant4 by  doxygen 1.4.7