Pythia8 as a ROOT Plugin

I’m using Pythia8 and am trying to use it as a root plugin. I am able to use the basic Pythia functionality from the ROOT class. To get the full functionality I tried to use the following.

TPythia8 tpythia8;
Pythia8:Pythia *pythia8 = tpythia8.Pythia8();

I’m getting the following errors.

Error: Symbol Pythia is not defined in current scope Higgs1.C:25:
Warning: Automatic variable Pythiapythia8 is allocated Higgs1.C:25:
Error: Undeclared variable Pythia
pythia8 Higgs1.C:25:

What should I do?

Note that you have a typing mistake. Instead of

Pythia8:Pythia *pythia8 = tpythia8.Pythia8(); it must be

Pythia8::Pythia *pythia8 = tpythia8.Pythia8();

However to use the Pythia8 classes from the interpreter or IO you must create a dictionary for these classes.
You will find in attachment un small tar file containing 3 small files to create the shared lib with the Pythia8 interface. run makePythict script and then in your interactive session do

{ // Load libraries gSystem->Load("$PYTHIA8/lib/libpythia8"); gSystem->Load("libEG"); gSystem->Load("libEGPythia8"); gSystem->Load("libPythiaDict"); TPythia8 tpythia8; Pythia8::Pythia *pythia8 = tpythia8.Pythia8(); }

The makePythiaDict script assumes that you have shared libs for Pythia8. I have reported problems on 64 bits machines with the configure of Pythia8 to Torbjorn. These problems found in version 8135 are supposed to be fixed in version 8140.
p.tar.gz (796 Bytes)

When I’m trying to run it,i get many errors.

PythiaDict.cxx: In function ‘int G__PythiaDict_406_0_14(G__value*, const char*, G__param*, int)’:
PythiaDict.cxx:5569: error: invalid initialization of reference of type ‘const Pythia8::Particle&’ from expression of type ‘Pythia8::Vec4’
/home/thomas/HEP/root/include/Event.h:288: error: in passing argument 1 of ‘double Pythia8::m(const Pythia8::Particle&, const Pythia8::Particle&)’
PythiaDict.cxx: In function ‘int G__PythiaDict_406_0_15(G__value*, const char*, G__param*, int)’:
PythiaDict.cxx:5575: error: invalid initialization of reference of type ‘const Pythia8::Particle&’ from expression of type ‘Pythia8::Vec4’
/home/thomas/HEP/root/include/Event.h:289: error: in passing argument 1 of ‘double Pythia8::m2(const Pythia8::Particle&, const Pythia8::Particle&)’

[i]I copied all pythia header files to the folder $ROOTSYS/include. Now the code compiles without any problem. But when executed, it gives upto 90% of the results and hangs showing the error

*** Break *** segmentation violation
I tried to cut down the code, so that i can find out the problem.

[b]#include
#include “TROOT.h”
#include “TFile.h”
#include <stdio.h>
#include “TChain.h”
#include “string.h”
#include “TSystem.h”
#include “TH1F.h”
#include “TClonesArray.h”
#include “TPythia8.h”
#include “TParticle.h”
#include “TCanvas.h”

using namespace std;

int myHiggs2(Int_t nev = 100, Int_t ndeb = 2) {

char* path = gSystem->ExpandPathName("$PYTHIA8DATA");

// Load libraries
gSystem->Load("$PYTHIA8/lib/libpythia8");
gSystem->Load(“libEG”);
gSystem->Load(“libEGPythia8”);
gSystem->Load(“libPythiaDict”);
gSystem->Load("$PYTHIA8/include/Pythia.h");

// Create pythia8 object

TPythia8 tpythia8;
Pythia8::Pythia *pythia8 = tpythia8.Pythia8();

// Configure
pythia8->readString(“HiggsSM:gg2H = on”);

//List changed settings
pythia8->particleData.listChanged();

// Initialize
pythia8->init(2212, 2212, 7000.);

// Event loop
for (Int_t iev = 0; iev < nev; iev++) {
if(!(pythia8->next())) continue;

      if (iev < ndeb) 
        {
        pythia8->process.list();
    //    pythia8->event.list();
        }
}

pythia8->statistics();
return 0;
}[/b]

The code compiles without any problem. But after it prints out the statistics, it hangs saying
*** Break *** segmentation violation

It also shows the error.

Note: File “/usr/local/root/lib/libEG.so” already loaded
Error in TUnixSystem::DynamicPathName: libPythiaDict[.so | .sl | .dl | .a | .dll] does not exist in .:/usr/local/root/lib::/usr/local/root/lib:/usr/local/root/cint/cint/stl
Error in TUnixSystem::DynamicPathName: $PYTHIA8/include/Pythia.h[.so | .sl | .dl | .a | .dll] does not exist in .:/usr/local/root/lib::/usr/local/root/lib:/usr/local/root/cint/cint/stl[/i]

[quote]Note: File “/usr/local/root/lib/libEG.so” already loaded
[/quote]means that gSystem->Load("libEG");is unnecessary.

gSystem->Load("$PYTHIA8/include/Pythia.h");is also unnecessary and actually could be harmful as it is likely to tell ROOT/CINT that the pythia classes are interpreted rather than compiled.

The real problem is:[quote]Error in TUnixSystem::DynamicPathName: libPythiaDict[.so | .sl | .dl | .a | .dll] does not exist in .:/usr/local/root/lib::/usr/local/root/lib:/usr/local/root/cint/cint/stl[/quote]which means that you either did not succeed in creating this library or it is not in any of the directory on the library path.

Cheers,
Philippe.

I cannot see any problem in the tar file that I posted in an earlier mail.
In attachment you will find another small tar file containing
-goex1 the 3 lines script generating the dictionary and compiling ex1.C
-ex1.C the standard pythia8 example modified to generate some histograms
-pythiaROOT.h pythiaLinkdef.f files to generate the dictionary and used by goex1

If you run it on a 64 bit platform, you must have pythia8 compiled with-enabled-shared and -fPIC

Rene
ex1.tar.gz (1.28 KB)

Dear Rene:

[quote=“brun”]I cannot see any problem in the tar file that I posted in an earlier mail.

If you run it on a 64 bit platform, you must have pythia8 compiled with-enabled-shared and -fPIC

[/quote]

I have installed root (5.26/00b) and pythia 8(142) I am able to run pythia in stand-alone mode and the ROOT macro in $ROOTSYS/tutorials/pythia. I have a mac 64 bit. I want to survey some parameters whithin pythia process (xsection, ntries etc) which are not accesible through the ROOT interface. Hence I need this libPythiaDict loaded in my macro.

I tried your pytia dict generation files (posted in this thread). After running the script I get the following error:


ld: unknown option: -soname
collect2: ld returned 1 exit status

my compiler seems to not recognize the “-soname”. Apparently first two command run safely.

Any help is appreciated,

best regards

here you have the config status of my pythia 8(142). Options -fPIC and shared library were ON in the comilation. The single thing I see related to the error above is the “dylib extension”.

SHELL = /bin/sh
ARCH = Darwin-gcc4
MYLCGPLATFORM = slc4_ia32_gcc34
SHAREDLIBS = yes
FC = gfortran
CC = gcc
FFLAGS = -O2
CFLAGS = -O2
CXXFLAGS = -O2 -ansi -pedantic -W -Wall -Wshadow -m64
FLIBS = -lgfortran
LDFLAGSSHARED = -O2 -ansi -pedantic -W -Wall -Wshadow -m64 -dynamiclib -single_module -flat_namespace -undefined suppress
LDFLAGLIBNAME = -Wl,-dylib_install_name
SHAREDSUFFIX = dylib

===========================

Hi:

I have resolved the issue in my Mac. A few googling and a post from this forum http://root.cern.ch/phpBB3//viewtopic.php?t=6527&highlight=

The executable posted by Rene for dictionary Generation in my Mac was changed as:

my generation macro works like a charm. After adding the needed libraries,I can look into pythia base like:

I hope it helps others,

Hi,
Did anybody resolved this issue. I still get this on SL. Same errors…
my uname -a gives:

Linux localhost.localdomain 2.6.18-164.el5xen #1 SMP Sat Sep 5 20:00:11 CEST 2009 x86_64 x86_64 x86_64 GNU/Linux

and gcc version
gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46)

