Back to home page

EIC code displayed by LXR

 
 

    


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

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 // G4ChordFinderDelegate
0027 //
0028 // Class description:
0029 //
0030 // Implementation of common algorithm of finding step size 
0031 // with distance to chord less then provided value. 
0032 
0033 // Created: D.Sorokin
0034 // --------------------------------------------------------------------
0035 #ifndef G4CHORD_FINDER_DELEGATE_HH
0036 #define G4CHORD_FINDER_DELEGATE_HH
0037 
0038 #include "G4VIntegrationDriver.hh"
0039 
0040 template <class Driver>
0041 class G4ChordFinderDelegate
0042 {
0043   public:
0044 
0045     virtual ~G4ChordFinderDelegate();
0046 
0047     G4double AdvanceChordLimitedImpl(G4FieldTrack& track,
0048                                      G4double hstep,
0049                                      G4double eps,
0050                                      G4double chordDistance);
0051     void ResetStepEstimate();
0052 
0053     void TestChordPrint(G4int noTrials, 
0054                         G4int lastStepTrial, 
0055                         G4double dChordStep, 
0056                         G4double fDeltaChord,
0057                         G4double nextStepTrial);
0058 
0059     // Get statistics about number of calls & trials in FindNextChord
0060     G4int GetNoCalls(); 
0061     G4int GetNoTrials();        // Total number of trials
0062     G4int GetNoMaxTrials();     // Maximum # of trials for one call
0063 
0064     // Parameters for  performance ... change with great care
0065     void SetFractions_Last_Next(G4double fractLast = 0.90, 
0066                                 G4double fractNext = 0.95); 
0067     void SetFirstFraction(G4double fractFirst);
0068 
0069     // Printing for monitoring ...
0070     G4double GetFirstFraction();         // Originally 0.999
0071     G4double GetFractionLast();          // Originally 1.000
0072     G4double GetFractionNextEstimate();  // Originally 0.980
0073 
0074     G4double GetLastStepEstimateUnc(); 
0075     void SetLastStepEstimateUnc(G4double stepEst);
0076 
0077     void  StreamDelegateInfo( std::ostream& os ) const;
0078      // Write out the parameters / state of the driver
0079    
0080   private:
0081 
0082     Driver& GetDriver();
0083 
0084     G4double FindNextChord(const G4FieldTrack& yStart,
0085                            G4double stepMax,
0086                            G4double epsStep,
0087                            G4double chordDistance,
0088                            G4FieldTrack& yEnd, // Endpoint
0089                            G4double& dyErrPos, // Error of endpoint
0090                            G4double& pStepForAccuracy);
0091 
0092     G4double NewStep(G4double stepTrialOld, 
0093                      G4double dChordStep, // Curr. dchord achieved
0094                      G4double fDeltaChord,
0095                      G4double& stepEstimate_Unconstrained);
0096 
0097     void AccumulateStatistics(G4int noTrials);
0098 
0099     void PrintStatistics();
0100 
0101     G4double fFirstFraction = 0.999;
0102     G4double fFractionLast = 1.0;
0103     G4double fFractionNextEstimate = 0.98;
0104     G4double fLastStepEstimate_Unconstrained = DBL_MAX;
0105 
0106     G4int fTotalNoTrials = 0;
0107     G4int fNoCalls = 0;
0108     G4int fmaxTrials = 0;
0109 };
0110 
0111 #include "G4ChordFinderDelegate.icc"
0112 
0113 #endif