32 #include "fastjet/Error.hh"
33 #include "fastjet/PseudoJet.hh"
34 #include "fastjet/ClusterSequence.hh"
35 #include "fastjet/internal/DynamicNearestNeighbours.hh"
43 #ifndef DROP_CGAL // in case we do not have the code for CGAL
44 #include "fastjet/internal/Dnn4piCylinder.hh"
45 #include "fastjet/internal/Dnn3piCylinder.hh"
46 #include "fastjet/internal/Dnn2piCylinder.hh"
49 FASTJET_BEGIN_NAMESPACE
60 void ClusterSequence::_delaunay_cluster () {
64 vector<EtaPhi> points(n);
65 for (
int i = 0; i < n; i++) {
66 points[i] = EtaPhi(_jets[i].rap(),_jets[i].phi_02pi());
71 auto_ptr<DynamicNearestNeighbours> DNN;
72 #ifndef DROP_CGAL // strategy = NlnN* are not supported if we drop CGAL...
74 bool ignore_nearest_is_mirror = (_Rparam < twopi);
75 if (_strategy == NlnN4pi) {
76 DNN.reset(
new Dnn4piCylinder(points,verbose));
77 }
else if (_strategy == NlnN3pi) {
78 DNN.reset(
new Dnn3piCylinder(points,ignore_nearest_is_mirror,verbose));
79 }
else if (_strategy == NlnN) {
80 DNN.reset(
new Dnn2piCylinder(points,ignore_nearest_is_mirror,verbose));
83 if (_strategy == NlnN4pi || _strategy == NlnN3pi || _strategy == NlnN) {
85 err <<
"ERROR: Requested strategy "<<strategy_string()<<
" but it is not"<<endl;
86 err <<
" supported because FastJet was compiled without CGAL"<<endl;
87 throw Error(err.str());
108 for (
int ii = 0; ii < n; ii++) {
109 _add_ktdistance_to_map(ii, DijMap, DNN.get());
115 for (
int i=0;i<n;i++) {
118 TwoVertices SmallestDijPair;
122 bool recombine_with_beam;
124 SmallestDij = DijMap.begin()->first;
125 SmallestDijPair = DijMap.begin()->second;
126 jet_i = SmallestDijPair.first;
127 jet_j = SmallestDijPair.second;
133 DijMap.erase(DijMap.begin());
138 recombine_with_beam = (jet_j == BeamJet);
139 if (!recombine_with_beam) {Valid2 = DNN->Valid(jet_j);}
140 else {Valid2 =
true;}
142 }
while ( !DNN->Valid(jet_i) || !Valid2);
148 if (! recombine_with_beam) {
150 _do_ij_recombination_step(jet_i, jet_j, SmallestDij, nn);
166 EtaPhi newpoint(_jets[nn].rap(), _jets[nn].phi_02pi());
168 points.push_back(newpoint);
171 _do_iB_recombination_step(jet_i, SmallestDij);
178 if (i == n-1) {
break;}
180 vector<int> updated_neighbours;
181 if (! recombine_with_beam) {
184 DNN->RemoveCombinedAddCombination(jet_i, jet_j,
185 points[points.size()-1], point3,
190 if (static_cast<unsigned int> (point3) != points.size()-1) {
191 throw Error(
"INTERNAL ERROR: point3 != points.size()-1");}
194 DNN->RemovePoint(jet_i, updated_neighbours);
198 vector<int>::iterator it = updated_neighbours.begin();
199 for (; it != updated_neighbours.end(); ++it) {
201 _add_ktdistance_to_map(ii, DijMap, DNN.get());
224 void ClusterSequence::_add_ktdistance_to_map(
227 const DynamicNearestNeighbours * DNN) {
229 double yiB = jet_scale_for_algorithm(_jets[ii]);
233 DijMap.insert(DijEntry(yiB, TwoVertices(ii,-1)));
235 double DeltaR2 = DNN->NearestNeighbourDistance(ii) * _invR2;
246 DijMap.insert(DijEntry(yiB, TwoVertices(ii,-1)));
248 double kt2i = jet_scale_for_algorithm(_jets[ii]);
249 int jj = DNN->NearestNeighbourIndex(ii);
250 if (kt2i <= jet_scale_for_algorithm(_jets[jj])) {
251 double dij = DeltaR2 * kt2i;
252 DijMap.insert(DijEntry(dij, TwoVertices(ii,jj)));
259 FASTJET_END_NAMESPACE