PseudoJet columns in rootdataframe


Please read tips for efficient and successful posting and posting code

_ROOT Version:_6.30.04
Platform: Not Provided
Compiler: Not Provided


Hi experts,
I have formed a rootdataframe from a given root file. In this rootdataframe, i wanted to create a column of “PseudoJet” objects. I have used the following command but end up in having some errors-

using namespace ROOT;
using namespace std;
using namespace fastjet;

ROOT::RDataFrame df("events", "events_029930132.root");

std::vector<PseudoJet> particles;

auto rdf = df.Define("Particle_P4", "auto p = particles.push_back(PseudoJet(ReconstructedParticles.momentum.x, ReconstructedParticles.momentum.y, ReconstructedParticles.momentum.z, ReconstructedParticles.energy)); return p");

Also i have used the following compilation command:

g++ -I/home/ganeshh/FASTJET/fastjet-install/include `root-config --cflags` fastjet_fcc1.cc -lfastjet -L/home/ganeshh/FASTJET/fastjet-install/lib `root-config --glibs`

The error i am getting is the following:

fastjet_fcc1.cc: In function ‘void fastjet_fcc1()’:
fastjet_fcc1.cc:5:19: error: ‘ROOT’ is not a namespace-name
    5 |   using namespace ROOT;
      |                   ^~~~
fastjet_fcc1.cc:7:19: error: ‘fastjet’ is not a namespace-name
    7 |   using namespace fastjet;
      |                   ^~~~~~~
fastjet_fcc1.cc:9:3: error: ‘ROOT’ has not been declared
    9 |   ROOT::RDataFrame df("events", "events_029930132.root");
      |   ^~~~
fastjet_fcc1.cc:12:8: error: ‘vector’ is not a member of ‘std’
   12 |   std::vector<PseudoJet> particles;
      |        ^~~~~~
fastjet_fcc1.cc:1:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
  +++ |+#include <vector>
    1 | void fastjet_fcc1()
fastjet_fcc1.cc:12:15: error: ‘PseudoJet’ was not declared in this scope
   12 |   std::vector<PseudoJet> particles;
      |               ^~~~~~~~~
fastjet_fcc1.cc:12:26: error: ‘particles’ was not declared in this scope
   12 |   std::vector<PseudoJet> particles;
      |                          ^~~~~~~~~
fastjet_fcc1.cc:18:14: error: ‘df’ was not declared in this scope; did you mean ‘df0’?
   18 |   auto df0 = df.Define("Particle_P4", "auto p = particles.push_back(PseudoJet(ReconstructedParticles.momentum.x, ReconstructedParticles.momentum.y, ReconstructedParticles.momentum.z, ReconstructedParticles.energy)); return p");
      |              ^~
      |              df0

How these errors can be fixed?

Hi,

Mixing RDF and FastJet sounds like an interesting experiment, thanks for posting.
I suspect you did not properly include all the necessary headers in the fastjet_fcc1.cc: could you cross-check? (Note that it does not seem to be an issue of ROOT, since you have errors relative to fastjet and even the standard library).

If I may, I could suggest an improvement of your C++ code: it could be made much more elegant, and non-jitted, with Construct (see also this post for example RDataFrame: Snapshot does not work properly after Define and Range call - #4 by mczurylo )

Cheers,
D

Got the error fixed on the fastjet side but still error persists on root side.
Following is the error i am getting-

fastjet_fcc1.cc:2:17: error: ‘ROOT’ is not a namespace-name
2 | using namespace ROOT;
| ^~~~
fastjet_fcc1.cc: In function ‘void fastjet_fcc1()’:
fastjet_fcc1.cc:13:3: error: ‘ROOT’ has not been declared
13 | ROOT::RDataFrame df(“events”, “events_029930132.root”);
| ^~~~
fastjet_fcc1.cc:22:14: error: ‘df’ was not declared in this scope; did you mean ‘df0’?
22 | auto df0 = df.Define(“Particle_P4”, “auto p = particles.push_back(PseudoJet(ReconstructedParticles.momentum.x, ReconstructedParticles.momentum.y, ReconstructedParticles.momentum.z, ReconstructedParticles.energy)); return p”);
| ^~
| df0

Hi,

This is odd. Are you sure the right headers have been included?

Cheers,
D