| Summary: | SteppingManager::GetfN2ndaries__DoIt() is incorrect | ||
|---|---|---|---|
| Product: | Geant4 | Reporter: | tmmacpha |
| Component: | tracking | Assignee: | Katsuya.Amako |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | other | ||
| Hardware: | All | ||
| OS: | Linux | ||
Since there doesnt seem to have been any activity on this bug and there has been
a new release since it has been posted I've included my solution to it in the
patch below:
==========================================================================
--- G4SteppingManager2.cc-bak Thu Feb 12 08:57:10 2004
+++ G4SteppingManager2.cc Thu Feb 12 09:22:58 2004
@@ -235,7 +235,7 @@
G4double lifeTime, shortestLifeTime;
fAtRestDoItProcTriggered = 0;
- fN2ndariesAtRestDoIt = 0;
+
shortestLifeTime = DBL_MAX;
unsigned int NofInactiveProc=0;
@@ -296,10 +296,11 @@
// Now Store the secondaries from ParticleChange to SecondaryList
G4Track* tempSecondaryTrack;
+ G4int fN2ndariesAtRestDoIt_2 =
+ fParticleChange->GetNumberOfSecondaries();
+ fN2ndariesAtRestDoIt += fN2ndariesAtRestDoIt_2;
- fN2ndariesAtRestDoIt = fParticleChange->GetNumberOfSecondaries();
-
- for(G4int DSecLoop=0 ; DSecLoop< fN2ndariesAtRestDoIt; DSecLoop++){
+ for(G4int DSecLoop=0 ; DSecLoop< fN2ndariesAtRestDoIt_2; DSecLoop++){
tempSecondaryTrack = fParticleChange->GetSecondary(DSecLoop);
if(tempSecondaryTrack->GetDefinition()->GetApplyCutsFlag())
@@ -351,7 +352,6 @@
}
// Invoke the all active continuous processes
- fN2ndariesAlongStepDoIt = 0;
for( size_t ci=0 ; ci<MAXofAlongStepLoops ; ci++ ){
fCurrentProcess = (*fAlongStepDoItVector)[ci];
@@ -370,10 +370,11 @@
// Now Store the secondaries from ParticleChange to SecondaryList
G4Track* tempSecondaryTrack;
+ G4int fN2ndariesAlongStepDoIt_2 =
+ fParticleChange->GetNumberOfSecondaries();
+ fN2ndariesAlongStepDoIt += fN2ndariesAlongStepDoIt_2;
- fN2ndariesAlongStepDoIt = fParticleChange->GetNumberOfSecondaries();
-
- for(G4int DSecLoop=0 ; DSecLoop< fN2ndariesAlongStepDoIt; DSecLoop++){
+ for(G4int DSecLoop=0 ; DSecLoop< fN2ndariesAlongStepDoIt_2; DSecLoop++){
tempSecondaryTrack = fParticleChange->GetSecondary(DSecLoop);
if(tempSecondaryTrack->GetDefinition()->GetApplyCutsFlag())
@@ -414,7 +415,6 @@
{
// Invoke the specified discrete processes
- fN2ndariesPostStepDoIt = 0;
for(size_t np=0; np < MAXofPostStepLoops; np++){
//
@@ -471,9 +471,11 @@
// Now Store the secondaries from ParticleChange to SecondaryList
G4Track* tempSecondaryTrack;
- fN2ndariesPostStepDoIt = fParticleChange->GetNumberOfSecondaries();
+ G4int fN2ndariesPostStepDoIt_2 =
+ fParticleChange->GetNumberOfSecondaries();
+ fN2ndariesPostStepDoIt += fN2ndariesPostStepDoIt_2;
- for(G4int DSecLoop=0 ; DSecLoop< fN2ndariesPostStepDoIt; DSecLoop++){
+ for(G4int DSecLoop=0 ; DSecLoop< fN2ndariesPostStepDoIt_2; DSecLoop++){
tempSecondaryTrack = fParticleChange->GetSecondary(DSecLoop);
if(tempSecondaryTrack->GetDefinition()->GetApplyCutsFlag())
|
Geant4.6.0 In the SteppingManager the GetfN2ndariesAtRestDoIt(), GetfN2ndariesAlongStepDoIt(), and fN2ndariesPostStepDoIt() functions return the wrong value in certain situations. This happens when there are multiple processes of a particular type (AtRest,AlongStep, or PostStep) that create secondaries during a single step. The functions above will only return the value of the number of secondaries created in the most recent process called (of that type). Also, if two processes have their DoIt called but only the first creates secondaries then the second will overwrite the value of the count. For example: I can use this piece of code in my stepping action: ------------------ G4TrackVector* fSecondary=fpSteppingManager->GetfSecondary(); G4int tN2ndariesTot = fpSteppingManager->GetfN2ndariesAtRestDoIt() + fpSteppingManager->GetfN2ndariesAlongStepDoIt() + fpSteppingManager->GetfN2ndariesPostStepDoIt(); G4cout<<"tN2ndariesTot = "<<tN2ndariesTot<<" (*fSecondary).size() = " <<(*fSecondary).size()<<G4endl; ------------------ And one step it will output: tN2ndariesTot = 0 (*fSecondary).size() = 0 The next step it will output: tN2ndariesTot = 0 (*fSecondary).size() = 1 The next step it will output: tN2ndariesTot = 409 (*fSecondary).size() = 411 Obviously there is 1 particle that is not being counted in the second step and another one in the third. The following loop used in several SteppingVerbose classes in the novice examples would miss these new secondaries: for(size_t lp1=(*fSecondary).size()-tN2ndariesTot; lp1<(*fSecondary).size(); lp1++){ //do some output } -- Trevor MacPhail