# AvalancheMC doesn't take magnetic field

**URL:** <https://root-forum.cern.ch/t/avalanchemc-doesnt-take-magnetic-field/50588>\
**Category:** Garfield++\
**Created:** [June 29, 2022, 7:01am UTC](https://root-forum.cern.ch/t/avalanchemc-doesnt-take-magnetic-field/50588 "2022-06-29T07:01:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Crisps](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crisps/32/39101_2.png) [@Crisps](https://root-forum.cern.ch/u/Crisps)\
**Post date:** [June 29, 2022, 7:01am UTC](https://root-forum.cern.ch/t/avalanchemc-doesnt-take-magnetic-field/50588/1 "2022-06-29T07:01:40Z")

</div>

Dear experts

I tried to simulate drift lines in a cell, using AvalancheMC method. I set magnetic field to 1T for z+, but seems it doesn’t work to drift process. I confirmed that it works to track trajectory calculation. Any clues?  
The basic method I used is:

```auto
ComponentAnalyticField* field;
field->SetMagneticField(0,0,1);
//pass to the sensor
//Then make track and make drift

```

If I use DriftLineRKF it looks fine with curved drift lines.

---

<div class="post-metadata">

**Author:** ![hschindl](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/977dab/32.png) [@hschindl](https://root-forum.cern.ch/u/hschindl)\
**Post date:** [June 29, 2022, 10:41am UTC](https://root-forum.cern.ch/t/avalanchemc-doesnt-take-magnetic-field/50588/2 "2022-06-29T10:41:11Z")

</div>

Can you provide a minimal working example?

---

<div class="post-metadata">

**Author:** ![Crisps](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crisps/32/39101_2.png) [@Crisps](https://root-forum.cern.ch/u/Crisps)\
**Post date:** [June 29, 2022, 2:02pm UTC](https://root-forum.cern.ch/t/avalanchemc-doesnt-take-magnetic-field/50588/3 "2022-06-29T14:02:39Z")

</div>

[xt\_simulation.zip](https://root-forum.cern.ch/uploads/short-url/t4ugzg1V16oLxfXWuoiaEdwRVWy.zip) (36.1 KB)  
I was used this code on a server, when I download this and ran on my local PC, it works with magnetic field…not sure what caused such problem.

---

<div class="post-metadata">

**Author:** ![hschindl](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/977dab/32.png) [@hschindl](https://root-forum.cern.ch/u/hschindl)\
**Post date:** [June 29, 2022, 3:45pm UTC](https://root-forum.cern.ch/t/avalanchemc-doesnt-take-magnetic-field/50588/4 "2022-06-29T15:45:29Z")

</div>

Maybe you are using an older version of the code on the server? In the past you had to switch on using the magnetic field explicitly in `AvalancheMC` (`EnableMagneticField`).

---

<div class="post-metadata">

**Author:** ![Crisps](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crisps/32/39101_2.png) [@Crisps](https://root-forum.cern.ch/u/Crisps)\
**Post date:** [June 30, 2022, 2:08am UTC](https://root-forum.cern.ch/t/avalanchemc-doesnt-take-magnetic-field/50588/5 "2022-06-30T02:08:43Z")

</div>

You are right, after I updated Garfield++ on the server it works fine!

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [July 14, 2022, 2:08am UTC](https://root-forum.cern.ch/t/avalanchemc-doesnt-take-magnetic-field/50588/6 "2022-07-14T02:08:48Z")

</div>

Closed on July 14, 2022, 2:08am UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
