# How to deal with huge model in garfieldpp

**URL:** <https://root-forum.cern.ch/t/how-to-deal-with-huge-model-in-garfieldpp/63566>\
**Category:** Garfield++\
**Created:** [May 16, 2025, 3:33am UTC](https://root-forum.cern.ch/t/how-to-deal-with-huge-model-in-garfieldpp/63566 "2025-05-16T03:33:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dm-leo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dm-leo/32/29761_2.png) [@dm-leo](https://root-forum.cern.ch/u/dm-leo)\
**Post date:** [May 16, 2025, 3:33am UTC](https://root-forum.cern.ch/t/how-to-deal-with-huge-model-in-garfieldpp/63566/1 "2025-05-16T03:33:19Z")

</div>

Dear all,  
I have built a huge model of TPC with 2_2_5 m, but the anode is consists of 10 k pixels with radius 0.5 mm. So if the distance step was set to 1e-6, it’s too slow. I have tried that

```auto
                std::vector<double> path_tot_x, path_tot_y, path_tot_z,path_tot_t;
                std::vector<double> sig;
                drift.SetDistanceSteps(0.01);
                drift.DriftNegativeIon((*x_s)[i]/10,(*y_s)[i]/10,(*z_s)[i]/10+250,0);

                const auto& ions1 = drift.GetNegativeIons();
                if (ions1.empty()) continue;
                const auto& path1 = ions1[0].path;
                if (path1.size() == 0) continue;

                int switch_idx = -1;

                //for (int j = 0; j<path1.size();j++){
                for (const auto& pt : path1) {
                        if (pt.z>5){
                                path_tot_x.push_back(pt.x);
                                path_tot_y.push_back(pt.y);
                                path_tot_z.push_back(pt.z);
                                path_tot_t.push_back(pt.t);
                                sig.push_back(nElectrons*sensor.GetElectronSignal("anode", i));
                        }
                }

                if (switch_idx == -1) continue;

                sensor.ClearSignal();
                drift.SetDistanceSteps(1e-6);

                drift.DriftNegativeIon(path1.back().x,path1.back().y,path1.back().z,path1.back().t);

                const auto& ions2 = drift.GetNegativeIons();
                if (ions2.empty()) continue;
                const auto& path2 = ions2[0].path;
                if (path2.size() == 0) continue;
                for (const auto& pt2 : path2){
                        path_tot_x.push_back(pt2.x);
                        path_tot_y.push_back(pt2.y);
                        path_tot_z.push_back(pt2.z);
                        path_tot_t.push_back(pt2.t);
                        sig.push_back(nElectrons*sensor.GetElectronSignal("anode", i));
                }

                //const auto& endp = ions[0].path.back();

                x_end = path_tot_x.back();
                y_end = path_tot_y.back();
                t_end = path_tot_t.back();

```

to divide 2 area. When ions in drift area, the step was set to 0.01, and near anode, the step was set to 1e-6. But I don’t know how to save the message in the same sensor because I also want to convolve the signal in later process. Or any other method could I have a try?

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [May 16, 2025, 6:46am UTC](https://root-forum.cern.ch/t/how-to-deal-with-huge-model-in-garfieldpp/63566/2 "2025-05-16T06:46:28Z")

</div>

Hi @dm-leo,  
I think @hschindl can help you.

---

<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:** [May 17, 2025, 3:20pm UTC](https://root-forum.cern.ch/t/how-to-deal-with-huge-model-in-garfieldpp/63566/3 "2025-05-17T15:20:23Z")

</div>

Hi,  
you can set a location-dependent step size using something like this

```cpp
// Step size as function of position.
auto step = [](double x, double y, double z) {
  // If (x, y, z) near anode return 1.e-6;
  // else
  return 0.1;
};
drift.SetStepDistanceFunction(step);

```

---

<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:** [May 31, 2025, 3:20pm UTC](https://root-forum.cern.ch/t/how-to-deal-with-huge-model-in-garfieldpp/63566/4 "2025-05-31T15:20:44Z")

</div>

Closed on May 31, 2025, 3:20pm UTC

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