Is there a way to print the interaction type of a step?

I would like to know the physics process of each step a particle goes through if any.

For example an electron which is compton scattered, is there a way to print that it was compton scattered?

i.e. does something like step->getprocesstype() exist?

You could define a stepping action and grab the process for the post or pre-step point. The example below is for the PostStepPoint. If the process was a Compton scatter, the returned name would be compt

MySteppingAction::UserSteppingAction(const G4Step * theStep) {
G4String processName = theStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName();