77 #define __FJCORE__ // remove all the non-core code (a safekeeper)
78 #define __FJCORE_DROP_CGAL // disable CGAL support
79 #ifndef __FJCORE_FASTJET_BASE_HH__
80 #define __FJCORE_FASTJET_BASE_HH__
81 #define FJCORE_BEGIN_NAMESPACE namespace fjcore {
82 #define FJCORE_END_NAMESPACE }
83 #endif // __FJCORE_FASTJET_BASE_HH__
84 #ifndef __FJCORE_NUMCONSTS__
85 #define __FJCORE_NUMCONSTS__
86 FJCORE_BEGIN_NAMESPACE
87 const double pi = 3.141592653589793238462643383279502884197;
88 const double twopi = 6.283185307179586476925286766559005768394;
89 const double pisq = 9.869604401089358618834490999876151135314;
90 const double zeta2 = 1.644934066848226436472415166646025189219;
91 const double zeta3 = 1.202056903159594285399738161511449990765;
92 const double eulergamma = 0.577215664901532860606512090082402431042;
93 const double ln2 = 0.693147180559945309417232121458176568076;
95 #endif // __FJCORE_NUMCONSTS__
96 #ifndef __FJCORE_INTERNAL_IS_BASE_HH__
97 #define __FJCORE_INTERNAL_IS_BASE_HH__
98 FJCORE_BEGIN_NAMESPACE
99 template<
typename T, T _t>
105 template<
typename T, T _t>
109 typedef char (&__yes_type)[1];
110 typedef char (&__no_type) [2];
111 template<
typename B,
typename D>
113 #if !((_MSC_VER !=0 ) && (_MSC_VER == 1310)) // MSVC 7.1
114 template <
typename T>
115 static __yes_type check_sig(D
const volatile *, T);
117 static __yes_type check_sig(D
const volatile *,
long);
119 static __no_type check_sig(B
const volatile *,
int);
121 template<
typename B,
typename D>
123 #if ((_MSC_FULL_VER != 0) && (_MSC_FULL_VER >= 140050000))
124 #pragma warning(push)
125 #pragma warning(disable:6334)
128 #if !((_MSC_VER !=0 ) && (_MSC_VER == 1310))
129 operator B
const volatile *()
const;
131 operator B
const volatile *
const&()
const;
133 operator D
const volatile *();
135 static const bool value = ((
sizeof(B)!=0) &&
138 #if ((_MSC_FULL_VER != 0) && (_MSC_FULL_VER >= 140050000))
142 template<
class B,
class D>
143 B* cast_if_derived(D* d){
147 #endif // __IS_BASE_OF_HH__
148 #ifndef _INCLUDE_FJCORE_CONFIG_AUTO_H
149 #define _INCLUDE_FJCORE_CONFIG_AUTO_H 1
150 #ifndef FJCORE_HAVE_DLFCN_H
151 #define FJCORE_HAVE_DLFCN_H 1
153 #ifndef FJCORE_HAVE_EXECINFO_H
154 #define FJCORE_HAVE_EXECINFO_H 1
156 #ifndef FJCORE_HAVE_INTTYPES_H
157 #define FJCORE_HAVE_INTTYPES_H 1
159 #ifndef FJCORE_HAVE_LIBM
160 #define FJCORE_HAVE_LIBM 1
162 #ifndef FJCORE_HAVE_MEMORY_H
163 #define FJCORE_HAVE_MEMORY_H 1
165 #ifndef FJCORE_HAVE_STDINT_H
166 #define FJCORE_HAVE_STDINT_H 1
168 #ifndef FJCORE_HAVE_STDLIB_H
169 #define FJCORE_HAVE_STDLIB_H 1
171 #ifndef FJCORE_HAVE_STRINGS_H
172 #define FJCORE_HAVE_STRINGS_H 1
174 #ifndef FJCORE_HAVE_STRING_H
175 #define FJCORE_HAVE_STRING_H 1
177 #ifndef FJCORE_HAVE_SYS_STAT_H
178 #define FJCORE_HAVE_SYS_STAT_H 1
180 #ifndef FJCORE_HAVE_SYS_TYPES_H
181 #define FJCORE_HAVE_SYS_TYPES_H 1
183 #ifndef FJCORE_HAVE_UNISTD_H
184 #define FJCORE_HAVE_UNISTD_H 1
186 #ifndef FJCORE_LT_OBJDIR
187 #define FJCORE_LT_OBJDIR ".libs/"
189 #ifndef FJCORE_PACKAGE
190 #define FJCORE_PACKAGE "fastjet"
192 #ifndef FJCORE_PACKAGE_BUGREPORT
193 #define FJCORE_PACKAGE_BUGREPORT ""
195 #ifndef FJCORE_PACKAGE_NAME
196 #define FJCORE_PACKAGE_NAME "FastJet"
198 #ifndef FJCORE_PACKAGE_STRING
199 #define FJCORE_PACKAGE_STRING "FastJet 3.0.5"
201 #ifndef FJCORE_PACKAGE_TARNAME
202 #define FJCORE_PACKAGE_TARNAME "fastjet"
204 #ifndef FJCORE_PACKAGE_VERSION
205 #define FJCORE_PACKAGE_VERSION "3.0.5"
207 #ifndef FJCORE_STDC_HEADERS
208 #define FJCORE_STDC_HEADERS 1
210 #ifndef FJCORE_VERSION
211 #define FJCORE_VERSION "3.0.5"
214 #ifndef __FJCORE_CONFIG_H__
215 #define __FJCORE_CONFIG_H__
216 #endif // __FJCORE_CONFIG_H__
217 #ifndef __FJCORE_SHARED_PTR_HH__
218 #define __FJCORE_SHARED_PTR_HH__
220 #ifdef __FJCORE_USETR1SHAREDPTR
221 #include <tr1/memory>
222 #endif // __FJCORE_USETR1SHAREDPTR
223 FJCORE_BEGIN_NAMESPACE
224 #ifdef __FJCORE_USETR1SHAREDPTR
226 class SharedPtr :
public std::tr1::shared_ptr<T> {
228 SharedPtr() : std::tr1::shared_ptr<T>() {}
229 SharedPtr(T * t) : std::tr1::shared_ptr<T>(t) {}
231 inline operator bool()
const {
return (this->
get()!=NULL);}
232 T* operator ()()
const{
236 #else // __FJCORE_USETR1SHAREDPTR
242 template<
class Y>
explicit SharedPtr(Y* ptr){
246 if (_ptr!=NULL) ++(*_ptr);
249 if (_ptr==NULL)
return;
255 template<
class Y>
void reset(Y * ptr){
258 template<
class Y>
void reset(
SharedPtr<Y> const & share){
260 if (_ptr == share._get_container())
return;
263 _ptr = share._get_container();
264 if (_ptr!=NULL) ++(*_ptr);
274 T* operator ()()
const{
275 if (_ptr==NULL)
return NULL;
278 inline T& operator*()
const{
279 return *(_ptr->get());
281 inline T* operator->()
const{
282 if (_ptr==NULL)
return NULL;
285 inline T*
get()
const{
286 if (_ptr==NULL)
return NULL;
289 inline bool unique()
const{
290 return (use_count()==1);
292 inline long use_count()
const{
293 if (_ptr==NULL)
return 0;
294 return _ptr->use_count();
296 inline operator bool()
const{
297 return (
get()!=NULL);
302 _ptr = share_container;
304 void set_count(
const long & count){
305 if (_ptr==NULL)
return;
306 _ptr->set_count(count);
313 if (_ptr!=NULL){
delete _ptr;}
315 inline T*
get()
const {
return _ptr;}
316 inline long use_count()
const {
return _count;}
317 inline long operator++(){
return ++_count;}
318 inline long operator--(){
return --_count;}
319 inline long operator++(
int){
return _count++;}
320 inline long operator--(
int){
return _count--;}
321 void set_count(
const long & count){
332 void _decrease_count(){
334 if (_ptr->use_count()==0)
337 __SharedCountingPtr *_ptr;
339 template<
class T,
class U>
341 return t.get() == u.get();
343 template<
class T,
class U>
345 return t.get() != u.get();
347 template<
class T,
class U>
348 inline bool operator<(SharedPtr<T>
const & t,
SharedPtr<U> const & u){
349 return t.get() < u.get();
359 #endif // __FJCORE_USETR1SHAREDPTR
361 #endif // __FJCORE_SHARED_PTR_HH__
362 #ifndef __FJCORE_ERROR_HH__
363 #define __FJCORE_ERROR_HH__
366 FJCORE_BEGIN_NAMESPACE
370 Error(
const std::string & message);
372 std::string message()
const {
return _message;}
373 static void set_print_errors(
bool print_errors) {_print_errors = print_errors;}
374 static void set_print_backtrace(
bool enabled) {_print_backtrace = enabled;}
375 static void set_default_stream(std::ostream * ostr) {
376 _default_ostr = ostr;
379 std::string _message;
380 static bool _print_errors;
381 static bool _print_backtrace;
382 static std::ostream * _default_ostr;
385 #endif // __FJCORE_ERROR_HH__
386 #ifndef __FJCORE_LIMITEDWARNING_HH__
387 #define __FJCORE_LIMITEDWARNING_HH__
391 FJCORE_BEGIN_NAMESPACE
394 LimitedWarning() : _max_warn(_max_warn_default), _n_warn_so_far(0), _this_warning_summary(0) {}
395 LimitedWarning(
int max_warn) : _max_warn(max_warn), _n_warn_so_far(0), _this_warning_summary(0) {}
396 void warn(
const std::string & warning);
397 void warn(
const std::string & warning, std::ostream * ostr);
398 static void set_default_stream(std::ostream * ostr) {
399 _default_ostr = ostr;
401 static void set_default_max_warn(
int max_warn) {
402 _max_warn_default = max_warn;
404 static std::string summary();
406 int _max_warn, _n_warn_so_far;
407 static int _max_warn_default;
408 static std::ostream * _default_ostr;
409 typedef std::pair<std::string, unsigned int> Summary;
410 static std::list< Summary > _global_warnings_summary;
411 Summary * _this_warning_summary;
414 #endif // __FJCORE_LIMITEDWARNING_HH__
415 #ifndef __FJCORE_PSEUDOJET_STRUCTURE_BASE_HH__
416 #define __FJCORE_PSEUDOJET_STRUCTURE_BASE_HH__
419 FJCORE_BEGIN_NAMESPACE
426 virtual std::string description()
const{
return "PseudoJet with an unknown structure"; }
427 virtual bool has_associated_cluster_sequence()
const {
return false;}
429 virtual bool has_valid_cluster_sequence()
const {
return false;}
435 virtual bool has_constituents()
const {
return false;}
436 virtual std::vector<PseudoJet> constituents(
const PseudoJet &reference)
const;
437 virtual bool has_exclusive_subjets()
const {
return false;}
438 virtual std::vector<PseudoJet> exclusive_subjets(
const PseudoJet &reference,
const double & dcut)
const;
439 virtual int n_exclusive_subjets(
const PseudoJet &reference,
const double & dcut)
const;
440 virtual std::vector<PseudoJet> exclusive_subjets_up_to (
const PseudoJet &reference,
int nsub)
const;
441 virtual double exclusive_subdmerge(
const PseudoJet &reference,
int nsub)
const;
442 virtual double exclusive_subdmerge_max(
const PseudoJet &reference,
int nsub)
const;
443 virtual bool has_pieces(
const PseudoJet & )
const {
445 virtual std::vector<PseudoJet> pieces(
const PseudoJet &
449 #endif // __FJCORE_PSEUDOJET_STRUCTURE_BASE_HH__
450 #ifndef __FJCORE_PSEUDOJET_HH__
451 #define __FJCORE_PSEUDOJET_HH__
457 FJCORE_BEGIN_NAMESPACE
458 const double MaxRap = 1e5;
459 const double pseudojet_invalid_phi = -100.0;
460 const double pseudojet_invalid_rap = -1e200;
463 PseudoJet() : _px(0), _py(0), _pz(0), _E(0) {_finish_init(); _reset_indices();}
464 PseudoJet(
const double px,
const double py,
const double pz,
const double E);
465 template <
class L>
PseudoJet(
const L & some_four_vector);
468 inline double E()
const {
return _E;}
469 inline double e()
const {
return _E;}
470 inline double px()
const {
return _px;}
471 inline double py()
const {
return _py;}
472 inline double pz()
const {
return _pz;}
473 inline double phi()
const {
return phi_02pi();}
474 inline double phi_std()
const {
475 _ensure_valid_rap_phi();
476 return _phi > pi ? _phi-twopi : _phi;}
477 inline double phi_02pi()
const {
478 _ensure_valid_rap_phi();
481 inline double rap()
const {
482 _ensure_valid_rap_phi();
485 inline double rapidity()
const {
return rap();}
486 double pseudorapidity()
const;
487 double eta()
const {
return pseudorapidity();}
488 inline double pt2()
const {
return _kt2;}
489 inline double pt()
const {
return sqrt(_kt2);}
490 inline double perp2()
const {
return _kt2;}
491 inline double perp()
const {
return sqrt(_kt2);}
492 inline double kt2()
const {
return _kt2;}
493 inline double m2()
const {
return (_E+_pz)*(_E-_pz)-_kt2;}
494 inline double m()
const;
495 inline double mperp2()
const {
return (_E+_pz)*(_E-_pz);}
496 inline double mperp()
const {
return sqrt(std::abs(mperp2()));}
497 inline double mt2()
const {
return (_E+_pz)*(_E-_pz);}
498 inline double mt()
const {
return sqrt(std::abs(mperp2()));}
499 inline double modp2()
const {
return _kt2+_pz*_pz;}
500 inline double modp()
const {
return sqrt(_kt2+_pz*_pz);}
501 inline double Et()
const {
return (_kt2==0) ? 0.0 : _E/sqrt(1.0+_pz*_pz/_kt2);}
502 inline double Et2()
const {
return (_kt2==0) ? 0.0 : _E*_E/(1.0+_pz*_pz/_kt2);}
503 double operator () (
int i)
const ;
504 inline double operator [] (
int i)
const {
return (*
this)(i); };
505 double kt_distance(
const PseudoJet & other)
const;
506 double plain_distance(
const PseudoJet & other)
const;
507 inline double squared_distance(
const PseudoJet & other)
const {
508 return plain_distance(other);}
509 inline double delta_R(
const PseudoJet & other)
const {
510 return sqrt(squared_distance(other));
512 double delta_phi_to(
const PseudoJet & other)
const;
513 inline double beam_distance()
const {
return _kt2;}
514 std::valarray<double> four_mom()
const;
515 enum { X=0, Y=1, Z=2, T=3, NUM_COORDINATES=4, SIZE=NUM_COORDINATES };
518 void operator*=(
double);
519 void operator/=(
double);
522 inline void reset(
double px,
double py,
double pz,
double E);
523 inline void reset(
const PseudoJet & psjet) {
526 template <
class L>
inline void reset(
const L & some_four_vector) {
527 const PseudoJet * pj = fjcore::cast_if_derived<const PseudoJet>(&some_four_vector);
531 reset(some_four_vector[0], some_four_vector[1],
532 some_four_vector[2], some_four_vector[3]);
535 inline void reset_PtYPhiM(
double pt_in,
double y_in,
double phi_in,
double m_in=0.0) {
536 reset_momentum_PtYPhiM(pt_in, y_in, phi_in, m_in);
539 inline void reset_momentum(
double px,
double py,
double pz,
double E);
540 inline void reset_momentum(
const PseudoJet & pj);
541 void reset_momentum_PtYPhiM(
double pt,
double y,
double phi,
double m=0.0);
542 template <
class L>
inline void reset_momentum(
const L & some_four_vector) {
543 reset_momentum(some_four_vector[0], some_four_vector[1],
544 some_four_vector[2], some_four_vector[3]);
546 void set_cached_rap_phi(
double rap,
double phi);
547 inline int user_index()
const {
return _user_index;}
548 inline void set_user_index(
const int index) {_user_index = index;}
559 _user_info.reset(user_info_in);
562 const L & user_info()
const{
563 if (_user_info.get() == 0)
throw InexistentUserInfo();
564 return dynamic_cast<const L &
>(* _user_info.get());
566 bool has_user_info()
const{
567 return _user_info.get();
570 bool has_user_info()
const{
571 return _user_info.get() &&
dynamic_cast<const L *
>(_user_info.get());
573 const UserInfoBase * user_info_ptr()
const{
574 if (!_user_info())
return NULL;
575 return _user_info.get();
583 std::string description()
const;
584 bool has_associated_cluster_sequence()
const;
585 bool has_associated_cs()
const {
return has_associated_cluster_sequence();}
586 bool has_valid_cluster_sequence()
const;
587 bool has_valid_cs()
const {
return has_valid_cluster_sequence();}
589 const ClusterSequence* associated_cs()
const {
return associated_cluster_sequence();}
591 return validated_cs();
595 bool has_structure()
const;
600 template<
typename StructureType>
601 const StructureType & structure()
const;
602 template<
typename TransformerType>
603 bool has_structure_of()
const;
604 template<
typename TransformerType>
605 const typename TransformerType::StructureType & structure_of()
const;
606 virtual bool has_partner(
PseudoJet &partner)
const;
607 virtual bool has_child(
PseudoJet &child)
const;
609 virtual bool contains(
const PseudoJet &constituent)
const;
610 virtual bool is_inside(
const PseudoJet &jet)
const;
611 virtual bool has_constituents()
const;
612 virtual std::vector<PseudoJet> constituents()
const;
613 virtual bool has_exclusive_subjets()
const;
614 std::vector<PseudoJet> exclusive_subjets (
const double & dcut)
const;
615 int n_exclusive_subjets(
const double & dcut)
const;
616 std::vector<PseudoJet> exclusive_subjets (
int nsub)
const;
617 std::vector<PseudoJet> exclusive_subjets_up_to (
int nsub)
const;
618 double exclusive_subdmerge(
int nsub)
const;
619 double exclusive_subdmerge_max(
int nsub)
const;
620 virtual bool has_pieces()
const;
621 virtual std::vector<PseudoJet> pieces()
const;
622 inline int cluster_hist_index()
const {
return _cluster_hist_index;}
623 inline void set_cluster_hist_index(
const int index) {_cluster_hist_index = index;}
624 inline int cluster_sequence_history_index()
const {
625 return cluster_hist_index();}
626 inline void set_cluster_sequence_history_index(
const int index) {
627 set_cluster_hist_index(index);}
632 double _px,_py,_pz,_E;
633 mutable double _phi, _rap;
635 int _cluster_hist_index, _user_index;
637 void _reset_indices();
638 inline void _ensure_valid_rap_phi()
const {
639 if (_phi == pseudojet_invalid_phi) _set_rap_phi();
641 void _set_rap_phi()
const;
650 bool operator==(
const PseudoJet & jet,
const double val);
651 inline bool operator!=(
const PseudoJet & a,
const double & val) {
return !(a==val);}
653 return a.E()*b.E() - a.px()*b.px() - a.py()*b.py() - a.pz()*b.pz();
656 PseudoJet PtYPhiM(
double pt,
double y,
double phi,
double m = 0.0);
657 std::vector<PseudoJet> sorted_by_pt(
const std::vector<PseudoJet> & jets);
658 std::vector<PseudoJet> sorted_by_rapidity(
const std::vector<PseudoJet> & jets);
659 std::vector<PseudoJet> sorted_by_E(
const std::vector<PseudoJet> & jets);
660 std::vector<PseudoJet> sorted_by_pz(
const std::vector<PseudoJet> & jets);
661 void sort_indices(std::vector<int> & indices,
662 const std::vector<double> & values);
663 template<
class T> std::vector<T> objects_sorted_by_values(
const std::vector<T> & objects,
664 const std::vector<double> & values);
668 _ref_values = reference_values;
670 inline int operator() (
const int & i1,
const int & i2)
const {
671 return (*_ref_values)[i1] < (*_ref_values)[i2];
674 const std::vector<double> * _ref_values;
676 template <
class L>
inline PseudoJet::PseudoJet(
const L & some_four_vector) {
677 reset(some_four_vector);
679 inline void PseudoJet::_reset_indices() {
680 set_cluster_hist_index(-1);
685 inline double PseudoJet::m()
const {
687 return mm < 0.0 ? -std::sqrt(-mm) : std::sqrt(mm);
689 inline void PseudoJet::reset(
double px_in,
double py_in,
double pz_in,
double E_in) {
697 inline void PseudoJet::reset_momentum(
double px_in,
double py_in,
double pz_in,
double E_in) {
704 inline void PseudoJet::reset_momentum(
const PseudoJet & pj) {
713 template<
typename StructureType>
714 const StructureType & PseudoJet::structure()
const{
715 return dynamic_cast<const StructureType &
>(* validated_structure_ptr());
717 template<
typename TransformerType>
718 bool PseudoJet::has_structure_of()
const{
719 if (!_structure())
return false;
720 return dynamic_cast<const typename TransformerType::StructureType *
>(_structure.get()) != 0;
722 template<
typename TransformerType>
723 const typename TransformerType::StructureType & PseudoJet::structure_of()
const{
725 throw Error(
"Trying to access the structure of a PseudoJet without an associated structure");
726 return dynamic_cast<const typename TransformerType::StructureType &
>(*_structure);
728 PseudoJet join(
const std::vector<PseudoJet> & pieces);
734 #endif // __FJCORE_PSEUDOJET_HH__
735 #ifndef __FJCORE_FUNCTION_OF_PSEUDOJET_HH__
736 #define __FJCORE_FUNCTION_OF_PSEUDOJET_HH__
737 FJCORE_BEGIN_NAMESPACE
738 template<
typename TOut>
744 virtual std::string description()
const{
return "";}
745 virtual TOut result(
const PseudoJet &pj)
const = 0;
746 TOut operator()(
const PseudoJet &pj)
const {
return result(pj);}
747 std::vector<TOut> operator()(
const std::vector<PseudoJet> &pjs)
const {
748 std::vector<TOut> res(pjs.size());
749 for (
unsigned int i=0; i<pjs.size(); i++)
750 res[i] = result(pjs[i]);
755 #endif // __FJCORE_FUNCTION_OF_PSEUDOJET_HH__
756 #ifndef __FJCORE_SELECTOR_HH__
757 #define __FJCORE_SELECTOR_HH__
760 FJCORE_BEGIN_NAMESPACE
765 virtual bool pass(
const PseudoJet & jet)
const = 0;
766 virtual void terminator(std::vector<const PseudoJet *> & jets)
const {
767 for (
unsigned i = 0; i < jets.size(); i++) {
768 if (jets[i] && !pass(*jets[i])) jets[i] = NULL;
771 virtual bool applies_jet_by_jet()
const {
return true;}
772 virtual std::string description()
const {
return "missing description";}
773 virtual bool takes_reference()
const {
return false;}
774 virtual void set_reference(
const PseudoJet & ){
775 throw Error(
"set_reference(...) cannot be used for a selector worker that does not take a reference");
778 throw Error(
"this SelectorWorker has nothing to copy");
780 virtual void get_rapidity_extent(
double & rapmin,
double & rapmax)
const {
781 rapmax = std::numeric_limits<double>::infinity();
784 virtual bool is_geometric()
const {
return false;}
785 virtual bool has_finite_area()
const;
786 virtual bool has_known_area()
const {
return false;}
787 virtual double known_area()
const{
788 throw Error(
"this selector has no computable area");
797 if (!validated_worker()->applies_jet_by_jet()) {
798 throw Error(
"Cannot apply this selector to an individual jet");
800 return _worker->pass(jet);
802 bool operator()(
const PseudoJet & jet)
const {
805 unsigned int count(
const std::vector<PseudoJet> & jets)
const;
806 void sift(
const std::vector<PseudoJet> & jets,
807 std::vector<PseudoJet> & jets_that_pass,
808 std::vector<PseudoJet> & jets_that_fail)
const;
809 bool applies_jet_by_jet()
const {
810 return validated_worker()->applies_jet_by_jet();
812 std::vector<PseudoJet> operator()(
const std::vector<PseudoJet> & jets)
const;
813 virtual void nullify_non_selected(std::vector<const PseudoJet *> & jets)
const {
814 validated_worker()->terminator(jets);
816 void get_rapidity_extent(
double &rapmin,
double &rapmax)
const {
817 return validated_worker()->get_rapidity_extent(rapmin, rapmax);
819 std::string description()
const {
820 return validated_worker()->description();
822 bool is_geometric()
const{
823 return validated_worker()->is_geometric();
825 bool has_finite_area()
const{
826 return validated_worker()->has_finite_area();
834 bool takes_reference()
const {
835 return validated_worker()->takes_reference();
838 if (! validated_worker()->takes_reference()){
841 _copy_worker_if_needed();
842 _worker->set_reference(reference);
851 InvalidArea() :
Error(
"Attempt to obtain area from Selector for which this is not meaningful") {}
856 void _copy_worker_if_needed(){
857 if (_worker.unique())
return;
858 _worker.reset(_worker->copy());
868 Selector SelectorPtMin(
double ptmin);
869 Selector SelectorPtMax(
double ptmax);
870 Selector SelectorPtRange(
double ptmin,
double ptmax);
871 Selector SelectorEtMin(
double Etmin);
872 Selector SelectorEtMax(
double Etmax);
873 Selector SelectorEtRange(
double Etmin,
double Etmax);
876 Selector SelectorERange(
double Emin,
double Emax);
877 Selector SelectorMassMin(
double Mmin);
878 Selector SelectorMassMax(
double Mmax);
879 Selector SelectorMassRange(
double Mmin,
double Mmax);
880 Selector SelectorRapMin(
double rapmin);
881 Selector SelectorRapMax(
double rapmax);
882 Selector SelectorRapRange(
double rapmin,
double rapmax);
883 Selector SelectorAbsRapMin(
double absrapmin);
884 Selector SelectorAbsRapMax(
double absrapmax);
885 Selector SelectorAbsRapRange(
double absrapmin,
double absrapmax);
886 Selector SelectorEtaMin(
double etamin);
887 Selector SelectorEtaMax(
double etamax);
888 Selector SelectorEtaRange(
double etamin,
double etamax);
889 Selector SelectorAbsEtaMin(
double absetamin);
890 Selector SelectorAbsEtaMax(
double absetamax);
891 Selector SelectorAbsEtaRange(
double absetamin,
double absetamax);
892 Selector SelectorPhiRange(
double phimin,
double phimax);
893 Selector SelectorRapPhiRange(
double rapmin,
double rapmax,
double phimin,
double phimax);
894 Selector SelectorNHardest(
unsigned int n);
895 Selector SelectorCircle(
const double & radius);
896 Selector SelectorDoughnut(
const double & radius_in,
const double & radius_out);
897 Selector SelectorStrip(
const double & half_width);
898 Selector SelectorRectangle(
const double & half_rap_width,
const double & half_phi_width);
899 Selector SelectorPtFractionMin(
double fraction);
902 #endif // __FJCORE_SELECTOR_HH__
903 #ifndef __FJCORE_JETDEFINITION_HH__
904 #define __FJCORE_JETDEFINITION_HH__
908 FJCORE_BEGIN_NAMESPACE
909 std::string fastjet_version_string();
923 plugin_strategy = 999
927 cambridge_algorithm=1,
930 cambridge_for_passive_algorithm=11,
931 genkt_for_passive_algorithm=13,
933 ee_genkt_algorithm=53,
934 plugin_algorithm = 99,
935 undefined_jet_algorithm = 999
937 typedef JetAlgorithm JetFinder;
938 const JetAlgorithm aachen_algorithm = cambridge_algorithm;
939 const JetAlgorithm cambridge_aachen_algorithm = cambridge_algorithm;
940 enum RecombinationScheme {
957 RecombinationScheme recomb_scheme_in = E_scheme,
958 Strategy strategy_in = Best) {
959 *
this =
JetDefinition(jet_algorithm_in, R_in, strategy_in, recomb_scheme_in, 1);
962 RecombinationScheme recomb_scheme_in = E_scheme,
963 Strategy strategy_in = Best) {
965 *
this =
JetDefinition(jet_algorithm_in, dummyR, strategy_in, recomb_scheme_in, 0);
969 double xtra_param_in,
970 RecombinationScheme recomb_scheme_in = E_scheme,
971 Strategy strategy_in = Best) {
972 *
this =
JetDefinition(jet_algorithm_in, R_in, strategy_in, recomb_scheme_in, 2);
973 set_extra_param(xtra_param_in);
978 Strategy strategy_in = Best) {
979 *
this =
JetDefinition(jet_algorithm_in, R_in, external_scheme, strategy_in);
980 _recombiner = recombiner_in;
984 Strategy strategy_in = Best) {
985 *
this =
JetDefinition(jet_algorithm_in, external_scheme, strategy_in);
986 _recombiner = recombiner_in;
990 double xtra_param_in,
992 Strategy strategy_in = Best) {
993 *
this =
JetDefinition(jet_algorithm_in, R_in, external_scheme, strategy_in);
994 _recombiner = recombiner_in;
995 set_extra_param(xtra_param_in);
1001 _plugin = plugin_in;
1002 _strategy = plugin_strategy;
1003 _Rparam = _plugin->R();
1004 _jet_algorithm = plugin_algorithm;
1005 set_recombination_scheme(E_scheme);
1009 Strategy strategy_in,
1010 RecombinationScheme recomb_scheme_in = E_scheme,
1011 int nparameters_in = 1);
1012 static const double max_allowable_R;
1013 void set_recombination_scheme(RecombinationScheme);
1014 void set_recombiner(
const Recombiner * recomb) {
1015 if (_recombiner_shared()) _recombiner_shared.reset(recomb);
1016 _recombiner = recomb;
1019 void delete_recombiner_when_unused();
1020 const Plugin * plugin()
const {
return _plugin;};
1021 void delete_plugin_when_unused();
1022 JetAlgorithm jet_algorithm ()
const {
return _jet_algorithm ;}
1023 JetAlgorithm jet_finder ()
const {
return _jet_algorithm ;}
1024 double R ()
const {
return _Rparam ;}
1025 double extra_param ()
const {
return _extra_param ;}
1026 Strategy strategy ()
const {
return _strategy ;}
1027 RecombinationScheme recombination_scheme()
const {
1028 return _default_recombiner.scheme();}
1029 void set_jet_algorithm(JetAlgorithm njf) {_jet_algorithm = njf;}
1030 void set_jet_finder(JetAlgorithm njf) {_jet_algorithm = njf;}
1031 void set_extra_param(
double xtra_param) {_extra_param = xtra_param;}
1033 return _recombiner == 0 ? & _default_recombiner : _recombiner;}
1034 bool has_same_recombiner(
const JetDefinition &other_jd)
const;
1035 std::string description()
const;
1039 virtual std::string description()
const = 0;
1042 virtual void preprocess(
PseudoJet & )
const {};
1046 recombine(pa,pb,pres);
1053 _recomb_scheme(recomb_scheme) {}
1054 virtual std::string description()
const;
1057 virtual void preprocess(
PseudoJet & p)
const;
1058 RecombinationScheme scheme()
const {
return _recomb_scheme;}
1060 RecombinationScheme _recomb_scheme;
1064 virtual std::string description()
const = 0;
1066 virtual double R()
const = 0;
1067 virtual bool supports_ghosted_passive_areas()
const {
return false;}
1068 virtual void set_ghost_separation_scale(
double scale)
const;
1069 virtual double ghost_separation_scale()
const {
return 0.0;}
1070 virtual bool exclusive_sequence_meaningful()
const {
return false;}
1074 JetAlgorithm _jet_algorithm;
1076 double _extra_param ;
1077 Strategy _strategy ;
1093 FJCORE_END_NAMESPACE
1094 #endif // __FJCORE_JETDEFINITION_HH__
1095 #ifndef __FJCORE_COMPOSITEJET_STRUCTURE_HH__
1096 #define __FJCORE_COMPOSITEJET_STRUCTURE_HH__
1097 FJCORE_BEGIN_NAMESPACE
1106 virtual std::string description()
const;
1107 virtual bool has_constituents()
const;
1108 virtual std::vector<PseudoJet> constituents(
const PseudoJet &jet)
const;
1109 virtual bool has_pieces(
const PseudoJet & )
const {
return true;}
1110 virtual std::vector<PseudoJet> pieces(
const PseudoJet &jet)
const;
1115 template<
typename T>
PseudoJet join(
const std::vector<PseudoJet> & pieces){
1117 for (
unsigned int i=0; i<pieces.size(); i++){
1121 T *cj_struct =
new T(pieces);
1126 return join<T>(std::vector<PseudoJet>(1,j1));
1129 std::vector<PseudoJet> pieces;
1130 pieces.push_back(j1);
1131 pieces.push_back(j2);
1132 return join<T>(pieces);
1136 std::vector<PseudoJet> pieces;
1137 pieces.push_back(j1);
1138 pieces.push_back(j2);
1139 pieces.push_back(j3);
1140 return join<T>(pieces);
1144 std::vector<PseudoJet> pieces;
1145 pieces.push_back(j1);
1146 pieces.push_back(j2);
1147 pieces.push_back(j3);
1148 pieces.push_back(j4);
1149 return join<T>(pieces);
1151 template<
typename T>
PseudoJet join(
const std::vector<PseudoJet> & pieces,
1154 if (pieces.size()>0){
1156 for (
unsigned int i=1; i<pieces.size(); i++){
1157 recombiner.plus_equal(result, pieces[i]);
1160 T *cj_struct =
new T(pieces, &recombiner);
1166 return join<T>(std::vector<PseudoJet>(1,j1), recombiner);
1170 std::vector<PseudoJet> pieces;
1171 pieces.push_back(j1);
1172 pieces.push_back(j2);
1173 return join<T>(pieces, recombiner);
1178 std::vector<PseudoJet> pieces;
1179 pieces.push_back(j1);
1180 pieces.push_back(j2);
1181 pieces.push_back(j3);
1182 return join<T>(pieces, recombiner);
1187 std::vector<PseudoJet> pieces;
1188 pieces.push_back(j1);
1189 pieces.push_back(j2);
1190 pieces.push_back(j3);
1191 pieces.push_back(j4);
1192 return join<T>(pieces, recombiner);
1194 FJCORE_END_NAMESPACE
1195 #endif // __FJCORE_MERGEDJET_STRUCTURE_HH__
1196 #ifndef __FJCORE_CLUSTER_SEQUENCE_STRUCTURE_HH__
1197 #define __FJCORE_CLUSTER_SEQUENCE_STRUCTURE_HH__
1199 FJCORE_BEGIN_NAMESPACE
1204 set_associated_cs(cs);
1207 virtual std::string description()
const{
return "PseudoJet with an associated ClusterSequence"; }
1208 virtual bool has_associated_cluster_sequence()
const{
return true;}
1210 virtual bool has_valid_cluster_sequence()
const;
1213 _associated_cs = new_cs;
1219 virtual bool has_constituents()
const;
1220 virtual std::vector<PseudoJet> constituents(
const PseudoJet &reference)
const;
1221 virtual bool has_exclusive_subjets()
const;
1222 virtual std::vector<PseudoJet> exclusive_subjets(
const PseudoJet &reference,
const double & dcut)
const;
1223 virtual int n_exclusive_subjets(
const PseudoJet &reference,
const double & dcut)
const;
1224 virtual std::vector<PseudoJet> exclusive_subjets_up_to (
const PseudoJet &reference,
int nsub)
const;
1225 virtual double exclusive_subdmerge(
const PseudoJet &reference,
int nsub)
const;
1226 virtual double exclusive_subdmerge_max(
const PseudoJet &reference,
int nsub)
const;
1227 virtual bool has_pieces(
const PseudoJet &reference)
const;
1228 virtual std::vector<PseudoJet> pieces(
const PseudoJet &reference)
const;
1232 FJCORE_END_NAMESPACE
1233 #endif // __FJCORE_CLUSTER_SEQUENCE_STRUCTURE_HH__
1234 #ifndef __FJCORE_CLUSTERSEQUENCE_HH__
1235 #define __FJCORE_CLUSTERSEQUENCE_HH__
1244 FJCORE_BEGIN_NAMESPACE
1251 const std::vector<L> & pseudojets,
1253 const bool & writeout_combinations =
false);
1255 transfer_from_sequence(cs);
1258 std::vector<PseudoJet> inclusive_jets (
const double & ptmin = 0.0)
const;
1259 int n_exclusive_jets (
const double & dcut)
const;
1260 std::vector<PseudoJet> exclusive_jets (
const double & dcut)
const;
1261 std::vector<PseudoJet> exclusive_jets (
const int & njets)
const;
1262 std::vector<PseudoJet> exclusive_jets_up_to (
const int & njets)
const;
1263 double exclusive_dmerge (
const int & njets)
const;
1264 double exclusive_dmerge_max (
const int & njets)
const;
1265 double exclusive_ymerge (
int njets)
const {
return exclusive_dmerge(njets) / Q2();}
1266 double exclusive_ymerge_max (
int njets)
const {
return exclusive_dmerge_max(njets)/Q2();}
1267 int n_exclusive_jets_ycut (
double ycut)
const {
return n_exclusive_jets(ycut*Q2());}
1268 std::vector<PseudoJet> exclusive_jets_ycut (
double ycut)
const {
1269 int njets = n_exclusive_jets_ycut(ycut);
1270 return exclusive_jets(njets);
1272 std::vector<PseudoJet> exclusive_subjets (
const PseudoJet & jet,
1273 const double & dcut)
const;
1274 int n_exclusive_subjets(
const PseudoJet & jet,
1275 const double & dcut)
const;
1276 std::vector<PseudoJet> exclusive_subjets (
const PseudoJet & jet,
1278 std::vector<PseudoJet> exclusive_subjets_up_to (
const PseudoJet & jet,
1280 double exclusive_subdmerge(
const PseudoJet & jet,
int nsub)
const;
1281 double exclusive_subdmerge_max(
const PseudoJet & jet,
int nsub)
const;
1282 double Q()
const {
return _Qtot;}
1283 double Q2()
const {
return _Qtot*_Qtot;}
1290 std::vector<PseudoJet> constituents (
const PseudoJet & jet)
const;
1291 void print_jets_for_root(
const std::vector<PseudoJet> & jets,
1292 std::ostream & ostr = std::cout)
const;
1293 void print_jets_for_root(
const std::vector<PseudoJet> & jets,
1294 const std::string & filename,
1295 const std::string & comment =
"")
const;
1296 void add_constituents (
const PseudoJet & jet,
1297 std::vector<PseudoJet> & subjet_vector)
const;
1298 inline Strategy strategy_used ()
const {
return _strategy;}
1299 std::string strategy_string ()
const {
return strategy_string(_strategy);}
1300 std::string strategy_string (Strategy strategy_in)
const;
1302 void delete_self_when_unused();
1303 bool will_delete_self_when_unused()
const {
return _deletes_self_when_unused;}
1304 void signal_imminent_self_deletion()
const;
1305 double jet_scale_for_algorithm(
const PseudoJet & jet)
const;
1306 void plugin_record_ij_recombination(
int jet_i,
int jet_j,
double dij,
1308 assert(plugin_activated());
1309 _do_ij_recombination_step(jet_i, jet_j, dij, newjet_k);
1311 void plugin_record_ij_recombination(
int jet_i,
int jet_j,
double dij,
1314 void plugin_record_iB_recombination(
int jet_i,
double diB) {
1315 assert(plugin_activated());
1316 _do_iB_recombination_step(jet_i, diB);
1321 virtual std::string description()
const {
return "This is a dummy extras class that contains no extra information! Derive from it if you want to use it to provide extra information from a plugin jet finder";}
1323 inline void plugin_associate_extras(std::auto_ptr<Extras> extras_in) {
1324 _extras.reset(extras_in.release());
1326 inline bool plugin_activated()
const {
return _plugin_activated;}
1327 const Extras * extras()
const {
return _extras.get();}
1328 template<
class GBJ>
void plugin_simple_N2_cluster () {
1329 assert(plugin_activated());
1330 _simple_N2_cluster<GBJ>();
1346 enum JetType {Invalid=-3, InexistentParent = -2, BeamJet = -1};
1347 const std::vector<PseudoJet> & jets()
const;
1348 const std::vector<history_element> & history()
const;
1349 unsigned int n_particles()
const;
1350 std::vector<int> particle_jet_indices(
const std::vector<PseudoJet> &)
const;
1351 std::vector<int> unique_history_order()
const;
1352 std::vector<PseudoJet> unclustered_particles()
const;
1353 std::vector<PseudoJet> childless_pseudojets()
const;
1354 bool contains(
const PseudoJet &
object)
const;
1358 return _structure_shared_ptr;
1361 static void print_banner();
1362 static void set_fastjet_banner_stream(std::ostream * ostr) {_fastjet_banner_ostr = ostr;}
1363 static std::ostream * fastjet_banner_stream() {
return _fastjet_banner_ostr;}
1365 static std::ostream * _fastjet_banner_ostr;
1368 template<
class L>
void _transfer_input_jets(
1369 const std::vector<L> & pseudojets);
1371 const bool & writeout_combinations);
1372 void _initialise_and_run_no_decant();
1374 const bool & writeout_combinations);
1375 void _decant_options_partial();
1376 void _fill_initial_history();
1377 void _do_ij_recombination_step(
const int & jet_i,
const int & jet_j,
1378 const double & dij,
int & newjet_k);
1379 void _do_iB_recombination_step(
const int & jet_i,
const double & diB);
1380 void _set_structure_shared_ptr(
PseudoJet & j);
1381 void _update_structure_use_count();
1382 std::vector<PseudoJet> _jets;
1383 std::vector<history_element> _history;
1384 void get_subhist_set(std::set<const history_element*> & subhist,
1385 const PseudoJet & jet,
double dcut,
int maxjet)
const;
1386 bool _writeout_combinations;
1388 double _Rparam, _R2, _invR2;
1391 JetAlgorithm _jet_algorithm;
1393 int _structure_use_count_after_construction;
1394 mutable bool _deletes_self_when_unused;
1396 bool _plugin_activated;
1398 void _really_dumb_cluster ();
1399 void _delaunay_cluster ();
1400 template<
class BJ>
void _simple_N2_cluster ();
1401 void _tiled_N2_cluster ();
1402 void _faster_tiled_N2_cluster ();
1403 void _minheap_faster_tiled_N2_cluster();
1404 void _CP2DChan_cluster();
1405 void _CP2DChan_cluster_2pi2R ();
1406 void _CP2DChan_cluster_2piMultD ();
1407 void _CP2DChan_limited_cluster(
double D);
1408 void _do_Cambridge_inclusive_jets();
1409 void _fast_NsqrtN_cluster();
1410 void _add_step_to_history(
const int & step_number,
const int & parent1,
1411 const int & parent2,
const int & jetp_index,
1412 const double & dij);
1413 void _extract_tree_children(
int pos, std::valarray<bool> &,
1414 const std::valarray<int> &, std::vector<int> &)
const;
1415 void _extract_tree_parents (
int pos, std::valarray<bool> &,
1416 const std::valarray<int> &, std::vector<int> &)
const;
1417 typedef std::pair<int,int> TwoVertices;
1418 typedef std::pair<double,TwoVertices> DijEntry;
1419 typedef std::multimap<double,TwoVertices> DistMap;
1420 void _add_ktdistance_to_map(
const int & ii,
1423 static bool _first_time;
1424 static int _n_exclusive_warnings;
1427 double eta, phi, kt2, NN_dist;
1433 double eta, phi, kt2, NN_dist;
1435 int _jets_index, tile_index, diJ_posn;
1436 inline void label_minheap_update_needed() {diJ_posn = 1;}
1437 inline void label_minheap_update_done() {diJ_posn = 0;}
1438 inline bool minheap_update_needed()
const {
return diJ_posn==1;}
1440 template <
class J>
void _bj_set_jetinfo( J *
const jet,
1441 const int _jets_index)
const;
1442 void _bj_remove_from_tiles(
TiledJet *
const jet)
const;
1443 template <
class J>
double _bj_dist(
const J *
const jeta,
1444 const J *
const jetb)
const;
1445 template <
class J>
double _bj_diJ(
const J *
const jeta)
const;
1446 template <
class J>
inline J * _bj_of_hindex(
1447 const int hist_index,
1448 J *
const head, J *
const tail)
1451 for(res = head; res<tail; res++) {
1452 if (_jets[res->_jets_index].cluster_hist_index() == hist_index) {
break;}
1456 template <
class J>
void _bj_set_NN_nocross(J *
const jeta,
1457 J *
const head,
const J *
const tail)
const;
1458 template <
class J>
void _bj_set_NN_crosscheck(J *
const jeta,
1459 J *
const head,
const J *
const tail)
const;
1460 static const int n_tile_neighbours = 9;
1462 Tile * begin_tiles[n_tile_neighbours];
1463 Tile ** surrounding_tiles;
1469 std::vector<Tile> _tiles;
1470 double _tiles_eta_min, _tiles_eta_max;
1471 double _tile_size_eta, _tile_size_phi;
1472 int _n_tiles_phi,_tiles_ieta_min,_tiles_ieta_max;
1473 inline int _tile_index (
int ieta,
int iphi)
const {
1474 return (ieta-_tiles_ieta_min)*_n_tiles_phi
1475 + (iphi+_n_tiles_phi) % _n_tiles_phi;
1477 int _tile_index(
const double & eta,
const double & phi)
const;
1478 void _tj_set_jetinfo (
TiledJet *
const jet,
const int _jets_index);
1479 void _bj_remove_from_tiles(
TiledJet *
const jet);
1480 void _initialise_tiles();
1481 void _print_tiles(
TiledJet * briefjets )
const;
1482 void _add_neighbours_to_tile_union(
const int tile_index,
1483 std::vector<int> & tile_union,
int & n_near_tiles)
const;
1484 void _add_untagged_neighbours_to_tile_union(
const int tile_index,
1485 std::vector<int> & tile_union,
int & n_near_tiles);
1493 void _simple_N2_cluster_BriefJet();
1494 void _simple_N2_cluster_EEBriefJet();
1496 template<
class L>
void ClusterSequence::_transfer_input_jets(
1497 const std::vector<L> & pseudojets) {
1498 _jets.reserve(pseudojets.size()*2);
1499 for (
unsigned int i = 0; i < pseudojets.size(); i++) {
1500 _jets.push_back(pseudojets[i]);}
1502 template<
class L> ClusterSequence::ClusterSequence (
1503 const std::vector<L> & pseudojets,
1505 const bool & writeout_combinations) :
1506 _jet_def(jet_def_in), _writeout_combinations(writeout_combinations),
1509 _transfer_input_jets(pseudojets);
1510 _decant_options_partial();
1511 _initialise_and_run_no_decant();
1513 inline const std::vector<PseudoJet> & ClusterSequence::jets ()
const {
1516 inline const std::vector<ClusterSequence::history_element> & ClusterSequence::history ()
const {
1519 inline unsigned int ClusterSequence::n_particles()
const {
return _initial_n;}
1520 template <
class J>
inline void ClusterSequence::_bj_set_jetinfo(
1521 J *
const jetA,
const int _jets_index)
const {
1522 jetA->eta = _jets[_jets_index].rap();
1523 jetA->phi = _jets[_jets_index].phi_02pi();
1524 jetA->kt2 = jet_scale_for_algorithm(_jets[_jets_index]);
1525 jetA->_jets_index = _jets_index;
1526 jetA->NN_dist = _R2;
1529 template <
class J>
inline double ClusterSequence::_bj_dist(
1530 const J *
const jetA,
const J *
const jetB)
const {
1531 double dphi = std::abs(jetA->phi - jetB->phi);
1532 double deta = (jetA->eta - jetB->eta);
1533 if (dphi > pi) {dphi = twopi - dphi;}
1534 return dphi*dphi + deta*deta;
1536 template <
class J>
inline double ClusterSequence::_bj_diJ(
const J *
const jet)
const {
1537 double kt2 = jet->kt2;
1538 if (jet->NN != NULL) {
if (jet->NN->kt2 < kt2) {kt2 = jet->NN->kt2;}}
1539 return jet->NN_dist * kt2;
1541 template <
class J>
inline void ClusterSequence::_bj_set_NN_nocross(
1542 J *
const jet, J *
const head,
const J *
const tail)
const {
1543 double NN_dist = _R2;
1546 for (J * jetB = head; jetB != jet; jetB++) {
1547 double dist = _bj_dist(jet,jetB);
1548 if (dist < NN_dist) {
1555 for (J * jetB = jet+1; jetB != tail; jetB++) {
1556 double dist = _bj_dist(jet,jetB);
1557 if (dist < NN_dist) {
1564 jet->NN_dist = NN_dist;
1566 template <
class J>
inline void ClusterSequence::_bj_set_NN_crosscheck(J *
const jet,
1567 J *
const head,
const J *
const tail)
const {
1568 double NN_dist = _R2;
1570 for (J * jetB = head; jetB != tail; jetB++) {
1571 double dist = _bj_dist(jet,jetB);
1572 if (dist < NN_dist) {
1576 if (dist < jetB->NN_dist) {
1577 jetB->NN_dist = dist;
1582 jet->NN_dist = NN_dist;
1584 FJCORE_END_NAMESPACE
1585 #endif // __FJCORE_CLUSTERSEQUENCE_HH__
1586 #ifndef __FJCORE_NNH_HH__
1587 #define __FJCORE_NNH_HH__
1588 FJCORE_BEGIN_NAMESPACE
1593 NNHInfo(I * info) : _info(info) {}
1594 template<
class NNBJ>
void init_jet(NNBJ * briefjet,
const fjcore::PseudoJet & jet,
int index) { briefjet->init(jet, index, _info);}
1602 template<
class NNBJ>
void init_jet(NNBJ * briefjet,
const fjcore::PseudoJet & jet,
int index) { briefjet->init(jet, index);}
1604 template<
class BJ,
class I = _NoInfo>
class NNH :
public NNHInfo<I> {
1606 NNH(
const std::vector<PseudoJet> & jets) {start(jets);}
1607 NNH(
const std::vector<PseudoJet> & jets, I * info) :
NNHInfo<I>(info) {start(jets);}
1608 void start(
const std::vector<PseudoJet> & jets);
1609 double dij_min(
int & iA,
int & iB);
1610 void remove_jet(
int iA);
1611 void merge_jets(
int iA,
int iB,
const PseudoJet & jet,
int jet_index);
1617 void set_NN_crosscheck(NNBJ * jet, NNBJ * begin, NNBJ * end);
1618 void set_NN_nocross (NNBJ * jet, NNBJ * begin, NNBJ * end);
1620 NNBJ * head, * tail;
1622 std::vector<NNBJ *> where_is;
1623 class NNBJ :
public BJ {
1625 void init(
const PseudoJet & jet,
int index_in) {
1627 other_init(index_in);
1629 void init(
const PseudoJet & jet,
int index_in, I * info) {
1630 BJ::init(jet, info);
1631 other_init(index_in);
1633 void other_init(
int index_in) {
1635 NN_dist = BJ::beam_distance();
1638 int index()
const {
return _index;}
1645 template<
class BJ,
class I>
void NNH<BJ,I>::start(
const std::vector<PseudoJet> & jets) {
1647 briefjets =
new NNBJ[n];
1648 where_is.resize(2*n);
1649 NNBJ * jetA = briefjets;
1650 for (
int i = 0; i< n; i++) {
1651 this->init_jet(jetA, jets[i], i);
1657 for (jetA = head + 1; jetA != tail; jetA++) {
1658 set_NN_crosscheck(jetA, head, jetA);
1662 double diJ_min = briefjets[0].NN_dist;
1663 int diJ_min_jet = 0;
1664 for (
int i = 1; i < n; i++) {
1665 if (briefjets[i].NN_dist < diJ_min) {
1667 diJ_min = briefjets[i].NN_dist;
1670 NNBJ * jetA = & briefjets[diJ_min_jet];
1672 iB = jetA->NN ? jetA->NN->index() : -1;
1676 NNBJ * jetA = where_is[iA];
1679 where_is[jetA->index()] = jetA;
1680 for (NNBJ * jetI = head; jetI != tail; jetI++) {
1681 if (jetI->NN == jetA) set_NN_nocross(jetI, head, tail);
1682 if (jetI->NN == tail) {jetI->NN = jetA;}
1687 NNBJ * jetA = where_is[iA];
1688 NNBJ * jetB = where_is[iB];
1689 if (jetA < jetB) std::swap(jetA,jetB);
1690 this->init_jet(jetB, jet, index);
1691 if (index >=
int(where_is.size())) where_is.resize(2*index);
1692 where_is[jetB->index()] = jetB;
1695 where_is[jetA->index()] = jetA;
1696 for (NNBJ * jetI = head; jetI != tail; jetI++) {
1697 if (jetI->NN == jetA || jetI->NN == jetB) {
1698 set_NN_nocross(jetI, head, tail);
1700 double dist = jetI->distance(jetB);
1701 if (dist < jetI->NN_dist) {
1703 jetI->NN_dist = dist;
1707 if (dist < jetB->NN_dist) {
1709 jetB->NN_dist = dist;
1713 if (jetI->NN == tail) {jetI->NN = jetA;}
1717 NNBJ * begin, NNBJ * end) {
1718 double NN_dist = jet->beam_distance();
1720 for (NNBJ * jetB = begin; jetB != end; jetB++) {
1721 double dist = jet->distance(jetB);
1722 if (dist < NN_dist) {
1726 if (dist < jetB->NN_dist) {
1727 jetB->NN_dist = dist;
1732 jet->NN_dist = NN_dist;
1735 NNBJ * jet, NNBJ * begin, NNBJ * end) {
1736 double NN_dist = jet->beam_distance();
1739 for (NNBJ * jetB = begin; jetB != jet; jetB++) {
1740 double dist = jet->distance(jetB);
1741 if (dist < NN_dist) {
1748 for (NNBJ * jetB = jet+1; jetB != end; jetB++) {
1749 double dist = jet->distance (jetB);
1750 if (dist < NN_dist) {
1757 jet->NN_dist = NN_dist;
1759 FJCORE_END_NAMESPACE
1760 #endif // __FJCORE_NNH_HH__
double dij
index in the _jets vector where we will find the
static const T value
the value (only member carrying info)
int child
index in _history where second parent of this jet
T value_type
a typedef for the type T
std::vector< PseudoJet > _pieces
the pieces building the jet
PseudoJet * _area_4vector_ptr
pointer to the 4-vector jet area
int parent2
index in _history where first parent of this jet
integral_type< T, _t > type
a typedef for the whole structure