FastJet 3.4.1
D0RunIBaseConePlugin.cc
1//FJSTARTHEADER
2// $Id: D0RunIBaseConePlugin.cc 1779 2010-10-25 10:32:59Z soyez $
3//
4// Copyright (c) 2009-2023, Matteo Cacciari, Gavin P. 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. They are described in the original FastJet paper,
16// hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
17// FastJet as part of work towards a scientific publication, please
18// quote the version you use and include a citation to the manual and
19// optionally also to hep-ph/0512210.
20//
21// FastJet is distributed in the hope that it will be useful,
22// but WITHOUT ANY WARRANTY; without even the implied warranty of
23// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24// GNU General Public License for more details.
25//
26// You should have received a copy of the GNU General Public License
27// along with FastJet. If not, see <http://www.gnu.org/licenses/>.
28//----------------------------------------------------------------------
29//FJENDHEADER
30
31// D0 stuff
32// apparently this has to go first to avoid a problem with gcc-4.0.1 builds on Macs
33#include <list>
34#include "ConeClusterAlgo.hpp"
35#include "HepEntityIpre96.h"
36#include "HepEntityI.h"
37
38#include "fastjet/D0RunIBaseConePlugin.hh"
39#include "fastjet/D0RunIpre96ConePlugin.hh"
40#include "fastjet/D0RunIConePlugin.hh"
41#include "fastjet/ClusterSequence.hh"
42#include "fastjet/Error.hh"
43#include <sstream>
44
45FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
46
47using namespace std;
48using namespace d0runi;
49
50/////////////////////////////////////////////
51// //
52// D0RunIBaseConePlugin implementation //
53// //
54/////////////////////////////////////////////
55
56const double D0RunIBaseConePlugin::_DEFAULT_SPLifr = 0.5; //shared Et fraction threshold
57const double D0RunIBaseConePlugin::_DEFAULT_TWOrad = 0.;
58const bool D0RunIBaseConePlugin::_DEFAULT_D0_Angle = false;
59const bool D0RunIBaseConePlugin::_DEFAULT_Increase_Delta_R = true;
60const bool D0RunIBaseConePlugin::_DEFAULT_Kill_Far_Clusters = true;
61const bool D0RunIBaseConePlugin::_DEFAULT_Jet_Et_Min_On_Iter = true;
62const double D0RunIBaseConePlugin::_DEFAULT_Far_Ratio = 0.5;
63const double D0RunIBaseConePlugin::_DEFAULT_Eitem_Negdrop = -1.0;
64const double D0RunIBaseConePlugin::_DEFAULT_Et_Min_Ratio = 0.5;
65const double D0RunIBaseConePlugin::_DEFAULT_Thresh_Diff_Et = 0.01;
66
67
68// for the real work, we write a template class that decides which
69// HepEntity type to use
70template<typename HepEntityType>
71void D0RunIBaseConePlugin::run_clustering_worker(ClusterSequence & clust_seq) const{
72 // create the entities needed by the D0 code
73 vector<HepEntityType> entities(clust_seq.jets().size());
74 list<const HepEntityType * > ensemble;
75 for (unsigned i = 0; i < clust_seq.jets().size(); i++) {
76 entities[i].Fill(clust_seq.jets()[i].E(),
77 clust_seq.jets()[i].px(),
78 clust_seq.jets()[i].py(),
79 clust_seq.jets()[i].pz(),
80 i);
81 // use only the particles that do not have infinite rapidity
82 if (abs(entities[i].pz() ) < entities[i].E() ) {
83 ensemble.push_back(& (entities[i]));
84 }
85 }
86
87 // prepare the D0 algorithm
88 ConeClusterAlgo<HepEntityType>
89 RunIconeAlgo(CONErad(),
90 JETmne(),
91 TWOrad(),
92 SPLifr(),
93 D0_Angle(),
94 Increase_Delta_R(),
95 Kill_Far_Clusters(),
96 Jet_Et_Min_On_Iter(),
97 Far_Ratio(),
98 Eitem_Negdrop(),
99 Et_Min_Ratio(),
100 Thresh_Diff_Et());
101
102
103 // run the algorithm
104 float Zvertex = 0.;
105 list<HepEntityType> jets;
106 RunIconeAlgo.makeClusters(jets, ensemble, Zvertex);
107
108 // now transfer the information about the jets into the
109 // FastJet structure
110 for(int i = RunIconeAlgo.TempColl.size()-1; i >= 0; i--) {
111
112 std::list<const HepEntityType*> tlist = RunIconeAlgo.TempColl[i].LItems();
113 typename std::list<const HepEntityType*>::iterator tk;
114
115 // get first particle in list
116 tk = tlist.begin();
117 int jet_k = (*tk)->index;
118
119 // GS addition: in order to use the proper recombination scheme
120 // used by D0 we need to keep track of the sum as a
121 // "HepEntityType"
122 HepEntityType jet_current_momentum = *(*tk);
123
124 // now merge with remaining particles in list
125 tk++;
126 for (; tk != tlist.end(); tk++) {
127 int jet_i = jet_k;
128 int jet_j = (*tk)->index;
129 // do a fake recombination step with dij=0
130 double dij = 0.0;
131
132 // GS addition: find the new momentum and convert that into a
133 // pseudo-jet
134 jet_current_momentum.Add(**tk);
135 PseudoJet new_mom(jet_current_momentum.px(), jet_current_momentum.py(),
136 jet_current_momentum.pz(), jet_current_momentum.E());
137
138 clust_seq.plugin_record_ij_recombination(jet_i, jet_j, dij, new_mom, jet_k);
139 }
140
141 // NB: put a sensible looking d_iB just to be nice...
142 double d_iB = clust_seq.jets()[jet_k].perp2();
143 clust_seq.plugin_record_iB_recombination(jet_k, d_iB);
144 }
145}
146
147
148/////////////////////////////////////////////
149// //
150// D0RunIpre96ConePlugin implementation //
151// //
152/////////////////////////////////////////////
153
154thread_safety_helpers::FirstTimeTrue D0RunIpre96ConePlugin::_first_time;
155
156string D0RunIpre96ConePlugin::description () const {
157 ostringstream desc;
158
159 desc << "D0 Run I (pre 96) cone jet algorithm, with ";
160 desc << "cone_radius = " << CONErad () << ", "
161 << "min_jet_Et = " << JETmne () << ", "
162 << "split_fraction = " << SPLifr ();
163
164 return desc.str();
165}
166
167void D0RunIpre96ConePlugin::run_clustering(ClusterSequence & clust_seq) const {
168 // print a banner if we run this for the first time
169 _print_banner(clust_seq.fastjet_banner_stream());
170
171 run_clustering_worker<HepEntityIpre96>(clust_seq);
172}
173
174// print a banner for reference to the 3rd-party code
175void D0RunIpre96ConePlugin::_print_banner(ostream *ostr) const{
176 if (! _first_time()) return;
177
178 // make sure the user has not set the banner stream to NULL
179 if (!ostr) return;
180
181 (*ostr) << "#--------------------------------------------------------------------------" << endl;
182 (*ostr) << "# You are running the D0 Run I (pre96) Cone plugin for FastJet " << endl;
183 (*ostr) << "# Original code by the D0 collaboration, provided by Lars Sonnenschein; " << endl;
184 (*ostr) << "# interface by FastJet authors " << endl;
185 (*ostr) << "# If you use this plugin, please cite " << endl;
186 (*ostr) << "# B. Abbott et al. [D0 Collaboration], FERMILAB-PUB-97-242-E. " << endl;
187 (*ostr) << "# in addition to the usual FastJet reference. " << endl;
188 (*ostr) << "#--------------------------------------------------------------------------" << endl;
189
190 // make sure we really have the output done.
191 ostr->flush();
192}
193
194
195/////////////////////////////////////////////
196// //
197// D0RunIConePlugin implementation //
198// //
199/////////////////////////////////////////////
200
201thread_safety_helpers::FirstTimeTrue D0RunIConePlugin::_first_time;
202
203string D0RunIConePlugin::description () const {
204 ostringstream desc;
205
206 desc << "D0 Run I cone jet algorithm, with ";
207 desc << "cone_radius = " << CONErad () << ", "
208 << "min_jet_Et = " << JETmne () << ", "
209 << "split_fraction = " << SPLifr ();
210
211 return desc.str();
212}
213
214void D0RunIConePlugin::run_clustering(ClusterSequence & clust_seq) const {
215 // print a banner if we run this for the first time
216 _print_banner(clust_seq.fastjet_banner_stream());
217
218 run_clustering_worker<HepEntityI>(clust_seq);
219}
220
221// print a banner for reference to the 3rd-party code
222void D0RunIConePlugin::_print_banner(ostream *ostr) const{
223 if (! _first_time()) return;
224
225 // make sure the user has not set the banner stream to NULL
226 if (!ostr) return;
227
228 (*ostr) << "#--------------------------------------------------------------------------" << endl;
229 (*ostr) << "# You are running the D0 Run I Cone plugin for FastJet " << endl;
230 (*ostr) << "# Original code provided by Lars Sonnenschein; interface by FastJet authors" << endl;
231 (*ostr) << "# If you use this plugin, please cite " << endl;
232 (*ostr) << "# B. Abbott et al. [D0 Collaboration], FERMILAB-PUB-97-242-E. " << endl;
233 (*ostr) << "# in addition to the usual FastJet reference. " << endl;
234 (*ostr) << "#--------------------------------------------------------------------------" << endl;
235
236 // make sure we really have the output done.
237 ostr->flush();
238}
239
240
241
242FASTJET_END_NAMESPACE // defined in fastjet/internal/base.hh
deals with clustering
static std::ostream * fastjet_banner_stream()
returns a pointer to the stream to be used to print banners (cout by default).