Importing (and utilizing correctly) Magnetic field maps

I have setup successfully and ran Garfield++ simulations using ComponentAnalyticFields with the geometry and Voltages of a wire drift chamber I work with. This has enabled me to build time-to-space mappings of my chamber for analysis, with lorentz angles when Magnetic field is applied in our chamber. The Garfield++ software works and is written well, I like working with it! I am trying to understand if the software supports importing a Magnetic field map on top of the Drift Chamber Electric Fields. The magnetic field map within my chamber is not constant; I have a pretty good measurement of its mapping and could work on importing that into a simulation. But I believe the Magbolz gas file will be rather large if I allow many steps in both Electric Field and Magnetic Field. The gas files I use currently have 1 magnetic field value and many Electric Field values to cover the range calculated by the component analytic fields of my chamber. In addition, I am unsure if AvalanchMC supports multiple lorentz angle and drift velocity table lookups for a single electron drifting. Maybe I need to switch to DriftLineRKF for my time-to-space simulations and that would be more straightforward integrating the velocity vector with changing lorentz angle along a drift line. Is there already support or examples in the software for this type of calculation? I am sorry if I missed it but couldn’t easily find the answer myself. Thanks for your time!

Hi @keithwm422,

Welcome to the ROOT Forum! Let me add @hschindl in the loop.

Cheers,

Dev

Hi,

many thanks for your message!

  • Yes, it’s possible to use a magnetic field map on top of the electric field. If you have the values of the B field on a regular (Cartesian or cylindrical) grid, you can use the class ComponentGrid, see this example.
  • The size of the gas file is not necessarily an issue, but the time for running Magboltz might become very long if you include too many points, so it’s indeed a good idea to stick to a reasonable (“just enough”) number of electric fields, magnetic fields and angles. How many electric field values do you have at the moment? Perhaps you can reduce the number a bit if the Magboltz run time becomes unmanageable?
  • AvalancheMCand DriftLineRKF both use the same methods to compute the drift velocity vector at a given electric and magnetic field, there is no difference between the two classes in that respect.

Thanks for the prompt reply. I have investigated the use of ComponentGrid . I already utilize CompenentAnalyticField with many wires and 2 planes, all at various voltages. So I went ahead and tried to add both together in my simulation like this:

Sensor * sensor = new Sensor;
sensor->AddComponent(cmp);
sensor->AddComponent(cmpB); 

The first component (ComponentAnalyticField) is where I add wires and planes and the second component (ComponentGrid) I utilize the LoadMagneticField function in the example you linked me to. Currently, I am running DriftLineRKF and getting status code -10 which I don’t see in the documentation. I do get many errors or complaints about Electric Fields:
ComponentGrid::ElectricField: Map not available.

This is fine with me since I haven’t tried to add any Electric Fields into the cmpB object.

On the Magbolz/gasfile topic, I did generate a gas table successfully with both B and E fields that cover the range I need in the field setup I configure. I previously had been generating gas files separately and then loading them into my DriftLineRKF simulation (to prevent the need to run Magbolz every time I adjust the DriftLineRKF or decide to include more starting points, etc). However, my gas files will not load after successfully generating with multiple B and E fields. I attach both my gas file generator and my load gas file code here for feedback, guidance, and criticism. Thanks for your help!

MakeGasFile_flight.C (2.1 KB)

LoadGasFile.C (1.5 KB)

Hi,
I don’t see anything particularly suspicious in your code to generate and load gas files. Can you post your .gas file?
As for the DriftLineRKF error, can you post a minimal reproducible example?
Thanks!

Here is the gas file I generated which doesn’t seem to load with the LoadGasFile code I posted above. I renamed the file extension when uploaded here because it wouldn’t let me upload with the .gas one. I am working on the minimum reproducible example of the DriftLineRKF code. Thanks!

Flight2024_Bon_P_755.865_T_303.15_10Ar_90CO2_multiE.txt (28.0 KB)