How to set an electric field to a section

Hi everyone. I have a simple geometry: 3 boxes in series. I want to set a uniform electric field in the center one. In my “fieldsetup.cc” and “.hh” I introduced both global and local field, then I set the global to zero and the local along the Z-axe to 5 kV/m.
Then in “detectorconstruction.cc” I wrote:

B1ElectricFieldSetup* fieldSetup = new B1ElectricFieldSetup();
fEmFieldSetup.Put(fieldSetup);
fScoringVolume->SetFieldManager(fEmFieldSetup.Get()->GetLocalFieldManager(), true );

But when i try to visualize the electric field, it is still associated to all the world and not to the scoring volume. What is the (possible) problem? I don’t want to send all the code if it is not necessary because it would be too messy.
Thanks to all.

Hi Gregorio,
The key issue is associating the field manager with the Logical volume. It seems that your code is doing this. But there may be something hidden which is not obvious.

Could you please clarify whether B1ElectricFieldSetup is a modified version of the
similar class from the electromagnetic field example(s) ? Or is it your own class? In addition, what is fEmFieldSetup ?

Best regards,
John

B1ElectricFieldSetup Is modified by me. Setting the fScoringVolume on “false” actually sets the field locally in that volume but from the guide for application developer I was sure that if it was “true” than the electric field would be associated with the volume. I still believe that this is an error, am I right?
Thank you for your help,
Gregorio