Fork me on GitHub

source: svn/trunk/external/fastjet/plugins/CDFCones/CDFMidPointPlugin.cc@ 1288

Last change on this file since 1288 was 859, checked in by Pavel Demin, 12 years ago

update fastjet to version 3.0.3

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision Date
File size: 6.3 KB
Line 
1//STARTHEADER
2// $Id: CDFMidPointPlugin.cc 859 2012-11-28 01:49:23Z pavel $
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/CDFMidPointPlugin.hh"
30#include "fastjet/ClusterSequence.hh"
31#include "fastjet/Error.hh"
32#include <sstream>
33
34// CDF stuff
35#include "MidPointAlgorithm.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 CDFMidPointPlugin::_first_time = true;
45
46string CDFMidPointPlugin::description () const {
47 ostringstream desc;
48
49 string sm_scale_string = "split-merge uses ";
50 switch(_sm_scale) {
51 case SM_pt:
52 sm_scale_string += "pt";
53 break;
54 case SM_Et:
55 sm_scale_string += "Et";
56 break;
57 case SM_mt:
58 sm_scale_string += "mt";
59 break;
60 case SM_pttilde:
61 sm_scale_string += "pttilde (scalar sum of pts)";
62 break;
63 default:
64 ostringstream err;
65 err << "Unrecognized split-merge scale choice = " << _sm_scale;
66 throw Error(err.str());
67 }
68
69
70 if (cone_area_fraction() == 1) {
71 desc << "CDF MidPoint jet algorithm, with " ;
72 } else {
73 desc << "CDF MidPoint+Searchcone jet algorithm, with ";
74 }
75 desc << "seed_threshold = " << seed_threshold () << ", "
76 << "cone_radius = " << cone_radius () << ", "
77 << "cone_area_fraction = " << cone_area_fraction () << ", "
78 << "max_pair_size = " << max_pair_size () << ", "
79 << "max_iterations = " << max_iterations () << ", "
80 << "overlap_threshold = " << overlap_threshold () << ", "
81 << sm_scale_string ;
82
83 return desc.str();
84}
85
86
87void CDFMidPointPlugin::run_clustering(ClusterSequence & clust_seq) const {
88 // print a banner if we run this for the first time
89 _print_banner(clust_seq.fastjet_banner_stream());
90
91 // create the physics towers needed by the CDF code
92 vector<PhysicsTower> towers;
93 towers.reserve(clust_seq.jets().size());
94 for (unsigned i = 0; i < clust_seq.jets().size(); i++) {
95 LorentzVector fourvect(clust_seq.jets()[i].px(),
96 clust_seq.jets()[i].py(),
97 clust_seq.jets()[i].pz(),
98 clust_seq.jets()[i].E());
99 PhysicsTower tower(fourvect);
100 // misuse one of the indices for tracking, since the MidPoint
101 // implementation doesn't seem to make use of these indices
102 tower.calTower.iEta = i;
103 towers.push_back(tower);
104 }
105
106 // prepare the CDF algorithm
107 MidPointAlgorithm m(_seed_threshold,_cone_radius,_cone_area_fraction,
108 _max_pair_size,_max_iterations,_overlap_threshold,
109 MidPointAlgorithm::SplitMergeScale(_sm_scale));
110
111 // run the CDF algorithm
112 std::vector<Cluster> jets;
113 m.run(towers,jets);
114
115
116 // now transfer the jets back into our own structure -- we will
117 // mimic the cone code with a sequential recombination sequence in
118 // which the jets are built up by adding one particle at a time
119 for(vector<Cluster>::const_iterator jetIter = jets.begin();
120 jetIter != jets.end(); jetIter++) {
121 const vector<PhysicsTower> & tower_list = jetIter->towerList;
122 int jet_k = tower_list[0].calTower.iEta;
123
124 int ntow = int(jetIter->towerList.size());
125 for (int itow = 1; itow < ntow; itow++) {
126 int jet_i = jet_k;
127 // retrieve our misappropriated index for the jet
128 int jet_j = tower_list[itow].calTower.iEta;
129 // do a fake recombination step with dij=0
130 double dij = 0.0;
131 clust_seq.plugin_record_ij_recombination(jet_i, jet_j, dij, jet_k);
132 }
133
134 // NB: put a sensible looking d_iB just to be nice...
135 double d_iB = clust_seq.jets()[jet_k].perp2();
136 clust_seq.plugin_record_iB_recombination(jet_k, d_iB);
137 }
138
139
140 // following code is for testing only
141 //cout << endl;
142 //for(vector<Cluster>::const_iterator jetIter = jets.begin();
143 // jetIter != jets.end(); jetIter++) {
144 // cout << jetIter->fourVector.pt() << " " << jetIter->fourVector.y() << endl;
145 //}
146 //cout << "-----------------------------------------------------\n";
147 //vector<PseudoJet> ourjets(clust_seq.inclusive_jets());
148 //for (vector<PseudoJet>::const_reverse_iterator ourjet = ourjets.rbegin();
149 // ourjet != ourjets.rend(); ourjet++) {
150 // cout << ourjet->perp() << " " << ourjet->rap() << endl;
151 //}
152 //cout << endl;
153}
154
155// print a banner for reference to the 3rd-party code
156void CDFMidPointPlugin::_print_banner(ostream *ostr) const{
157 if (! _first_time) return;
158 _first_time=false;
159
160 // make sure the user has not set the banner stream to NULL
161 if (!ostr) return;
162
163 (*ostr) << "#-------------------------------------------------------------------------" << endl;
164 (*ostr) << "# You are running the CDF MidPoint plugin for FastJet " << endl;
165 (*ostr) << "# This is based on an implementation provided by Joey Huston. " << endl;
166 (*ostr) << "# If you use this plugin, please cite " << endl;
167 (*ostr) << "# G. C. Blazey et al., hep-ex/0005012. " << endl;
168 (*ostr) << "# in addition to the usual FastJet reference. " << endl;
169 (*ostr) << "#-------------------------------------------------------------------------" << endl;
170
171 // make sure we really have the output done.
172 ostr->flush();
173}
174
175FASTJET_END_NAMESPACE // defined in fastjet/internal/base.hh
Note: See TracBrowser for help on using the repository browser.