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