Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-16 08:25:31

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 G4PropagatorInField Inline implementation
0027 //
0028 //  To create an object of this type, must have:
0029 //  - an object that calculates the Curved paths 
0030 //  - the navigator to find (linear) intersections
0031 //  - and also must know the value of the maximum displacement allowed
0032 // 
0033 // Author: John Apostolakis (CERN), 25 October 1996
0034 // ------------------------------------------------------------------------
0035 
0036 // ------------------------------------------------------------------------
0037 //
0038 inline
0039 G4ChordFinder* G4PropagatorInField::GetChordFinder()
0040 {
0041   // The "Chord Finder" of the current Field Mgr is used
0042   //    -- this could be of the global field manager
0043   //        or that of another, from the current volume 
0044   return fCurrentFieldMgr->GetChordFinder(); 
0045 }
0046 
0047 // ------------------------------------------------------------------------
0048 // Obtain the final space-point and velocity (normal) at the end of the Step
0049 //
0050 inline
0051 G4ThreeVector G4PropagatorInField::EndPosition() const
0052 {
0053   return End_PointAndTangent.GetPosition(); 
0054 }
0055 
0056 // ------------------------------------------------------------------------
0057 //
0058 inline
0059 G4ThreeVector  G4PropagatorInField::EndMomentumDir() const
0060 {
0061   return End_PointAndTangent.GetMomentumDir(); 
0062 }
0063 
0064 // ------------------------------------------------------------------------
0065 //
0066 inline
0067 G4double G4PropagatorInField::GetEpsilonStep() const
0068 { 
0069   return fEpsilonStep; 
0070 }
0071 
0072 // ------------------------------------------------------------------------
0073 //
0074 inline
0075 void G4PropagatorInField::SetEpsilonStep( G4double newEps )
0076 {
0077   fEpsilonStep = newEps;
0078 }
0079 
0080 // ------------------------------------------------------------------------
0081 //
0082 inline
0083 G4bool G4PropagatorInField::IsParticleLooping() const
0084 {
0085   return fParticleIsLooping;
0086 }
0087 
0088 // ------------------------------------------------------------------------
0089 //
0090 inline
0091 G4int G4PropagatorInField::GetMaxLoopCount() const
0092 {
0093   return fMax_loop_count;
0094 }
0095 
0096 // ------------------------------------------------------------------------
0097 //
0098 inline
0099 void G4PropagatorInField::SetMaxLoopCount( G4int new_max ) 
0100 {
0101   fMax_loop_count = new_max;
0102 }
0103 
0104 // ------------------------------------------------------------------------
0105 //
0106 inline
0107 G4double G4PropagatorInField::GetDeltaIntersection() const
0108 {
0109   return fCurrentFieldMgr->GetDeltaIntersection();
0110 } 
0111 
0112 // ------------------------------------------------------------------------
0113 //
0114 inline
0115 G4double G4PropagatorInField::GetDeltaOneStep() const
0116 {
0117   return fCurrentFieldMgr->GetDeltaOneStep();
0118 }
0119 
0120 // ------------------------------------------------------------------------
0121 //
0122 inline
0123 G4int G4PropagatorInField::GetVerboseLevel() const
0124 {
0125   return fVerboseLevel;
0126 }
0127 
0128 // ------------------------------------------------------------------------
0129 //
0130 inline
0131 G4int G4PropagatorInField::Verbose() const // Obsolete
0132 {
0133   return GetVerboseLevel();
0134 }
0135 
0136 // ------------------------------------------------------------------------
0137 //
0138 inline
0139 void G4PropagatorInField::SetVerboseTrace( G4bool enable )
0140 {
0141   fVerbTracePiF = enable;
0142 }
0143 
0144 // ------------------------------------------------------------------------
0145 //
0146 inline
0147 G4bool G4PropagatorInField::GetVerboseTrace()
0148 {
0149   return fVerbTracePiF;
0150 }
0151 
0152 // ------------------------------------------------------------------------
0153 //
0154 inline
0155 void G4PropagatorInField::CheckMode(G4bool mode)
0156 {
0157   fCheck = mode;
0158   if (fIntersectionLocator != nullptr)
0159   {
0160     fIntersectionLocator->SetCheckMode(mode);
0161   }
0162 }
0163 
0164 // ------------------------------------------------------------------------
0165 //
0166 inline
0167 G4FieldTrack G4PropagatorInField::GetEndState() const
0168 {
0169   return End_PointAndTangent;
0170 }
0171 
0172 // ------------------------------------------------------------------------
0173 // Minimum for Relative accuracy of a Step in volumes of global field
0174 //
0175 inline 
0176 G4double  G4PropagatorInField::GetMinimumEpsilonStep() const
0177 {
0178   return fDetectorFieldMgr->GetMinimumEpsilonStep();
0179 }
0180 
0181 // ------------------------------------------------------------------------
0182 //
0183 inline 
0184 void G4PropagatorInField::SetMinimumEpsilonStep( G4double newEpsMin )
0185 {
0186   fDetectorFieldMgr->SetMinimumEpsilonStep(newEpsMin);
0187 }
0188 
0189 // ------------------------------------------------------------------------
0190 // Maximum for Relative accuracy of any Step 
0191 //
0192 inline 
0193 G4double  G4PropagatorInField::GetMaximumEpsilonStep() const
0194 {
0195   return fDetectorFieldMgr->GetMaximumEpsilonStep();
0196 }
0197 
0198 // ------------------------------------------------------------------------
0199 //
0200 inline 
0201 void G4PropagatorInField::SetMaximumEpsilonStep( G4double newEpsMax )
0202 {
0203   fDetectorFieldMgr->SetMaximumEpsilonStep( newEpsMax );
0204 }
0205 
0206 // ------------------------------------------------------------------------
0207 //
0208 inline
0209 G4FieldManager* G4PropagatorInField::GetCurrentFieldManager()
0210 {
0211   return fCurrentFieldMgr;
0212 } 
0213 
0214 // ------------------------------------------------------------------------
0215 //
0216 inline
0217 void G4PropagatorInField::SetThresholdNoZeroStep( G4int noAct,
0218                                                   G4int noHarsh,
0219                                                   G4int noAbandon )
0220 {
0221   if( noAct>0 )
0222   { 
0223     fActionThreshold_NoZeroSteps = noAct; 
0224   }
0225 
0226   if( noHarsh > fActionThreshold_NoZeroSteps )
0227   {
0228     fSevereActionThreshold_NoZeroSteps = noHarsh; 
0229   }
0230   else
0231   {
0232     fSevereActionThreshold_NoZeroSteps = 2*(fActionThreshold_NoZeroSteps+1);
0233 }
0234 
0235   if( noAbandon > fSevereActionThreshold_NoZeroSteps+5 )
0236   {
0237     fAbandonThreshold_NoZeroSteps = noAbandon; 
0238   }
0239   else
0240   {
0241     fAbandonThreshold_NoZeroSteps = 2*(fSevereActionThreshold_NoZeroSteps+3); 
0242   }
0243 }
0244 
0245 // ------------------------------------------------------------------------
0246 //
0247 inline
0248 G4int G4PropagatorInField::GetThresholdNoZeroSteps( G4int i )
0249 {
0250    G4int t=0;
0251    if( i==0 )     { t = 3; }     // No of parameters
0252    else if (i==1) { t = fActionThreshold_NoZeroSteps; }
0253    else if (i==2) { t = fSevereActionThreshold_NoZeroSteps; }
0254    else if (i==3) { t = fAbandonThreshold_NoZeroSteps; }
0255 
0256    return t;
0257 }
0258 
0259 // ------------------------------------------------------------------------
0260 //
0261 inline G4double  G4PropagatorInField::GetZeroStepThreshold()
0262 {
0263   return fZeroStepThreshold;
0264 }
0265 
0266 // ------------------------------------------------------------------------
0267 //
0268 inline void G4PropagatorInField::SetZeroStepThreshold( G4double newLength )
0269 { 
0270   fZeroStepThreshold= newLength;
0271 }
0272 
0273 // ------------------------------------------------------------------------
0274 //
0275 inline
0276 void G4PropagatorInField::SetDetectorFieldManager(G4FieldManager* newDFMan)
0277 {
0278   fDetectorFieldMgr = newDFMan; 
0279 }
0280 
0281 // ------------------------------------------------------------------------
0282 //
0283 inline
0284 void  G4PropagatorInField:: SetUseSafetyForOptimization( G4bool value )
0285 {
0286   fUseSafetyForOptimisation = value;
0287 }
0288 
0289 // ------------------------------------------------------------------------
0290 //
0291 inline 
0292 G4bool G4PropagatorInField::GetUseSafetyForOptimization() 
0293 { 
0294   return fUseSafetyForOptimisation; 
0295 }
0296 
0297 // ------------------------------------------------------------------------
0298 //
0299 inline 
0300 void G4PropagatorInField::
0301 SetNavigatorForPropagating( G4Navigator* SimpleOrMultiNavigator )
0302 {
0303   if (SimpleOrMultiNavigator != nullptr)
0304   { 
0305     fNavigator = SimpleOrMultiNavigator; 
0306     if( fIntersectionLocator != nullptr )
0307     {
0308       fIntersectionLocator->SetNavigatorFor( SimpleOrMultiNavigator );
0309     }
0310   }
0311 }
0312 
0313 // ------------------------------------------------------------------------
0314 //
0315 inline
0316 G4Navigator* G4PropagatorInField::GetNavigatorForPropagating()
0317 {
0318   return fNavigator;
0319 } 
0320 
0321 // ------------------------------------------------------------------------
0322 //
0323 inline 
0324 void G4PropagatorInField::
0325 SetIntersectionLocator( G4VIntersectionLocator* pIntLoc )
0326 {
0327   if (pIntLoc != nullptr)
0328   { 
0329     fIntersectionLocator= pIntLoc; 
0330 
0331     // Ensure that the Intersection Locator uses the correct Navigator
0332     //
0333     pIntLoc->SetNavigatorFor( fNavigator ); 
0334   }
0335 }
0336 
0337 // ------------------------------------------------------------------------
0338 //
0339 inline
0340 G4VIntersectionLocator* G4PropagatorInField::GetIntersectionLocator()
0341 {
0342   return fIntersectionLocator;
0343 } 
0344 
0345 // ------------------------------------------------------------------------
0346 //
0347 inline
0348 G4bool G4PropagatorInField::IntersectChord( const G4ThreeVector& StartPointA,
0349                                             const G4ThreeVector& EndPointB,
0350                                             G4double& NewSafety,
0351                                             G4double& LinearStepLength,
0352                                             G4ThreeVector& IntersectionPoint )
0353 {
0354   // Calculate the direction and length of the chord AB
0355   //
0356 #ifdef G4DEBUG_PROPAGATION   
0357   if( fVerbTracePiF )
0358      G4cout << "**** G4PropagatorInField::IntersectChord called."
0359             << " InPut: StartPointA: " << StartPointA
0360             << " EndPointB= " << EndPointB
0361             << " StepLength= " << LinearStepLength
0362             << " IntersecLen= " << IntersectionPoint
0363             << G4endl;
0364 #endif  
0365 
0366   G4bool retVal= fIntersectionLocator
0367          ->IntersectChord(StartPointA,EndPointB,NewSafety,
0368                           fPreviousSafety,fPreviousSftOrigin,
0369                           LinearStepLength,IntersectionPoint);
0370 
0371 #ifdef G4DEBUG_PROPAGATION
0372   if( fVerbTracePiF )
0373      G4cout << "**** G4PropagatorInField::IntersectChord  ended."
0374             << " OutPut: Safety= " << NewSafety
0375             << " StepLength= " << LinearStepLength
0376             << " IntersecPt= " << IntersectionPoint
0377             << G4endl;
0378 #endif  
0379 
0380   return retVal;
0381 }
0382 
0383 // ------------------------------------------------------------------------
0384 //
0385 inline G4bool G4PropagatorInField::IsFirstStepInVolume()
0386 {
0387   return fFirstStepInVolume;
0388 }
0389 
0390 // ------------------------------------------------------------------------
0391 //
0392 inline G4bool G4PropagatorInField::IsLastStepInVolume()
0393 {
0394   return fLastStepInVolume;
0395 }
0396 
0397 // ------------------------------------------------------------------------
0398 //
0399 inline void G4PropagatorInField::PrepareNewTrack()
0400 {
0401   fNewTrack = true;
0402   fFirstStepInVolume = false;
0403   fLastStepInVolume = false;
0404 } 
0405 
0406 // ------------------------------------------------------------------------
0407 //
0408 inline G4EquationOfMotion* G4PropagatorInField::GetCurrentEquationOfMotion()
0409 {
0410   if (auto pChordFinder = GetChordFinder())
0411   {
0412     if (auto pIntDriver = pChordFinder->GetIntegrationDriver())
0413     {
0414       return pIntDriver->GetEquationOfMotion();
0415     }
0416   }
0417   return nullptr;
0418 }
0419 
0420 // ------------------------------------------------------------------------
0421 //
0422 G4int G4PropagatorInField::GetIterationsToIncreaseChordDistance() const
0423 {
0424    return fIncreaseChordDistanceThreshold;
0425 }
0426 
0427 // ------------------------------------------------------------------------
0428 //
0429 void G4PropagatorInField::SetIterationsToIncreaseChordDistance(G4int numIters)
0430 {
0431    fIncreaseChordDistanceThreshold = numIters;
0432    if(numIters <= 0)
0433    {
0434      // Disables relaxation
0435      if( fVerboseLevel != 0 ){
0436        G4cout << "G4PropagatorInField: Turned OFF the Relaxation of chord "
0437               << "finder as iteration threshold = " << numIters
0438               << " is not positive." << G4endl;
0439      }
0440    }
0441 }