8 #include "RecoJets/JetAlgorithms/interface/FastPrunePlugin.hh" 18 FastPrunePlugin::FastPrunePlugin(
const JetDefinition& find_definition,
19 const JetDefinition& prune_definition,
21 const double& Rcut_factor)
22 : _find_definition(find_definition),
23 _prune_definition(prune_definition),
25 _unpruned_seq(nullptr),
26 _pruned_recombiner(nullptr),
27 _cut_setter(new DefaultCutSetter(
zcut, Rcut_factor)) {
36 RecombinationScheme
scheme = _prune_definition.recombination_scheme();
37 if (
scheme == external_scheme)
38 _pruned_recombiner =
new PrunedRecombiner(_prune_definition.recombiner(),
zcut, 0.0);
40 _pruned_recombiner =
new PrunedRecombiner(
scheme,
zcut, 0.0);
43 FastPrunePlugin::FastPrunePlugin(
const JetDefinition& find_definition,
44 const JetDefinition& prune_definition,
45 const JetDefinition::Recombiner* recomb,
47 const double& Rcut_factor)
48 : _find_definition(find_definition),
49 _prune_definition(prune_definition),
51 _unpruned_seq(nullptr),
52 _pruned_recombiner(new PrunedRecombiner(recomb,
zcut, 0.0)),
53 _cut_setter(new DefaultCutSetter(
zcut, Rcut_factor)) {}
55 FastPrunePlugin::FastPrunePlugin(
const JetDefinition& find_definition,
56 const JetDefinition& prune_definition,
57 CutSetter*
const cut_setter)
58 : _find_definition(find_definition),
59 _prune_definition(prune_definition),
61 _unpruned_seq(nullptr),
62 _pruned_recombiner(nullptr),
63 _cut_setter(cut_setter) {
65 RecombinationScheme
scheme = _prune_definition.recombination_scheme();
66 if (
scheme == external_scheme)
67 _pruned_recombiner =
new PrunedRecombiner(_prune_definition.recombiner());
69 _pruned_recombiner =
new PrunedRecombiner(
scheme);
72 FastPrunePlugin::FastPrunePlugin(
const JetDefinition& find_definition,
73 const JetDefinition& prune_definition,
74 CutSetter*
const cut_setter,
75 const JetDefinition::Recombiner* recomb)
76 : _find_definition(find_definition),
77 _prune_definition(prune_definition),
79 _unpruned_seq(nullptr),
80 _pruned_recombiner(new PrunedRecombiner(recomb)),
81 _cut_setter(cut_setter) {}
86 desc <<
"Pruned jet algorithm \n" 87 <<
"----------------------- \n" 88 <<
"Jet finder: " << _find_definition.description() <<
"\n----------------------- \n" 89 <<
"Prune jets with: " << _prune_definition.description() <<
"\n----------------------- \n" 90 <<
"Pruning parameters: " 91 <<
"zcut = " << _cut_setter->zcut <<
", " 93 if (DefaultCutSetter*
cs = dynamic_cast<DefaultCutSetter*>(_cut_setter))
98 <<
"----------------------- \n";
115 void FastPrunePlugin::run_clustering(ClusterSequence& input_seq)
const {
117 _pruned_subjets.clear();
119 vector<PseudoJet>
inputs = input_seq.jets();
126 for (
unsigned int i = 0;
i <
inputs.size();
i++)
131 delete _unpruned_seq;
132 _unpruned_seq =
new ClusterSequence(
inputs, _find_definition);
135 vector<PseudoJet> unpruned_jets = sorted_by_pt(_unpruned_seq->inclusive_jets(_minpT));
137 for (
unsigned int i = 0;
i < unpruned_jets.size();
i++) {
138 _cut_setter->SetCuts(unpruned_jets[
i], *_unpruned_seq);
139 _pruned_recombiner->reset(_cut_setter->zcut, _cut_setter->Rcut);
140 _prune_definition.set_recombiner(_pruned_recombiner);
143 vector<PseudoJet> constituents;
144 for (
size_t j = 0;
j <
inputs.size(); ++
j)
145 if (_unpruned_seq->object_in_jet(
inputs[
j], unpruned_jets[
i])) {
146 constituents.push_back(
inputs[
j]);
148 ClusterSequence pruned_seq(constituents, _prune_definition);
150 vector<int> pruned_PJs = _pruned_recombiner->pruned_pseudojets();
151 _output_mergings(pruned_seq, pruned_PJs, input_seq);
162 void FastPrunePlugin::_output_mergings(ClusterSequence& in_seq,
163 vector<int>& pruned_pseudojets,
164 ClusterSequence& out_seq)
const {
166 vector<PseudoJet> temp_pruned_subjets;
168 vector<PseudoJet>
p = in_seq.jets();
171 sort(pruned_pseudojets.begin(), pruned_pseudojets.end());
174 const vector<ClusterSequence::history_element>&
hist = in_seq.history();
175 vector<ClusterSequence::history_element>::const_iterator iter =
hist.begin();
178 while (iter->parent1 == ClusterSequence::InexistentParent)
184 for (; iter !=
hist.end(); iter++) {
185 int new_jet_index = -1;
186 int jet_index = iter->jetp_index;
187 int parent1 = iter->parent1;
188 int parent2 = iter->parent2;
189 int parent1_index =
p[
hist[iter->parent1].jetp_index].user_index() - 1;
191 if (parent2 == ClusterSequence::BeamJet) {
192 out_seq.plugin_record_iB_recombination(parent1_index, iter->dij);
194 int parent2_index =
p[
hist[parent2].jetp_index].user_index() - 1;
198 if (
binary_search(pruned_pseudojets.begin(), pruned_pseudojets.end(), parent2)) {
200 p[jet_index].set_user_index(
p[
hist[parent1].jetp_index].user_index());
201 temp_pruned_subjets.push_back(out_seq.jets()[parent2_index]);
202 }
else if (
binary_search(pruned_pseudojets.begin(), pruned_pseudojets.end(), parent1)) {
204 p[jet_index].set_user_index(
p[
hist[parent2].jetp_index].user_index());
205 temp_pruned_subjets.push_back(out_seq.jets()[parent1_index]);
208 out_seq.plugin_record_ij_recombination(parent1_index, parent2_index, iter->dij, new_jet_index);
209 p[jet_index].set_user_index(new_jet_index + 1);
214 _pruned_subjets.push_back(temp_pruned_subjets);
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE int binary_search(const unsigned int *data, unsigned int search_val, unsigned int ndata)