# 2D area clustering or DBSCAN analysis

**URL:** <https://root-forum.cern.ch/t/2d-area-clustering-or-dbscan-analysis/58374>\
**Category:** ROOT\
**Tags:** roofit, hist, root\
**Created:** [March 4, 2024, 8:37am UTC](https://root-forum.cern.ch/t/2d-area-clustering-or-dbscan-analysis/58374 "2024-03-04T08:37:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![HitMan01KW9](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/hitman01kw9/32/35457_2.png) [@HitMan01KW9](https://root-forum.cern.ch/u/HitMan01KW9)\
**Post date:** [March 4, 2024, 8:37am UTC](https://root-forum.cern.ch/t/2d-area-clustering-or-dbscan-analysis/58374/1 "2024-03-04T08:37:23Z")

</div>

* * *

\_ROOT Version: 6.30  
\_Platform: Windows

* * *

Hey guys,

I have several datasets that would come in TH2D histograms, in these data sets there’s are several separated areas that I would like to analyse each one separately. If I was working with Python, I would have used a DBSCAN in order to separate them and have the clustering I want. I do have a clustering code in C++, but when I run it with root, I get the following message:

> [runStaticInitializersOnce]: Failed to materialize symbols: { (main, { \_\_orc\_init\_func.cling-module-8 }) }  
> cling JIT session error: Failed to materialize symbols: { (main, { ?read\_data\_v5@@YAXXZ }) }

Do you have any idea what I could use to have the clustering I want, I found a class called TH1K that would provide the nearest K Neighbours method but it only works in 1D, there’s no TH2K.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [March 4, 2024, 9:16pm UTC](https://root-forum.cern.ch/t/2d-area-clustering-or-dbscan-analysis/58374/2 "2024-03-04T21:16:04Z")

</div>

Hi,

In ROOT we don’t have really clustering code. There is a K nearest neighbours code in TMVA but is used for classification problems, see section 8.5 of the [TMVA Users guide](https://root.cern.ch/download/doc/tmva/TMVAUsersGuide.pdf).

If you have C++ code you should be able to use from ROOT. The error you are having looks like a linking error. How did you integrate your code with ROOT ?

Lorenzo

---

<div class="post-metadata">

**Author:** ![HitMan01KW9](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/hitman01kw9/32/35457_2.png) [@HitMan01KW9](https://root-forum.cern.ch/u/HitMan01KW9)\
**Post date:** [March 6, 2024, 7:38am UTC](https://root-forum.cern.ch/t/2d-area-clustering-or-dbscan-analysis/58374/3 "2024-03-06T07:38:59Z")

</div>

Thanks for your response I was able to solve the problem using the TCutG class and doing the clustering “manually”. However, I’m still looking to automatise the whole thing so I could run for multiple data files at the same time.

As for the error, the code is working when I compile it with CMD using:

> g++ main.cpp -o output

Then I would get the output.exe with the correct result. I don’t know how to integrate my code with ROOT. Should I start using different set of classes ? Any link or advice is much appreciated.

Thanks again.

---

<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:** [March 20, 2024, 7:39am UTC](https://root-forum.cern.ch/t/2d-area-clustering-or-dbscan-analysis/58374/4 "2024-03-20T07:39:07Z")

</div>

Closed on March 20, 2024, 7:39am UTC

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