Magnetic Field gradient

Hi!
I’m trying to create a magnetic field which has gradient in “z” axis. I need to find the z-coordinates for each point of the world, in which the magnetic field will be calculated. Here is my magnetic field class:

Header file:

#ifndef MAGFIELD_HH
#define MAGFIELD_HH

#include "G4SystemOfUnits.hh"
#include "G4MagneticField.hh"
#include "G4UserSteppingAction.hh"
#include "G4Navigator.hh"
#include "G4Step.hh"
#include "G4Track.hh"


class MyMagField : public G4MagneticField{
public:
    MyMagField();
    ~MyMagField();

    virtual void GetFieldValue(const G4double[4], G4double *bField) const override;
    virtual void SetFieldZ(G4double magFieldValue);

private:
    G4double fBz = 875.*gauss;
};
#endif

cc file:

#include "magfield.hh"

MyMagField::MyMagField() : G4MagneticField() {}

MyMagField::~MyMagField() {}

void MyMagField::GetFieldValue(const G4double[4], G4double *bField) const
{
    bField[0] = 0;
    bField[1] = 0;
    bField[2] = fBz;
}

void MyMagField::SetFieldZ(G4double magFieldValue)
{
    fBz = magFieldValue;
}

I tried to find information in Geant4 documentation, but unfortunately I couldn’t find anything specifically for setting gradient.

_Geant4 Version:_Latest
_Operating System:_Ubuntu 22.04
_Compiler/Version:__Latest
_CMake Version:__Latest