Fastjet in root on Mac OS

Hi,

I posted that on an existing thread, but the topic does not show up as unresolved, so I am posting it separately below:

Any hints / suggestions would be greatly appreciated
Yuri

Hi,

I think this is an example where ROOT6 shines.
Once ROOT6 is available on your system you can do the following.

  1. Get fastjet, compile it and start up root:
curl -O http://fastjet.fr/repo/fastjet-3.0.6.tar.gz
tar zxvf fastjet-3.0.6.tar.gz
cd fastjet-3.0.6/
./configure --prefix=$PWD/../fastjet-install
make -j 12
make check
make install
cd ..
ROOT_INCLUDE_PATH=fastjet-install/include/ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`/fastjet-install/lib/ root -b
  1. Take this code, copied from the fastjet main page, and copy it into the prompt:
gSystem->Load("libfastjet.so")
#include "fastjet/ClusterSequence.hh"
#include <iostream>
using namespace fastjet;
using namespace std;
 

vector<PseudoJet> particles;
// an event with three particles:   px    py  pz      E
particles.push_back(PseudoJet(99.0,  0.1,  0, 100.0));
particles.push_back(PseudoJet(4.0, -0.1,  0,   5.0));
particles.push_back(PseudoJet(-99.0,    0,  0,  99.0));

// choose a jet definition
double R = 0.7;
JetDefinition jet_def(antikt_algorithm, R);

// run the clustering, extract the jets
ClusterSequence cs(particles, jet_def);
vector<PseudoJet> jets = sorted_by_pt(cs.inclusive_jets());

// print out some infos
cout << "Clustering with " << jet_def.description() << endl;

// print the jets
cout <<   "        pt y phi" << endl;
for (unsigned i = 0; i < jets.size(); i++){
   cout << "jet " << i << ": " << jets[i].pt() << " "
        << jets[i].rap() << " " << jets[i].phi() << endl;
   vector<PseudoJet> constituents = jets[i].constituents();
   for (unsigned j = 0; j < constituents.size(); j++) {
      cout << "    constituent " << j << "'s pt: " << constituents[j].pt()
           << endl;
   }
}

You will get the desired output:

jet 0: 103 0 0
    constituent 0's pt: 99.0001
    constituent 1's pt: 4.00125
jet 1: 99 0 3.14159
    constituent 0's pt: 99

Best,
Danilo

[quote=“dpiparo”]Hi,

I think this is an example where ROOT6 shines.
Once ROOT6 is available on your system you can do the following.
[/quote]

I’m sure ROOT6 will also make me espresso and remind me to buy milk.

However, I’m stuck with ROOT5 for a little while. Any ideas about ROOT5?

Thanks,
Yuri

You might get some help if you post a full reproducer.

Danilo,

I thought I did? Which information is missing from what I posted?

Thanks,
Yuri

The actual files you used with correct names ant the list of commands typed at the prompt.

D

[quote=“dpiparo”][quote]
Which information is missing from what I posted?
[/quote]

The actual files you used with correct names ant the list of commands typed at the prompt.

D[/quote]

Files attached.
The fastjet files are standard unmodified fastjet-3.1.0,
built as per standard instructions.

Root command sequence
root [0] .include /Users/gerstein/fastjet/fastjet-install/include
root [1] int a = gSystem->Load(“fastjet-install/lib/libfastjet.so”); cout<<a<<"\n";
0
root [2] .L shortex.cc++
include.tar.gz (165 KB)
shortex.cc (1.16 KB)

turns out the dylib extensions are not allowed, so I slapped a .txt on top of it.
libfastjet.0.dylib.txt (754 KB)

Hi,

Use [code]
#ifndef CINT
//----------------------------------------------------------------------
// implementation of JetDefinition::operator() is here to avoid nasty
// issues of order of implementations and includes
template
std::vector JetDefinition::operator()(const std::vector & particles) const {
// create a new cluster sequence
ClusterSequence * cs = new ClusterSequence(particles, *this);

// get the jets, and sort them according to whether the algorithm
// is spherical or not
std::vector jets;
if (is_spherical()) {
jets = sorted_by_E(cs->inclusive_jets());
} else {
jets = sorted_by_pt(cs->inclusive_jets());
}

// make sure the ClusterSequence gets deleted once it’s no longer
// needed
if (jets.size() != 0) {
cs->delete_self_when_unused();
} else {
delete cs;
}

return jets;
}
#endif // CINT[/code]

This construct can not be parsed by CINT and is not essential to dictionary generation.

Cheers,
Philipe.

PS. Of course, a consequence is that this operator is not useable from the interpreter (for this, use ROOT v6).

[quote=“pcanal”]Hi,

This construct can not be parsed by CINT and is not essential to dictionary generation.

Cheers,
Philipe.
[/quote]

Hi Philippe,

thanks so much!
It works now.

regards,
Yuri