# How to get the step's ProcessName and print it out?

**URL:** <https://geant4-forum.web.cern.ch/t/how-to-get-the-steps-processname-and-print-it-out/5057>\
**Category:** Physics Processes, Models and Cross Sections\
**Created:** [April 28, 2021, 2:36am UTC](https://geant4-forum.web.cern.ch/t/how-to-get-the-steps-processname-and-print-it-out/5057 "2021-04-28T02:36:46Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![sallender](https://geant4-forum.web.cern.ch/letter_avatar_proxy/v4/letter/s/5e9695/32.png) [@sallender](https://geant4-forum.web.cern.ch/u/sallender)\
**Post date:** [April 28, 2021, 2:36am UTC](https://geant4-forum.web.cern.ch/t/how-to-get-the-steps-processname-and-print-it-out/5057/1 "2021-04-28T02:36:46Z")

</div>

![Screenshot from 2021-04-28 10-33-08](https://geant4-forum.web.cern.ch/uploads/default/original/2X/c/c0bab7ebd36fef4ba496dc948339a77afbf073f3.png)  
This is a part of my code in SteppingAction.I run it,but the system warn me that “Segmentation fault (core dumped)”.I don’t know why?

---

<div class="post-metadata">

**Author:** ![sallender](https://geant4-forum.web.cern.ch/letter_avatar_proxy/v4/letter/s/5e9695/32.png) [@sallender](https://geant4-forum.web.cern.ch/u/sallender)\
**Post date:** [April 28, 2021, 2:39am UTC](https://geant4-forum.web.cern.ch/t/how-to-get-the-steps-processname-and-print-it-out/5057/2 "2021-04-28T02:39:48Z")

</div>

Primarily,I want to set the processname as a kind of arguments.And transmit it to eventaction.

---

<div class="post-metadata">

**Author:** ![JDecunha](https://geant4-forum.web.cern.ch/user_avatar/geant4-forum.web.cern.ch/jdecunha/32/784_2.png) [@JDecunha](https://geant4-forum.web.cern.ch/u/JDecunha)\
**Post date:** [April 28, 2021, 7:03am UTC](https://geant4-forum.web.cern.ch/t/how-to-get-the-steps-processname-and-print-it-out/5057/3 "2021-04-28T07:03:00Z")

</div>

Hi there,

You create a pointer to a G4VProcess named process. When you call:

> G4VProcess\* process;

You are creating a pointer, but that pointer doesn’t point to anything because it is never assigned an address to point to. What you would like to do, is take either your pre or post step points and print the process name. You can do so like this:

> G4cout \<\< "ProcName: " \<\< step-\>GetPreStepPoint()-\>GetProcessDefinedStep()-\>GetProcessName() \<\< G4endl;

If you want to store your process name and pass it to event action like you mentioned you can store it with:

> const G4String& procName = step-\>GetPreStepPoint()-\>GetProcessDefinedStep()-\>GetProcessName();

I hope this is helpful,

Joseph

---

<div class="post-metadata">

**Author:** ![sallender](https://geant4-forum.web.cern.ch/letter_avatar_proxy/v4/letter/s/5e9695/32.png) [@sallender](https://geant4-forum.web.cern.ch/u/sallender)\
**Post date:** [April 28, 2021, 8:01am UTC](https://geant4-forum.web.cern.ch/t/how-to-get-the-steps-processname-and-print-it-out/5057/4 "2021-04-28T08:01:46Z")

</div>

Okay, I try it.But, it still show me “Segmentation fault (core dumped)” in terminal.

---

<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:** [April 28, 2021, 8:08am UTC](https://geant4-forum.web.cern.ch/t/how-to-get-the-steps-processname-and-print-it-out/5057/5 "2021-04-28T08:08:23Z")

</div>

try protecting with  
` if (step->GetPreStepPoint()->GetProcessDefinedStep())`

---

<div class="post-metadata">

**Author:** ![sallender](https://geant4-forum.web.cern.ch/letter_avatar_proxy/v4/letter/s/5e9695/32.png) [@sallender](https://geant4-forum.web.cern.ch/u/sallender)\
**Post date:** [April 28, 2021, 8:11am UTC](https://geant4-forum.web.cern.ch/t/how-to-get-the-steps-processname-and-print-it-out/5057/6 "2021-04-28T08:11:58Z")

</div>

Great!! Question has been solved! Thanks.

---

<div class="post-metadata">

**Author:** ![sallender](https://geant4-forum.web.cern.ch/letter_avatar_proxy/v4/letter/s/5e9695/32.png) [@sallender](https://geant4-forum.web.cern.ch/u/sallender)\
**Post date:** [April 28, 2021, 8:13am UTC](https://geant4-forum.web.cern.ch/t/how-to-get-the-steps-processname-and-print-it-out/5057/7 "2021-04-28T08:13:12Z")

</div>

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![sallender](https://geant4-forum.web.cern.ch/letter_avatar_proxy/v4/letter/s/5e9695/32.png) [@sallender](https://geant4-forum.web.cern.ch/u/sallender)\
**Post date:** [April 28, 2021, 9:01am UTC](https://geant4-forum.web.cern.ch/t/how-to-get-the-steps-processname-and-print-it-out/5057/9 "2021-04-28T09:01:57Z")

</div>

This kind of error always occur recently.

---

<div class="post-metadata">

**Author:** ![mkelsey](https://geant4-forum.web.cern.ch/user_avatar/geant4-forum.web.cern.ch/mkelsey/32/49_2.png) [@mkelsey](https://geant4-forum.web.cern.ch/u/mkelsey)\
**Post date:** [April 29, 2021, 6:35am UTC](https://geant4-forum.web.cern.ch/t/how-to-get-the-steps-processname-and-print-it-out/5057/11 "2021-04-29T06:35:00Z")

</div>

Good coding practice is that you should never dereference a pointer without checking that it is valid (non-null) first. It’s true that in user functions called in Geant4, you can “assume” that a lot of the pointers “can’t be” null, but that merely encourages bad practices. Check your pointers before using them.

---

<div class="post-metadata">

**Author:** ![andkon-narod](https://geant4-forum.web.cern.ch/user_avatar/geant4-forum.web.cern.ch/andkon-narod/32/4477_2.png) [@andkon-narod](https://geant4-forum.web.cern.ch/u/andkon-narod)\
**Post date:** [September 23, 2025, 1:59pm UTC](https://geant4-forum.web.cern.ch/t/how-to-get-the-steps-processname-and-print-it-out/5057/12 "2025-09-23T13:59:11Z")

</div>

exuse me, my dear friends, but i did not understand: where do i need use this row?

if (step-\>GetPreStepPoint()-\>GetProcessDefinedStep())
