G4PropagatorInField Class Reference

#include <G4PropagatorInField.hh>


Public Member Functions

 G4PropagatorInField (G4Navigator *theNavigator, G4FieldManager *detectorFieldMgr, G4VIntersectionLocator *vLocator=0)
 ~G4PropagatorInField ()
G4double ComputeStep (G4FieldTrack &pFieldTrack, G4double pCurrentProposedStepLength, G4double &pNewSafety, G4VPhysicalVolume *pPhysVol=0)
G4ThreeVector EndPosition () const
G4ThreeVector EndMomentumDir () const
G4bool IsParticleLooping () const
G4double GetEpsilonStep () const
void SetEpsilonStep (G4double newEps)
void SetChargeMomentumMass (G4double charge, G4double momentum, G4double pMass)
G4FieldManagerFindAndSetFieldManager (G4VPhysicalVolume *pCurrentPhysVol)
G4ChordFinderGetChordFinder ()
G4int SetVerboseLevel (G4int verbose)
G4int GetVerboseLevel () const
G4int Verbose () const
G4int GetMaxLoopCount () const
void SetMaxLoopCount (G4int new_max)
void printStatus (const G4FieldTrack &startFT, const G4FieldTrack &currentFT, G4double requestStep, G4double safety, G4int step, G4VPhysicalVolume *startVolume)
G4FieldTrack GetEndState () const
G4double GetMinimumEpsilonStep () const
void SetMinimumEpsilonStep (G4double newEpsMin)
G4double GetMaximumEpsilonStep () const
void SetMaximumEpsilonStep (G4double newEpsMax)
void SetLargestAcceptableStep (G4double newBigDist)
G4double GetLargestAcceptableStep ()
void SetTrajectoryFilter (G4VCurvedTrajectoryFilter *filter)
std::vector< G4ThreeVector > * GimmeTrajectoryVectorAndForgetIt () const
void ClearPropagatorState ()
void SetDetectorFieldManager (G4FieldManager *newGlobalFieldManager)
void SetUseSafetyForOptimization (G4bool)
G4bool GetUseSafetyForOptimization ()
G4bool IntersectChord (const G4ThreeVector &StartPointA, const G4ThreeVector &EndPointB, G4double &NewSafety, G4double &LinearStepLength, G4ThreeVector &IntersectionPoint)
G4VIntersectionLocatorGetIntersectionLocator ()
void SetIntersectionLocator (G4VIntersectionLocator *pLocator)
G4double GetDeltaIntersection () const
G4double GetDeltaOneStep () const
G4FieldManagerGetCurrentFieldManager ()
void SetNavigatorForPropagating (G4Navigator *SimpleOrMultiNavigator)
G4NavigatorGetNavigatorForPropagating ()
void SetThresholdNoZeroStep (G4int noAct, G4int noHarsh, G4int noAbandon)
G4int GetThresholdNoZeroSteps (G4int i)
G4double GetZeroStepThreshold ()
void SetZeroStepThreshold (G4double newLength)
void RefreshIntersectionLocator ()

Protected Member Functions

void PrintStepLengthDiagnostic (G4double currentProposedStepLength, G4double decreaseFactor, G4double stepTrial, const G4FieldTrack &aFieldTrack)


Detailed Description

Definition at line 64 of file G4PropagatorInField.hh.


Constructor & Destructor Documentation

G4PropagatorInField::G4PropagatorInField ( G4Navigator theNavigator,
G4FieldManager detectorFieldMgr,
G4VIntersectionLocator vLocator = 0 
)

Definition at line 59 of file G4PropagatorInField.cc.

References G4cout, G4endl, G4GeometryTolerance::GetInstance(), G4FieldManager::GetMaximumEpsilonStep(), G4GeometryTolerance::GetSurfaceTolerance(), and RefreshIntersectionLocator().

00062   : 
00063     fMax_loop_count(1000),
00064     fUseSafetyForOptimisation(true),   // (false) is less sensitive to incorrect safety
00065     fZeroStepThreshold( 0.0 ),         // length of what is recognised as 'zero' step
00066     fDetectorFieldMgr(detectorFieldMgr), 
00067     fpTrajectoryFilter( 0 ),
00068     fNavigator(theNavigator),
00069     fCurrentFieldMgr(detectorFieldMgr),
00070     fSetFieldMgr(false),
00071     fCharge(0.0), fInitialMomentumModulus(0.0), fMass(0.0),
00072     End_PointAndTangent(G4ThreeVector(0.,0.,0.),
00073                         G4ThreeVector(0.,0.,0.),0.0,0.0,0.0,0.0,0.0),
00074     fParticleIsLooping(false),
00075     fNoZeroStep(0), 
00076     fVerboseLevel(0)
00077 {
00078   if(fDetectorFieldMgr) { fEpsilonStep = fDetectorFieldMgr->GetMaximumEpsilonStep();}
00079   else                  { fEpsilonStep= 1.0e-5; } 
00080   fActionThreshold_NoZeroSteps = 2; 
00081   fSevereActionThreshold_NoZeroSteps = 10; 
00082   fAbandonThreshold_NoZeroSteps = 50; 
00083   fFull_CurveLen_of_LastAttempt = -1; 
00084   fLast_ProposedStepLength = -1;
00085   fLargestAcceptableStep = 1000.0 * meter;
00086 
00087   fPreviousSftOrigin= G4ThreeVector(0.,0.,0.);
00088   fPreviousSafety= 0.0;
00089   kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
00090   fZeroStepThreshold= std::max( 1.0e5 * kCarTolerance, 1.0e-1 * micrometer );
00091 
00092 #ifdef G4DEBUG_FIELD
00093   G4cout << " PiF: Zero Step Threshold set to "
00094          << fZeroStepThreshold / millimeter
00095          << " mm." << G4endl;
00096   G4cout << " PiF:   Value of kCarTolerance = "
00097          << kCarTolerance / millimeter 
00098          << " mm. " << G4endl;
00099 #endif 
00100 
00101   // Definding Intersection Locator and his parameters
00102   if(vLocator==0){
00103     fIntersectionLocator= new G4MultiLevelLocator(theNavigator);
00104     fAllocatedLocator=true;
00105   }else{
00106     fIntersectionLocator=vLocator;
00107     fAllocatedLocator=false;
00108   }
00109   RefreshIntersectionLocator();  //  Copy all relevant parameters 
00110 }

