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 | // |
---|
27 | // $Id: G4ChordFinder.icc,v 1.14 2008/10/29 14:34:35 gcosmo Exp $ |
---|
28 | // GEANT4 tag $Name: geant4-09-04-beta-01 $ |
---|
29 | // |
---|
30 | // G4ChordFinder inline implementations |
---|
31 | // |
---|
32 | // -------------------------------------------------------------------- |
---|
33 | |
---|
34 | inline |
---|
35 | void G4ChordFinder::SetIntegrationDriver(G4MagInt_Driver* IntegrationDriver) |
---|
36 | { |
---|
37 | fIntgrDriver=IntegrationDriver; |
---|
38 | } |
---|
39 | |
---|
40 | inline |
---|
41 | G4MagInt_Driver* G4ChordFinder::GetIntegrationDriver() |
---|
42 | { |
---|
43 | return fIntgrDriver; |
---|
44 | } |
---|
45 | |
---|
46 | inline |
---|
47 | G4bool G4ChordFinder::AcceptableMissDist(G4double dChordStep) const |
---|
48 | { |
---|
49 | return (dChordStep <= fDeltaChord) ; |
---|
50 | } |
---|
51 | |
---|
52 | inline |
---|
53 | void G4ChordFinder::SetChargeMomentumMass(G4double pCharge, // in e+ units |
---|
54 | G4double pMomentum, |
---|
55 | G4double pMass) |
---|
56 | { |
---|
57 | fIntgrDriver-> SetChargeMomentumMass(pCharge, pMomentum, pMass); |
---|
58 | } |
---|
59 | |
---|
60 | inline |
---|
61 | G4double G4ChordFinder::GetDeltaChord() const |
---|
62 | { |
---|
63 | return fDeltaChord; |
---|
64 | } |
---|
65 | |
---|
66 | inline |
---|
67 | void G4ChordFinder::SetDeltaChord(G4double newval) |
---|
68 | { |
---|
69 | fDeltaChord=newval; |
---|
70 | } |
---|
71 | |
---|
72 | // ...................................................................... |
---|
73 | inline |
---|
74 | G4double G4ChordFinder::GetLastStepEstimateUnc() |
---|
75 | { |
---|
76 | return fLastStepEstimate_Unconstrained; |
---|
77 | } |
---|
78 | inline |
---|
79 | void G4ChordFinder::SetLastStepEstimateUnc( G4double stepEst ) |
---|
80 | { |
---|
81 | fLastStepEstimate_Unconstrained = stepEst; |
---|
82 | } |
---|
83 | inline |
---|
84 | void G4ChordFinder::ResetStepEstimate() |
---|
85 | { |
---|
86 | fLastStepEstimate_Unconstrained = DBL_MAX; |
---|
87 | } |
---|
88 | |
---|
89 | // ...................................................................... |
---|
90 | inline G4int G4ChordFinder::GetNoCalls() { return fNoCalls_FNC; } |
---|
91 | inline G4int G4ChordFinder::GetNoTrials() { return fTotalNoTrials_FNC; } |
---|
92 | inline G4int G4ChordFinder::GetNoMaxTrials() { return fmaxTrials_FNC; } |
---|
93 | |
---|
94 | inline G4double G4ChordFinder::GetFirstFraction() { return fFirstFraction; } |
---|
95 | inline G4double G4ChordFinder::GetFractionLast() { return fFractionLast; } |
---|
96 | inline G4double G4ChordFinder::GetFractionNextEstimate() |
---|
97 | { return fFractionNextEstimate; } |
---|
98 | inline G4double G4ChordFinder::GetMultipleRadius() |
---|
99 | { return fMultipleRadius; } |
---|
100 | |
---|
101 | inline void G4ChordFinder::SetFirstFraction(G4double val){ fFirstFraction=val; } |
---|
102 | |
---|
103 | inline G4int G4ChordFinder::SetVerbose( G4int newvalue ) |
---|
104 | { |
---|
105 | G4int oldval= fStatsVerbose; |
---|
106 | fStatsVerbose = newvalue; |
---|
107 | return oldval; |
---|
108 | } |
---|
109 | |
---|
110 | inline |
---|
111 | void G4ChordFinder::AccumulateStatistics( G4int noTrials ) |
---|
112 | { |
---|
113 | // Statistics |
---|
114 | fTotalNoTrials_FNC += noTrials; |
---|
115 | fNoCalls_FNC++; |
---|
116 | // if( noTrials >= fmaxTrials_FNC ){ |
---|
117 | if (noTrials > fmaxTrials_FNC ) { |
---|
118 | fmaxTrials_FNC=noTrials; |
---|
119 | // fnoTimesMaxTrFNC=0; |
---|
120 | } else { |
---|
121 | // fnoTimesMaxTrFNC++; |
---|
122 | } |
---|
123 | // } |
---|
124 | } |
---|
125 | // A member that calculates the inverse parabolic through |
---|
126 | // the three points (x,y) and returns the value x that, for the |
---|
127 | // inverse parabolic, corresponds to y=0. |
---|
128 | // |
---|
129 | inline G4double G4ChordFinder::InvParabolic ( const G4double xa, const G4double ya, |
---|
130 | const G4double xb, const G4double yb, |
---|
131 | const G4double xc, const G4double yc ) |
---|
132 | { const G4double R = yb/yc, |
---|
133 | S = yb/ya, |
---|
134 | T = ya/yc; |
---|
135 | const G4double Q = (T-1)*(R-1)*(S-1); |
---|
136 | if (std::fabs(Q) <DBL_MIN ) return DBL_MAX; |
---|
137 | |
---|
138 | const G4double P = S*(T*(R-T)*(xc-xb) - (1-R)*(xb-xa)); |
---|
139 | return xb + P/Q; |
---|
140 | } |
---|