Getting and recording magnetic field values

Hello. Before starting run I am setting up uniform magnetic field in macro in this way
/globalField/setValue 0 0 0.5 tesla
Is it possible to get this values later in the code (when run starts or ends) to write it into ROOT output (or txt or somehow)??