G4PropagatorInField::~G4PropagatorInField (  ) 

Definition at line 112 of file G4PropagatorInField.cc.

00113 {
00114   if(fAllocatedLocator)delete  fIntersectionLocator; 
00115 }


Member Function Documentation

void G4PropagatorInField::ClearPropagatorState (  ) 

Definition at line 619 of file G4PropagatorInField.cc.

Referenced by G4Transportation::StartTracking(), G4ITTransportation::StartTracking(), and G4CoupledTransportation::StartTracking().

00620 {
00621   // Goal: Clear all memory of previous steps,  cached information
00622 
00623   fParticleIsLooping= false;
00624   fNoZeroStep= 0;
00625 
00626   End_PointAndTangent= G4FieldTrack( G4ThreeVector(0.,0.,0.),
00627                                      G4ThreeVector(0.,0.,0.),
00628                                      0.0,0.0,0.0,0.0,0.0); 
00629   fFull_CurveLen_of_LastAttempt = -1; 
00630   fLast_ProposedStepLength = -1;
00631 
00632   fPreviousSftOrigin= G4ThreeVector(0.,0.,0.);
00633   fPreviousSafety= 0.0;
00634 }

G4double G4PropagatorInField::ComputeStep ( G4FieldTrack pFieldTrack,
G4double  pCurrentProposedStepLength,
G4double pNewSafety,
G4VPhysicalVolume pPhysVol = 0 
)

Definition at line 131 of file G4PropagatorInField.cc.

References G4ChordFinder::AdvanceChordLimited(), G4VCurvedTrajectoryFilter::CreateNewTrajectorySegment(), FatalException, FindAndSetFieldManager(), G4cout, G4endl, G4Exception(), GetChordFinder(), G4FieldTrack::GetCurveLength(), G4FieldManager::GetDeltaOneStep(), G4VPhysicalVolume::GetLogicalVolume(), G4FieldManager::GetMaximumEpsilonStep(), G4FieldManager::GetMinimumEpsilonStep(), G4FieldTrack::GetMomentumDir(), G4VPhysicalVolume::GetName(), G4FieldTrack::GetPosition(), G4Navigator::GetWorldVolume(), IntersectChord(), JustWarning, G4Navigator::LocateGlobalPointWithinVolume(), printStatus(), PrintStepLengthDiagnostic(), RefreshIntersectionLocator(), G4ChordFinder::SetChargeMomentumMass(), SetEpsilonStep(), and G4VCurvedTrajectoryFilter::TakeIntermediatePoint().

Referenced by G4Transportation::AlongStepGetPhysicalInteractionLength(), and G4PathFinder::DoNextCurvedStep().

00136 {  
00137   // If CurrentProposedStepLength is too small for finding Chords
00138   // then return with no action (for now - TODO: some action)
00139   //
00140   if(CurrentProposedStepLength<kCarTolerance)
00141   {
00142     return kInfinity;
00143   }
00144 
00145   // Introducing smooth trajectory display (jacek 01/11/2002)
00146   //
00147   if (fpTrajectoryFilter)
00148   {
00149     fpTrajectoryFilter->CreateNewTrajectorySegment();
00150   }
00151 
00152   // Parameters for adaptive Runge-Kutta integration
00153   
00154   G4double      h_TrialStepSize;        // 1st Step Size 
00155   G4double      TruePathLength = CurrentProposedStepLength;
00156   G4double      StepTaken = 0.0; 
00157   G4double      s_length_taken, epsilon ; 
00158   G4bool        intersects;
00159   G4bool        first_substep = true;
00160 
00161   G4double      NewSafety;
00162   fParticleIsLooping = false;
00163 
00164   // If not yet done, 
00165   //   Set the field manager to the local  one if the volume has one, 
00166   //                      or to the global one if not
00167   //
00168   if( !fSetFieldMgr ) fCurrentFieldMgr= FindAndSetFieldManager( pPhysVol ); 
00169   // For the next call, the field manager must again be set
00170   fSetFieldMgr= false;
00171 
00172   GetChordFinder()->SetChargeMomentumMass(fCharge,fInitialMomentumModulus,fMass);
00173 
00174  // Values for Intersection Locator has to be updated on each call for the
00175  // case that CurrentFieldManager has changed from the one of previous step
00176   RefreshIntersectionLocator();
00177 
00178   G4FieldTrack  CurrentState(pFieldTrack);
00179   G4FieldTrack  OriginalState = CurrentState;
00180 
00181   // If the Step length is "infinite", then an approximate-maximum Step
00182   // length (used to calculate the relative accuracy) must be guessed.
00183   //
00184   if( CurrentProposedStepLength >= fLargestAcceptableStep )
00185   {
00186     G4ThreeVector StartPointA, VelocityUnit;
00187     StartPointA  = pFieldTrack.GetPosition();
00188     VelocityUnit = pFieldTrack.GetMomentumDir();
00189 
00190     G4double trialProposedStep = 1.e2 * ( 10.0 * cm + 
00191       fNavigator->GetWorldVolume()->GetLogicalVolume()->
00192                   GetSolid()->DistanceToOut(StartPointA, VelocityUnit) );
00193     CurrentProposedStepLength= std::min( trialProposedStep,
00194                                            fLargestAcceptableStep ); 
00195   }
00196   epsilon = fCurrentFieldMgr->GetDeltaOneStep() / CurrentProposedStepLength;
00197   // G4double raw_epsilon= epsilon;
00198   G4double epsilonMin= fCurrentFieldMgr->GetMinimumEpsilonStep();
00199   G4double epsilonMax= fCurrentFieldMgr->GetMaximumEpsilonStep();; 
00200   if( epsilon < epsilonMin ) epsilon = epsilonMin;
00201   if( epsilon > epsilonMax ) epsilon = epsilonMax;
00202   SetEpsilonStep( epsilon );
00203 
00204   // G4cout << "G4PiF: Epsilon of current step - raw= " << raw_epsilon
00205   //        << " final= " << epsilon << G4endl;
00206 
00207   //  Shorten the proposed step in case of earlier problems (zero steps)
00208   // 
00209   if( fNoZeroStep > fActionThreshold_NoZeroSteps )
00210   {
00211     G4double stepTrial;
00212 
00213     stepTrial= fFull_CurveLen_of_LastAttempt; 
00214     if( (stepTrial <= 0.0) && (fLast_ProposedStepLength > 0.0) ) 
00215       stepTrial= fLast_ProposedStepLength; 
00216 
00217     G4double decreaseFactor = 0.9; // Unused default
00218     if(   (fNoZeroStep < fSevereActionThreshold_NoZeroSteps)
00219        && (stepTrial > 100.0*fZeroStepThreshold) )
00220     {
00221       // Attempt quick convergence
00222       //
00223       decreaseFactor= 0.25;
00224     } 
00225     else
00226     {
00227       // We are in significant difficulties, probably at a boundary that
00228       // is either geometrically sharp or between very different materials.
00229       // Careful decreases to cope with tolerance are required.
00230       //
00231       if( stepTrial > 100.0*fZeroStepThreshold )
00232         decreaseFactor = 0.35;     // Try decreasing slower
00233       else if( stepTrial > 30.0*fZeroStepThreshold )
00234         decreaseFactor= 0.5;       // Try yet slower decrease
00235       else if( stepTrial > 10.0*fZeroStepThreshold )
00236         decreaseFactor= 0.75;      // Try even slower decreases
00237       else
00238         decreaseFactor= 0.9;       // Try very slow decreases
00239      }
00240      stepTrial *= decreaseFactor;
00241 
00242 #ifdef G4DEBUG_FIELD
00243      G4cout << " G4PropagatorInField::ComputeStep(): " << G4endl
00244             << "  Decreasing step -  " 
00245             << " decreaseFactor= " << std::setw(8) << decreaseFactor 
00246             << " stepTrial = "     << std::setw(18) << stepTrial << " "
00247             << " fZeroStepThreshold = " << fZeroStepThreshold << G4endl;
00248      PrintStepLengthDiagnostic(CurrentProposedStepLength, decreaseFactor,
00249                                stepTrial, pFieldTrack);
00250 #endif
00251      if( stepTrial == 0.0 )  //  Change to make it < 0.1 * kCarTolerance ??
00252      {
00253        std::ostringstream message;
00254        message << "Particle abandoned due to lack of progress in field."
00255                << G4endl
00256                << "  Properties : " << pFieldTrack << G4endl
00257                << "  Attempting a zero step = " << stepTrial << G4endl
00258                << "  while attempting to progress after " << fNoZeroStep
00259                << " trial steps. Will abandon step.";
00260        G4Exception("G4PropagatorInField::ComputeStep()", "GeomNav1002",
00261                    JustWarning, message);
00262        fParticleIsLooping= true;
00263        return 0;  // = stepTrial;
00264      }
00265      if( stepTrial < CurrentProposedStepLength )
00266        CurrentProposedStepLength = stepTrial;
00267   }
00268   fLast_ProposedStepLength = CurrentProposedStepLength;
00269 
00270   G4int do_loop_count = 0; 
00271   do
00272   { 
00273     G4FieldTrack SubStepStartState = CurrentState;
00274     G4ThreeVector SubStartPoint = CurrentState.GetPosition(); 
00275 
00276     if( !first_substep) {
00277       fNavigator->LocateGlobalPointWithinVolume( SubStartPoint );
00278     }
00279 
00280     // How far to attempt to move the particle !
00281     //
00282     h_TrialStepSize = CurrentProposedStepLength - StepTaken;
00283 
00284     // Integrate as far as "chord miss" rule allows.
00285     //
00286     s_length_taken = GetChordFinder()->AdvanceChordLimited( 
00287                              CurrentState,    // Position & velocity
00288                              h_TrialStepSize,
00289                              fEpsilonStep,
00290                              fPreviousSftOrigin,
00291                              fPreviousSafety
00292                              );
00293     //  CurrentState is now updated with the final position and velocity. 
00294 
00295     fFull_CurveLen_of_LastAttempt = s_length_taken;
00296 
00297     G4ThreeVector  EndPointB = CurrentState.GetPosition(); 
00298     G4ThreeVector  InterSectionPointE;
00299     G4double       LinearStepLength;
00300  
00301     // Intersect chord AB with geometry
00302     intersects= IntersectChord( SubStartPoint, EndPointB, 
00303                                 NewSafety,     LinearStepLength, 
00304                                 InterSectionPointE );
00305     // E <- Intersection Point of chord AB and either volume A's surface 
00306     //                                  or a daughter volume's surface ..
00307 
00308     if( first_substep ) { 
00309        currentSafety = NewSafety;
00310     } // Updating safety in other steps is potential future extention
00311 
00312     if( intersects )
00313     {
00314        G4FieldTrack IntersectPointVelct_G(CurrentState);  // FT-Def-Construct
00315 
00316        // Find the intersection point of AB true path with the surface
00317        //   of vol(A), if it exists. Start with point E as first "estimate".
00318        G4bool recalculatedEndPt= false;
00319        
00320          G4bool found_intersection = fIntersectionLocator->
00321          EstimateIntersectionPoint( SubStepStartState, CurrentState, 
00322                                   InterSectionPointE, IntersectPointVelct_G,
00323                                   recalculatedEndPt,fPreviousSafety,fPreviousSftOrigin);
00324        intersects = intersects && found_intersection;
00325        if( found_intersection ) {        
00326           End_PointAndTangent= IntersectPointVelct_G;  // G is our EndPoint ...
00327           StepTaken = TruePathLength = IntersectPointVelct_G.GetCurveLength()
00328                                       - OriginalState.GetCurveLength();
00329        } else {
00330           // intersects= false;          // "Minor" chords do not intersect
00331           if( recalculatedEndPt ){
00332              CurrentState= IntersectPointVelct_G; 
00333           }
00334        }
00335     }
00336     if( !intersects )
00337     {
00338       StepTaken += s_length_taken; 
00339       // For smooth trajectory display (jacek 01/11/2002)
00340       if (fpTrajectoryFilter) {
00341         fpTrajectoryFilter->TakeIntermediatePoint(CurrentState.GetPosition());
00342       }
00343     }
00344     first_substep = false;
00345 
00346 #ifdef G4DEBUG_FIELD
00347     if( fNoZeroStep > fActionThreshold_NoZeroSteps ) {
00348       printStatus( SubStepStartState,  // or OriginalState,
00349                    CurrentState,  CurrentProposedStepLength, 
00350                    NewSafety,     do_loop_count,  pPhysVol );
00351     }
00352     if( (fVerboseLevel > 1) && (do_loop_count > fMax_loop_count-10 )) {
00353       if( do_loop_count == fMax_loop_count-9 ){
00354         G4cout << " G4PropagatorInField::ComputeStep(): " << G4endl
00355                << "  Difficult track - taking many sub steps." << G4endl;
00356       }
00357       printStatus( SubStepStartState, CurrentState, CurrentProposedStepLength, 
00358                    NewSafety, do_loop_count, pPhysVol );
00359     }
00360 #endif
00361 
00362     do_loop_count++;
00363 
00364   } while( (!intersects )
00365         && (StepTaken + kCarTolerance < CurrentProposedStepLength)  
00366         && ( do_loop_count < fMax_loop_count ) );
00367 
00368   if( do_loop_count >= fMax_loop_count  )
00369   {
00370     fParticleIsLooping = true;
00371 
00372     if ( fVerboseLevel > 0 )
00373     {
00374        G4cout << " G4PropagateInField::ComputeStep(): " << G4endl
00375               << "  Killing looping particle " 
00376               // << " of " << energy  << " energy "
00377               << " after " << do_loop_count << " field substeps "
00378               << " totaling " << StepTaken / mm << " mm " ;
00379        if( pPhysVol )
00380           G4cout << " in volume " << pPhysVol->GetName() ; 
00381        else
00382          G4cout << " in unknown or null volume. " ; 
00383        G4cout << G4endl;
00384     }
00385   }
00386 
00387   if( !intersects )
00388   {
00389     // Chord AB or "minor chords" do not intersect
00390     // B is the endpoint Step of the current Step.
00391     //
00392     End_PointAndTangent = CurrentState; 
00393     TruePathLength = StepTaken;
00394   }
00395   
00396   // Set pFieldTrack to the return value
00397   //
00398   pFieldTrack = End_PointAndTangent;
00399 
00400 #ifdef G4VERBOSE
00401   // Check that "s" is correct
00402   //
00403   if( std::fabs(OriginalState.GetCurveLength() + TruePathLength 
00404       - End_PointAndTangent.GetCurveLength()) > 3.e-4 * TruePathLength )
00405   {
00406     std::ostringstream message;
00407     message << "Curve length mis-match between original state "
00408             << "and proposed endpoint of propagation." << G4endl
00409             << "  The curve length of the endpoint should be: " 
00410             << OriginalState.GetCurveLength() + TruePathLength << G4endl
00411             << "  and it is instead: "
00412             << End_PointAndTangent.GetCurveLength() << "." << G4endl
00413             << "  A difference of: "
00414             << OriginalState.GetCurveLength() + TruePathLength 
00415                - End_PointAndTangent.GetCurveLength() << G4endl
00416             << "  Original state = " << OriginalState   << G4endl
00417             << "  Proposed state = " << End_PointAndTangent;
00418     G4Exception("G4PropagatorInField::ComputeStep()",
00419                 "GeomNav0003", FatalException, message);
00420   }
00421 #endif
00422 
00423   // In particular anomalous cases, we can get repeated zero steps
00424   // In order to correct this efficiently, we identify these cases
00425   // and only take corrective action when they occur.
00426   // 
00427   if( ( (TruePathLength < fZeroStepThreshold) 
00428         && ( TruePathLength+kCarTolerance < CurrentProposedStepLength  ) 
00429         ) 
00430       || ( TruePathLength < 0.5*kCarTolerance )
00431     )
00432   {
00433     fNoZeroStep++;
00434   }
00435   else{
00436     fNoZeroStep = 0;
00437   }
00438 
00439   if( fNoZeroStep > fAbandonThreshold_NoZeroSteps )
00440   { 
00441      fParticleIsLooping = true;
00442      std::ostringstream message;
00443      message << "Particle is stuck; it will be killed." << G4endl
00444              << "  Zero progress for "  << fNoZeroStep << " attempted steps." 
00445              << G4endl
00446              << "  Proposed Step is " << CurrentProposedStepLength
00447              << " but Step Taken is "<< fFull_CurveLen_of_LastAttempt << G4endl
00448              << "  For Particle with Charge = " << fCharge
00449              << " Momentum = "<< fInitialMomentumModulus
00450              << " Mass = " << fMass << G4endl;
00451      if( pPhysVol )
00452        message << " in volume " << pPhysVol->GetName() ; 
00453      else
00454        message << " in unknown or null volume. " ; 
00455      G4Exception("G4PropagatorInField::ComputeStep()",
00456                  "GeomNav1002", JustWarning, message);
00457      fNoZeroStep = 0; 
00458   }
00459  
00460   return TruePathLength;
00461 }

