@@ -283,46 +283,6 @@ static __device__ __forceinline__ void TransportElectrons(adept::TrackManager<Tr
283
283
const double theElCut = g4HepEmData.fTheMatCutData ->fMatCutData [auxData.fMCIndex ].fSecElProdCutE ;
284
284
const double theGammaCut = g4HepEmData.fTheMatCutData ->fMatCutData [auxData.fMCIndex ].fSecGamProdCutE ;
285
285
286
- if (stopped) {
287
- if (!IsElectron) {
288
- // Annihilate the stopped positron into two gammas heading to opposite
289
- // directions (isotropic).
290
-
291
- // Apply cuts
292
- if (ApplyCuts && (copcore::units::kElectronMassC2 < theGammaCut)) {
293
- // Deposit the energy here and don't initialize any secondaries
294
- energyDeposit += 2 * copcore::units::kElectronMassC2 ;
295
- } else {
296
- Track &gamma1 = secondaries.gammas ->NextTrack ();
297
- Track &gamma2 = secondaries.gammas ->NextTrack ();
298
-
299
- adept_scoring::AccountProduced (userScoring, /* numElectrons*/ 0 , /* numPositrons*/ 0 , /* numGammas*/ 2 );
300
-
301
- const double cost = 2 * currentTrack.Uniform () - 1 ;
302
- const double sint = sqrt (1 - cost * cost);
303
- const double phi = k2Pi * currentTrack.Uniform ();
304
- double sinPhi, cosPhi;
305
- sincos (phi, &sinPhi, &cosPhi);
306
-
307
- gamma1.InitAsSecondary (pos, navState, globalTime);
308
- newRNG.Advance ();
309
- gamma1.parentID = currentTrack.parentID ;
310
- gamma1.rngState = newRNG;
311
- gamma1.eKin = copcore::units::kElectronMassC2 ;
312
- gamma1.dir .Set (sint * cosPhi, sint * sinPhi, cost);
313
-
314
- gamma2.InitAsSecondary (pos, navState, globalTime);
315
- // Reuse the RNG state of the dying track.
316
- gamma2.parentID = currentTrack.parentID ;
317
- gamma2.rngState = currentTrack.rngState ;
318
- gamma2.eKin = copcore::units::kElectronMassC2 ;
319
- gamma2.dir = -gamma1.dir ;
320
- }
321
- }
322
- // Particles are killed by not enqueuing them into the new activeQueue.
323
- // continue;
324
- }
325
-
326
286
if (!stopped) {
327
287
if (nextState.IsOnBoundary ()) {
328
288
// For now, just count that we hit something.
@@ -334,18 +294,15 @@ static __device__ __forceinline__ void TransportElectrons(adept::TrackManager<Tr
334
294
cross_boundary = true ;
335
295
}
336
296
// Particle left the world, don't enqueue it
337
- // continue;
338
297
} else if (!propagated || restrictedPhysicalStepLength) {
339
298
// Did not yet reach the interaction point due to error in the magnetic
340
299
// field propagation. Try again next time.
341
300
survive ();
342
301
reached_interaction = false ;
343
- // continue;
344
302
} else if (winnerProcessIndex < 0 ) {
345
303
// No discrete process, move on.
346
304
survive ();
347
305
reached_interaction = false ;
348
- // continue;
349
306
}
350
307
}
351
308
@@ -358,7 +315,6 @@ static __device__ __forceinline__ void TransportElectrons(adept::TrackManager<Tr
358
315
if (G4HepEmElectronManager::CheckDelta (&g4HepEmData, theTrack, currentTrack.Uniform ())) {
359
316
// A delta interaction happened, move on.
360
317
survive ();
361
- // continue;
362
318
} else {
363
319
// Perform the discrete interaction, make sure the branched RNG state is
364
320
// ready to be used.
@@ -395,6 +351,16 @@ static __device__ __forceinline__ void TransportElectrons(adept::TrackManager<Tr
395
351
}
396
352
397
353
eKin -= deltaEkin;
354
+
355
+ // if below tracking cut, deposit energy for electrons (positrons are annihilated later) and stop particles
356
+ if (eKin < g4HepEmPars.fElectronTrackingCut ) {
357
+ if (IsElectron) {
358
+ energyDeposit += eKin;
359
+ }
360
+ stopped = true ;
361
+ break ;
362
+ }
363
+
398
364
dir.Set (dirPrimary[0 ], dirPrimary[1 ], dirPrimary[2 ]);
399
365
survive ();
400
366
break ;
@@ -429,6 +395,16 @@ static __device__ __forceinline__ void TransportElectrons(adept::TrackManager<Tr
429
395
}
430
396
431
397
eKin -= deltaEkin;
398
+
399
+ // if below tracking cut, deposit energy for electrons (positrons are annihilated later) and stop particles
400
+ if (eKin < g4HepEmPars.fElectronTrackingCut ) {
401
+ if (IsElectron) {
402
+ energyDeposit += eKin;
403
+ }
404
+ stopped = true ;
405
+ break ;
406
+ }
407
+
432
408
dir.Set (dirPrimary[0 ], dirPrimary[1 ], dirPrimary[2 ]);
433
409
survive ();
434
410
break ;
@@ -480,7 +456,46 @@ static __device__ __forceinline__ void TransportElectrons(adept::TrackManager<Tr
480
456
}
481
457
}
482
458
483
- // Redord the step. Edep includes the continuous energy loss and edep from secondaries which were cut
459
+ if (stopped) {
460
+ if (!IsElectron) {
461
+ // Annihilate the stopped positron into two gammas heading to opposite
462
+ // directions (isotropic).
463
+
464
+ // Apply cuts
465
+ if (ApplyCuts && (copcore::units::kElectronMassC2 < theGammaCut)) {
466
+ // Deposit the energy here and don't initialize any secondaries
467
+ energyDeposit += 2 * copcore::units::kElectronMassC2 ;
468
+ } else {
469
+ Track &gamma1 = secondaries.gammas ->NextTrack ();
470
+ Track &gamma2 = secondaries.gammas ->NextTrack ();
471
+
472
+ adept_scoring::AccountProduced (userScoring, /* numElectrons*/ 0 , /* numPositrons*/ 0 , /* numGammas*/ 2 );
473
+
474
+ const double cost = 2 * currentTrack.Uniform () - 1 ;
475
+ const double sint = sqrt (1 - cost * cost);
476
+ const double phi = k2Pi * currentTrack.Uniform ();
477
+ double sinPhi, cosPhi;
478
+ sincos (phi, &sinPhi, &cosPhi);
479
+
480
+ gamma1.InitAsSecondary (pos, navState, globalTime);
481
+ newRNG.Advance ();
482
+ gamma1.parentID = currentTrack.parentID ;
483
+ gamma1.rngState = newRNG;
484
+ gamma1.eKin = copcore::units::kElectronMassC2 ;
485
+ gamma1.dir .Set (sint * cosPhi, sint * sinPhi, cost);
486
+
487
+ gamma2.InitAsSecondary (pos, navState, globalTime);
488
+ // Reuse the RNG state of the dying track.
489
+ gamma2.parentID = currentTrack.parentID ;
490
+ gamma2.rngState = currentTrack.rngState ;
491
+ gamma2.eKin = copcore::units::kElectronMassC2 ;
492
+ gamma2.dir = -gamma1.dir ;
493
+ }
494
+ }
495
+ // Particles are killed by not enqueuing them into the new activeQueue.
496
+ }
497
+
498
+ // Record the step. Edep includes the continuous energy loss and edep from secondaries which were cut
484
499
if (energyDeposit > 0 && auxData.fSensIndex >= 0 )
485
500
adept_scoring::RecordHit (userScoring, currentTrack.parentID ,
486
501
IsElectron ? 0 : 1 , // Particle type
0 commit comments