How to call magnetic field?

I’m trying to simulate a particle passing through different volumes using the geometry package of ROOT. Some of the volumes have magnetic field and some don’t. Is there a way to tell ROOT :“check the value of the magnetic field in this volume”?
I found GetField but I didn’t know how to use it.


You need to set a field object relevant for the volume using SetField. In the long term, it is preferable to use SetUserExtension() for this purpose. Then during tracking you can check the current volume and get the field pointer.


Thanks a lot Andrei :slight_smile: