Dear developers,
I am trying to couple Pythia8 and Root together.
I mean I want to use Root to diplay histograms from Pythia8.
I have copied the following example from the Welcome Webpage of Pythia:
//gSystem.Load("…/libPythia8");
// File: main01.cc
// This is a simple test program. It fits on one slide in a talk.
// It studies the charged multiplicity distribution at the LHC.
// Copyright C 2007 Torbjorn Sjostrand
//#include “Pythia.h”
#include "TH1.h"
using namespace Pythia8;
int ex1() {
// Generator. Process selection. LHC initialization. Histogram.
Pythia pythia;
pythia.readString(“HardQCD:all = on”);
pythia.readString(“PhaseSpace:pTHatMin = 20.”);
pythia.init( 2212, 2212, 14000.);
TFile *file = TFile::Open(“ex1.root”,“recreate”);
Event *event = &pythia.event;
TTree *T = new TTree(“T”,“ev1 Tree”);
T->Branch(“event”,“Event”,&event);
TH1F *mult = new TH1F(“mult”,“charged multiplicity”, 100, -0.5, 799.5);
// Begin event loop. Generate event. Skip if error. List first one.
for (int iEvent = 0; iEvent < 100; ++iEvent) {
if (!pythia.next()) continue;
//if (iEvent < 1) {pythia.info.list(); pythia.event.list();}
// Find number of all final charged particles and fill histogram.
int nCharged = 0;
for (int i = 0; i < pythia.event.size(); ++i)
if (pythia.event[i].isFinal() && pythia.event[i].isCharged())
++nCharged;
mult->Fill( nCharged );
T->Fill();
// End of event loop. Statistics. Histogram. Done.
}
pythia.statistics();
cout << mult;
T->Print();
T->Write();
delete file;
return 0;
}
When I run this example the error message is:
[mpellen@ppepc22 examples]$ make mymain011
g++ -O2 -ansi -pedantic -W -Wall -Wshadow -I…/include mymain011.cc -o …/bin/mymain011.exe
-L…/lib/archive -lpythia8 -llhapdfdummy
mymain011.cc:8:17: TH1.h: No such file or directory
mymain011.cc:9: error: Pythia8' is not a namespace-name mymain011.cc:9: error: expected namespace-name before ';' token mymain011.cc: In function
int ex1()’:
mymain011.cc:12: error: Pythia' was not declared in this scope mymain011.cc:12: error: expected
;’ before "pythia"
mymain011.cc:13: error: pythia' was not declared in this scope mymain011.cc:16: error:
TFile’ was not declared in this scope
mymain011.cc:16: error: file' was not declared in this scope mymain011.cc:16: error:
TFile’ is not a class or namespace
mymain011.cc:16: error: Open' was not declared in this scope mymain011.cc:17: error:
Event’ was not declared in this scope
mymain011.cc:17: error: event' was not declared in this scope mymain011.cc:18: error:
TTree’ was not declared in this scope
mymain011.cc:18: error: T' was not declared in this scope mymain011.cc:18: error:
TTree’ is not a type
mymain011.cc:20: error: TH1F' was not declared in this scope mymain011.cc:20: error:
mult’ was not declared in this scope
mymain011.cc:20: error: TH1F' is not a type mymain011.cc:35: error:
cout’ was not declared in this scope
mymain011.cc:38: error: type <type error>' argument given to
delete’, expected pointer
mymain011.cc:12: warning: unused variable 'Pythia’
mymain011.cc:16: warning: unused variable 'TFile’
mymain011.cc:16: warning: unused variable 'Open’
mymain011.cc:17: warning: unused variable 'Event’
mymain011.cc:18: warning: unused variable 'TTree’
mymain011.cc:20: warning: unused variable 'TH1F’
mymain011.cc:35: warning: unused variable 'cout’
make: *** [mymain011] Error 1
or:
[mpellen@ppepc22 examples]$ root
-
*
-
W E L C O M E to R O O T *
-
*
- Version 5.14/00b 17 January 2007 *
-
*
- You are welcome to visit our Web site *
-
[root.cern.ch](http://root.cern.ch) *
-
*
FreeType Engine v2.1.9 used to render TrueType fonts.
Compiled on 3 August 2009 for linux with thread support.
CINT/ROOT C/C++ Interpreter version 5.16.16, November 24, 2006
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] .x mymain011.cc++
Info in TUnixSystem::ACLiC: creating shared library /home/mpellen/Pythia/pythia8135/examples/./mymain011_cc.so
Error: namespace Pythia8 is not defined mymain011.cc:9:
Warning: Error occurred during reading source files
Warning: Error occurred during dictionary source generation
!!!Removing /home/mpellen/Pythia/pythia8135/examples/./file6Xd0j0.cxx /home/mpellen/Pythia/pythia8135/examples/./file6Xd0j0.h !!!
Error: rootcint: error loading headers…
Error in : Dictionary generation failed!
Info in : Invoking compiler to check macro’s validity
/home/mpellen/Pythia/pythia8135/examples/./mymain011.cc:9: error: Pythia8' is not a namespace-name /home/mpellen/Pythia/pythia8135/examples/./mymain011.cc:9: error: expected namespace-name before ';' token /home/mpellen/Pythia/pythia8135/examples/./mymain011.cc: In function
int ex1()’:
/home/mpellen/Pythia/pythia8135/examples/./mymain011.cc:12: error: Pythia' was not declared in this scope /home/mpellen/Pythia/pythia8135/examples/./mymain011.cc:12: error: expected
;’ before “pythia”
/home/mpellen/Pythia/pythia8135/examples/./mymain011.cc:13: error: pythia' was not declared in this scope /home/mpellen/Pythia/pythia8135/examples/./mymain011.cc:16: error: incomplete type
TFile’ used in nested name specifier
/home/mpellen/Pythia/pythia8135/examples/./mymain011.cc:17: error: Event' was not declared in this scope /home/mpellen/Pythia/pythia8135/examples/./mymain011.cc:17: error:
event’ was not declared in this scope
/home/mpellen/Pythia/pythia8135/examples/./mymain011.cc:18: error: TTree' was not declared in this scope /home/mpellen/Pythia/pythia8135/examples/./mymain011.cc:18: error:
T’ was not declared in this scope
/home/mpellen/Pythia/pythia8135/examples/./mymain011.cc:18: error: TTree' is not a type /home/mpellen/Pythia/pythia8135/examples/./mymain011.cc:35: error:
cout’ was not declared in this scope
/home/mpellen/Pythia/pythia8135/examples/./mymain011.cc:38: warning: possible problem detected in invocation of delete operator:
/home/mpellen/Pythia/pythia8135/examples/./mymain011.cc:16: warning: file' has incomplete type /usr/local/include/root/TUUID.h:39: warning: forward declaration of
struct TFile’
/home/mpellen/Pythia/pythia8135/examples/./mymain011.cc:38: note: neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined.
/home/mpellen/Pythia/pythia8135/examples/./mymain011.cc:12: warning: unused variable ‘Pythia’
/home/mpellen/Pythia/pythia8135/examples/./mymain011.cc:17: warning: unused variable ‘Event’
/home/mpellen/Pythia/pythia8135/examples/./mymain011.cc:18: warning: unused variable ‘TTree’
/home/mpellen/Pythia/pythia8135/examples/./mymain011.cc:35: warning: unused variable 'cout’
Error: Function mymain011() is not defined in current scope :0:
*** Interpreter error recovered ***
I think that the problem comes from configuration of Root i.e. executing the following lines:
./configure --enable-pythia8
./configure --with-pythia8-incdir=$PYTHIA8/include
./configure --with-pythia8-libdir=$PYTHIA8/lib
So the problem is that I don’t have access to the configuartion of Root on my computer (computing network at the laboratory).
Is there any other possibility?
I’ve also tried to uncomment the first line and #include “Pythia.h” but it doesn’t work either.
I’ve also tried the tutorial pythia8.C but it doesn’t work either:
root [0] .x pythia8.C
Error in TUnixSystem::DynamicPathName: libEGPythia8[.so | .sl | .dl | .a | .dll] does not exist in .:/usr/local/lib/root:
Error: Symbol TPythia8 is not defined in current scope pythia8.C:33:
Error: Symbol TPythia8 is not defined in current scope pythia8.C:33:
Error: type TPythia8 not defined FILE:/home/mpellen/PythiaRoot/True/./pythia8.C LINE:33
Warning: Automatic variable TPythia8* pythia8 is allocated pythia8.C:33:
Error: Undeclared variable TPythia8* pythia8 pythia8.C:33:
*** Interpreter error recovered ***
Am I missing something? If anybody has any idea how to deal with this problem, please let me know.
Best regards,
Mathieu