~madteam/mg5amcnlo/series2.0

« back to all changes in this revision

Viewing changes to Template/FKS-born/SubProcesses/fastjetfortran_madfks.cc.fj-2.4.xx

  • Committer: Marco Zaro
  • Date: 2012-08-28 21:06:34 UTC
  • mto: (78.35.14 AutoMint)
  • mto: This revision was merged to the branch mainline in revision 249.
  • Revision ID: marco.zaro@gmail.com-20120828210634-5a06yvda3hplw8ur
doing some renaming:
 Template/FKS-born -> Template/NLO
 fks_born.py -> fks_base.py
 fks_born_helas_objects.py -> fks_helas_objects.py
 export_fks_born.py -> export_fks.py

also functions/classes and tests renamed
all unit tests ok, exporting ok

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//STARTHEADER
2
 
// $Id: fastjetfortran.cc 1570 2009-05-25 10:45:18Z salam $
3
 
//
4
 
// Copyright (c) 2005-2007, Matteo Cacciari, Gavin Salam and Gregory Soyez
5
 
//
6
 
//----------------------------------------------------------------------
7
 
// This file is part of FastJet.
8
 
//
9
 
//  FastJet is free software; you can redistribute it and/or modify
10
 
//  it under the terms of the GNU General Public License as published by
11
 
//  the Free Software Foundation; either version 2 of the License, or
12
 
//  (at your option) any later version.
13
 
//
14
 
//  The algorithms that underlie FastJet have required considerable
15
 
//  development and are described in hep-ph/0512210. If you use
16
 
//  FastJet as part of work towards a scientific publication, please
17
 
//  include a citation to the FastJet paper.
18
 
//
19
 
//  FastJet is distributed in the hope that it will be useful,
20
 
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 
//  GNU General Public License for more details.
23
 
//
24
 
//  You should have received a copy of the GNU General Public License
25
 
//  along with FastJet; if not, write to the Free Software
26
 
//  Foundation, Inc.:
27
 
//      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28
 
//----------------------------------------------------------------------
29
 
//ENDHEADER
30
 
 
31
 
#include <iostream>
32
 
#include "fastjet/ClusterSequence.hh"
33
 
 
34
 
namespace fj = fastjet;
35
 
using namespace std;
36
 
bool _first_time = true;
37
 
auto_ptr<fj::ClusterSequence> cs;
38
 
 
39
 
