Root interface with pythia8

hi
i installed root version 5.32.04 using fixed location installation
and i installed pythia8

i run sample main programs in example subdirectory of pythia8 and i got output.

i run program hist.cc in rootexamples subdirectory (a sample program to show histogram in root format)
and i got histogram in root format .

then i modified a sample main program in examples subdirectory to get its histgram output in root format.

i used

to make executeable file but i got error as:
g++ -O2 -ansi -pedantic -W -Wall -Wshadow mainw71.cc -o mainw71
mainw71.cc:2:28: fatal error: Pythia8/Pythia.h: No such file or directory
compilation terminated.
make: *** [mainw71] Error 1

then i copied file hist.cc from rootexamples to examples
and i typed

cd examples make hist

i got error as:
g++ -O2 -ansi -pedantic -W -Wall -Wshadow hist.cc -o hist
hist.cc:12:28: fatal error: Pythia8/Pythia.h: No such file or directory
compilation terminated.
make: *** [hist] Error 1

Hi,

You have to tell the compiler where to find the pythia8 headers, by using the “-I” compiler flag. For example: g++ -O2 -ansi -pedantic -W -Wall -Wshadow -I$PYTHIA8/include mainw71.cc -o mainw71
See for example the “Include Directories” paragraph of Compiling with g++

Cheers, Bertrand.

hi
i run the

i got error as:mainw71.cc:3:32: fatal error: fastjet/PseudoJet.hh: No such file or directory
compilation terminated.

Well, then do the same with the fastjet headers location…

Bertrand.

Thanks

i run

g++ -O2 -ansi -pedantic -W -Wall -Wshadow -I$Fastjet-install/include mainw71.cc -o mainw71

i got error as:
mainw71.cc:2:28: fatal error: Pythia8/Pythia.h: No such file or directory
compilation terminated.

And what about this:

:wink:

i still got error as:
mainw71.cc:3:32: fatal error: fastjet/PseudoJet.hh: No such file or directory
compilation terminated.
:frowning:

You have to give the location of those header files on your system. Then those errors will disappear. So please locate PseudoJet.hh, and use this path with the -I compiler flag.
For example, according to your example, it should be in $Fastjet-install/include/fastjet/PseudoJet.hh. If not, then give the correct path and try again.
And you have to do that each time the compiler is complaining about a missing header file.

i used

g++ -O2 -ansi -pedantic -W -Wall -Wshadow -I$PYTHIA8/include -I$/home/raman/Downloads/Fastjet-install/include/fastjet mainw71.cc -o mainw71

i still got the same error

What is the result of ls $PYTHIA8/include and ls /home/raman/Downloads/Fastjet-install/include/fastjet

the output of

ls /home/raman/Downloads/fastjet-install/include/fastjet/

is:
ActiveAreaSpec.hh FunctionOfPseudoJet.hh
AreaDefinition.hh GhostedAreaSpec.hh
CDFJetCluPlugin.hh GridJetPlugin.hh
CDFMidPointPlugin.hh internal
CircularRange.hh JadePlugin.hh
ClusterSequence1GhostPassiveArea.hh JetDefinition.hh
ClusterSequenceActiveAreaExplicitGhosts.hh LimitedWarning.hh
ClusterSequenceActiveArea.hh NestedDefsPlugin.hh
ClusterSequenceAreaBase.hh NNH.hh
ClusterSequenceArea.hh PseudoJet.hh
ClusterSequence.hh PseudoJetStructureBase.hh
ClusterSequencePassiveArea.hh RangeDefinition.hh
ClusterSequenceStructure.hh Selector.hh
ClusterSequenceVoronoiArea.hh SharedPtr.hh
ClusterSequenceWithArea.hh SISConeBasePlugin.hh
CompositeJetStructure.hh SISConePlugin.hh
config_auto.h SISConeSphericalPlugin.hh
config.h tools
EECambridgePlugin.hh version.hh
Error.hh WrappedStructure.hh

i was using Fastjet-install instead of fastjet -install

but now i also used

g++ -O2 -ansi -pedantic -W -Wall -Wshadow -I$PYTHIA8/include -I$/home/raman/Downloads/fastjet-install/include/fastjet mainw71.cc -o mainw71

i still got same error

to execute sample main programs in example subdirectory i use

why i can’t use the same code for my modified program mainw71.cc

Well, you could, you have to modify the Makefile (add your mainw71) and then just type “make mainw71”…

ok
thanks :slight_smile:

i added mainw71 to my makefile
i then typed

i got error as:
mainw71.cc:5:17: fatal error: TH1.h: No such file or directory
compilation terminated.
make: *** [mainw71] Error 1

Add -I$ROOTSYS/include to the compiler flags, as already explained many times before… [-o<

sorry, i am new to this :cry:
i used

g++ -O2 -ansi -pedantic -W -Wall -Wshadow -I$PYTHIA8/include -I$/home/raman/Downloads/fastjet-install/include/fastjet/ -I$ROOTSYS/include mainw71.cc -o mainw71

i got error as:
mainw71.cc:3:32: fatal error: fastjet/PseudoJet.hh: No such file or directory
compilation terminated.
:frowning:

OK, look: the compiler is looking for “fastjet/PseudoJet.hh” so you should add (with -I)the part of the full path which is missing to find the file.

For example, if your mainw71.cc source file contains
#include "fastjet/PseudoJet.hh"
and the full path of PseudoJet.hh is /home/raman/Downloads/fastjet-install/include/fastjet/PseudoJet.hh
You should use -I/home/raman/Downloads/fastjet-install/include

And if your mainw71.cc source file contains
#include "PseudoJet.hh"
You should use -I/home/raman/Downloads/fastjet-install/include/fastjet

I hope this clear enough? You really have to understand how all this works, and take some course or tutorials, otherwise we will never manage…

thanks after using

g++ -O2 -ansi -pedantic -W -Wall -Wshadow -I$PYTHIA8/include -I/home/raman/Downloads/fastjet-install/include/ -I$ROOTSYS/include mainw71.cc -o mainw71

it works fine now. :smiley: \:D/

can you refer any site for pythia8 programming tutorials