G4ThreeVector G4PropagatorInField::EndMomentumDir (  )  const [inline]

Definition at line 76 of file G4PropagatorInField.icc.

References G4FieldTrack::GetMomentumDir().

00077 {
00078   return   End_PointAndTangent.GetMomentumDir(); 
00079 }

G4ThreeVector G4PropagatorInField::EndPosition (  )  const [inline]

Definition at line 70 of file G4PropagatorInField.icc.

References G4FieldTrack::GetPosition().

00071 {
00072   return   End_PointAndTangent.GetPosition(); 
00073 }

G4FieldManager * G4PropagatorInField::FindAndSetFieldManager ( G4VPhysicalVolume pCurrentPhysVol  ) 

Definition at line 637 of file G4PropagatorInField.cc.

References G4LogicalVolume::GetFieldManager(), G4Region::GetFieldManager(), G4VPhysicalVolume::GetLogicalVolume(), and G4LogicalVolume::GetRegion().

Referenced by G4Transportation::AlongStepGetPhysicalInteractionLength(), G4ITTransportation::AlongStepGetPhysicalInteractionLength(), G4CoupledTransportation::AlongStepGetPhysicalInteractionLength(), ComputeStep(), G4PathFinder::ComputeStep(), G4SynchrotronRadiationInMat::GetMeanFreePath(), G4SynchrotronRadiation::GetMeanFreePath(), G4SynchrotronRadiationInMat::GetPhotonEnergy(), G4QSynchRad::GetRadius(), G4SynchrotronRadiationInMat::PostStepDoIt(), and G4SynchrotronRadiation::PostStepDoIt().

