# Multiple Steps on geometricBoundary

**URL:** <https://geant4-forum.web.cern.ch/t/multiple-steps-on-geometricboundary/10540>\
**Category:** Particles, Track, Event, Run and Biasing\
**Created:** [May 8, 2023, 6:07pm UTC](https://geant4-forum.web.cern.ch/t/multiple-steps-on-geometricboundary/10540 "2023-05-08T18:07:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![weller](https://geant4-forum.web.cern.ch/user_avatar/geant4-forum.web.cern.ch/weller/32/3357_2.png) [@weller](https://geant4-forum.web.cern.ch/u/weller)\
**Post date:** [May 8, 2023, 6:07pm UTC](https://geant4-forum.web.cern.ch/t/multiple-steps-on-geometricboundary/10540/1 "2023-05-08T18:07:38Z")

</div>

Hi everyone,  
I have an observation that does not make to much sense to me… the code is as follows:

```auto
void VolumeRecorder::UserSteppingAction(const G4Step* aStep)
{
    G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
    // process inbound particles only
    if (preStepPoint->GetStepStatus() != fGeomBoundary) {
        return;
    }

    G4cerr << "Debug: StepStatus: "
           << preStepPoint->GetStepStatus()
           << " IsFirstStepInVolume: " << aStep->IsFirstStepInVolume() 
           << G4endl;
    ...

```

I would expect only one step within the volume and on the boundary, and indeed, the windows machine gives:

```auto
G4WT1 > Debug: StepStatus: 1 IsFirstStepInVolume: 1
G4WT1 > Debug: StepStatus: 1 IsFirstStepInVolume: 1
G4WT1 > Debug: StepStatus: 1 IsFirstStepInVolume: 1
G4WT1 > Debug: StepStatus: 1 IsFirstStepInVolume: 1
G4WT1 > Debug: StepStatus: 1 IsFirstStepInVolume: 1

```

for a trajectory across multiple volumes with that UserSteppingAction.

_However_, on the ubuntu 20.04.1 machine, the very same code yields a pattern like this:

```auto
G4WT0 > Debug: StepStatus: 1 IsFirstStepInVolume: 1
G4WT0 > Debug: StepStatus: 1 IsFirstStepInVolume: 0
G4WT0 > Debug: StepStatus: 1 IsFirstStepInVolume: 0
G4WT0 > Debug: StepStatus: 1 IsFirstStepInVolume: 0
G4WT0 > Debug: StepStatus: 1 IsFirstStepInVolume: 1
G4WT0 > Debug: StepStatus: 1 IsFirstStepInVolume: 0
G4WT0 > Debug: StepStatus: 1 IsFirstStepInVolume: 0

```

In order to only catch inbound particles, apparently I would have to filter for both fGeomBoundary **and** IsFirstStepInVolume, but _only on the linux machine_. Is that expected behavior for certain configurations?

cmake options for geant4.11.1.1 build:  
windows:

```auto
    -DGEANT4_BUILD_MULTITHREADED=ON `
    -DGEANT4_BUILD_MSVC_MP=ON `
    -DCMAKE_BUILD_TYPE=RelWithDebInfo

```

linux:

```auto
    -DGEANT4_BUILD_MULTITHREADED=ON \
    -DGEANT4_BUILD_VERBOSE_CODE=OFF \
    -DGEANT4_BUILD_STORE_TRAJECTORY=OFF \
    -DGEANT4_BUILD_BUILTIN_BACKTRACE=OFF \
    -DCMAKE_BUILD_TYPE=Release 

```

Any ideas? Should I file a bug report?  
Thanks in advance 🙂
