Fork me on GitHub

Opened 7 years ago

Closed 7 years ago

#1143 closed Bug (fixed)

std::vector with Delphes classes

Reported by: Blake Owned by:
Priority: minor Milestone:
Component: Delphes code Version: Delphes 3
Keywords: Cc:

Description

I'm fairly certain that this should be a simple fix and has something to do with my Delphes and ROOT environment but I can't seem to figure out my problem. I'm trying to use std::vectors with the Jet class. A short example of what I am trying to accomplish is this:

#include <vector>

main go(){
 gSystem->Load("libDelphes.so");
 vector<Jet *> bJets;
}

I get a wall of text error that starts with this:

Error: class,struct,union or type decltype(nullptr) not defined /usr/include/x86_64-linux-gnu/c++/6/bits/c++config.h:205:
Error: unrecognized language construct /usr/include/c++/6/bits/atomic_base.h:162:
Error: Symbol default is not defined in current scope /usr/include/c++/6/bits/atomic_base.h:162:
Error: unrecognized language construct /usr/include/c++/6/bits/atomic_base.h:163:
Error: Symbol default is not defined in current scope /usr/include/c++/6/bits/atomic_base.h:163:

Thanks!

Change History (10)

comment:1 by Pavel Demin, 7 years ago

I'm afraid the information you provide isn't enough to reproduce the problem.

Please provide more information about your installation. What are your OS, C++ compiler, ROOT version, Delphes version? What is exactly the code that you're running in ROOT?

I've just tried the following commands under Ubuntu 16.04, with gcc 5.4.0, ROOT 6.08.02, Delphes 3.4.1:

# root -l
root [0] gSystem->Load("libDelphes");
root [1] vector<Jet *> bJets;
root [2] bJets.size()
(std::vector::size_type) 0

It works.

If I copy and paste your code, I get the following error messages:

root [0] #include <vector>
root [1] main go(){
root [2]   gSystem->Load("libDelphes.so");
root [3]   vector<Jet *> bJets;
root [4] }
ROOT_prompt_1:1:1: error: unknown type name 'main'
main go(){
^
ROOT_prompt_3:1:8: error: use of undeclared identifier 'Jet'
vector<Jet *> bJets;
       ^
ROOT_prompt_3:1:13: error: expected expression
vector<Jet *> bJets;
            ^

With a few fixes here and there it works:

# root -l
root [0] #include <vector>
root [1] gSystem->Load("libDelphes.so");
root [2] int go(){
root [3]   vector<Jet *> bJets;
root [4]   return bJets.size();
root [5] }
root [6] go()
(int) 0

Last edited 7 years ago by Pavel Demin (previous) (diff)

comment:2 by Blake, 7 years ago

Pavel,

Yeah I definitely should have included this in my first post. I'm running Ubuntu 16.10 with gcc 6.2.0 20161005, ROOT 5.34, Delphes 3.4.0. I tried the first set of code you have and I get this error:

root [0] gSystem->Load("libDelphes");
root [1] vector<Jet *> bJets;
Error: Symbol vector<Jet*>bJets is not defined in current scope  (tmpfile):1:
*** Interpreter error recovered ***

Please let me know what other information I can provide to help.

comment:3 by Pavel Demin, 7 years ago

If I'm not mistaken, ROOT 5.34 had very limited support for the STL containers. I'd suggest to install the latest ROOT version.

in reply to:  3 comment:4 by Blake, 7 years ago

Replying to pavel:

If I'm not mistaken, ROOT 5.34 had very limited support for the STL containers. I'd suggest to install the latest ROOT version.

I have ROOT 6.08 installed as well and also get an error. I replied with it above.

comment:5 by Pavel Demin, 7 years ago

I have ROOT 6.08 installed as well and also get an error. I replied with it above.

How you installed ROOT 6.08?

in reply to:  5 comment:6 by Blake, 7 years ago

Replying to pavel:

I have ROOT 6.08 installed as well and also get an error. I replied with it above.

How you installed ROOT 6.08?

If I recall correctly I followed the instructions here:
https://root.cern.ch/building-root
I think I documented exactly what I did and I've listed it below.

wget https://root.cern.ch/download/root_v6.08.source.tar.gz
tar -zxf root_<version>.source.tar.gz
This will not be the ROOT folder that you build in so unpack it somewhere else
mkdir <build_dir>
cd <build_dir>
cmake <untar_dir>
cmake --build . --target install
source <path_to_build_root>/bin/thisroot.sh
cd
vi .bashrc
export ROOTSYS=/home/bforland/Documents/root
export PATH=$PATH:$ROOTSYS:$ROOTSYS/bin
for pyROOT
sudo apt-get install libroot-bindings-python-dev

comment:7 by Pavel Demin, 7 years ago

I've just built ROOT 6.08.06 under Ubuntu 16.10 and checked that the vector code works with this ROOT version and Delphes 3.4.0.

I'd suggest to try to download and install this pre-built version:

wget http://cp3.irmp.ucl.ac.be/downloads/root_6.08.06_ub1610.tgz

mkdir -p /opt/root

tar -zxf root_6.08.06_ub1610.tgz -C /opt/root

Here are the commands that I used to build ROOT:

wget http://cp3.irmp.ucl.ac.be/downloads/packages-ub1610.txt
apt-get install `cat packages-ub1610.txt`

mkdir -p /opt/root

version=6.08.06
export ROOTSYS=/opt/root/root_${version}

wget https://root.cern.ch/download/root_v${version}.source.tar.gz
tar -zxf root_v${version}.source.tar.gz

mkdir root_${version}_build
cd root_${version}_build

cmake ../root-${version} -DCMAKE_INSTALL_PREFIX=$ROOTSYS -Dcxx11=ON -Dgdml=ON -Dminuit2=ON -Dqt=ON -Dqtgsi=ON -Droofit=ON -Dtable=ON -Dunuran=ON

make -j 8
make install

comment:8 by Blake, 7 years ago

I downloaded and installed the pre-build version as you suggested above and then I ran the code the way you fixed and suggested above.

root [0] #include <vector>
root [1] gSystem->Load("libDelphes.so");
cling::DynamicLibraryManager::loadLibrary(): /home/bforland/WORKING/MG5_aMC_v2_5_3/Delphes/libDelphes.so: undefined symbol: _ZN8TFormula11ShowMembersER16TMemberInspector
root [2] int go(){
root (cont'ed, cancel with .@) [3]vector<Jet *> bJets;
root (cont'ed, cancel with .@) [4]return bJets.size();
root (cont'ed, cancel with .@) [5]}
ROOT_prompt_2:1:8: error: use of undeclared identifier 'Jet'
vector<Jet *> bJets;
       ^
ROOT_prompt_2:1:13: error: expected expression
vector<Jet *> bJets;
            ^
ROOT_prompt_3:1:8: error: use of undeclared identifier 'bJets'
return bJets.size();
       ^
root [6]

I still get errors. Just not sure what I'm missing.

Last edited 7 years ago by Blake (previous) (diff)

comment:9 by Pavel Demin, 7 years ago

I'd say that the undefined symbol: _ZN8TFormula11ShowMembersER16TMemberInspector message indicates that Delphes wasn't rebuilt with the new ROOT version. Could you please try to rebuild Delphes by running make distclean ; make in the Delphes directory?

comment:10 by Pavel Demin, 7 years ago

Resolution: fixed
Status: newclosed

I'm closing this issue since I can't reproduce it.

Note: See TracTickets for help on using tickets.