00638 {
00639   G4FieldManager* currentFieldMgr;
00640 
00641   currentFieldMgr = fDetectorFieldMgr;
00642   if( pCurrentPhysicalVolume)
00643   {
00644      G4FieldManager *pRegionFieldMgr= 0, *localFieldMgr = 0;
00645      G4LogicalVolume* pLogicalVol= pCurrentPhysicalVolume->GetLogicalVolume();
00646 
00647      if( pLogicalVol ) { 
00648         // Value for Region, if any, Overrides 
00649         G4Region*  pRegion= pLogicalVol->GetRegion();
00650         if( pRegion ) { 
00651            pRegionFieldMgr= pRegion->GetFieldManager();
00652            if( pRegionFieldMgr ) 
00653              currentFieldMgr= pRegionFieldMgr;
00654         }
00655 
00656         // 'Local' Value from logical volume, if any, Overrides 
00657         localFieldMgr= pLogicalVol->GetFieldManager();
00658         if ( localFieldMgr ) 
00659            currentFieldMgr = localFieldMgr;
00660      }
00661   }
00662   fCurrentFieldMgr= currentFieldMgr;
00663 
00664   // Flag that field manager has been set.
00665   fSetFieldMgr= true;
00666 
00667   return currentFieldMgr;
00668 }

G4ChordFinder * G4PropagatorInField::GetChordFinder (  )  [inline]

Definition at line 45 of file G4PropagatorInField.icc.

References G4FieldManager::GetChordFinder().

Referenced by ComputeStep(), RefreshIntersectionLocator(), SetVerboseLevel(), and G4CoupledTransportation::StartTracking().

00046 {
00047   // The "Chord Finder" of the current Field Mgr is used
00048   //    -- this could be of the global field manager
00049   //        or that of another, from the current volume 
00050   return fCurrentFieldMgr->GetChordFinder(); 
00051 }

G4FieldManager * G4PropagatorInField::GetCurrentFieldManager (  )  [inline]

Definition at line 184 of file G4PropagatorInField.icc.

Referenced by G4Transportation::AlongStepGetPhysicalInteractionLength(), G4CoupledTransportation::AlongStepGetPhysicalInteractionLength(), and G4DecayWithSpin::DecayIt().

00185 {
00186   return fCurrentFieldMgr;
00187 } 

G4double G4PropagatorInField::GetDeltaIntersection (  )  const [inline]

Definition at line 113 of file G4PropagatorInField.icc.

References G4FieldManager::GetDeltaIntersection().

00114 {
00115   return fCurrentFieldMgr->GetDeltaIntersection();
00116 } 

G4double G4PropagatorInField::GetDeltaOneStep (  )  const [inline]

Definition at line 119 of file G4PropagatorInField.icc.

References G4FieldManager::GetDeltaOneStep().

00120 {
00121   return fCurrentFieldMgr->GetDeltaOneStep();
00122 }

G4FieldTrack G4PropagatorInField::GetEndState (  )  const [inline]

Definition at line 137 of file G4PropagatorInField.icc.

00138 {
00139   return End_PointAndTangent;
00140 }

G4double G4PropagatorInField::GetEpsilonStep (  )  const [inline]

Definition at line 82 of file G4PropagatorInField.icc.

00083 { 
00084   return fEpsilonStep; 
00085 }

G4VIntersectionLocator * G4PropagatorInField::GetIntersectionLocator (  )  [inline]

Definition at line 271 of file G4PropagatorInField.icc.

00272 {
00273   return fIntersectionLocator;
00274 } 

G4double G4PropagatorInField::GetLargestAcceptableStep (  )  [inline]

Definition at line 178 of file G4PropagatorInField.icc.

00179 {
00180   return fLargestAcceptableStep;
00181 }

