Filtering trajectories by energy

Dear all,
I wrote a simple program that simulates calorimeter. I want to filter low energy tracks, take example from documentation:

/vis/filtering/trajectories/create/attributeFilter
/vis/filtering/trajectories/attributeFilter-0/setAttribute IMag
/vis/filtering/trajectories/attributeFilter-0/addInterval 1 MeV 1000 MeV

and catch such a error (see pic).
Geant_error

There was a similar problem on the forum, but no one has solved it. Maybe now someone has found a solution to the problem, or suggest an alternative approach?

Geant4 Version:
_Operating System:_WIN
Compiler/Version:
CMake Version:


Hmmm. Works fine for me. With your commands, with exampleB1:

/run/beamOn 100
/vis/filtering/trajectories/list

gives me

Printing data for filter: attributeFilter-0
Printing data for G4Attribute filter named: attributeFilter-0
Filtered attribute name: IMag
Printing sub filter data:
Printing data for filter: G4AttValueFilter
Interval data:
1 MeV : 1000 MeV
Single value data:
Active ?   : 1
Inverted ? : 0
#Processed : 411
#Passed    : 189

I can get that G4Exception if I deliberately give wrong arguments, such as

/vis/filtering/trajectories/attributeFilter-0/addInterval 1 1000 MeV

I wonder if it’s a Windows issue? You don’t say what version of Geant4 you are using.

I tested on B1 and catch the same error. Arguments were set like example (1 MeV 1000 MeV).
My geant version v11.0.3.

Mmm. Geant4 11.0 should be OK.

I don’t use Windows, but I do know that if you produce a text file on Windows using a Windows editor, it places an extra (invisible) CR (carriage-return) character at end of line. I wonder if the parameter parser is tripping up on this.

Windows users out there, does anyone know how to work around that?

It’s very strange because it doesn’t work in prompt command line too. And i can filter trajectories by charge and type and arguments reads correctly.