Skip to content

Commit 79b02bc

Browse files
committed
* streamline the fix to G4MagHelicalStepper for spiraling electrons
in a strong magnetic field, complete the port back to G4.10.p02 and forward to G4.10.06.p01, add a reset of the step size factor at the start of each new track to ClearAllChordFindersState in class G4FieldManagerStore. [rtj]
1 parent 95920d8 commit 79b02bc

File tree

6 files changed

+19
-33
lines changed

6 files changed

+19
-33
lines changed

src/G4.10.02.p02fixes/G4FieldManagerStore.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ G4FieldManagerStore::ClearAllChordFindersState()
155155
if( pChordFnd )
156156
{
157157
pChordFnd->ResetStepEstimate();
158+
pChordFnd->SetFractions_Last_Next(-1, -1);
158159
G4MagInt_Driver *driver =
159160
dynamic_cast<G4MagInt_Driver*>(pChordFnd->GetIntegrationDriver());
160161
if (driver) {

src/G4.10.02.p02fixes/G4MagHelicalStepper.cc

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,10 @@ G4MagHelicalStepper::AdvanceHelix( const G4double yIn[],
188188
G4ChordFinder *cf = G4TransportationManager::GetTransportationManager()->
189189
GetPropagatorInField()->
190190
GetChordFinder();
191-
G4double flast = cf->GetFractionLast();
192-
G4double fnext = cf->GetFractionNextEstimate();
193-
static G4double fnext_saved = 0.98;
194-
if (GetAngCurve() > 2*M_PI && 2*GetRadHelix() > cf->GetDeltaChord()) {
195-
cf->SetFractions_Last_Next(flast, 2*M_PI / GetAngCurve());
196-
}
197-
else if (fnext != fnext_saved) {
198-
cf->SetFractions_Last_Next(flast, fnext_saved);
199-
}
191+
if (GetAngCurve() > M_PI && 2*GetRadHelix() > cf->GetDeltaChord())
192+
cf->SetFractions_Last_Next(-1, M_PI / GetAngCurve());
193+
else
194+
cf->SetFractions_Last_Next(-1, -1);
200195
}
201196

202197
//

src/G4.10.04.p02fixes/G4FieldManagerStore.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ G4FieldManagerStore::ClearAllChordFindersState()
164164
if( pChordFnd )
165165
{
166166
pChordFnd->ResetStepEstimate();
167+
pChordFnd->SetFractions_Last_Next(-1, -1);
167168
G4MagInt_Driver *driver =
168169
dynamic_cast<G4MagInt_Driver*>(pChordFnd->GetIntegrationDriver());
169170
if (driver) {

src/G4.10.04.p02fixes/G4MagHelicalStepper.cc

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,10 @@ G4MagHelicalStepper::AdvanceHelix( const G4double yIn[],
188188
G4ChordFinder *cf = G4TransportationManager::GetTransportationManager()->
189189
GetPropagatorInField()->
190190
GetChordFinder();
191-
G4double flast = cf->GetFractionLast();
192-
G4double fnext = cf->GetFractionNextEstimate();
193-
static G4double fnext_saved = 0.98;
194-
if (GetAngCurve() > 2*M_PI && 2*GetRadHelix() > cf->GetDeltaChord()) {
195-
cf->SetFractions_Last_Next(flast, 2*M_PI / GetAngCurve());
196-
}
197-
else if (fnext != fnext_saved) {
198-
cf->SetFractions_Last_Next(flast, fnext_saved);
199-
}
191+
if (GetAngCurve() > M_PI && 2*GetRadHelix() > cf->GetDeltaChord())
192+
cf->SetFractions_Last_Next(-1, M_PI / GetAngCurve());
193+
else
194+
cf->SetFractions_Last_Next(-1, -1);
200195
}
201196

202197
//

src/G4.10.06.p01fixes/G4FieldManagerStore.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ G4FieldManagerStore::ClearAllChordFindersState()
165165
G4MagInt_Driver *driver =
166166
dynamic_cast<G4MagInt_Driver*>(pChordFnd->GetIntegrationDriver());
167167
if (driver) {
168+
driver->SetFractions_Last_Next(-1, -1);
168169
G4MagHelicalStepper *stepper =
169170
dynamic_cast<G4MagHelicalStepper*>(driver->GetStepper());
170171
if (stepper)

src/G4.10.06.p01fixes/G4MagHelicalStepper.cc

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#include "G4ChordFinder.hh"
4141
#include "G4PropagatorInField.hh"
4242
#include "G4TransportationManager.hh"
43-
43+
#include "G4MagIntegratorDriver.hh"
4444

4545
// Constant for determining unit conversion when using normal as integrand.
4646
//
@@ -187,21 +187,14 @@ G4MagHelicalStepper::AdvanceHelix( const G4double yIn[],
187187
G4ChordFinder *cf = G4TransportationManager::GetTransportationManager()->
188188
GetPropagatorInField()->
189189
GetChordFinder();
190-
//G4double flast = cf->GetFractionLast();
191-
//G4double fnext = cf->GetFractionNextEstimate();
192-
//static G4double fnext_saved = 0.98;
193-
if (GetAngCurve() > 2*M_PI && 2*GetRadHelix() > cf->GetDeltaChord()) {
194-
G4cerr << "Warning in G4MagHelicalStepper::AdvanceHelix - "
195-
<< "low-energy particle spiralling in strong magnetic field "
196-
<< G4endl;
197-
G4cerr << "needs to limit the step, but hooks to do so were removed "
198-
<< "from G4ChordFinder in v4.10.06 -- complain to R.T. Jones!"
199-
<< G4endl;
200-
//cf->SetFractions_Last_Next(flast, 2*M_PI / GetAngCurve());
190+
if (GetAngCurve() > M_PI && 2*GetRadHelix() > cf->GetDeltaChord()) {
191+
G4MagInt_Driver *driver =
192+
dynamic_cast<G4MagInt_Driver*>(cf->GetIntegrationDriver());
193+
if (driver)
194+
driver->SetFractions_Last_Next(-1, M_PI / GetAngCurve());
195+
else
196+
driver->SetFractions_Last_Next(-1, -1);
201197
}
202-
//else if (fnext != fnext_saved) {
203-
// cf->SetFractions_Last_Next(flast, fnext_saved);
204-
//}
205198
}
206199

207200
// Use the midpoint method to get an error estimate and correction

0 commit comments

Comments
 (0)