This repository has been archived by the owner on Feb 22, 2021. It is now read-only.
forked from alisw/POWHEG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfastjetsisconewrap.cc
100 lines (89 loc) · 3.15 KB
/
fastjetsisconewrap.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//STARTHEADER
// $Id: fastjetsiscone.cc 939 2007-11-08 12:18:08Z salam $
//
// Copyright (c) 2005-2007, Matteo Cacciari, Gavin Salam and Gregory Soyez
//
//----------------------------------------------------------------------
// This file is part of FastJet.
//
// FastJet is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// The algorithms that underlie FastJet have required considerable
// development and are described in hep-ph/0512210. If you use
// FastJet as part of work towards a scientific publication, please
// include a citation to the FastJet paper.
//
// FastJet is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with FastJet; if not, write to the Free Software
// Foundation, Inc.:
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//----------------------------------------------------------------------
//ENDHEADER
#include <iostream>
#include "fastjet/ClusterSequence.hh"
#include "fastjet/SISConePlugin.hh"
namespace fj = fastjet;
using namespace std;
extern "C" {
// f77 interface to SISCone (via fastjet)
//
// Corresponds to the following Fortran subroutine
// interface structure:
//
// SUBROUTINE FASTJETSISCONE(P,NPART,R,F,F77JETS,NJETS)
// DOUBLE PRECISION P(4,*), R, F, F77JETS(4,*)
// INTEGER NPART, NJETS
//
// where on input
//
// P the input particle 4-momenta
// NPART the number of input momenta
// R the radius parameter
// F the overlap threshold
//
// and on output
//
// F77JETS the output jet momenta (whose second dim should be >= NPART)
// sorted in order of decreasing p_t.
// NJETS the number of output jets
//
void fastjetsiscone_(const double * p, const int & npart,
const double & R, const double & f,
double * f77jets, int & njets) {
// transfer p[4*ipart+0..3] -> input_particles[i]
vector<fj::PseudoJet> input_particles;
for (int i=0; i<npart; i++) {
valarray<double> mom(4); // mom[0..3]
for (int j=0;j<=3; j++) {
mom[j] = *(p++);
}
fj::PseudoJet psjet(mom);
input_particles.push_back(psjet);
}
// prepare jet def and run fastjet
fj::SISConePlugin * plugin = new fj::SISConePlugin(R,f);
fj::JetDefinition jet_def(plugin);
// perform clustering
fj::ClusterSequence cs(input_particles,jet_def);
// extract jets (pt-ordered)
vector<fj::PseudoJet> jets = sorted_by_pt(cs.inclusive_jets());
njets = jets.size();
// transfer jets -> f77jets[4*ijet+0..3]
for (int i=0; i<njets; i++) {
for (int j=0;j<=3; j++) {
*f77jets = jets[i][j];
f77jets++;
}
}
// clean up
delete plugin;
}
}