# How to change the wire directions in MWPC?

**URL:** <https://root-forum.cern.ch/t/how-to-change-the-wire-directions-in-mwpc/47420>\
**Category:** Garfield++\
**Created:** [October 27, 2021, 5:53am UTC](https://root-forum.cern.ch/t/how-to-change-the-wire-directions-in-mwpc/47420 "2021-10-27T05:53:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Youngju\_Cho](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/youngju_cho/32/27733_2.png) [@Youngju\_Cho](https://root-forum.cern.ch/u/Youngju_Cho)\
**Post date:** [October 27, 2021, 5:53am UTC](https://root-forum.cern.ch/t/how-to-change-the-wire-directions-in-mwpc/47420/1 "2021-10-27T05:53:19Z")

</div>

Hello,  
I am trying to simulate the MWPC whose anode and two cathode planes are composed of wires.  
I want to change the direction of wires of one cathode perpendicular to the anode wires, but I can’t find how to do it.  
Is there any method to make such MWPC structure?

---

<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:** [October 27, 2021, 6:15am UTC](https://root-forum.cern.ch/t/how-to-change-the-wire-directions-in-mwpc/47420/2 "2021-10-27T06:15:57Z")

</div>

Hi,  
not with `ComponentAnalyticField` which is limited to two-dimensional geometries.  
One option is to use neBEM ([Examples/neBEM/crossingWires.C · master · garfield / garfieldpp · GitLab](https://gitlab.cern.ch/garfield/garfieldpp/-/blob/master/Examples/neBEM/crossingWires.C))  
Alternatively, you could model your geometry in a finite-element field solver like Ansys, Elmer, or Comsol, and then import the field map in Garfield++.

---

<div class="post-metadata">

**Author:** ![Youngju\_Cho](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/youngju_cho/32/27733_2.png) [@Youngju\_Cho](https://root-forum.cern.ch/u/Youngju_Cho)\
**Post date:** [October 27, 2021, 6:40am UTC](https://root-forum.cern.ch/t/how-to-change-the-wire-directions-in-mwpc/47420/3 "2021-10-27T06:40:26Z")

</div>

Thank you for the kind answer. I will try those methods.

---

<div class="post-metadata">

**Author:** ![Youngju\_Cho](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/youngju_cho/32/27733_2.png) [@Youngju\_Cho](https://root-forum.cern.ch/u/Youngju_Cho)\
**Post date:** [October 27, 2021, 10:00am UTC](https://root-forum.cern.ch/t/how-to-change-the-wire-directions-in-mwpc/47420/4 "2021-10-27T10:00:54Z")

</div>

I chose the first option neBEM to simulate electric fields. The code works well for a few wires, but it take a long time as the number of wires increases.  
I tried to use OpenMP by making Garfield libraries with the package, but it doesn’t work…  
I checked the neBEM source files and it looks like “\_OPENMP” variable is not defined anywhere. Also, the number of threads is not designated well. Is there something I misunderstand or miss?

---

<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:** [October 28, 2021, 5:23am UTC](https://root-forum.cern.ch/t/how-to-change-the-wire-directions-in-mwpc/47420/5 "2021-10-28T05:23:41Z")

</div>

> [@Youngju\_Cho](#):
>
> I checked the neBEM source files and it looks like “\_OPENMP” variable is not defined anywhere.

neBEM uses parallel for loops in quite a few places (search for `#pragma omp`).

> [@Youngju\_Cho](#):
>
> Also, the number of threads is not designated well. Is there something I misunderstand or miss?

You can set the number of threads in the `ComponentNeBem3d` interface, something like this:

```auto
ComponentNeBem3d nebem;
nebem.SetGeometry(&geo);
// ...
nebem.SetNumberOfThreads(4);
nebem.Initialise();

```

---

<div class="post-metadata">

**Author:** ![Youngju\_Cho](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/youngju_cho/32/27733_2.png) [@Youngju\_Cho](https://root-forum.cern.ch/u/Youngju_Cho)\
**Post date:** [November 1, 2021, 1:55am UTC](https://root-forum.cern.ch/t/how-to-change-the-wire-directions-in-mwpc/47420/6 "2021-11-01T01:55:18Z")

</div>

Yes, it works well now. Thank you very much.

---

<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:** [November 15, 2021, 1:55am UTC](https://root-forum.cern.ch/t/how-to-change-the-wire-directions-in-mwpc/47420/7 "2021-11-15T01:55:31Z")

</div>

Closed on November 15, 2021, 1:55am UTC

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