ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
G4InterpolationDriver.hh
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file G4InterpolationDriver.hh
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
// G4InterpolationDriver
27
//
28
// Class description:
29
//
30
// Driver class which uses Runge-Kutta stepper with interpolation property
31
// to integrate track with error control
32
33
// Created: D.Sorokin, 2018
34
// --------------------------------------------------------------------
35
#ifndef G4INTERPOLATION_DRIVER_HH
36
#define G4INTERPOLATION_DRIVER_HH
37
38
#include "
G4RKIntegrationDriver.hh
"
39
#include "
G4FieldUtils.hh
"
40
41
#include "
globals.hh
"
42
43
#include <vector>
44
#include <memory>
45
46
template
<
class
T>
47
class
G4InterpolationDriver
:
public
G4RKIntegrationDriver
<T>
48
{
49
public
:
50
51
G4InterpolationDriver
(
G4double
hminimum,
52
T
*
stepper
,
53
G4int
numberOfComponents = 6,
54
G4int
statisticsVerbosity = 0);
55
56
virtual
~G4InterpolationDriver
()
override
;
57
58
G4InterpolationDriver
(
const
G4InterpolationDriver
&)=
delete
;
59
const
G4InterpolationDriver
&
operator=
(
const
G4InterpolationDriver
&)=
delete
;
60
61
virtual
G4double
AdvanceChordLimited
(
G4FieldTrack
&
track
,
62
G4double
hstep,
63
G4double
eps
,
64
G4double
chordDistance)
override
;
65
66
virtual
void
OnStartTracking
()
override
;
67
virtual
void
OnComputeStep
()
override
;
68
virtual
G4bool
DoesReIntegrate
()
override
{
return
false
; }
69
// Interpolation driver does not recalculate when AccurateAdvance is called
70
// -- reintegration would require other calls
71
72
virtual
G4bool
AccurateAdvance
(
G4FieldTrack
& track,
73
G4double
hstep,
74
G4double
eps,
// Requested y_err/hstep
75
G4double
hinitial = 0)
override
;
76
// Integrates ODE from current s (s=s0) to s=s0+h with accuracy eps.
77
// On output track is replaced by value at end of interval.
78
// The concept is similar to the odeint routine from NRC p.721-722.
79
80
virtual
void
SetVerboseLevel
(
G4int
level)
override
;
81
virtual
G4int
GetVerboseLevel
()
const override
;
82
83
private
:
84
85
struct
InterpStepper
86
{
87
std::unique_ptr<T>
stepper
;
88
G4double
begin
;
89
G4double
end
;
90
G4double
inverseLength
;
91
};
92
93
using
StepperIterator
=
typename
std::vector<InterpStepper>::iterator;
94
using
ConstStepperIterator
=
typename
std::vector<InterpStepper>::const_iterator;
95
96
G4double
OneGoodStep
(
StepperIterator
it
,
97
field_utils::State
&
y
,
98
field_utils::State
& dydx,
99
G4double
& hstep,
100
G4double
eps,
101
G4double
curveLength);
102
// This takes one Step that is of size htry, or as large
103
// as possible while satisfying the accuracy criterion of:
104
// yerr < eps * |y_end-y_start|
105
// return hdid
106
107
void
Interpolate
(
G4double
curveLength,
field_utils::State
&
y
)
const
;
108
109
void
InterpolateImpl
(
G4double
curveLength,
110
ConstStepperIterator
it
,
111
field_utils::State
&
y
)
const
;
112
113
G4double
DistChord
(
const
field_utils::State
& yBegin,
114
G4double
curveLengthBegin,
115
const
field_utils::State
& yEnd,
116
G4double
curveLengthEnd)
const
;
117
118
G4double
FindNextChord
(
const
field_utils::State
& yBegin,
119
G4double
curveLengthBegin,
120
field_utils::State
& yEnd,
121
G4double
curveLengthEnd,
122
G4double
dChord,
123
G4double
maxChordDistance);
124
125
G4double
CalcChordStep
(
G4double
stepTrialOld,
126
G4double
dChordStep,
127
G4double
fDeltaChord);
128
129
void
PrintState
()
const
;
130
131
void
CheckState
()
const
;
132
133
void
AccumulateStatistics
(
G4int
noTrials);
134
135
private
:
136
137
std::vector<InterpStepper>
fSteppers
;
138
StepperIterator
fLastStepper
;
139
G4bool
fKeepLastStepper
=
false
;
140
141
G4double
fhnext
=
DBL_MAX
;
// Memory of last good step size for integration
142
143
// Minimum Step allowed in a Step (in units of length) // Parameter
144
G4double
fMinimumStep
;
145
146
G4double
fChordStepEstimate
=
DBL_MAX
;
147
const
G4double
fFractionNextEstimate
= 0.98;
// Constant
148
const
G4double
fSmallestCurveFraction
= 0.01;
// Constant
149
150
G4int
fVerboseLevel
;
// Parameter
151
152
field_utils::State
fdydx
;
153
G4bool
fFirstStep
=
true
;
154
155
const
G4int
fMaxTrials
= 100;
// Constant
156
G4int
fTotalStepsForTrack
= 0;
157
158
// statistics
159
G4int
fTotalNoTrials
= 0;
160
G4int
fNoCalls
= 0;
161
G4int
fmaxTrials
= 0;
162
163
using
Base
=
G4RKIntegrationDriver<T>
;
164
};
165
166
#include "G4InterpolationDriver.icc"
167
168
#endif
geant4
tree
geant4-10.6-release
source
geometry
magneticfield
include
G4InterpolationDriver.hh
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:16
using
1.8.2 with
ECCE GitHub integration