Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ChordFinderDelegate.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// G4ChordFinderDelegate
27//
28// Class description:
29//
30// Implementation of common algorithm of finding step size
31// with distance to chord less than provided value.
32
33// Author: Dmitry Sorokin (CERN, Google Summer of Code 2017), 12.09.2018
34// --------------------------------------------------------------------
35#ifndef G4CHORD_FINDER_DELEGATE_HH
36#define G4CHORD_FINDER_DELEGATE_HH
37
38#include <iomanip>
40
41/**
42 * @brief G4ChordFinderDelegate is a templated class for a common algorithm
43 * of finding step size with distance to the chord less than the provided value.
44 */
45
46template <class Driver>
48{
49 public:
50
51 /**
52 * Virtual Destructor.
53 */
55
56 /**
57 * Computes the step to take, based on chord limits.
58 * @param[in,out] track The current track in field.
59 * @param[in] hstep Proposed step length.
60 * @param[in] eps Requested accuracy, y_err/hstep.
61 * @param[in] chordDistance Maximum sagitta distance.
62 * @returns The length of step taken.
63 */
65 G4double hstep,
66 G4double eps,
67 G4double chordDistance);
68
69 /**
70 * Resets last step estimate to DBL_MAX.
71 */
73
74 /**
75 * Getter and setter for step estimate.
76 */
79
80 /**
81 * Gets statistics about number of calls & trials in FindNextChord().
82 */
84 G4int GetNoTrials(); // Total number of trials
85 G4int GetNoMaxTrials(); // Maximum # of trials for one call
86
87 /**
88 * Setters of performance parameters... change with great care!
89 */
90 void SetFractions_Last_Next(G4double fractLast = 0.90,
91 G4double fractNext = 0.95);
92 void SetFirstFraction(G4double fractFirst);
93
94 /**
95 * Printing for monitoring ...
96 */
97 G4double GetFirstFraction(); // Originally 0.999
98 G4double GetFractionLast(); // Originally 1.000
99 G4double GetFractionNextEstimate(); // Originally 0.980
100
101 /**
102 * Writes out to stream the parameters/state of the driver.
103 */
104 void StreamDelegateInfo( std::ostream& os ) const;
105
106 /**
107 * statistics printout for testing.
108 */
109 void TestChordPrint(G4int noTrials,
110 G4int lastStepTrial,
111 G4double dChordStep,
112 G4double fDeltaChord,
113 G4double nextStepTrial);
114 private:
115
116 Driver& GetDriver();
117
118 G4double FindNextChord(const G4FieldTrack& yStart,
119 G4double stepMax,
120 G4double epsStep,
121 G4double chordDistance,
122 G4FieldTrack& yEnd, // Endpoint
123 G4double& dyErrPos, // Error of endpoint
124 G4double& pStepForAccuracy);
125
126 G4double NewStep(G4double stepTrialOld,
127 G4double dChordStep, // Curr. dchord achieved
128 G4double fDeltaChord,
129 G4double& stepEstimate_Unconstrained);
130
131 void AccumulateStatistics(G4int noTrials);
132
133 void PrintStatistics();
134
135 private:
136
137 G4double fFirstFraction = 0.999;
138 G4double fFractionLast = 1.0;
139 G4double fFractionNextEstimate = 0.98;
140 G4double fLastStepEstimate_Unconstrained = DBL_MAX;
141
142 G4int fTotalNoTrials = 0;
143 G4int fNoCalls = 0;
144 G4int fmaxTrials = 0;
145};
146
147#include "G4ChordFinderDelegate.icc"
148
149#endif
double G4double
Definition G4Types.hh:83
int G4int
Definition G4Types.hh:85
G4ChordFinderDelegate is a templated class for a common algorithm of finding step size with distance ...
G4double GetFirstFraction()
void StreamDelegateInfo(std::ostream &os) const
void SetFractions_Last_Next(G4double fractLast=0.90, G4double fractNext=0.95)
void SetFirstFraction(G4double fractFirst)
void SetLastStepEstimateUnc(G4double stepEst)
G4double AdvanceChordLimitedImpl(G4FieldTrack &track, G4double hstep, G4double eps, G4double chordDistance)
G4double GetFractionNextEstimate()
G4double GetFractionLast()
void TestChordPrint(G4int noTrials, G4int lastStepTrial, G4double dChordStep, G4double fDeltaChord, G4double nextStepTrial)
virtual ~G4ChordFinderDelegate()
G4double GetLastStepEstimateUnc()
G4FieldTrack defines a data structure bringing together a magnetic track's state (position,...
#define DBL_MAX
Definition templates.hh:62