G4double G4PropagatorInField::GetMaximumEpsilonStep (  )  const [inline]

Definition at line 157 of file G4PropagatorInField.icc.

References G4FieldManager::GetMaximumEpsilonStep().

00158 {
00159   return fDetectorFieldMgr->GetMaximumEpsilonStep();
00160 }

G4int G4PropagatorInField::GetMaxLoopCount (  )  const [inline]

Definition at line 100 of file G4PropagatorInField.icc.

00101 {
00102   return fMax_loop_count;
00103 }

G4double G4PropagatorInField::GetMinimumEpsilonStep (  )  const [inline]

Definition at line 144 of file G4PropagatorInField.icc.

References G4FieldManager::GetMinimumEpsilonStep().

00145 {
00146   return fDetectorFieldMgr->GetMinimumEpsilonStep();
00147 }

G4Navigator * G4PropagatorInField::GetNavigatorForPropagating (  )  [inline]

Definition at line 258 of file G4PropagatorInField.icc.

00259 {
00260   return fNavigator;
00261 } 

G4int G4PropagatorInField::GetThresholdNoZeroSteps ( G4int  i  )  [inline]

Definition at line 209 of file G4PropagatorInField.icc.

00210 {
00211    G4int t=0;
00212    if( i==0 )     { t = 3; }     // No of parameters
00213    else if (i==1) { t = fActionThreshold_NoZeroSteps; }
00214    else if (i==2) { t = fSevereActionThreshold_NoZeroSteps; }
00215    else if (i==3) { t = fAbandonThreshold_NoZeroSteps; }
00216 
00217    return t;
00218 }

G4bool G4PropagatorInField::GetUseSafetyForOptimization (  )  [inline]

Definition at line 240 of file G4PropagatorInField.icc.

00241 { 
00242    return fUseSafetyForOptimisation; 
00243 }

G4int G4PropagatorInField::GetVerboseLevel (  )  const [inline]

Definition at line 126 of file G4PropagatorInField.icc.

Referenced by Verbose().

00127 {
00128   return fVerboseLevel;
00129 }

G4double G4PropagatorInField::GetZeroStepThreshold (  )  [inline]

Definition at line 220 of file G4PropagatorInField.icc.

00220 { return fZeroStepThreshold; }

std::vector< G4ThreeVector > * G4PropagatorInField::GimmeTrajectoryVectorAndForgetIt (  )  const

Definition at line 598 of file G4PropagatorInField.cc.

References G4VCurvedTrajectoryFilter::GimmeThePointsAndForgetThem().

Referenced by G4Transportation::AlongStepDoIt(), and G4ITTransportation::AlongStepDoIt().

00599 {
00600   // NB, GimmeThePointsAndForgetThem really forgets them, so it can
00601   // only be called (exactly) once for each step.
00602 
00603   if (fpTrajectoryFilter)
00604   {
00605     return fpTrajectoryFilter->GimmeThePointsAndForgetThem();
00606   }
00607   else
00608   {
00609     return 0;
00610   }
00611 }

G4bool G4PropagatorInField::IntersectChord ( const G4ThreeVector StartPointA,
const G4ThreeVector EndPointB,
G4double NewSafety,
G4double LinearStepLength,
G4ThreeVector IntersectionPoint 
) [inline]

Definition at line 277 of file G4PropagatorInField.icc.

References G4VIntersectionLocator::IntersectChord().

Referenced by ComputeStep().

00282 {
00283   // Calculate the direction and length of the chord AB
00284   //
00285   return fIntersectionLocator
00286          ->IntersectChord(StartPointA,EndPointB,NewSafety,
00287                           fPreviousSafety,fPreviousSftOrigin,
00288                           LinearStepLength,IntersectionPoint);
00289 }

G4bool G4PropagatorInField::IsParticleLooping (  )  const [inline]

Definition at line 94 of file G4PropagatorInField.icc.

Referenced by G4Transportation::AlongStepGetPhysicalInteractionLength(), and G4CoupledTransportation::AlongStepGetPhysicalInteractionLength().

00095 {
00096   return fParticleIsLooping;
00097 }

void G4PropagatorInField::printStatus ( const G4FieldTrack startFT,
const G4FieldTrack currentFT,
G4double  requestStep,
G4double  safety,
G4int  step,
G4VPhysicalVolume startVolume 
)

Definition at line 468 of file G4PropagatorInField.cc.

References G4cout, G4endl, G4FieldTrack::GetCurveLength(), G4FieldTrack::GetMomentum(), G4FieldTrack::GetMomentumDir(), G4VPhysicalVolume::GetName(), and G4FieldTrack::GetPosition().

Referenced by ComputeStep().