I have compiled Pythia8 with enabled-shared and with -fPIC. The things run interactively well but not the
goex1 example.

Thanks
with best regards
Pawan

Hi,

In one of the pythia[8] makefile I have seen (I can not vouch whether they were locally modified or not), the produced .dylib was being given the wrong internal name. If I remember correctly the argument to -install_name was the full pathname instead of the file/library name. Can you copy/paste the exact command line used by the makefile to generate the library?

Cheers,
Philippe.

Hi,

a late follow-up: there was a problem with Pythia8 that will get fixed in a new version; attached patch should get it going until then.

Cheers, Axel.
Pythia8145_namespace_func_decl.diff (3.65 KB)

Hi everyone…
I’m trying to run a root script with some pythia parameters and I followed what you said: I change those files with the differences in the file diff and goex seems to run without a problem.

But I didn’t see any libPythiaDict anywhere. When I executed goex or the makePythiaDict file and just created two files: pythiaDict.cxx and pythiaDict.h

What else I need to do??? How can I do it??

I really appreciated your help.
Kind Regards

[quote]When I executed goex or the makePythiaDict file[/quote]Don’t they contains calls to g++? How did those fails?

Philippe.

Thanks Phillip for your response.
Well, I am using Ubuntu 11.04. It turns out that I need a another package to make it run. For Ubuntu users, you need to install:

