Fork me on GitHub

source: git/external/fastjet/plugins/CDFCones/CDFJetCluPlugin.cc@ 374bbcc

ImprovedOutputFile Timing dual_readout llp
Last change on this file since 374bbcc was d7d2da3, checked in by pavel <pavel@…>, 12 years ago

move branches/ModularDelphes to trunk

  • Property mode set to 100644
File size: 6.9 KB
Line 
1//STARTHEADER
2// $Id$
3//
4// Copyright (c) 2005-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#include "fastjet/CDFJetCluPlugin.hh"
30#include "fastjet/ClusterSequence.hh"
31#include <sstream>
32#include <cassert>
33
34// CDF stuff
35#include "JetCluAlgorithm.hh"
36#include "PhysicsTower.hh"
37#include "Cluster.hh"
38
39FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
40
41using namespace std;
42using namespace cdf;
43
44bool CDFJetCluPlugin::_first_time = true;
45
46string CDFJetCluPlugin::description () const {
47 ostringstream desc;
48
49 desc << "CDF JetClu jet algorithm with "
50 << "seed_threshold = " << seed_threshold () << ", "
51 << "cone_radius = " << cone_radius () << ", "
52 << "adjacency_cut = " << adjacency_cut () << ", "
53 << "max_iterations = " << max_iterations () << ", "
54 << "iratch = " << iratch () << ", "
55 << "overlap_threshold = " << overlap_threshold () ;
56
57 return desc.str();
58}
59
60
61void CDFJetCluPlugin::run_clustering(ClusterSequence & clust_seq) const {
62 // print a banner if we run this for the first time
63 _print_banner(clust_seq.fastjet_banner_stream());
64
65 // create the physics towers needed by the CDF code
66 vector<PhysicsTower> towers;
67 towers.reserve(clust_seq.jets().size());
68
69 // create a map to identify jets (actually just the input particles)...
70 //map<double,int> jetmap;
71
72 for (unsigned i = 0; i < clust_seq.jets().size(); i++) {
73 PseudoJet particle(clust_seq.jets()[i]);
74 //_insert_unique(particle, jetmap);
75 LorentzVector fourvect(particle.px(), particle.py(),
76 particle.pz(), particle.E());
77 PhysicsTower tower(fourvect);
78 // add tracking information for later
79 tower.fjindex = i;
80 towers.push_back(tower);
81 }
82
83 // prepare the CDF algorithm
84 JetCluAlgorithm j(seed_threshold(), cone_radius(), adjacency_cut(),
85 max_iterations(), iratch(), overlap_threshold());
86
87 // run the CDF algorithm
88 std::vector<Cluster> jets;
89 j.run(towers,jets);
90
91
92 // now transfer the jets back into our own structure -- we will
93 // mimic the cone code with a sequential recombination sequence in
94 // which the jets are built up by adding one particle at a time
95
96 // NB: with g++-4.0, the reverse iterator code gave problems, so switch
97 // to indices instead
98 //for(vector<Cluster>::const_reverse_iterator jetIter = jets.rbegin();
99 // jetIter != jets.rend(); jetIter++) {
100 // const vector<PhysicsTower> & tower_list = jetIter->towerList;
101 // int jet_k = jetmap[tower_list[0].fourVector.E];
102 //
103 // int ntow = int(jetIter->towerList.size());
104
105 for(int iCDFjets = jets.size()-1; iCDFjets >= 0; iCDFjets--) {
106
107 const vector<PhysicsTower> & tower_list = jets[iCDFjets].towerList;
108 int ntow = int(tower_list.size());
109
110 // 2008-09-04: sort the towerList (according to fjindex) so as
111 // to have a consistent order for particles in jet
112 // (necessary because addition of ultra-soft particles
113 // sometimes often modifies the order, while maintaining
114 // the same overall set)
115 vector<int> jc_indices(ntow);
116 vector<double> fj_indices(ntow); // use double: benefit from existing routine
117 for (int itow = 0; itow < ntow; itow++) {
118 jc_indices[itow] = itow;
119 fj_indices[itow] = tower_list[itow].fjindex;
120 }
121 sort_indices(jc_indices, fj_indices);
122
123 int jet_k = tower_list[jc_indices[0]].fjindex;
124
125 for (int itow = 1; itow < ntow; itow++) {
126 if (tower_list[jc_indices[itow]].Et() > 1e-50) {
127 }
128 int jet_i = jet_k;
129 // retrieve our index for the jet
130 int jet_j;
131 jet_j = tower_list[jc_indices[itow]].fjindex;
132
133 // safety check
134 assert (jet_j >= 0 && jet_j < int(towers.size()));
135
136 // do a fake recombination step with dij=0
137 double dij = 0.0;
138
139 // JetClu does E-scheme recombination so we can stick with the
140 // simple option
141 clust_seq.plugin_record_ij_recombination(jet_i, jet_j, dij, jet_k);
142
143 }
144
145 // NB: put a sensible looking d_iB just to be nice...
146 double d_iB = clust_seq.jets()[jet_k].perp2();
147 clust_seq.plugin_record_iB_recombination(jet_k, d_iB);
148 }
149
150
151 // following code is for testing only
152 //cout << endl;
153 //for(vector<Cluster>::const_iterator jetIter = jets.begin();
154 // jetIter != jets.end(); jetIter++) {
155 // cout << jetIter->fourVector.pt() << " " << jetIter->fourVector.y() << endl;
156 //}
157 //cout << "-----------------------------------------------------\n";
158 //vector<PseudoJet> ourjets(clust_seq.inclusive_jets());
159 //for (vector<PseudoJet>::const_iterator ourjet = ourjets.begin();
160 // ourjet != ourjets.end(); ourjet++) {
161 // cout << ourjet->perp() << " " << ourjet->rap() << endl;
162 //}
163 //cout << endl;
164}
165
166
167// print a banner for reference to the 3rd-party code
168void CDFJetCluPlugin::_print_banner(ostream *ostr) const{
169 if (! _first_time) return;
170 _first_time=false;
171
172 // make sure the user has not set the banner stream to NULL
173 if (!ostr) return;
174
175 (*ostr) << "#-------------------------------------------------------------------------" << endl;
176 (*ostr) << "# You are running the CDF JetClu plugin for FastJet " << endl;
177 (*ostr) << "# This is based on an implementation provided by Joey Huston. " << endl;
178 (*ostr) << "# If you use this plugin, please cite " << endl;
179 (*ostr) << "# F. Abe et al. [CDF Collaboration], Phys. Rev. D 45 (1992) 1448. " << endl;
180 (*ostr) << "# in addition to the usual FastJet reference. " << endl;
181 (*ostr) << "#-------------------------------------------------------------------------" << endl;
182
183 // make sure we really have the output done.
184 ostr->flush();
185}
186
187FASTJET_END_NAMESPACE // defined in fastjet/internal/base.hh
Note: See TracBrowser for help on using the repository browser.