Fork me on GitHub

source: git/external/fastjet/contribs/Nsubjettiness/NjettinessPlugin.cc@ 83582c8

ImprovedOutputFile Timing dual_readout llp 3.4.1pre02
Last change on this file since 83582c8 was 973b92a, checked in by Pavel Demin <pavel.demin@…>, 9 years ago

update FastJet library to 3.1.3 and Nsubjettiness library to 2.2.1

  • Property mode set to 100644
File size: 3.6 KB
Line 
1// Nsubjettiness Package
2// Questions/Comments? jthaler@jthaler.net
3//
4// Copyright (c) 2011-14
5// Jesse Thaler, Ken Van Tilburg, Christopher K. Vermilion, and TJ Wilkason
6//
7// $Id: NjettinessPlugin.cc 821 2015-06-15 18:50:53Z jthaler $
8//----------------------------------------------------------------------
9// This file is part of FastJet contrib.
10//
11// It is free software; you can redistribute it and/or modify it under
12// the terms of the GNU General Public License as published by the
13// Free Software Foundation; either version 2 of the License, or (at
14// your option) any later version.
15//
16// It is distributed in the hope that it will be useful, but WITHOUT
17// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
19// License for more details.
20//
21// You should have received a copy of the GNU General Public License
22// along with this code. If not, see <http://www.gnu.org/licenses/>.
23//----------------------------------------------------------------------
24
25#include "NjettinessPlugin.hh"
26
27FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
28
29namespace contrib{
30
31LimitedWarning NjettinessPlugin::_old_constructor_warning;
32
33std::string NjettinessPlugin::description() const {return "N-jettiness jet finder";}
34
35
36// Clusters the particles according to the Njettiness jet algorithm
37// Apologies for the complication with this code, but we need to make
38// a fake jet clustering tree. The partitioning is done by getPartitionList
39void NjettinessPlugin::run_clustering(ClusterSequence& cs) const
40{
41 std::vector<fastjet::PseudoJet> particles = cs.jets();
42
43 // HACK: remove area information from particles (in case this is called by
44 // a ClusterSequenceArea. Will be fixed in a future FastJet release)
45 for (unsigned i = 0; i < particles.size(); i++) {
46 particles[i].set_structure_shared_ptr(SharedPtr<PseudoJetStructureBase>());
47 }
48
49
50 TauComponents tau_components = _njettinessFinder.getTauComponents(_N, particles);
51 TauPartition tau_partition = _njettinessFinder.currentPartition();
52 std::vector<std::list<int> > partition = tau_partition.jets_list();
53
54 std::vector<int> jet_indices_for_extras;
55
56 // output clusterings for each jet
57 for (size_t i0 = 0; i0 < partition.size(); ++i0) {
58 size_t i = partition.size() - 1 - i0; // reversed order of reading to match axes order
59 std::list<int>& indices = partition[i];
60 if (indices.size() == 0) continue;
61 while (indices.size() > 1) {
62 int merge_i = indices.back(); indices.pop_back();
63 int merge_j = indices.back(); indices.pop_back();
64 int newIndex;
65 double fakeDij = -1.0;
66
67 cs.plugin_record_ij_recombination(merge_i, merge_j, fakeDij, newIndex);
68
69 indices.push_back(newIndex);
70 }
71 double fakeDib = -1.0;
72
73 int finalJet = indices.back();
74 cs.plugin_record_iB_recombination(finalJet, fakeDib);
75 jet_indices_for_extras.push_back(cs.jets()[finalJet].cluster_hist_index()); // Get the four vector for the final jets to compare later.
76 }
77
78 //HACK: Re-reverse order of reading to match CS order
79 reverse(jet_indices_for_extras.begin(),jet_indices_for_extras.end());
80
81 // Store extra information about jets
82 NjettinessExtras * extras = new NjettinessExtras(tau_components,jet_indices_for_extras);
83
84#if FASTJET_VERSION_NUMBER>=30100
85 cs.plugin_associate_extras(extras);
86#else
87 // auto_ptr no longer supported, apparently
88 cs.plugin_associate_extras(std::auto_ptr<ClusterSequence::Extras>(extras));
89#endif
90
91}
92
93
94} // namespace contrib
95
96FASTJET_END_NAMESPACE
Note: See TracBrowser for help on using the repository browser.