G4PropagatorInField.hh

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 // Class G4PropagatorInField 
00031 //
00032 // class description:
00033 // 
00034 // This class performs the navigation/propagation of a particle/track 
00035 // in a magnetic field. The field is in general non-uniform.
00036 // For the calculation of the path, it relies on the class G4ChordFinder.
00037 //
00038 // Key Method: ComputeStep(..)
00039 
00040 // History:
00041 // -------
00042 // 25.10.96 John Apostolakis,  design and implementation 
00043 // 25.03.97 John Apostolakis,  adaptation for G4Transportation and cleanup
00044 //  8.11.02 John Apostolakis,  changes to enable use of safety in intersecting
00045 // ---------------------------------------------------------------------------
00046 
00047 #ifndef G4PropagatorInField_hh 
00048 #define G4PropagatorInField_hh  1
00049 
00050 #include "G4Types.hh"
00051 
00052 #include <vector>
00053 
00054 #include "G4FieldTrack.hh"
00055 #include "G4FieldManager.hh"
00056 #include "G4VIntersectionLocator.hh"
00057 
00058 class G4ChordFinder; 
00059 
00060 class G4Navigator;
00061 class G4VPhysicalVolume;
00062 class G4VCurvedTrajectoryFilter;
00063 
00064 class G4PropagatorInField
00065 {
00066 
00067  public:  // with description
00068 
00069    G4PropagatorInField( G4Navigator    *theNavigator, 
00070                         G4FieldManager *detectorFieldMgr,
00071                         G4VIntersectionLocator *vLocator=0 );
00072   ~G4PropagatorInField();
00073 
00074    G4double ComputeStep( G4FieldTrack      &pFieldTrack,
00075                          G4double           pCurrentProposedStepLength,
00076                          G4double          &pNewSafety, 
00077                          G4VPhysicalVolume *pPhysVol=0 );
00078      // Compute the next geometric Step
00079 
00080    inline G4ThreeVector  EndPosition() const;       
00081    inline G4ThreeVector  EndMomentumDir() const;
00082    inline G4bool         IsParticleLooping() const;
00083      // Return the state after the Step
00084 
00085    inline G4double  GetEpsilonStep() const;
00086      // Relative accuracy for current Step (Calc.)
00087    inline void      SetEpsilonStep(G4double newEps);
00088      // The ratio DeltaOneStep()/h_current_step
00089 
00090    inline void SetChargeMomentumMass( G4double charge,     // in e+ units
00091                                       G4double momentum,   // in Geant4 units
00092                                       G4double pMass );  
00093      // Inform this and all associated classes of q, p, m 
00094 
00095    G4FieldManager*  FindAndSetFieldManager(G4VPhysicalVolume* pCurrentPhysVol);
00096      // Set (and return) the correct field manager (global or local), 
00097      //    if it exists.
00098      // Should be called before ComputeStep is called;
00099      //   - currently, ComputeStep will call it, if it has not been called.
00100  
00101    inline G4ChordFinder* GetChordFinder();
00102 
00103           G4int  SetVerboseLevel( G4int verbose );
00104    inline G4int  GetVerboseLevel() const;
00105    inline G4int  Verbose() const;
00106 
00107    inline G4int   GetMaxLoopCount() const;
00108    inline void    SetMaxLoopCount( G4int new_max );
00109      // A maximum for the number of steps that a (looping) particle can take.
00110 
00111    void printStatus( const G4FieldTrack&        startFT,
00112                      const G4FieldTrack&        currentFT, 
00113                            G4double             requestStep, 
00114                            G4double             safety,
00115                            G4int                step, 
00116                            G4VPhysicalVolume*   startVolume);
00117      // Print Method - useful mostly for debugging.
00118 
00119    inline G4FieldTrack GetEndState() const;
00120 
00121    inline G4double  GetMinimumEpsilonStep() const;  // Min for relative accuracy 
00122    inline void      SetMinimumEpsilonStep( G4double newEpsMin ); //  of any step
00123    inline G4double  GetMaximumEpsilonStep() const;
00124    inline void      SetMaximumEpsilonStep( G4double newEpsMax );
00125      // The 4 above methods are now obsolescent but *for now* will work 
00126      // They are being replaced by same-name methods in G4FieldManager,
00127      // allowing the specialisation in different volumes. 
00128      // Their new behaviour is to change the values for the global field
00129      // manager
00130 
00131    inline void      SetLargestAcceptableStep( G4double newBigDist );
00132    inline G4double  GetLargestAcceptableStep();
00133 
00134    void SetTrajectoryFilter(G4VCurvedTrajectoryFilter* filter);
00135      // Set the filter that examines & stores 'intermediate' 
00136      //  curved trajectory points.  Currently only position is stored.
00137 
00138    std::vector<G4ThreeVector>* GimmeTrajectoryVectorAndForgetIt() const;
00139      // Access the points which have passed by the filter.
00140      // Responsibility for deleting the points lies with the client.
00141      // This method MUST BE called exactly ONCE per step. 
00142 
00143    void ClearPropagatorState();
00144      // Clear all the State of this class and its current associates
00145      //   --> the current field manager & chord finder will also be called
00146 
00147    inline void SetDetectorFieldManager( G4FieldManager* newGlobalFieldManager );
00148      // Update this (dangerous) state -- for the time being
00149   
00150    inline void   SetUseSafetyForOptimization( G4bool );
00151    inline G4bool GetUseSafetyForOptimization();
00152      // Toggle & view parameter for using safety to discard 
00153      //   unneccesary calls to navigator (thus 'optimising' performance)
00154    inline G4bool IntersectChord( const G4ThreeVector&  StartPointA,
00155                                  const G4ThreeVector&  EndPointB,
00156                                  G4double      &NewSafety,
00157                                  G4double      &LinearStepLength,
00158                                  G4ThreeVector &IntersectionPoint);
00159      // Intersect the chord from StartPointA to EndPointB
00160      // and return whether an intersection occurred
00161      // NOTE : SAFETY IS CHANGED
00162 
00163    inline G4VIntersectionLocator* GetIntersectionLocator();
00164    inline void SetIntersectionLocator(G4VIntersectionLocator *pLocator );
00165      // Change or get the object which calculates the exact 
00166      //  intersection point with the next boundary
00167  
00168  public:  // without description
00169 
00170    inline G4double  GetDeltaIntersection() const;
00171    inline G4double  GetDeltaOneStep() const;
00172 
00173    inline G4FieldManager*  GetCurrentFieldManager();
00174    inline void             SetNavigatorForPropagating( G4Navigator *SimpleOrMultiNavigator ); 
00175    inline G4Navigator*     GetNavigatorForPropagating(); 
00176 
00177    inline void SetThresholdNoZeroStep( G4int noAct,
00178                                        G4int noHarsh,
00179                                        G4int noAbandon );
00180    inline G4int GetThresholdNoZeroSteps( G4int i ); 
00181 
00182    inline G4double  GetZeroStepThreshold(); 
00183    inline void      SetZeroStepThreshold( G4double newLength ); 
00184 
00185    void RefreshIntersectionLocator(); 
00186      // Update the Locator with parameters from this class
00187      //    and from current field manager
00188 
00189  protected:  // with description
00190 
00191    void PrintStepLengthDiagnostic( G4double      currentProposedStepLength,
00192                                    G4double      decreaseFactor,
00193                                    G4double      stepTrial,
00194                              const G4FieldTrack& aFieldTrack);
00195  private:
00196    // ----------------------------------------------------------------------
00197    //  DATA Members
00198    // ----------------------------------------------------------------------
00199 
00200    //  ==================================================================
00201    //  INVARIANTS - Must not change during tracking
00202 
00203    //  ** PARAMETERS -----------
00204    G4int    fMax_loop_count;
00205        // Limit for the number of sub-steps taken in one call to ComputeStep
00206    G4bool   fUseSafetyForOptimisation;
00207 
00208     //  Thresholds for identifying "abnormal" cases - which cause looping
00209    G4int    fActionThreshold_NoZeroSteps;       //  Threshold # - above it act
00210    G4int    fSevereActionThreshold_NoZeroSteps; //  Threshold # to act harshly
00211    G4int    fAbandonThreshold_NoZeroSteps;      //  Threshold # to abandon
00212    G4double fZeroStepThreshold; 
00213        // Threshold *length* for counting of tiny or 'zero' steps 
00214  
00215    G4double fLargestAcceptableStep;
00216        // Maximum size of a step - for optimization (and to avoid problems)
00217    //  ** End of PARAMETERS -----
00218 
00219    G4double kCarTolerance;
00220        // Geometrical tolerance defining surface thickness
00221 
00222    G4bool   fAllocatedLocator;                    //  Book-keeping
00223 
00224    //  --------------------------------------------------------
00225    //  ** Dependent Objects - to which work is delegated 
00226 
00227    G4FieldManager         *fDetectorFieldMgr; 
00228        // The  Field Manager of the whole Detector.  (default)
00229 
00230    G4VIntersectionLocator *fIntersectionLocator;
00231      // Refines candidate intersection
00232 
00233    G4VCurvedTrajectoryFilter* fpTrajectoryFilter;
00234      // The filter encapsulates the algorithm which selects which
00235      // intermediate points should be stored in a trajectory. 
00236      // When it is NULL, no intermediate points will be stored.
00237      // Else PIF::ComputeStep must submit (all) intermediate
00238      // points it calculates, to this filter.  (jacek 04/11/2002)
00239 
00240    G4Navigator            *fNavigator;
00241      // Set externally - only by tracking / run manager
00242    //
00243    //  ** End of Dependent Objects ----------------------------
00244 
00245    //  End of INVARIANTS 
00246    //  ==================================================================
00247 
00248    //  STATE information
00249    //  -----------------
00250    G4FieldManager *fCurrentFieldMgr;
00251       // The  Field Manager of the current volume (may be the global)
00252    G4bool         fSetFieldMgr;  // Has it been set for the current step
00253 
00254    // Parameters of current step
00255    G4double       fCharge, fInitialMomentumModulus, fMass;
00256    G4double       fEpsilonStep;        // Relative accuracy of current Step
00257    G4FieldTrack   End_PointAndTangent; // End point storage
00258    G4bool         fParticleIsLooping;
00259    G4int          fNoZeroStep;         //  Count of zero Steps
00260 
00261    // State used for Optimisation
00262    G4double       fFull_CurveLen_of_LastAttempt; 
00263    G4double       fLast_ProposedStepLength; 
00264        // Previous step information -- for use in adjust step size
00265    G4ThreeVector  fPreviousSftOrigin;
00266    G4double       fPreviousSafety; 
00267        // Last safety origin & value: for optimisation
00268 
00269    G4int          fVerboseLevel;
00270        // For debuging purposes
00271 
00272  private:
00273 };
00274 
00275 // Inline methods.
00276 // *******************************
00277 
00278 #include "G4PropagatorInField.icc"
00279 
00280 #endif 

Generated on Mon May 27 17:49:26 2013 for Geant4 by  doxygen 1.4.7