Fork me on GitHub

source: svn/trunk/Utilities/Fastjet/plugins/CDFCones/CDFJetCluPlugin.cc@ 77

Last change on this file since 77 was 11, checked in by severine ovyn, 16 years ago

Fastjet added; CDFCones directory has been changed

File size: 6.4 KB
Line 
1//STARTHEADER
2// $Id: CDFJetCluPlugin.cc,v 1.1 2008-11-06 14:32:10 ovyn Exp $
3//
4// Copyright (c) 2005-2006, Matteo Cacciari and Gavin Salam
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 "CDFJetCluPlugin.hh"
32#include "Utilities/Fastjet/include/fastjet/ClusterSequence.hh"
33#include <sstream>
34#include <cassert>
35
36// CDF stuff
37#include "interface/JetCluAlgorithm.hh"
38#include "interface/PhysicsTower.hh"
39#include "interface/Cluster.hh"
40
41FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
42
43using namespace std;
44
45string CDFJetCluPlugin::description () const {
46 ostringstream desc;
47
48 desc << "CDF JetClu jet algorithm with "
49 << "seed_threshold = " << seed_threshold () << ", "
50 << "cone_radius = " << cone_radius () << ", "
51 << "adjacency_cut = " << adjacency_cut () << ", "
52 << "max_iterations = " << max_iterations () << ", "
53 << "iratch = " << iratch () << ", "
54 << "overlap_threshold = " << overlap_threshold () ;
55
56 return desc.str();
57}
58
59
60void CDFJetCluPlugin::run_clustering(ClusterSequence & clust_seq) const {
61
62 // create the physics towers needed by the CDF code
63 vector<PhysicsTower> towers;
64 towers.reserve(clust_seq.jets().size());
65
66 // create a map to identify jets (actually just the input particles)...
67 //map<double,int> jetmap;
68
69 for (unsigned i = 0; i < clust_seq.jets().size(); i++) {
70 PseudoJet particle(clust_seq.jets()[i]);
71 //_insert_unique(particle, jetmap);
72 LorentzVector fourvect(particle.px(), particle.py(),
73 particle.pz(), particle.E());
74 PhysicsTower tower(fourvect);
75 // add tracking information for later
76 tower.fjindex = i;
77 towers.push_back(tower);
78 }
79
80 // prepare the CDF algorithm
81 JetCluAlgorithm j(seed_threshold(), cone_radius(), adjacency_cut(),
82 max_iterations(), iratch(), overlap_threshold());
83
84 // run the CDF algorithm
85 std::vector<Cluster> jets;
86 j.run(towers,jets);
87
88
89 // now transfer the jets back into our own structure -- we will
90 // mimic the cone code with a sequential recombination sequence in
91 // which the jets are built up by adding one particle at a time
92
93 // NB: with g++-4.0, the reverse iterator code gave problems, so switch
94 // to indices instead
95 //for(vector<Cluster>::const_reverse_iterator jetIter = jets.rbegin();
96 // jetIter != jets.rend(); jetIter++) {
97 // const vector<PhysicsTower> & tower_list = jetIter->towerList;
98 // int jet_k = jetmap[tower_list[0].fourVector.E];
99 //
100 // int ntow = int(jetIter->towerList.size());
101
102 for(int iCDFjets = jets.size()-1; iCDFjets >= 0; iCDFjets--) {
103 const vector<PhysicsTower> & tower_list = jets[iCDFjets].towerList;
104 //int jet_k = jetmap[tower_list[0].fourVector.E];
105 int jet_k = tower_list[0].fjindex;
106
107 int ntow = int(tower_list.size());
108 for (int itow = 1; itow < ntow; itow++) {
109 int jet_i = jet_k;
110 // retrieve our misappropriated index for the jet
111 int jet_j;
112 jet_j = tower_list[itow].fjindex;
113 //int alt_jet_j = jetmap[tower_list[itow].fourVector.E];
114 //assert(jet_j == alt_jet_j);
115 //cout << jet_j << endl;
116 // safety check
117 assert (jet_j >= 0 && jet_j < int(towers.size()));
118 // do a fake recombination step with dij=0
119 double dij = 0.0;
120 // JetClu does E-scheme recombination so we can stick with the
121 // simple option
122 clust_seq.plugin_record_ij_recombination(jet_i, jet_j, dij, jet_k);
123 //if (itow != ntow) {
124 // clust_seq.plugin_record_ij_recombination(jet_i, jet_j, dij, jet_k);
125 //} else {
126 // clust_seq.plugin_record_ij_recombination(jet_i, jet_j, dij,
127 // PseudoJet(jetIter->fourVector.px,jetIter->fourVector.py,
128 // jetIter->fourVector.pz,jetIter->fourVector.E),
129 // jet_k);
130 //}
131 }
132
133 // NB: put a sensible looking d_iB just to be nice...
134 double d_iB = clust_seq.jets()[jet_k].perp2();
135 clust_seq.plugin_record_iB_recombination(jet_k, d_iB);
136 }
137
138
139 // following code is for testing only
140 //cout << endl;
141 //for(vector<Cluster>::const_iterator jetIter = jets.begin();
142 // jetIter != jets.end(); jetIter++) {
143 // cout << jetIter->fourVector.pt() << " " << jetIter->fourVector.y() << endl;
144 //}
145 //cout << "-----------------------------------------------------\n";
146 //vector<PseudoJet> ourjets(clust_seq.inclusive_jets());
147 //for (vector<PseudoJet>::const_iterator ourjet = ourjets.begin();
148 // ourjet != ourjets.end(); ourjet++) {
149 // cout << ourjet->perp() << " " << ourjet->rap() << endl;
150 //}
151 //cout << endl;
152}
153
154
155//// following code should now be obsolete since addition of
156//// index to the physics tower in the CDF code
157// void CDFJetCluPlugin::_insert_unique(PseudoJet & jet,
158// map<double,int> & jetmap) const {
159// while (jetmap.find(jet.E()) != jetmap.end()) {
160// // deal with cases where something else has the same energy, and
161// // also with situation where that energy is zero.
162// if (jet.E() != 0.0) {
163// jet *= 1.0+1e-12;
164// } else {
165// jet += PseudoJet(0.0,0.0,0.0,1e-300);
166// }
167// }
168// jetmap[jet.E()] = jet.cluster_hist_index();
169// }
170
171
172FASTJET_END_NAMESPACE // defined in fastjet/internal/base.hh
Note: See TracBrowser for help on using the repository browser.