1 #ifndef __FASTJET_NNFJN2PLAIN_HH__ 2 #define __FASTJET_NNFJN2PLAIN_HH__ 34 #include <fastjet/NNBase.hh> 36 FASTJET_BEGIN_NAMESPACE
106 virtual void start(
const std::vector<PseudoJet> & jets);
110 double dij_min(
int & iA,
int & iB);
113 void remove_jet(
int iA);
117 void merge_jets(
int iA,
int iB,
const PseudoJet & jet,
int jet_index);
129 inline double compute_diJ(
const NNBJ *
const jet)
const {
130 double mom_fact = jet->momentum_factor();
131 if (jet->NN != NULL) {
132 double other_mom_fact = jet->NN->momentum_factor();
133 if (other_mom_fact < mom_fact) {mom_fact = other_mom_fact;}
135 return jet->NN_dist * mom_fact;
141 void set_NN_crosscheck(NNBJ * jet, NNBJ * begin, NNBJ * end);
145 void set_NN_nocross (NNBJ * jet, NNBJ * begin, NNBJ * end);
157 std::vector<NNBJ *> where_is;
164 class NNBJ :
public BJ {
166 void init(
const PseudoJet & jet,
int index_in) {
168 other_init(index_in);
170 void init(
const PseudoJet & jet,
int index_in, I * info) {
172 other_init(index_in);
174 void other_init(
int index_in) {
176 NN_dist = BJ::geometrical_beam_distance();
179 int index()
const {
return _index;}
195 briefjets =
new NNBJ[n];
196 where_is.resize(2*n);
198 NNBJ * jetA = briefjets;
201 for (
int i = 0; i< n; i++) {
204 this->init_jet(jetA, jets[i], i);
213 for (jetA = head + 1; jetA != tail; jetA++) {
217 set_NN_crosscheck(jetA, head, jetA);
224 for (
int i = 0; i < n; i++) {
225 diJ[i] = compute_diJ(jetA);
234 double diJ_min = diJ[0];
236 for (
int i = 1; i < n; i++) {
237 if (diJ[i] < diJ_min) {
244 NNBJ * jetA = & briefjets[diJ_min_jet];
247 iB = jetA->NN ? jetA->NN->index() : -1;
255 NNBJ * jetA = where_is[iA];
262 where_is[jetA->index()] = jetA;
263 diJ[jetA - head] = diJ[tail-head];
266 for (NNBJ * jetI = head; jetI != tail; jetI++) {
268 if (jetI->NN == jetA) {
269 set_NN_nocross(jetI, head, tail);
270 diJ[jetI-head] = compute_diJ(jetI);
273 if (jetI->NN == tail) {jetI->NN = jetA;}
282 NNBJ * jetA = where_is[iA];
283 NNBJ * jetB = where_is[iB];
289 if (jetA < jetB) std::swap(jetA,jetB);
292 this->init_jet(jetB, jet, index);
294 if (index >=
int(where_is.size())) where_is.resize(2*index);
295 where_is[jetB->index()] = jetB;
303 where_is[jetA->index()] = jetA;
304 diJ[jetA - head] = diJ[tail-head];
307 for (NNBJ * jetI = head; jetI != tail; jetI++) {
309 if (jetI->NN == jetA || jetI->NN == jetB) {
310 set_NN_nocross(jetI, head, tail);
311 diJ[jetI-head] = compute_diJ(jetI);
316 double dist = jetI->geometrical_distance(jetB);
317 if (dist < jetI->NN_dist) {
319 jetI->NN_dist = dist;
321 diJ[jetI-head] = compute_diJ(jetI);
324 if (dist < jetB->NN_dist) {
326 jetB->NN_dist = dist;
332 if (jetI->NN == tail) {jetI->NN = jetA;}
336 diJ[jetB-head] = compute_diJ(jetB);
343 NNBJ * begin, NNBJ * end) {
344 double NN_dist = jet->geometrical_beam_distance();
346 for (NNBJ * jetB = begin; jetB != end; jetB++) {
347 double dist = jet->geometrical_distance(jetB);
348 if (dist < NN_dist) {
352 if (dist < jetB->NN_dist) {
353 jetB->NN_dist = dist;
358 jet->NN_dist = NN_dist;
366 NNBJ * jet, NNBJ * begin, NNBJ * end) {
367 double NN_dist = jet->geometrical_beam_distance();
372 for (NNBJ * jetB = begin; jetB != jet; jetB++) {
373 double dist = jet->geometrical_distance(jetB);
374 if (dist < NN_dist) {
383 for (NNBJ * jetB = jet+1; jetB != end; jetB++) {
384 double dist = jet->geometrical_distance(jetB);
385 if (dist < NN_dist) {
392 jet->NN_dist = NN_dist;
398 FASTJET_END_NAMESPACE
401 #endif // __FASTJET_NNFJN2PLAIN_HH__ ~NNFJN2Plain()
a destructor
Helps solve closest pair problems with generic interparticle and particle-beam distances.
NNFJN2Plain(const std::vector< PseudoJet > &jets)
constructor with an initial set of jets (which will be assigned indices 0...jets.size()-1) ...
Class to contain pseudojets, including minimal information of use to jet-clustering routines...
Helps solve closest pair problems with factorised interparticle and beam distances (ie satisfying the...