and then everything looks fine, but when I run the macro listed above (myHiggs), I got the follow message:

dlopen error: /home/ale/Documents/HEP/PythiaExercices/test/libPythiaDict.so: wrong ELF class: ELFCLASS32 Load Error: Failed to load Dynamic link library /home/ale/Documents/HEP/PythiaExercices/test/libPythiaDict.so
what could it be???
Thanks you

Hi,

Your version of ROOT was compiled in 64 bits mode while you dictionary has been compile in 32 bits mode.

Cheers,
Philippe.

Hello!
I have a problem with creating pythia dictionary on Ubuntu 10.10 64bit, gcc version is 4.4.5.
I have ROOT 5-33-02b, PYTHIA8 8162, compiled with enable-shared and fPIC. To compile with fPIC I tried to

  1. use USRCXXFLAGS variable, which is used by ./configure
  2. edit config.mk file as described here http://root.cern.ch/root/roottalk/roottalk10/0723.html and edit MakeFile - force it not to run ./configure by commenting corresponding lines, since it recreates the config.mk file.

But still can’t create a dictionary.

Running “make dict” in $PYTHIA/rootexamples/ gives an error about fPIC:

rootcint -f pythiaDict.cc -c -I/opt/pythia/pythia8162/include \ -DPYTHIA8_COMPLETE_ROOT_DICTIONARY \ pythiaROOT.h pythiaLinkdef.h g++ -shared -o pythiaDict.so pythiaDict.cc \ -DPYTHIA8_COMPLETE_ROOT_DICTIONARY \ -I/opt/pythia/pythia8162/include -pthread -m64 -I/opt/alice/root/v5-33-02b/include -m64 -L/opt/alice/root/v5-33-02b/lib -lGui -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic -L/opt/pythia/pythia8162/lib -lpythia8 -llhapdfdummy /usr/bin/ld: /tmp/ccHpQfvk.o: relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC /tmp/ccHpQfvk.o: could not read symbols: Bad value collect2: ld returned 1 exit status

Scripts from this thread also dont create the dictionary. makePythiDict from p.tar.gz gives the following:

./makePythiaDict /usr/bin/ld: skipping incompatible /opt/pythia/pythia8162/lib/libpythia8.so when searching for -lpythia8 /usr/bin/ld: cannot find -lpythia8 /usr/bin/ld: skipping incompatible /opt/alice/root/v5-33-02b/lib/libCore.so when searching for -lCore /usr/bin/ld: cannot find -lCore /usr/bin/ld: skipping incompatible /opt/alice/root/v5-33-02b/lib/libCint.so when searching for -lCint /usr/bin/ld: cannot find -lCint collect2: ld returned 1 exit status

goex1 from ex1.tar.gz runs without any errors and creates an executable, which giving an error

./ex1 ./ex1: error while loading shared libraries: liblhapdfdummy.so: cannot open shared object file: No such file or directory

Can someone say what I am doing wrong or give some tips ?

Thank you in advance!
Rishat

Hi,

The lineg++ -shared -o pythiaDict.so pythiaDict.cc seems to be missing -fPIC

Cheers,
Philippe.