Running FastJet in ROOT 5 problem

Hi,
I follow FastJet quick start:
http://fastjet.fr/quickstart.html

And I can run it using

g++ short-example.cc -o short-example `fastjet-install/bin/fastjet-config --cxxflags --libs --plugins`

But then I want to use the code in ROOT 5, I use :

ui@ui:~/tools/package/fastjet$ root -l root [0] gSystem->Load("lib/libfastjet.so") (int)0 root [1] .L short-example.cc+ Info in <TUnixSystem::ACLiC>: creating shared library /home/ui/tools/package/fastjet/./short-example_cc.so

It generate a file: short-example_cc.so

But it con not run,

ui@ui:~/tools/package/fastjet$ ./short-example_cc.so Segmentation fault (core dumped)

It is wired , How can I solve it.

My view is to use fastjet code in ROOT, so I can link some code together.

BTW, there is one more question, can I use python code to include fastjet? It seems a more complex problem. And I find there is a python interface for fastjet, but it doesn’t update from 2012.
https://spartyjet.hepforge.org/

Hi,

if you generate a library with aclic, i.e. with “.L mymacro.C+”, you will be able to call the functions defined in the code from within a root session or macro and not as a standalone executable.
Therefore, supposing that you have a function called “run” in your short-example.cc file, you will be able to invoke it at the root interpreter.

This is not the right forum to comment about the FastJet python interface. On the other hand, you can try and use FastJet as any other C++ library via PyROOT.

If using ROOT6 is an option, all operations described above will be much easier. See for example the interactive ROOT demo on the web, nbviewer.jupyter.org/github/cern … tive.ipynb .

Cheers,
Danilo

[quote=“dpiparo”]Hi,

if you generate a library with aclic, i.e. with “.L mymacro.C+”, you will be able to call the functions defined in the code from within a root session or macro and not as a standalone executable.
Therefore, supposing that you have a function called “run” in your short-example.cc file, you will be able to invoke it at the root interpreter.

This is not the right forum to comment about the FastJet python interface. On the other hand, you can try and use FastJet as any other C++ library via PyROOT.

If using ROOT6 is an option, all operations described above will be much easier. See for example the interactive ROOT demo on the web, nbviewer.jupyter.org/github/cern … tive.ipynb .

Cheers,
Danilo[/quote]

Hi,
So you mean that the reason I failed to run the short-example.cc in root is because I don’t generate it with aclic? Sorry I don’t know the root cint, compilation…etc, so I don’t understand it.

But I think your links are great, using C++ in Python with ROOT is exactly what I want. And the example for FastJet seems good, I will follow it.

It seems ROOT 6 is better at compilation.

Thanks a lot ! I will follow your instruction soon.

Best,
Li

[quote=“dpiparo”]Hi,

if you generate a library with aclic, i.e. with “.L mymacro.C+”, you will be able to call the functions defined in the code from within a root session or macro and not as a standalone executable.
Therefore, supposing that you have a function called “run” in your short-example.cc file, you will be able to invoke it at the root interpreter.

This is not the right forum to comment about the FastJet python interface. On the other hand, you can try and use FastJet as any other C++ library via PyROOT.

If using ROOT6 is an option, all operations described above will be much easier. See for example the interactive ROOT demo on the web, nbviewer.jupyter.org/github/cern … tive.ipynb .

Cheers,
Danilo[/quote]

Hi Danilo,
When I follow your suggestions, the first link, I find :

%%cpp cout << "This is a C++ cell" << endl;

%%cpp class A{ public: A(){cout << "Constructor of A!" << endl;} };

a = ROOT.A()

I don’t understand these codes and I can’t run it. What’s the meaning of %%cpp , and I think first two codes are c++ code while the last one is python code, how can I organize them?

Should I write them all , the second and third in a python script? I tried it , but it seems wrong.

Best,
Li

Hi Li,

this is simple notebook syntax.
The point is that, with ROOT6, it is enough to inject the C++ code in the interpreter for finding all the relevant C++ entities back in Python.

Cheers,
Danilo

[quote=“dpiparo”]Hi Li,

this is simple notebook syntax.
The point is that, with ROOT6, it is enough to inject the C++ code in the interpreter for finding all the relevant C++ entities back in Python.

Cheers,
Danilo[/quote]

Hi Danilo,
So the %%cpp here is just a notation and irrelevant to the code?

Can you please say something more about " inject the C++ code in Python" or show me a link of the nice document ? because I am really interesting in this.

Bese,
Li

Hi Li,

you could start with indico.cern.ch/event/278289/con … 052014.pdf slide 12.
We’ll add an howto about this too. I’ll keep you posted.

Cheers,
Danilo

[quote=“dpiparo”]Hi Li,

you could start with indico.cern.ch/event/278289/con … 052014.pdf slide 12.
We’ll add an howto about this too. I’ll keep you posted.

Cheers,
Danilo[/quote]

Hi Danilo,
Thanks very much! :laughing:

Best,
Li