Who owns the electric or magnetic field?

Where does ownership of a created G4Field* object end up? I notice that the G4FieldManager takes a non-const pointer as argument, both to the constructor and to the Set/Propose/Change functions. This might suggest that ownership is being transferred to the receiving object, but in the source code, the field manager destructor does not delete the field.

Is ownership assumed to be retained by the user code which created the field?

1 Like

Hi Mike,

Indeed until now ownership has been assumed to be retained by the user code that created the field.

One key reason is that one field object could be shared by multiple field managers - e.g. a global field could be used everywhere and different field managers could be applied in different volumes to obtain different accuracy in the tracker than the calorimeter.

Perfect! That works for me; I couldn’t find anything explicit, either in the .hh comments or in the Developers’ Guide. Thank you!