00474 {
00475   const G4int verboseLevel=fVerboseLevel;
00476   const G4ThreeVector StartPosition       = StartFT.GetPosition();
00477   const G4ThreeVector StartUnitVelocity   = StartFT.GetMomentumDir();
00478   const G4ThreeVector CurrentPosition     = CurrentFT.GetPosition();
00479   const G4ThreeVector CurrentUnitVelocity = CurrentFT.GetMomentumDir();
00480 
00481   G4double step_len = CurrentFT.GetCurveLength() - StartFT.GetCurveLength();
00482 
00483   G4int oldprec;   // cout/cerr precision settings
00484       
00485   if( ((stepNo == 0) && (verboseLevel <3)) || (verboseLevel >= 3) )
00486   {
00487     oldprec = G4cout.precision(4);
00488     G4cout << std::setw( 6)  << " " 
00489            << std::setw( 25) << " Current Position  and  Direction" << " "
00490            << G4endl; 
00491     G4cout << std::setw( 5) << "Step#" 
00492            << std::setw(10) << "  s  " << " "
00493            << std::setw(10) << "X(mm)" << " "
00494            << std::setw(10) << "Y(mm)" << " "  
00495            << std::setw(10) << "Z(mm)" << " "
00496            << std::setw( 7) << " N_x " << " "
00497            << std::setw( 7) << " N_y " << " "
00498            << std::setw( 7) << " N_z " << " " ;
00499     G4cout << std::setw( 7) << " Delta|N|" << " "
00500            << std::setw( 9) << "StepLen" << " "  
00501            << std::setw(12) << "StartSafety" << " "  
00502            << std::setw( 9) << "PhsStep" << " ";  
00503     if( startVolume )
00504       { G4cout << std::setw(18) << "NextVolume" << " "; }
00505     G4cout.precision(oldprec);
00506     G4cout << G4endl;
00507   }
00508   if((stepNo == 0) && (verboseLevel <=3))
00509   {
00510     // Recurse to print the start values
00511     //
00512     printStatus( StartFT, StartFT, -1.0, safety, -1, startVolume);
00513   }
00514   if( verboseLevel <= 3 )
00515   {
00516     if( stepNo >= 0)
00517       { G4cout << std::setw( 4) << stepNo << " "; }
00518     else
00519       { G4cout << std::setw( 5) << "Start" ; }
00520     oldprec = G4cout.precision(8);
00521     G4cout << std::setw(10) << CurrentFT.GetCurveLength() << " "; 
00522     G4cout.precision(8);
00523     G4cout << std::setw(10) << CurrentPosition.x() << " "
00524            << std::setw(10) << CurrentPosition.y() << " "
00525            << std::setw(10) << CurrentPosition.z() << " ";
00526     G4cout.precision(4);
00527     G4cout << std::setw( 7) << CurrentUnitVelocity.x() << " "
00528            << std::setw( 7) << CurrentUnitVelocity.y() << " "
00529            << std::setw( 7) << CurrentUnitVelocity.z() << " ";
00530     G4cout.precision(3); 
00531     G4cout << std::setw( 7)
00532            << CurrentFT.GetMomentum().mag()-StartFT.GetMomentum().mag() << " "; 
00533     G4cout << std::setw( 9) << step_len << " "; 
00534     G4cout << std::setw(12) << safety << " ";
00535     if( requestStep != -1.0 ) 
00536       { G4cout << std::setw( 9) << requestStep << " "; }
00537     else
00538       { G4cout << std::setw( 9) << "Init/NotKnown" << " "; }
00539     if( startVolume != 0)
00540       { G4cout << std::setw(12) << startVolume->GetName() << " "; }
00541     G4cout.precision(oldprec);
00542     G4cout << G4endl;
00543   }
00544   else // if( verboseLevel > 3 )
00545   {
00546     //  Multi-line output
00547       
00548     G4cout << "Step taken was " << step_len  
00549            << " out of PhysicalStep = " <<  requestStep << G4endl;
00550     G4cout << "Final safety is: " << safety << G4endl;
00551     G4cout << "Chord length = " << (CurrentPosition-StartPosition).mag()
00552            << G4endl;
00553     G4cout << G4endl; 
00554   }
00555 }

void G4PropagatorInField::PrintStepLengthDiagnostic ( G4double  currentProposedStepLength,
G4double  decreaseFactor,
G4double  stepTrial,
const G4FieldTrack aFieldTrack 
) [protected]

Definition at line 562 of file G4PropagatorInField.cc.

References G4cout, and G4endl.

Referenced by ComputeStep().

00567 {
00568   G4int  iprec= G4cout.precision(8); 
00569   G4cout << " " << std::setw(12) << " PiF: NoZeroStep " 
00570          << " " << std::setw(20) << " CurrentProposed len " 
00571          << " " << std::setw(18) << " Full_curvelen_last" 
00572          << " " << std::setw(18) << " last proposed len " 
00573          << " " << std::setw(18) << " decrease factor   " 
00574          << " " << std::setw(15) << " step trial  " 
00575          << G4endl;
00576 
00577   G4cout << " " << std::setw(10) << fNoZeroStep << "  "
00578          << " " << std::setw(20) << CurrentProposedStepLength
00579          << " " << std::setw(18) << fFull_CurveLen_of_LastAttempt
00580          << " " << std::setw(18) << fLast_ProposedStepLength 
00581          << " " << std::setw(18) << decreaseFactor
00582          << " " << std::setw(15) << stepTrial
00583          << G4endl;
00584   G4cout.precision( iprec ); 
00585 
00586 }

void G4PropagatorInField::RefreshIntersectionLocator (  ) 

Definition at line 119 of file G4PropagatorInField.cc.

References GetChordFinder(), G4FieldManager::GetDeltaIntersection(), G4VIntersectionLocator::SetChordFinderFor(), G4VIntersectionLocator::SetDeltaIntersectionFor(), G4VIntersectionLocator::SetEpsilonStepFor(), and G4VIntersectionLocator::SetSafetyParametersFor().

Referenced by ComputeStep(), and G4PropagatorInField().

00120 {
00121   fIntersectionLocator->SetEpsilonStepFor(fEpsilonStep);
00122   fIntersectionLocator->SetDeltaIntersectionFor(fCurrentFieldMgr->GetDeltaIntersection());
00123   fIntersectionLocator->SetChordFinderFor(GetChordFinder());
00124   fIntersectionLocator->SetSafetyParametersFor( fUseSafetyForOptimisation);
00125 }

void G4PropagatorInField::SetChargeMomentumMass ( G4double  charge,
G4double  momentum,
G4double  pMass 
) [inline]

Definition at line 54 of file G4PropagatorInField.icc.

Referenced by G4Transportation::AlongStepGetPhysicalInteractionLength(), and G4CoupledTransportation::AlongStepGetPhysicalInteractionLength().