extern "C" {   
40
 
 
41
 
// f77 interface to the pp generalised-kt (sequential recombination)
42
 
// algorithms, as defined in arXiv.org:0802.1189, which includes
43
 
// kt, Cambridge/Aachen and anti-kt as special cases.
44
 
//
45
 
// Corresponds to the following Fortran subroutine
46
 
// interface structure:
47
 
//
48
 
//   SUBROUTINE FASTJETPPSEQREC(P,NPART,R,PALG,F77JETS,NJETS)
49
 
//   DOUBLE PRECISION P(4,*), R, PALG, F, F77JETS(4,*)
50
 
//   INTEGER          NPART, NJETS
51
 
// 
52
 
// where on input
53
 
//
54
 
//   P        the input particle 4-momenta
55
 
//   NPART    the number of input momenta
56
 
//   R        the radius parameter
57
 
//   PALG     the power for the generalised kt alg 
58
 
//            (1.0=kt, 0.0=C/A,  -1.0 = anti-kt)
59
 
//
60
 
// and on output 
61
 
//
62
 
//   F77JETS  the output jet momenta (whose second dim should be >= NPART)
63
 
//            sorted in order of decreasing p_t.
64
 
//   NJETS    the number of output jets 
65
 
//
66
 
// For the values of PALG that correspond to "standard" cases (1.0=kt,
67
 
// 0.0=C/A, -1.0 = anti-kt) this routine actually calls the direct
68
 
// implementation of those algorithms, whereas for other values of
69
 
// PALG it calls the generalised kt implementation.
70
 
//
71
 
void fastjetppgenkt_(const double * p, const int & npart,                   
72
 
                     const double & R, const double & jetptmin, const double & palg,
73
 
                     double * f77jets, int & njets, int * whichjet) {
74
 
  
75
 
  // transfer p[4*ipart+0..3] -> input_particles[i]
76
 
  vector<fj::PseudoJet> input_particles;   
77
 
  for (int i=0; i<npart; i++) {
78
 
    valarray<double> mom(4); // mom[0..3]
79
 
    for (int j=0;j<=3; j++) {
80
 
      // mom[j] = *(p++);
81
 
      // RF: reorder the arguments because in madfks energy goes first; in fastjet last.
82
 
      mom[(j+3) % 4] = *(p++);
83
 
    }
84
 
    fj::PseudoJet psjet(mom);
85
 
    psjet.set_user_index(i);
86
 
    input_particles.push_back(psjet);    
87
 
  }
88
 
  
89
 
  // prepare jet def and run fastjet
90
 
  fj::JetDefinition jet_def;
91
 
  if (palg == 1.0) {
92
 
    jet_def = fj::JetDefinition(fj::kt_algorithm, R);
93
 
  }  else if (palg == 0.0) {
94
 
    jet_def = fj::JetDefinition(fj::cambridge_algorithm, R);
95
 
  }  else if (palg == -1.0) {
96
 
    jet_def = fj::JetDefinition(fj::antikt_algorithm, R);
97
 
  } else {
98
 
    jet_def = fj::JetDefinition(fj::genkt_algorithm, R, palg);
99
 
  }
100
 
  
101
 
  
102
 
  // perform clustering
103
 
  cs.reset(new fj::ClusterSequence(input_particles,jet_def));
104
 
  // extract jets (pt-ordered)
105
 
  vector<fj::PseudoJet> jets = sorted_by_pt(cs->inclusive_jets(jetptmin));
106
 
  njets = jets.size();
107
 
  
108
 
  // tell the user what was done
109
 
  if (_first_time) {
110
 
    cout << "# " << jet_def.description() << endl;
111
 
    cout <<("# and minimum jet pt of %E \n",jetptmin);
112
 
    cout <<("#------------------------------------------------------------------------- \n");
113
 
    _first_time = false;
114
 
  }
115
 
  
116
 
  // transfer jets -> f77jets[4*ijet+0..3]
117
 
  for (int i=0; i<njets; i++) {
118
 
    for (int j=0;j<=3; j++) {
119
 
      // *f77jets = jets[i][j];
120
 
      // RF: reorder the arguments because in madfks energy goes first; in fastjet last.
121
 
      *f77jets = jets[i][(j+3) % 4];
122
 
      f77jets++;
123
 
    } 
124
 
  }
125
 
  
126
 
  // clean up
127
 
  
128
 
  // set all jet entrie to zero first
129
 
  for(unsigned int ii=0; ii<npart; ++ii) whichjet[ii]=0;       
130
 
  
131
 
  for (unsigned int kk=0; kk<jets.size(); ++kk) {   
132
 
  vector<fj::PseudoJet> constit = cs->constituents(jets[kk]);
133
 
  for(unsigned int ll=0; ll<constit.size(); ++ll)
134
 
  whichjet[constit[ll].user_index()]=kk+1;
135
 
  }
136
 
  
137
 
}
138
 
 
139
 
/// return the dmin corresponding to the recombination that went from
140
 
/// n+1 to n jets (sometimes known as d_{n n+1}).
141
 
//
142
 
// Corresponds to the following Fortran interface
143
 
// 
144
 
//   FUNCTION FASTJETDMERGE(N)
145
 
//   DOUBLE PRECISION FASTJETDMERGE
146
 
//   INTEGER N
147
 
//   
148
 
double fastjetdmerge_(const int & n) {
149
 
  assert(cs.get() != 0);
150
 
  return cs->exclusive_dmerge(n);
151
 
}
152
 
 
153
 
/// return the maximum of the dmin encountered during all recombinations 
154
 
/// up to the one that led to an n-jet final state; identical to
155
 
/// exclusive_dmerge, except in cases where the dmin do not increase
156
 
/// monotonically.
157
 
//
158
 
// Corresponds to the following Fortran interface
159
 
// 
160
 
//   FUNCTION FASTJETDMERGEMAX(N)
161
 
//   DOUBLE PRECISION FASTJETDMERGEMAX
162
 
//   INTEGER N
163
 
//   
164
 
double fastjetdmergemax_(const int & n) {
165
 
  assert(cs.get() != 0);
166
 
  return cs->exclusive_dmerge_max(n);
167
 
}
168
 
 
169
 
 
170
 
}
171