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