00058 {
00059   // GetChordFinder()->SetChargeMomentumMass(Charge, Momentum, Mass);
00060   //  --> Not needed anymore, as it is done in ComputeStep for the 
00061   //       ChordFinder of the current step (which is known only then).
00062   fCharge = Charge;
00063   fInitialMomentumModulus = Momentum;
00064   fMass = Mass; 
00065 }

void G4PropagatorInField::SetDetectorFieldManager ( G4FieldManager newGlobalFieldManager  )  [inline]

Definition at line 227 of file G4PropagatorInField.icc.

00228 {
00229    fDetectorFieldMgr = newDetectorFieldManager; 
00230 }

void G4PropagatorInField::SetEpsilonStep ( G4double  newEps  )  [inline]

Definition at line 88 of file G4PropagatorInField.icc.

Referenced by ComputeStep().

00089 {
00090   fEpsilonStep=newEps;
00091 }

void G4PropagatorInField::SetIntersectionLocator ( G4VIntersectionLocator pLocator  )  [inline]

Definition at line 265 of file G4PropagatorInField.icc.

00266 {
00267   if(pIntLoc)  { fIntersectionLocator= pIntLoc; }
00268 }

void G4PropagatorInField::SetLargestAcceptableStep ( G4double  newBigDist  )  [inline]

Definition at line 169 of file G4PropagatorInField.icc.

00170 {
00171   if( fLargestAcceptableStep>0.0 )
00172   {
00173     fLargestAcceptableStep = newBigDist;
00174   }
00175 }

void G4PropagatorInField::SetMaximumEpsilonStep ( G4double  newEpsMax  )  [inline]

Definition at line 163 of file G4PropagatorInField.icc.

References G4FieldManager::SetMaximumEpsilonStep().

00164 {
00165   fDetectorFieldMgr->SetMaximumEpsilonStep( newEpsMax );
00166 }

void G4PropagatorInField::SetMaxLoopCount ( G4int  new_max  )  [inline]

Definition at line 106 of file G4PropagatorInField.icc.

00107 {
00108   fMax_loop_count = new_max;
00109 }

void G4PropagatorInField::SetMinimumEpsilonStep ( G4double  newEpsMin  )  [inline]

Definition at line 150 of file G4PropagatorInField.icc.

References G4FieldManager::SetMinimumEpsilonStep().

00151 {
00152   fDetectorFieldMgr->SetMinimumEpsilonStep(newEpsMin);
00153 }

void G4PropagatorInField::SetNavigatorForPropagating ( G4Navigator SimpleOrMultiNavigator  )  [inline]

Definition at line 247 of file G4PropagatorInField.icc.

References G4VIntersectionLocator::SetNavigatorFor().

Referenced by G4PathFinder::EnableParallelNavigation().

00248 {
00249   if(SimpleOrMultiNavigator)  { 
00250      fNavigator= SimpleOrMultiNavigator; 
00251      if( fIntersectionLocator ) {
00252          fIntersectionLocator->SetNavigatorFor( SimpleOrMultiNavigator );
00253      }
00254   }
00255 }

void G4PropagatorInField::SetThresholdNoZeroStep ( G4int  noAct,
G4int  noHarsh,
G4int  noAbandon 
) [inline]

Definition at line 190 of file G4PropagatorInField.icc.

00193 {
00194   if( noAct>0 ) 
00195     fActionThreshold_NoZeroSteps = noAct; 
00196 
00197   if( noHarsh > fActionThreshold_NoZeroSteps )
00198     fSevereActionThreshold_NoZeroSteps = noHarsh; 
00199   else
00200     fSevereActionThreshold_NoZeroSteps = 2*(fActionThreshold_NoZeroSteps+1);
00201 
00202   if( noAbandon > fSevereActionThreshold_NoZeroSteps+5 )
00203     fAbandonThreshold_NoZeroSteps = noAbandon; 
00204   else
00205     fAbandonThreshold_NoZeroSteps = 2*(fSevereActionThreshold_NoZeroSteps+3); 
00206 }

void G4PropagatorInField::SetTrajectoryFilter ( G4VCurvedTrajectoryFilter filter  ) 

Definition at line 614 of file G4PropagatorInField.cc.

Referenced by G4VisCommandSceneAddTrajectories::SetNewValue().

00615 {
00616   fpTrajectoryFilter = filter;
00617 }

void G4PropagatorInField::SetUseSafetyForOptimization ( G4bool   )  [inline]

Definition at line 234 of file G4PropagatorInField.icc.

00235 {
00236    fUseSafetyForOptimisation= value;
00237 }

G4int G4PropagatorInField::SetVerboseLevel ( G4int  verbose  ) 

Definition at line 670 of file G4PropagatorInField.cc.

References G4cout, G4endl, GetChordFinder(), G4ChordFinder::GetIntegrationDriver(), and G4MagInt_Driver::SetVerboseLevel().

00671 {
00672   G4int oldval= fVerboseLevel;
00673   fVerboseLevel= level;
00674 
00675   // Forward the verbose level 'reduced' to ChordFinder,
00676   // MagIntegratorDriver ... ? 
00677   //
00678   G4MagInt_Driver* integrDriver= GetChordFinder()->GetIntegrationDriver(); 
00679   integrDriver->SetVerboseLevel( fVerboseLevel - 2 );
00680   G4cout << "Set Driver verbosity to " << fVerboseLevel - 2 << G4endl;
00681 
00682   return oldval;
00683 }

void G4PropagatorInField::SetZeroStepThreshold ( G4double  newLength  )  [inline]

Definition at line 221 of file G4PropagatorInField.icc.

00222 { 
00223   fZeroStepThreshold= newLength;
00224 }

G4int G4PropagatorInField::Verbose (  )  const [inline]

Definition at line 131 of file G4PropagatorInField.icc.

References GetVerboseLevel().

00132 {
00133   return GetVerboseLevel();
00134 }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:53:00 2013 for Geant4 by  doxygen 1.4.7