9 #include "RecoJets/JetAlgorithms/interface/FastPrunePlugin.hh"
17 using namespace fastjet;
19 FastPrunePlugin::FastPrunePlugin (
const JetDefinition & find_definition,
20 const JetDefinition & prune_definition,
22 const double & Rcut_factor) :
23 _find_definition(find_definition),
24 _prune_definition(prune_definition),
27 _pruned_recombiner(0),
28 _cut_setter(new DefaultCutSetter(zcut, Rcut_factor))
38 RecombinationScheme scheme = _prune_definition.recombination_scheme();
39 if (scheme == external_scheme)
40 _pruned_recombiner =
new PrunedRecombiner(_prune_definition.recombiner(), zcut, 0.0);
42 _pruned_recombiner =
new PrunedRecombiner(scheme, zcut, 0.0);
45 FastPrunePlugin::FastPrunePlugin (
const JetDefinition & find_definition,
46 const JetDefinition & prune_definition,
47 const JetDefinition::Recombiner* recomb,
49 const double & Rcut_factor) :
50 _find_definition(find_definition),
51 _prune_definition(prune_definition),
54 _pruned_recombiner(new PrunedRecombiner(recomb, zcut, 0.0)),
55 _cut_setter(new DefaultCutSetter(zcut, Rcut_factor))
58 FastPrunePlugin::FastPrunePlugin (
const JetDefinition & find_definition,
59 const JetDefinition & prune_definition,
60 CutSetter*
const cut_setter) :
61 _find_definition(find_definition),
62 _prune_definition(prune_definition),
65 _pruned_recombiner(0),
66 _cut_setter(cut_setter)
69 RecombinationScheme scheme = _prune_definition.recombination_scheme();
70 if (scheme == external_scheme)
71 _pruned_recombiner =
new PrunedRecombiner(_prune_definition.recombiner());
73 _pruned_recombiner =
new PrunedRecombiner(scheme);
76 FastPrunePlugin::FastPrunePlugin (
const JetDefinition & find_definition,
77 const JetDefinition & prune_definition,
78 CutSetter*
const cut_setter,
79 const JetDefinition::Recombiner* recomb) :
80 _find_definition(find_definition),
81 _prune_definition(prune_definition),
84 _pruned_recombiner(new PrunedRecombiner(recomb)),
85 _cut_setter(cut_setter)
91 desc <<
"Pruned jet algorithm \n"
92 <<
"----------------------- \n"
93 <<
"Jet finder: " << _find_definition.description()
94 <<
"\n----------------------- \n"
95 <<
"Prune jets with: " << _prune_definition.description()
96 <<
"\n----------------------- \n"
97 <<
"Pruning parameters: "
98 <<
"zcut = " << _cut_setter->zcut <<
", "
100 if (DefaultCutSetter *
cs = dynamic_cast<DefaultCutSetter*>(_cut_setter))
101 desc <<
cs->Rcut_factor;
105 <<
"----------------------- \n" ;
122 void FastPrunePlugin::run_clustering(ClusterSequence & input_seq)
const {
125 _pruned_subjets.clear();
127 vector<PseudoJet>
inputs = input_seq.jets();
134 for (
unsigned int i = 0;
i < inputs.size();
i++)
135 inputs[
i].set_user_index(
i+1);
138 if(_unpruned_seq)
delete _unpruned_seq;
139 _unpruned_seq =
new ClusterSequence(inputs, _find_definition);
142 vector<PseudoJet> unpruned_jets =
143 sorted_by_pt(_unpruned_seq->inclusive_jets(_minpT));
145 for (
unsigned int i = 0;
i < unpruned_jets.size();
i++) {
146 _cut_setter->SetCuts(unpruned_jets[
i], *_unpruned_seq);
147 _pruned_recombiner->reset(_cut_setter->zcut, _cut_setter->Rcut);
148 _prune_definition.set_recombiner(_pruned_recombiner);
151 vector<PseudoJet> constituents;
152 for (
size_t j = 0;
j < inputs.size(); ++
j)
153 if (_unpruned_seq->object_in_jet(inputs[
j], unpruned_jets[i])) {
154 constituents.push_back(inputs[j]);
156 ClusterSequence pruned_seq(constituents, _prune_definition);
158 vector<int> pruned_PJs = _pruned_recombiner->pruned_pseudojets();
159 _output_mergings(pruned_seq, pruned_PJs, input_seq);
171 void FastPrunePlugin::_output_mergings(ClusterSequence & in_seq,
172 vector<int> & pruned_pseudojets,
173 ClusterSequence & out_seq)
const {
175 vector<PseudoJet> temp_pruned_subjets;
177 vector<PseudoJet>
p = in_seq.jets();
180 sort(pruned_pseudojets.begin(), pruned_pseudojets.end());
183 const vector<ClusterSequence::history_element> &
hist = in_seq.history();
184 vector<ClusterSequence::history_element>::const_iterator
188 while (iter->parent1 == ClusterSequence::InexistentParent)
194 for (; iter != hist.end(); iter++) {
195 int new_jet_index = -1;
196 int jet_index = iter->jetp_index;
197 int parent1 = iter->parent1;
198 int parent2 = iter->parent2;
199 int parent1_index = p[hist[iter->parent1].jetp_index].user_index() - 1;
201 if (parent2 == ClusterSequence::BeamJet) {
202 out_seq.plugin_record_iB_recombination(parent1_index, iter->dij);
204 int parent2_index = p[hist[parent2].jetp_index].user_index() - 1;
208 if (binary_search(pruned_pseudojets.begin(), pruned_pseudojets.end(),
211 p[jet_index].set_user_index(p[hist[parent1].jetp_index].user_index());
212 temp_pruned_subjets.push_back(out_seq.jets()[parent2_index]);
213 }
else if (binary_search(pruned_pseudojets.begin(), pruned_pseudojets.end(),
216 p[jet_index].set_user_index(p[hist[parent2].jetp_index].user_index());
217 temp_pruned_subjets.push_back(out_seq.jets()[parent1_index]);
220 out_seq.plugin_record_ij_recombination(parent1_index, parent2_index,
221 iter->dij, new_jet_index);
222 p[jet_index].set_user_index(new_jet_index + 1);
227 _pruned_subjets.push_back(temp_pruned_subjets);
auto_ptr< ClusterSequence > cs