Back to home page

EIC code displayed by LXR

 
 

    


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

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