80 #define __FJCORE__ // remove all the non-core code (a safekeeper)
81 #define __FJCORE_DROP_CGAL // disable CGAL support
82 #ifndef _INCLUDE_FJCORE_CONFIG_AUTO_H
83 #define _INCLUDE_FJCORE_CONFIG_AUTO_H 1
84 #ifndef FJCORE_HAVE_DEMANGLING_SUPPORT
86 #ifndef FJCORE_HAVE_DLFCN_H
87 # define FJCORE_HAVE_DLFCN_H 1
89 #ifndef FJCORE_HAVE_EXECINFO_H
91 #ifndef FJCORE_HAVE_GNUCXX_DEPRECATED
93 #ifndef FJCORE_HAVE_INTTYPES_H
94 # define FJCORE_HAVE_INTTYPES_H 1
96 #ifndef FJCORE_HAVE_LIBM
97 # define FJCORE_HAVE_LIBM 1
99 #ifndef FJCORE_HAVE_MEMORY_H
100 # define FJCORE_HAVE_MEMORY_H 1
102 #ifndef FJCORE_HAVE_STDINT_H
103 # define FJCORE_HAVE_STDINT_H 1
105 #ifndef FJCORE_HAVE_STDLIB_H
106 # define FJCORE_HAVE_STDLIB_H 1
108 #ifndef FJCORE_HAVE_STRINGS_H
109 # define FJCORE_HAVE_STRINGS_H 1
111 #ifndef FJCORE_HAVE_STRING_H
112 # define FJCORE_HAVE_STRING_H 1
114 #ifndef FJCORE_HAVE_SYS_STAT_H
115 # define FJCORE_HAVE_SYS_STAT_H 1
117 #ifndef FJCORE_HAVE_SYS_TYPES_H
118 # define FJCORE_HAVE_SYS_TYPES_H 1
120 #ifndef FJCORE_HAVE_UNISTD_H
121 # define FJCORE_HAVE_UNISTD_H 1
123 #ifndef FJCORE_LT_OBJDIR
124 # define FJCORE_LT_OBJDIR ".libs/"
126 #ifndef FJCORE_PACKAGE
127 # define FJCORE_PACKAGE "fastjet"
129 #ifndef FJCORE_PACKAGE_BUGREPORT
130 # define FJCORE_PACKAGE_BUGREPORT ""
132 #ifndef FJCORE_PACKAGE_NAME
133 # define FJCORE_PACKAGE_NAME "FastJet"
135 #ifndef FJCORE_PACKAGE_STRING
136 # define FJCORE_PACKAGE_STRING "FastJet 3.2.1"
138 #ifndef FJCORE_PACKAGE_TARNAME
139 # define FJCORE_PACKAGE_TARNAME "fastjet"
141 #ifndef FJCORE_PACKAGE_URL
142 # define FJCORE_PACKAGE_URL ""
144 #ifndef FJCORE_PACKAGE_VERSION
145 # define FJCORE_PACKAGE_VERSION "3.2.1"
147 #ifndef FJCORE_STDC_HEADERS
148 # define FJCORE_STDC_HEADERS 1
150 #ifndef FJCORE_VERSION
151 # define FJCORE_VERSION "3.2.1"
153 #ifndef FJCORE_VERSION_MAJOR
154 # define FJCORE_VERSION_MAJOR 3
156 #ifndef FJCORE_VERSION_MINOR
157 # define FJCORE_VERSION_MINOR 2
159 #ifndef FJCORE_VERSION_NUMBER
160 # define FJCORE_VERSION_NUMBER 30201
162 #ifndef FJCORE_VERSION_PATCHLEVEL
163 # define FJCORE_VERSION_PATCHLEVEL 1
166 #ifndef __FJCORE_CONFIG_H__
167 #define __FJCORE_CONFIG_H__
168 #endif // __FJCORE_CONFIG_H__
169 #ifndef __FJCORE_FASTJET_BASE_HH__
170 #define __FJCORE_FASTJET_BASE_HH__
174 #define FJCORE_BEGIN_NAMESPACE namespace Pythia8 { namespace fjcore {
175 #define FJCORE_END_NAMESPACE }}
176 #ifdef FJCORE_HAVE_OVERRIDE
177 # define FJCORE_OVERRIDE override
179 # define FJCORE_OVERRIDE
181 #endif // __FJCORE_FASTJET_BASE_HH__
182 #ifndef __FJCORE_NUMCONSTS__
183 #define __FJCORE_NUMCONSTS__
184 FJCORE_BEGIN_NAMESPACE
185 const double pi = 3.141592653589793238462643383279502884197;
186 const double twopi = 6.283185307179586476925286766559005768394;
187 const double pisq = 9.869604401089358618834490999876151135314;
188 const double zeta2 = 1.644934066848226436472415166646025189219;
189 const double zeta3 = 1.202056903159594285399738161511449990765;
190 const double eulergamma = 0.577215664901532860606512090082402431042;
191 const double ln2 = 0.693147180559945309417232121458176568076;
193 #endif // __FJCORE_NUMCONSTS__
194 #ifndef __FJCORE_INTERNAL_IS_BASE_HH__
195 #define __FJCORE_INTERNAL_IS_BASE_HH__
196 FJCORE_BEGIN_NAMESPACE
197 template<
typename T, T _t>
199 static const T
value = _t;
203 template<
typename T, T _t>
207 typedef char (&__yes_type)[1];
208 typedef char (&__no_type) [2];
209 template<
typename B,
typename D>
211 #if !((_MSC_VER !=0 ) && (_MSC_VER == 1310)) // MSVC 7.1
212 template <
typename T>
213 static __yes_type check_sig(D
const volatile *, T);
215 static __yes_type check_sig(D
const volatile *,
long);
217 static __no_type check_sig(B
const volatile *,
int);
219 template<
typename B,
typename D>
221 #if ((_MSC_FULL_VER != 0) && (_MSC_FULL_VER >= 140050000))
222 #pragma warning(push)
223 #pragma warning(disable:6334)
226 #if !((_MSC_VER !=0 ) && (_MSC_VER == 1310))
227 operator B
const volatile *()
const;
229 operator B
const volatile *
const&()
const;
231 operator D
const volatile *();
233 static const bool value = ((
sizeof(B)!=0) &&
236 #if ((_MSC_FULL_VER != 0) && (_MSC_FULL_VER >= 140050000))
240 template<
class B,
class D>
241 B* cast_if_derived(D* d){
245 #endif // __IS_BASE_OF_HH__
246 #ifndef __FJCORE_FJCORE_DEPRECATED_HH__
247 #define __FJCORE_FJCORE_DEPRECATED_HH__
248 #if defined(FJCORE_HAVE_CXX14_DEPRECATED)
249 # define FJCORE_DEPRECATED [[deprecated]]
250 # define FJCORE_DEPRECATED_MSG(message) [[deprecated(message)]]
251 #elif defined(FJCORE_HAVE_GNUCXX_DEPRECATED)
252 # define FJCORE_DEPRECATED __attribute__((__deprecated__))
253 # define FJCORE_DEPRECATED_MSG(message) __attribute__((__deprecated__))
255 # define FJCORE_DEPRECATED
256 # define FJCORE_DEPRECATED_MSG(message)
258 #endif // __FJCORE_FJCORE_DEPRECATED_HH__
259 #ifndef __FJCORE_SHARED_PTR_HH__
260 #define __FJCORE_SHARED_PTR_HH__
262 #ifdef __FJCORE_USETR1SHAREDPTR
263 #include <tr1/memory>
264 #endif // __FJCORE_USETR1SHAREDPTR
265 FJCORE_BEGIN_NAMESPACE
266 #ifdef __FJCORE_USETR1SHAREDPTR
268 class SharedPtr :
public std::tr1::shared_ptr<T> {
270 SharedPtr() : std::tr1::shared_ptr<T>() {}
271 SharedPtr(T * t) : std::tr1::shared_ptr<T>(t) {}
273 #ifdef FJCORE_HAVE_EXPLICIT_FOR_OPERATORS
276 inline operator bool()
const {
return (this->
get()!=NULL);}
277 T* operator ()()
const{
281 #else // __FJCORE_USETR1SHAREDPTR
285 class __SharedCountingPtr;
287 template<
class Y>
explicit SharedPtr(Y* ptr){
288 _ptr =
new __SharedCountingPtr(ptr);
291 if (_ptr!=NULL) ++(*_ptr);
294 if (_ptr==NULL)
return;
300 template<
class Y>
void reset(Y * ptr){
303 template<
class Y>
void reset(
SharedPtr<Y> const & share){
305 if (_ptr == share._get_container())
return;
308 _ptr = share._get_container();
309 if (_ptr!=NULL) ++(*_ptr);
319 FJCORE_DEPRECATED_MSG(
"Use SharedPtr<T>::get() instead")
320 T* operator ()()
const{
321 if (_ptr==NULL)
return NULL;
324 inline T& operator*()
const{
325 return *(_ptr->get());
327 inline T* operator->()
const{
328 if (_ptr==NULL)
return NULL;
331 inline T*
get()
const{
332 if (_ptr==NULL)
return NULL;
335 inline bool unique()
const{
336 return (use_count()==1);
338 inline long use_count()
const{
339 if (_ptr==NULL)
return 0;
340 return _ptr->use_count();
342 #ifdef FJCORE_HAVE_EXPLICIT_FOR_OPERATORS
345 inline operator bool()
const{
346 return (
get()!=NULL);
349 __SharedCountingPtr* share_container = share._ptr;
351 _ptr = share_container;
353 void set_count(
const long & count){
354 if (_ptr==NULL)
return;
355 _ptr->set_count(count);
357 class __SharedCountingPtr{
359 __SharedCountingPtr() : _ptr(NULL), _count(0){}
360 template<
class Y>
explicit __SharedCountingPtr(Y* ptr) : _ptr(ptr), _count(1){}
361 ~__SharedCountingPtr(){
362 if (_ptr!=NULL){
delete _ptr;}
364 inline T*
get()
const {
return _ptr;}
365 inline long use_count()
const {
return _count;}
366 inline long operator++(){
return ++_count;}
367 inline long operator--(){
return --_count;}
368 inline long operator++(
int){
return _count++;}
369 inline long operator--(
int){
return _count--;}
370 void set_count(
const long & count){
378 inline __SharedCountingPtr* _get_container()
const{
381 void _decrease_count(){
383 if (_ptr->use_count()==0)
386 __SharedCountingPtr *_ptr;
388 template<
class T,
class U>
390 return t.get() == u.get();
392 template<
class T,
class U>
394 return t.get() != u.get();
396 template<
class T,
class U>
397 inline bool operator<(SharedPtr<T>
const & t,
SharedPtr<U> const & u){
398 return t.get() < u.get();
408 #endif // __FJCORE_USETR1SHAREDPTR
410 #endif // __FJCORE_SHARED_PTR_HH__
411 #ifndef __FJCORE_LIMITEDWARNING_HH__
412 #define __FJCORE_LIMITEDWARNING_HH__
416 FJCORE_BEGIN_NAMESPACE
419 LimitedWarning() : _max_warn(_max_warn_default), _n_warn_so_far(0), _this_warning_summary(0) {}
420 LimitedWarning(
int max_warn_in) : _max_warn(max_warn_in), _n_warn_so_far(0), _this_warning_summary(0) {}
421 void warn(
const char * warning) {warn(warning, _default_ostr);}
422 void warn(
const std::string & warning) {warn(warning.c_str(), _default_ostr);}
423 void warn(
const char * warning, std::ostream * ostr);
424 void warn(
const std::string & warning, std::ostream * ostr) {warn(warning.c_str(), ostr);}
425 static void set_default_stream(std::ostream * ostr) {
426 _default_ostr = ostr;
428 static void set_default_max_warn(
int max_warn) {
429 _max_warn_default = max_warn;
431 int max_warn()
const {
return _max_warn;}
432 int n_warn_so_far()
const {
return _n_warn_so_far;}
433 static std::string summary();
435 int _max_warn, _n_warn_so_far;
436 static int _max_warn_default;
437 static std::ostream * _default_ostr;
438 typedef std::pair<std::string, unsigned int> Summary;
439 static std::list< Summary > _global_warnings_summary;
440 Summary * _this_warning_summary;
443 #endif // __FJCORE_LIMITEDWARNING_HH__
444 #ifndef __FJCORE_ERROR_HH__
445 #define __FJCORE_ERROR_HH__
448 #if (!defined(FJCORE_HAVE_EXECINFO_H)) || defined(__FJCORE__)
450 FJCORE_BEGIN_NAMESPACE
454 Error(
const std::string & message);
456 std::string message()
const {
return _message;}
457 static void set_print_errors(
bool print_errors) {_print_errors = print_errors;}
458 static void set_print_backtrace(
bool enabled);
459 static void set_default_stream(std::ostream * ostr) {
460 _default_ostr = ostr;
463 std::string _message;
464 static bool _print_errors;
465 static bool _print_backtrace;
466 static std::ostream * _default_ostr;
467 #if (!defined(FJCORE_HAVE_EXECINFO_H)) || defined(__FJCORE__)
473 InternalError(
const std::string & message_in) :
Error(std::string(
"*** CRITICAL INTERNAL FASTJET ERROR *** CONTACT THE AUTHORS *** ") + message_in){ }
476 #endif // __FJCORE_ERROR_HH__
477 #ifndef __FJCORE_PSEUDOJET_STRUCTURE_BASE_HH__
478 #define __FJCORE_PSEUDOJET_STRUCTURE_BASE_HH__
481 FJCORE_BEGIN_NAMESPACE
488 virtual std::string description()
const{
return "PseudoJet with an unknown structure"; }
489 virtual bool has_associated_cluster_sequence()
const {
return false;}
491 virtual bool has_valid_cluster_sequence()
const {
return false;}
497 virtual bool has_constituents()
const {
return false;}
498 virtual std::vector<PseudoJet> constituents(
const PseudoJet &reference)
const;
499 virtual bool has_exclusive_subjets()
const {
return false;}
500 virtual std::vector<PseudoJet> exclusive_subjets(
const PseudoJet &reference,
const double & dcut)
const;
501 virtual int n_exclusive_subjets(
const PseudoJet &reference,
const double & dcut)
const;
502 virtual std::vector<PseudoJet> exclusive_subjets_up_to (
const PseudoJet &reference,
int nsub)
const;
503 virtual double exclusive_subdmerge(
const PseudoJet &reference,
int nsub)
const;
504 virtual double exclusive_subdmerge_max(
const PseudoJet &reference,
int nsub)
const;
505 virtual bool has_pieces(
const PseudoJet & )
const {
507 virtual std::vector<PseudoJet> pieces(
const PseudoJet &
511 #endif // __FJCORE_PSEUDOJET_STRUCTURE_BASE_HH__
512 #ifndef __FJCORE_PSEUDOJET_HH__
513 #define __FJCORE_PSEUDOJET_HH__
519 FJCORE_BEGIN_NAMESPACE
520 const double MaxRap = 1e5;
521 const double pseudojet_invalid_phi = -100.0;
522 const double pseudojet_invalid_rap = -1e200;
525 PseudoJet() : _px(0), _py(0), _pz(0), _E(0) {_finish_init(); _reset_indices();}
526 PseudoJet(
const double px,
const double py,
const double pz,
const double E);
527 template <
class L>
PseudoJet(
const L & some_four_vector);
530 inline double E()
const {
return _E;}
531 inline double e()
const {
return _E;}
532 inline double px()
const {
return _px;}
533 inline double py()
const {
return _py;}
534 inline double pz()
const {
return _pz;}
535 inline double phi()
const {
return phi_02pi();}
536 inline double phi_std()
const {
537 _ensure_valid_rap_phi();
538 return _phi > pi ? _phi-twopi : _phi;}
539 inline double phi_02pi()
const {
540 _ensure_valid_rap_phi();
543 inline double rap()
const {
544 _ensure_valid_rap_phi();
547 inline double rapidity()
const {
return rap();}
548 double pseudorapidity()
const;
549 double eta()
const {
return pseudorapidity();}
550 inline double pt2()
const {
return _kt2;}
551 inline double pt()
const {
return sqrt(_kt2);}
552 inline double perp2()
const {
return _kt2;}
553 inline double perp()
const {
return sqrt(_kt2);}
554 inline double kt2()
const {
return _kt2;}
555 inline double m2()
const {
return (_E+_pz)*(_E-_pz)-_kt2;}
556 inline double m()
const;
557 inline double mperp2()
const {
return (_E+_pz)*(_E-_pz);}
558 inline double mperp()
const {
return sqrt(std::abs(mperp2()));}
559 inline double mt2()
const {
return (_E+_pz)*(_E-_pz);}
560 inline double mt()
const {
return sqrt(std::abs(mperp2()));}
561 inline double modp2()
const {
return _kt2+_pz*_pz;}
562 inline double modp()
const {
return sqrt(_kt2+_pz*_pz);}
563 inline double Et()
const {
return (_kt2==0) ? 0.0 : _E/sqrt(1.0+_pz*_pz/_kt2);}
564 inline double Et2()
const {
return (_kt2==0) ? 0.0 : _E*_E/(1.0+_pz*_pz/_kt2);}
565 double operator () (
int i)
const ;
566 inline double operator [] (
int i)
const {
return (*
this)(i); };
567 double kt_distance(
const PseudoJet & other)
const;
568 double plain_distance(
const PseudoJet & other)
const;
569 inline double squared_distance(
const PseudoJet & other)
const {
570 return plain_distance(other);}
571 inline double delta_R(
const PseudoJet & other)
const {
572 return sqrt(squared_distance(other));
574 double delta_phi_to(
const PseudoJet & other)
const;
575 inline double beam_distance()
const {
return _kt2;}
576 std::valarray<double> four_mom()
const;
577 enum { X=0, Y=1, Z=2, T=3, NUM_COORDINATES=4, SIZE=NUM_COORDINATES };
580 void operator*=(
double);
581 void operator/=(
double);
584 inline void reset(
double px,
double py,
double pz,
double E);
585 inline void reset(
const PseudoJet & psjet) {
588 template <
class L>
inline void reset(
const L & some_four_vector) {
589 const PseudoJet * pj = fjcore::cast_if_derived<const PseudoJet>(&some_four_vector);
593 reset(some_four_vector[0], some_four_vector[1],
594 some_four_vector[2], some_four_vector[3]);
597 inline void reset_PtYPhiM(
double pt_in,
double y_in,
double phi_in,
double m_in=0.0) {
598 reset_momentum_PtYPhiM(pt_in, y_in, phi_in, m_in);
601 inline void reset_momentum(
double px,
double py,
double pz,
double E);
602 inline void reset_momentum(
const PseudoJet & pj);
603 void reset_momentum_PtYPhiM(
double pt,
double y,
double phi,
double m=0.0);
604 template <
class L>
inline void reset_momentum(
const L & some_four_vector) {
605 reset_momentum(some_four_vector[0], some_four_vector[1],
606 some_four_vector[2], some_four_vector[3]);
608 void set_cached_rap_phi(
double rap,
double phi);
609 inline int user_index()
const {
return _user_index;}
610 inline void set_user_index(
const int index) {_user_index = index;}
614 virtual ~UserInfoBase(){};
616 class InexistentUserInfo :
public Error {
618 InexistentUserInfo();
620 void set_user_info(UserInfoBase * user_info_in) {
621 _user_info.reset(user_info_in);
624 const L & user_info()
const{
625 if (_user_info.get() == 0)
throw InexistentUserInfo();
626 return dynamic_cast<const L &
>(* _user_info.get());
628 bool has_user_info()
const{
629 return _user_info.get();
632 bool has_user_info()
const{
633 return _user_info.get() &&
dynamic_cast<const L *
>(_user_info.get());
635 const UserInfoBase * user_info_ptr()
const{
636 return _user_info.get();
644 std::string description()
const;
645 bool has_associated_cluster_sequence()
const;
646 bool has_associated_cs()
const {
return has_associated_cluster_sequence();}
647 bool has_valid_cluster_sequence()
const;
648 bool has_valid_cs()
const {
return has_valid_cluster_sequence();}
650 const ClusterSequence* associated_cs()
const {
return associated_cluster_sequence();}
652 return validated_cs();
656 bool has_structure()
const;
661 template<
typename StructureType>
662 const StructureType & structure()
const;
663 template<
typename TransformerType>
664 bool has_structure_of()
const;
665 template<
typename TransformerType>
666 const typename TransformerType::StructureType & structure_of()
const;
667 virtual bool has_partner(
PseudoJet &partner)
const;
668 virtual bool has_child(
PseudoJet &child)
const;
670 virtual bool contains(
const PseudoJet &constituent)
const;
671 virtual bool is_inside(
const PseudoJet &jet)
const;
672 virtual bool has_constituents()
const;
673 virtual std::vector<PseudoJet> constituents()
const;
674 virtual bool has_exclusive_subjets()
const;
675 std::vector<PseudoJet> exclusive_subjets (
const double dcut)
const;
676 int n_exclusive_subjets(
const double dcut)
const;
677 std::vector<PseudoJet> exclusive_subjets (
int nsub)
const;
678 std::vector<PseudoJet> exclusive_subjets_up_to (
int nsub)
const;
679 double exclusive_subdmerge(
int nsub)
const;
680 double exclusive_subdmerge_max(
int nsub)
const;
681 virtual bool has_pieces()
const;
682 virtual std::vector<PseudoJet> pieces()
const;
683 inline int cluster_hist_index()
const {
return _cluster_hist_index;}
684 inline void set_cluster_hist_index(
const int index) {_cluster_hist_index = index;}
685 inline int cluster_sequence_history_index()
const {
686 return cluster_hist_index();}
687 inline void set_cluster_sequence_history_index(
const int index) {
688 set_cluster_hist_index(index);}
693 double _px,_py,_pz,_E;
694 mutable double _phi, _rap;
696 int _cluster_hist_index, _user_index;
698 void _reset_indices();
699 inline void _ensure_valid_rap_phi()
const {
700 if (_phi == pseudojet_invalid_phi) _set_rap_phi();
702 void _set_rap_phi()
const;
712 bool operator==(
const PseudoJet & jet,
const double val);
713 inline bool operator==(
const double val,
const PseudoJet & jet) {
return jet == val;}
714 inline bool operator!=(
const PseudoJet & a,
const double val) {
return !(a==val);}
715 inline bool operator!=(
const double val,
const PseudoJet & a) {
return !(a==val);}
717 return a.E()*b.E() - a.px()*b.px() - a.py()*b.py() - a.pz()*b.pz();
720 PseudoJet PtYPhiM(
double pt,
double y,
double phi,
double m = 0.0);
721 std::vector<PseudoJet> sorted_by_pt(
const std::vector<PseudoJet> & jets);
722 std::vector<PseudoJet> sorted_by_rapidity(
const std::vector<PseudoJet> & jets);
723 std::vector<PseudoJet> sorted_by_E(
const std::vector<PseudoJet> & jets);
724 std::vector<PseudoJet> sorted_by_pz(
const std::vector<PseudoJet> & jets);
725 void sort_indices(std::vector<int> & indices,
726 const std::vector<double> & values);
727 template<
class T> std::vector<T> objects_sorted_by_values(
const std::vector<T> & objects,
728 const std::vector<double> & values) {
729 if (objects.size() != values.size()){
730 throw Error(
"fjcore::objects_sorted_by_values(...): the size of the 'objects' vector must match the size of the 'values' vector");
732 std::vector<int> indices(values.size());
733 for (
size_t i = 0; i < indices.size(); i++) {indices[i] = i;}
734 sort_indices(indices, values);
735 std::vector<T> objects_sorted(objects.size());
736 for (
size_t i = 0; i < indices.size(); i++) {
737 objects_sorted[i] = objects[indices[i]];
739 return objects_sorted;
744 _ref_values = reference_values;
746 inline int operator() (
const int i1,
const int i2)
const {
747 return (*_ref_values)[i1] < (*_ref_values)[i2];
750 const std::vector<double> * _ref_values;
752 template <
class L>
inline PseudoJet::PseudoJet(
const L & some_four_vector) {
753 reset(some_four_vector);
755 inline void PseudoJet::_reset_indices() {
756 set_cluster_hist_index(-1);
761 inline double PseudoJet::m()
const {
763 return mm < 0.0 ? -std::sqrt(-mm) : std::sqrt(mm);
765 inline void PseudoJet::reset(
double px_in,
double py_in,
double pz_in,
double E_in) {
773 inline void PseudoJet::reset_momentum(
double px_in,
double py_in,
double pz_in,
double E_in) {
780 inline void PseudoJet::reset_momentum(
const PseudoJet & pj) {
789 template<
typename StructureType>
790 const StructureType & PseudoJet::structure()
const{
791 return dynamic_cast<const StructureType &
>(* validated_structure_ptr());
793 template<
typename TransformerType>
794 bool PseudoJet::has_structure_of()
const{
795 if (!_structure)
return false;
796 return dynamic_cast<const typename TransformerType::StructureType *
>(_structure.get()) != 0;
798 template<
typename TransformerType>
799 const typename TransformerType::StructureType & PseudoJet::structure_of()
const{
801 throw Error(
"Trying to access the structure of a PseudoJet without an associated structure");
802 return dynamic_cast<const typename TransformerType::StructureType &
>(*_structure);
804 PseudoJet join(
const std::vector<PseudoJet> & pieces);
810 #endif // __FJCORE_PSEUDOJET_HH__
811 #ifndef __FJCORE_FUNCTION_OF_PSEUDOJET_HH__
812 #define __FJCORE_FUNCTION_OF_PSEUDOJET_HH__
813 FJCORE_BEGIN_NAMESPACE
814 template<
typename TOut>
819 virtual std::string description()
const{
return "";}
820 virtual TOut result(
const PseudoJet &pj)
const = 0;
821 TOut operator()(
const PseudoJet &pj)
const {
return result(pj);}
822 std::vector<TOut> operator()(
const std::vector<PseudoJet> &pjs)
const {
823 std::vector<TOut> res(pjs.size());
824 for (
unsigned int i=0; i<pjs.size(); i++)
825 res[i] = result(pjs[i]);
830 #endif // __FJCORE_FUNCTION_OF_PSEUDOJET_HH__
831 #ifndef __FJCORE_SELECTOR_HH__
832 #define __FJCORE_SELECTOR_HH__
835 FJCORE_BEGIN_NAMESPACE
840 virtual bool pass(
const PseudoJet & jet)
const = 0;
841 virtual void terminator(std::vector<const PseudoJet *> & jets)
const {
842 for (
unsigned i = 0; i < jets.size(); i++) {
843 if (jets[i] && !pass(*jets[i])) jets[i] = NULL;
846 virtual bool applies_jet_by_jet()
const {
return true;}
847 virtual std::string description()
const {
return "missing description";}
848 virtual bool takes_reference()
const {
return false;}
849 virtual void set_reference(
const PseudoJet & ){
850 throw Error(
"set_reference(...) cannot be used for a selector worker that does not take a reference");
853 throw Error(
"this SelectorWorker has nothing to copy");
855 virtual void get_rapidity_extent(
double & rapmin,
double & rapmax)
const {
856 rapmax = std::numeric_limits<double>::infinity();
859 virtual bool is_geometric()
const {
return false;}
860 virtual bool has_finite_area()
const;
861 virtual bool has_known_area()
const {
return false;}
862 virtual double known_area()
const{
863 throw Error(
"this selector has no computable area");
872 if (!validated_worker()->applies_jet_by_jet()) {
873 throw Error(
"Cannot apply this selector to an individual jet");
875 return _worker->pass(jet);
877 bool operator()(
const PseudoJet & jet)
const {
880 unsigned int count(
const std::vector<PseudoJet> & jets)
const;
881 PseudoJet sum(
const std::vector<PseudoJet> & jets)
const;
882 double scalar_pt_sum(
const std::vector<PseudoJet> & jets)
const;
883 void sift(
const std::vector<PseudoJet> & jets,
884 std::vector<PseudoJet> & jets_that_pass,
885 std::vector<PseudoJet> & jets_that_fail)
const;
886 bool applies_jet_by_jet()
const {
887 return validated_worker()->applies_jet_by_jet();
889 std::vector<PseudoJet> operator()(
const std::vector<PseudoJet> & jets)
const;
890 virtual void nullify_non_selected(std::vector<const PseudoJet *> & jets)
const {
891 validated_worker()->terminator(jets);
893 void get_rapidity_extent(
double &rapmin,
double &rapmax)
const {
894 return validated_worker()->get_rapidity_extent(rapmin, rapmax);
896 std::string description()
const {
897 return validated_worker()->description();
899 bool is_geometric()
const{
900 return validated_worker()->is_geometric();
902 bool has_finite_area()
const{
903 return validated_worker()->has_finite_area();
908 if (worker_ptr == 0)
throw InvalidWorker();
911 bool takes_reference()
const {
912 return validated_worker()->takes_reference();
915 if (! validated_worker()->takes_reference()){
918 _copy_worker_if_needed();
919 _worker->set_reference(reference);
922 class InvalidWorker :
public Error {
924 InvalidWorker() :
Error(
"Attempt to use Selector with no valid underlying worker") {}
926 class InvalidArea :
public Error {
928 InvalidArea() :
Error(
"Attempt to obtain area from Selector for which this is not meaningful") {}
933 void _copy_worker_if_needed(){
934 if (_worker.unique())
return;
935 _worker.reset(_worker->copy());
945 Selector SelectorPtMin(
double ptmin);
946 Selector SelectorPtMax(
double ptmax);
947 Selector SelectorPtRange(
double ptmin,
double ptmax);
948 Selector SelectorEtMin(
double Etmin);
949 Selector SelectorEtMax(
double Etmax);
950 Selector SelectorEtRange(
double Etmin,
double Etmax);
953 Selector SelectorERange(
double Emin,
double Emax);
954 Selector SelectorMassMin(
double Mmin);
955 Selector SelectorMassMax(
double Mmax);
956 Selector SelectorMassRange(
double Mmin,
double Mmax);
957 Selector SelectorRapMin(
double rapmin);
958 Selector SelectorRapMax(
double rapmax);
959 Selector SelectorRapRange(
double rapmin,
double rapmax);
960 Selector SelectorAbsRapMin(
double absrapmin);
961 Selector SelectorAbsRapMax(
double absrapmax);
962 Selector SelectorAbsRapRange(
double absrapmin,
double absrapmax);
963 Selector SelectorEtaMin(
double etamin);
964 Selector SelectorEtaMax(
double etamax);
965 Selector SelectorEtaRange(
double etamin,
double etamax);
966 Selector SelectorAbsEtaMin(
double absetamin);
967 Selector SelectorAbsEtaMax(
double absetamax);
968 Selector SelectorAbsEtaRange(
double absetamin,
double absetamax);
969 Selector SelectorPhiRange(
double phimin,
double phimax);
970 Selector SelectorRapPhiRange(
double rapmin,
double rapmax,
double phimin,
double phimax);
971 Selector SelectorNHardest(
unsigned int n);
972 Selector SelectorCircle(
const double radius);
973 Selector SelectorDoughnut(
const double radius_in,
const double radius_out);
974 Selector SelectorStrip(
const double half_width);
975 Selector SelectorRectangle(
const double half_rap_width,
const double half_phi_width);
976 Selector SelectorPtFractionMin(
double fraction);
979 #endif // __FJCORE_SELECTOR_HH__
980 #ifndef __FJCORE_JETDEFINITION_HH__
981 #define __FJCORE_JETDEFINITION_HH__
985 FJCORE_BEGIN_NAMESPACE
986 std::string fastjet_version_string();
988 N2MHTLazy9AntiKtSeparateGhosts = -10,
1005 plugin_strategy = 999
1009 cambridge_algorithm=1,
1012 cambridge_for_passive_algorithm=11,
1013 genkt_for_passive_algorithm=13,
1015 ee_genkt_algorithm=53,
1016 plugin_algorithm = 99,
1017 undefined_jet_algorithm = 999
1019 typedef JetAlgorithm JetFinder;
1020 const JetAlgorithm aachen_algorithm = cambridge_algorithm;
1021 const JetAlgorithm cambridge_aachen_algorithm = cambridge_algorithm;
1022 enum RecombinationScheme {
1032 external_scheme = 99
1041 RecombinationScheme recomb_scheme_in = E_scheme,
1042 Strategy strategy_in = Best) {
1043 *
this =
JetDefinition(jet_algorithm_in, R_in, recomb_scheme_in, strategy_in, 1);
1046 RecombinationScheme recomb_scheme_in = E_scheme,
1047 Strategy strategy_in = Best) {
1048 double dummyR = 0.0;
1049 *
this =
JetDefinition(jet_algorithm_in, dummyR, recomb_scheme_in, strategy_in, 0);
1053 double xtra_param_in,
1054 RecombinationScheme recomb_scheme_in = E_scheme,
1055 Strategy strategy_in = Best) {
1056 *
this =
JetDefinition(jet_algorithm_in, R_in, recomb_scheme_in, strategy_in, 2);
1057 set_extra_param(xtra_param_in);
1061 const Recombiner * recombiner_in,
1062 Strategy strategy_in = Best) {
1063 *
this =
JetDefinition(jet_algorithm_in, R_in, external_scheme, strategy_in);
1064 _recombiner = recombiner_in;
1067 const Recombiner * recombiner_in,
1068 Strategy strategy_in = Best) {
1069 *
this =
JetDefinition(jet_algorithm_in, external_scheme, strategy_in);
1070 _recombiner = recombiner_in;
1074 double xtra_param_in,
1075 const Recombiner * recombiner_in,
1076 Strategy strategy_in = Best) {
1077 *
this =
JetDefinition(jet_algorithm_in, R_in, xtra_param_in, external_scheme, strategy_in);
1078 _recombiner = recombiner_in;
1084 _plugin = plugin_in;
1085 _strategy = plugin_strategy;
1086 _Rparam = _plugin->R();
1088 _jet_algorithm = plugin_algorithm;
1089 set_recombination_scheme(E_scheme);
1093 RecombinationScheme recomb_scheme_in,
1094 Strategy strategy_in,
1095 int nparameters_in);
1096 FJCORE_DEPRECATED_MSG(
"This argument ordering is deprecated. Use JetDefinition(alg, R, strategy, scheme[, n_parameters]) instead")
1099 Strategy strategy_in,
1100 RecombinationScheme recomb_scheme_in = E_scheme,
1101 int nparameters_in = 1){
1102 (*this) =
JetDefinition(jet_algorithm_in,R_in,recomb_scheme_in,strategy_in,nparameters_in);
1105 std::vector<PseudoJet> operator()(
const std::vector<L> & particles)
const;
1106 static const double max_allowable_R;
1107 void set_recombination_scheme(RecombinationScheme);
1108 void set_recombiner(
const Recombiner * recomb) {
1109 if (_shared_recombiner) _shared_recombiner.reset(recomb);
1110 _recombiner = recomb;
1111 _default_recombiner = DefaultRecombiner(external_scheme);
1114 void delete_recombiner_when_unused();
1115 const Plugin * plugin()
const {
return _plugin;};
1116 void delete_plugin_when_unused();
1117 JetAlgorithm jet_algorithm ()
const {
return _jet_algorithm ;}
1118 JetAlgorithm jet_finder ()
const {
return _jet_algorithm ;}
1119 double R ()
const {
return _Rparam ;}
1120 double extra_param ()
const {
return _extra_param ;}
1121 Strategy strategy ()
const {
return _strategy ;}
1122 RecombinationScheme recombination_scheme()
const {
1123 return _default_recombiner.scheme();}
1124 void set_jet_algorithm(JetAlgorithm njf) {_jet_algorithm = njf;}
1125 void set_jet_finder(JetAlgorithm njf) {_jet_algorithm = njf;}
1126 void set_extra_param(
double xtra_param) {_extra_param = xtra_param;}
1127 const Recombiner * recombiner()
const {
1128 return _recombiner == 0 ? & _default_recombiner : _recombiner;}
1129 bool has_same_recombiner(
const JetDefinition &other_jd)
const;
1130 bool is_spherical()
const;
1131 std::string description()
const;
1132 std::string description_no_recombiner()
const;
1133 static std::string algorithm_description(
const JetAlgorithm jet_alg);
1134 static unsigned int n_parameters_for_algorithm(
const JetAlgorithm jet_alg);
1138 virtual std::string description()
const = 0;
1141 virtual void preprocess(
PseudoJet & )
const {};
1142 virtual ~Recombiner() {};
1145 recombine(pa,pb,pres);
1149 class DefaultRecombiner :
public Recombiner {
1151 DefaultRecombiner(RecombinationScheme recomb_scheme = E_scheme) :
1152 _recomb_scheme(recomb_scheme) {}
1153 virtual std::string description() const FJCORE_OVERRIDE;
1156 virtual
void preprocess(
PseudoJet & p) const FJCORE_OVERRIDE;
1157 RecombinationScheme scheme()
const {
return _recomb_scheme;}
1159 RecombinationScheme _recomb_scheme;
1163 virtual std::string description()
const = 0;
1165 virtual double R()
const = 0;
1166 virtual bool supports_ghosted_passive_areas()
const {
return false;}
1167 virtual void set_ghost_separation_scale(
double scale)
const;
1168 virtual double ghost_separation_scale()
const {
return 0.0;}
1169 virtual bool exclusive_sequence_meaningful()
const {
return false;}
1170 virtual bool is_spherical()
const {
return false;}
1171 virtual ~Plugin() {};
1174 JetAlgorithm _jet_algorithm;
1176 double _extra_param ;
1177 Strategy _strategy ;
1178 const Plugin * _plugin;
1180 DefaultRecombiner _default_recombiner;
1181 const Recombiner * _recombiner;
1193 FJCORE_END_NAMESPACE
1194 #endif // __FJCORE_JETDEFINITION_HH__
1195 #ifndef __FJCORE_COMPOSITEJET_STRUCTURE_HH__
1196 #define __FJCORE_COMPOSITEJET_STRUCTURE_HH__
1197 FJCORE_BEGIN_NAMESPACE
1206 virtual std::string description() const FJCORE_OVERRIDE;
1207 virtual
bool has_constituents() const FJCORE_OVERRIDE;
1208 virtual std::vector<
PseudoJet> constituents(const
PseudoJet &jet) const FJCORE_OVERRIDE;
1209 virtual
bool has_pieces(const
PseudoJet & ) const FJCORE_OVERRIDE {
return true;}
1210 virtual std::vector<PseudoJet> pieces(
const PseudoJet &jet)
const FJCORE_OVERRIDE;
1212 std::vector<PseudoJet>
_pieces;
1215 template<
typename T>
PseudoJet join(
const std::vector<PseudoJet> & pieces){
1217 for (
unsigned int i=0; i<pieces.size(); i++){
1221 T *cj_struct =
new T(pieces);
1226 return join<T>(std::vector<PseudoJet>(1,j1));
1229 std::vector<PseudoJet> pieces;
1230 pieces.push_back(j1);
1231 pieces.push_back(j2);
1232 return join<T>(pieces);
1236 std::vector<PseudoJet> pieces;
1237 pieces.push_back(j1);
1238 pieces.push_back(j2);
1239 pieces.push_back(j3);
1240 return join<T>(pieces);
1244 std::vector<PseudoJet> pieces;
1245 pieces.push_back(j1);
1246 pieces.push_back(j2);
1247 pieces.push_back(j3);
1248 pieces.push_back(j4);
1249 return join<T>(pieces);
1251 template<
typename T>
PseudoJet join(
const std::vector<PseudoJet> & pieces,
1254 if (pieces.size()>0){
1256 for (
unsigned int i=1; i<pieces.size(); i++){
1257 recombiner.plus_equal(result, pieces[i]);
1260 T *cj_struct =
new T(pieces, &recombiner);
1266 return join<T>(std::vector<PseudoJet>(1,j1), recombiner);
1270 std::vector<PseudoJet> pieces;
1272 pieces.push_back(j1);
1273 pieces.push_back(j2);
1274 return join<T>(pieces, recombiner);
1279 std::vector<PseudoJet> pieces;
1281 pieces.push_back(j1);
1282 pieces.push_back(j2);
1283 pieces.push_back(j3);
1284 return join<T>(pieces, recombiner);
1289 std::vector<PseudoJet> pieces;
1291 pieces.push_back(j1);
1292 pieces.push_back(j2);
1293 pieces.push_back(j3);
1294 pieces.push_back(j4);
1295 return join<T>(pieces, recombiner);
1297 FJCORE_END_NAMESPACE
1298 #endif // __FJCORE_MERGEDJET_STRUCTURE_HH__
1299 #ifndef __FJCORE_CLUSTER_SEQUENCE_STRUCTURE_HH__
1300 #define __FJCORE_CLUSTER_SEQUENCE_STRUCTURE_HH__
1302 FJCORE_BEGIN_NAMESPACE
1307 set_associated_cs(cs);
1310 virtual std::string description() const FJCORE_OVERRIDE{
1311 return "PseudoJet with an associated ClusterSequence";
1313 virtual bool has_associated_cluster_sequence() const FJCORE_OVERRIDE{
return true;}
1314 virtual const ClusterSequence* associated_cluster_sequence() const FJCORE_OVERRIDE;
1315 virtual
bool has_valid_cluster_sequence() const FJCORE_OVERRIDE;
1318 _associated_cs = new_cs;
1320 virtual bool has_partner(
const PseudoJet &reference,
PseudoJet &partner)
const FJCORE_OVERRIDE;
1321 virtual bool has_child(
const PseudoJet &reference,
PseudoJet &child)
const FJCORE_OVERRIDE;
1323 virtual bool object_in_jet(
const PseudoJet &reference,
const PseudoJet &jet)
const FJCORE_OVERRIDE;
1324 virtual bool has_constituents() const FJCORE_OVERRIDE;
1325 virtual std::vector<
PseudoJet> constituents(const
PseudoJet &reference) const FJCORE_OVERRIDE;
1326 virtual
bool has_exclusive_subjets() const FJCORE_OVERRIDE;
1327 virtual std::vector<
PseudoJet> exclusive_subjets(const
PseudoJet &reference, const
double & dcut) const FJCORE_OVERRIDE;
1328 virtual
int n_exclusive_subjets(const
PseudoJet &reference, const
double & dcut) const FJCORE_OVERRIDE;
1329 virtual std::vector<
PseudoJet> exclusive_subjets_up_to (const
PseudoJet &reference,
int nsub) const FJCORE_OVERRIDE;
1330 virtual
double exclusive_subdmerge(const
PseudoJet &reference,
int nsub) const FJCORE_OVERRIDE;
1331 virtual
double exclusive_subdmerge_max(const
PseudoJet &reference,
int nsub) const FJCORE_OVERRIDE;
1332 virtual
bool has_pieces(const
PseudoJet &reference) const FJCORE_OVERRIDE;
1333 virtual std::vector<
PseudoJet> pieces(const
PseudoJet &reference) const FJCORE_OVERRIDE;
1337 FJCORE_END_NAMESPACE
1338 #endif // __FJCORE_CLUSTER_SEQUENCE_STRUCTURE_HH__
1339 #ifndef __FJCORE_CLUSTERSEQUENCE_HH__
1340 #define __FJCORE_CLUSTERSEQUENCE_HH__
1349 FJCORE_BEGIN_NAMESPACE
1356 const std::vector<L> & pseudojets,
1358 const bool & writeout_combinations =
false);
1360 transfer_from_sequence(cs);
1364 std::vector<PseudoJet> inclusive_jets (
const double ptmin = 0.0)
const;
1365 int n_exclusive_jets (
const double dcut)
const;
1366 std::vector<PseudoJet> exclusive_jets (
const double dcut)
const;
1367 std::vector<PseudoJet> exclusive_jets (
const int njets)
const;
1368 std::vector<PseudoJet> exclusive_jets_up_to (
const int njets)
const;
1369 double exclusive_dmerge (
const int njets)
const;
1370 double exclusive_dmerge_max (
const int njets)
const;
1371 double exclusive_ymerge (
int njets)
const {
return exclusive_dmerge(njets) / Q2();}
1372 double exclusive_ymerge_max (
int njets)
const {
return exclusive_dmerge_max(njets)/Q2();}
1373 int n_exclusive_jets_ycut (
double ycut)
const {
return n_exclusive_jets(ycut*Q2());}
1374 std::vector<PseudoJet> exclusive_jets_ycut (
double ycut)
const {
1375 int njets = n_exclusive_jets_ycut(ycut);
1376 return exclusive_jets(njets);
1378 std::vector<PseudoJet> exclusive_subjets (
const PseudoJet & jet,
1379 const double dcut)
const;
1380 int n_exclusive_subjets(
const PseudoJet & jet,
1381 const double dcut)
const;
1382 std::vector<PseudoJet> exclusive_subjets (
const PseudoJet & jet,
1384 std::vector<PseudoJet> exclusive_subjets_up_to (
const PseudoJet & jet,
1386 double exclusive_subdmerge(
const PseudoJet & jet,
int nsub)
const;
1387 double exclusive_subdmerge_max(
const PseudoJet & jet,
int nsub)
const;
1388 double Q()
const {
return _Qtot;}
1389 double Q2()
const {
return _Qtot*_Qtot;}
1396 std::vector<PseudoJet> constituents (
const PseudoJet & jet)
const;
1397 void print_jets_for_root(
const std::vector<PseudoJet> & jets,
1398 std::ostream & ostr = std::cout)
const;
1399 void print_jets_for_root(
const std::vector<PseudoJet> & jets,
1400 const std::string & filename,
1401 const std::string & comment =
"")
const;
1402 void add_constituents (
const PseudoJet & jet,
1403 std::vector<PseudoJet> & subjet_vector)
const;
1404 inline Strategy strategy_used ()
const {
return _strategy;}
1405 std::string strategy_string ()
const {
return strategy_string(_strategy);}
1406 std::string strategy_string (Strategy strategy_in)
const;
1408 void delete_self_when_unused();
1409 bool will_delete_self_when_unused()
const {
return _deletes_self_when_unused;}
1410 void signal_imminent_self_deletion()
const;
1411 double jet_scale_for_algorithm(
const PseudoJet & jet)
const;
1412 void plugin_record_ij_recombination(
int jet_i,
int jet_j,
double dij,
1414 assert(plugin_activated());
1415 _do_ij_recombination_step(jet_i, jet_j, dij, newjet_k);
1417 void plugin_record_ij_recombination(
int jet_i,
int jet_j,
double dij,
1420 void plugin_record_iB_recombination(
int jet_i,
double diB) {
1421 assert(plugin_activated());
1422 _do_iB_recombination_step(jet_i, diB);
1426 virtual ~Extras() {}
1427 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";}
1429 inline void plugin_associate_extras(Extras * extras_in) {
1430 _extras.reset(extras_in);
1439 inline bool plugin_activated()
const {
return _plugin_activated;}
1440 const Extras * extras()
const {
return _extras.get();}
1441 template<
class GBJ>
void plugin_simple_N2_cluster () {
1442 assert(plugin_activated());
1443 _simple_N2_cluster<GBJ>();
1446 struct history_element{
1455 double max_dij_so_far;
1459 enum JetType {Invalid=-3, InexistentParent = -2, BeamJet = -1};
1460 const std::vector<PseudoJet> & jets()
const;
1461 const std::vector<history_element> & history()
const;
1462 unsigned int n_particles()
const;
1463 std::vector<int> particle_jet_indices(
const std::vector<PseudoJet> &)
const;
1464 std::vector<int> unique_history_order()
const;
1465 std::vector<PseudoJet> unclustered_particles()
const;
1466 std::vector<PseudoJet> childless_pseudojets()
const;
1467 bool contains(
const PseudoJet &
object)
const;
1471 return _structure_shared_ptr;
1474 static void print_banner();
1475 static void set_fastjet_banner_stream(std::ostream * ostr) {_fastjet_banner_ostr = ostr;}
1476 static std::ostream * fastjet_banner_stream() {
return _fastjet_banner_ostr;}
1478 static std::ostream * _fastjet_banner_ostr;
1481 template<
class L>
void _transfer_input_jets(
1482 const std::vector<L> & pseudojets);
1484 const bool & writeout_combinations);
1485 void _initialise_and_run_no_decant();
1487 const bool & writeout_combinations);
1488 void _decant_options_partial();
1489 void _fill_initial_history();
1490 void _do_ij_recombination_step(
const int jet_i,
const int jet_j,
1491 const double dij,
int & newjet_k);
1492 void _do_iB_recombination_step(
const int jet_i,
const double diB);
1493 void _set_structure_shared_ptr(
PseudoJet & j);
1494 void _update_structure_use_count();
1495 Strategy _best_strategy()
const;
1498 _Parabola(
double a,
double b,
double c) : _a(a), _b(b), _c(c) {}
1499 inline double operator()(
const double R)
const {
return _c*(_a*R*R + _b*R + 1);}
1505 _Line(
double a,
double b) : _a(a), _b(b) {}
1506 inline double operator()(
const double R)
const {
return _a*R + _b;}
1510 std::vector<PseudoJet> _jets;
1511 std::vector<history_element> _history;
1512 void get_subhist_set(std::set<const history_element*> & subhist,
1513 const PseudoJet & jet,
double dcut,
int maxjet)
const;
1514 bool _writeout_combinations;
1516 double _Rparam, _R2, _invR2;
1519 JetAlgorithm _jet_algorithm;
1521 int _structure_use_count_after_construction;
1522 mutable bool _deletes_self_when_unused;
1524 bool _plugin_activated;
1526 void _really_dumb_cluster ();
1527 void _delaunay_cluster ();
1528 template<
class BJ>
void _simple_N2_cluster ();
1529 void _tiled_N2_cluster ();
1530 void _faster_tiled_N2_cluster ();
1531 void _minheap_faster_tiled_N2_cluster();
1532 void _CP2DChan_cluster();
1533 void _CP2DChan_cluster_2pi2R ();
1534 void _CP2DChan_cluster_2piMultD ();
1535 void _CP2DChan_limited_cluster(
double D);
1536 void _do_Cambridge_inclusive_jets();
1537 void _fast_NsqrtN_cluster();
1538 void _add_step_to_history(
1540 const int parent2,
const int jetp_index,
1542 void _extract_tree_children(
int pos, std::valarray<bool> &,
1543 const std::valarray<int> &, std::vector<int> &)
const;
1544 void _extract_tree_parents (
int pos, std::valarray<bool> &,
1545 const std::valarray<int> &, std::vector<int> &)
const;
1546 typedef std::pair<int,int> TwoVertices;
1547 typedef std::pair<double,TwoVertices> DijEntry;
1548 typedef std::multimap<double,TwoVertices> DistMap;
1549 void _add_ktdistance_to_map(
const int ii,
1552 static bool _first_time;
1556 double eta, phi, kt2, NN_dist;
1562 double eta, phi, kt2, NN_dist;
1564 int _jets_index, tile_index, diJ_posn;
1565 inline void label_minheap_update_needed() {diJ_posn = 1;}
1566 inline void label_minheap_update_done() {diJ_posn = 0;}
1567 inline bool minheap_update_needed()
const {
return diJ_posn==1;}
1569 template <
class J>
void _bj_set_jetinfo( J *
const jet,
1570 const int _jets_index)
const;
1571 void _bj_remove_from_tiles(
TiledJet *
const jet)
const;
1572 template <
class J>
double _bj_dist(
const J *
const jeta,
1573 const J *
const jetb)
const;
1574 template <
class J>
double _bj_diJ(
const J *
const jeta)
const;
1575 template <
class J>
inline J * _bj_of_hindex(
1576 const int hist_index,
1577 J *
const head, J *
const tail)
1580 for(res = head; res<tail; res++) {
1581 if (_jets[res->_jets_index].cluster_hist_index() == hist_index) {
break;}
1585 template <
class J>
void _bj_set_NN_nocross(J *
const jeta,
1586 J *
const head,
const J *
const tail)
const;
1587 template <
class J>
void _bj_set_NN_crosscheck(J *
const jeta,
1588 J *
const head,
const J *
const tail)
const;
1589 static const int n_tile_neighbours = 9;
1591 Tile * begin_tiles[n_tile_neighbours];
1592 Tile ** surrounding_tiles;
1598 std::vector<Tile> _tiles;
1599 double _tiles_eta_min, _tiles_eta_max;
1600 double _tile_size_eta, _tile_size_phi;
1601 int _n_tiles_phi,_tiles_ieta_min,_tiles_ieta_max;
1602 inline int _tile_index (
int ieta,
int iphi)
const {
1603 return (ieta-_tiles_ieta_min)*_n_tiles_phi
1604 + (iphi+_n_tiles_phi) % _n_tiles_phi;
1606 int _tile_index(
const double eta,
const double phi)
const;
1607 void _tj_set_jetinfo (
TiledJet *
const jet,
const int _jets_index);
1608 void _bj_remove_from_tiles(
TiledJet *
const jet);
1609 void _initialise_tiles();
1610 void _print_tiles(
TiledJet * briefjets )
const;
1611 void _add_neighbours_to_tile_union(
const int tile_index,
1612 std::vector<int> & tile_union,
int & n_near_tiles)
const;
1613 void _add_untagged_neighbours_to_tile_union(
const int tile_index,
1614 std::vector<int> & tile_union,
int & n_near_tiles);
1622 void _simple_N2_cluster_BriefJet();
1623 void _simple_N2_cluster_EEBriefJet();
1625 template<
class L>
void ClusterSequence::_transfer_input_jets(
1626 const std::vector<L> & pseudojets) {
1627 _jets.reserve(pseudojets.size()*2);
1628 for (
unsigned int i = 0; i < pseudojets.size(); i++) {
1629 _jets.push_back(pseudojets[i]);}
1631 template<
class L> ClusterSequence::ClusterSequence (
1632 const std::vector<L> & pseudojets,
1634 const bool & writeout_combinations) :
1635 _jet_def(jet_def_in), _writeout_combinations(writeout_combinations),
1638 _transfer_input_jets(pseudojets);
1639 _decant_options_partial();
1640 _initialise_and_run_no_decant();
1642 inline const std::vector<PseudoJet> & ClusterSequence::jets ()
const {
1645 inline const std::vector<ClusterSequence::history_element> & ClusterSequence::history ()
const {
1648 inline unsigned int ClusterSequence::n_particles()
const {
return _initial_n;}
1651 std::vector<PseudoJet> JetDefinition::operator()(
const std::vector<L> & particles)
const {
1653 std::vector<PseudoJet> jets;
1654 if (is_spherical()) {
1655 jets = sorted_by_E(cs->inclusive_jets());
1657 jets = sorted_by_pt(cs->inclusive_jets());
1659 if (jets.size() != 0) {
1660 cs->delete_self_when_unused();
1667 template <
class J>
inline void ClusterSequence::_bj_set_jetinfo(
1668 J *
const jetA,
const int _jets_index)
const {
1669 jetA->eta = _jets[_jets_index].rap();
1670 jetA->phi = _jets[_jets_index].phi_02pi();
1671 jetA->kt2 = jet_scale_for_algorithm(_jets[_jets_index]);
1672 jetA->_jets_index = _jets_index;
1673 jetA->NN_dist = _R2;
1676 template <
class J>
inline double ClusterSequence::_bj_dist(
1677 const J *
const jetA,
const J *
const jetB)
const {
1678 #ifndef FJCORE_NEW_DELTA_PHI
1679 double dphi = std::abs(jetA->phi - jetB->phi);
1680 double deta = (jetA->eta - jetB->eta);
1681 if (dphi > pi) {dphi = twopi - dphi;}
1683 double dphi = pi-std::abs(pi-std::abs(jetA->phi - jetB->phi));
1684 double deta = (jetA->eta - jetB->eta);
1686 return dphi*dphi + deta*deta;
1688 template <
class J>
inline double ClusterSequence::_bj_diJ(
const J *
const jet)
const {
1689 double kt2 = jet->kt2;
1690 if (jet->NN != NULL) {
if (jet->NN->kt2 < kt2) {kt2 = jet->NN->kt2;}}
1691 return jet->NN_dist * kt2;
1693 template <
class J>
inline void ClusterSequence::_bj_set_NN_nocross(
1694 J *
const jet, J *
const head,
const J *
const tail)
const {
1695 double NN_dist = _R2;
1698 for (J * jetB = head; jetB != jet; jetB++) {
1699 double dist = _bj_dist(jet,jetB);
1700 if (dist < NN_dist) {
1707 for (J * jetB = jet+1; jetB != tail; jetB++) {
1708 double dist = _bj_dist(jet,jetB);
1709 if (dist < NN_dist) {
1716 jet->NN_dist = NN_dist;
1718 template <
class J>
inline void ClusterSequence::_bj_set_NN_crosscheck(J *
const jet,
1719 J *
const head,
const J *
const tail)
const {
1720 double NN_dist = _R2;
1722 for (J * jetB = head; jetB != tail; jetB++) {
1723 double dist = _bj_dist(jet,jetB);
1724 if (dist < NN_dist) {
1728 if (dist < jetB->NN_dist) {
1729 jetB->NN_dist = dist;
1734 jet->NN_dist = NN_dist;
1736 FJCORE_END_NAMESPACE
1737 #endif // __FJCORE_CLUSTERSEQUENCE_HH__
1738 #ifndef __FJCORE_NNBASE_HH__
1739 #define __FJCORE_NNBASE_HH__
1740 FJCORE_BEGIN_NAMESPACE
1742 template<
class I>
class NNInfo {
1744 NNInfo() : _info(NULL) {}
1745 NNInfo(I * info) : _info(info) {}
1746 template<
class BJ>
void init_jet(BJ * briefjet,
const fjcore::PseudoJet & jet,
int index) { briefjet->init(jet, index, _info);}
1754 template<
class BJ>
void init_jet(BJ * briefjet,
const fjcore::PseudoJet & jet,
int index) { briefjet->init(jet, index);}
1756 template<
class I = _NoInfo>
class NNBase :
public NNInfo<I> {
1760 virtual void start(
const std::vector<PseudoJet> & jets) = 0;
1761 virtual double dij_min(
int & iA,
int & iB) = 0;
1762 virtual void remove_jet(
int iA) = 0;
1763 virtual void merge_jets(
int iA,
int iB,
const PseudoJet & jet,
int jet_index) = 0;
1766 FJCORE_END_NAMESPACE
1767 #endif // __FJCORE_NNBASE_HH__
1768 #ifndef __FJCORE_NNH_HH__
1769 #define __FJCORE_NNH_HH__
1770 FJCORE_BEGIN_NAMESPACE
1771 template<
class BJ,
class I = _NoInfo>
class NNH :
public NNBase<I> {
1773 NNH(
const std::vector<PseudoJet> & jets) :
NNBase<I>() {start(jets);}
1774 NNH(
const std::vector<PseudoJet> & jets, I * info) :
NNBase<I>(info) {start(jets);}
1775 void start(
const std::vector<PseudoJet> & jets);
1776 double dij_min(
int & iA,
int & iB);
1777 void remove_jet(
int iA);
1778 void merge_jets(
int iA,
int iB,
const PseudoJet & jet,
int jet_index);
1784 void set_NN_crosscheck(NNBJ * jet, NNBJ * begin, NNBJ * end);
1785 void set_NN_nocross (NNBJ * jet, NNBJ * begin, NNBJ * end);
1787 NNBJ * head, * tail;
1789 std::vector<NNBJ *> where_is;
1790 class NNBJ :
public BJ {
1792 void init(
const PseudoJet & jet,
int index_in) {
1794 other_init(index_in);
1796 void init(
const PseudoJet & jet,
int index_in, I * info) {
1797 BJ::init(jet, info);
1798 other_init(index_in);
1800 void other_init(
int index_in) {
1802 NN_dist = BJ::beam_distance();
1805 int index()
const {
return _index;}
1812 template<
class BJ,
class I>
void NNH<BJ,I>::start(
const std::vector<PseudoJet> & jets) {
1814 briefjets =
new NNBJ[n];
1815 where_is.resize(2*n);
1816 NNBJ * jetA = briefjets;
1817 for (
int i = 0; i< n; i++) {
1818 this->init_jet(jetA, jets[i], i);
1824 for (jetA = head + 1; jetA != tail; jetA++) {
1825 set_NN_crosscheck(jetA, head, jetA);
1829 double diJ_min = briefjets[0].NN_dist;
1830 int diJ_min_jet = 0;
1831 for (
int i = 1; i < n; i++) {
1832 if (briefjets[i].NN_dist < diJ_min) {
1834 diJ_min = briefjets[i].NN_dist;
1837 NNBJ * jetA = & briefjets[diJ_min_jet];
1839 iB = jetA->NN ? jetA->NN->index() : -1;
1843 NNBJ * jetA = where_is[iA];
1846 where_is[jetA->index()] = jetA;
1847 for (NNBJ * jetI = head; jetI != tail; jetI++) {
1848 if (jetI->NN == jetA) set_NN_nocross(jetI, head, tail);
1849 if (jetI->NN == tail) {jetI->NN = jetA;}
1854 NNBJ * jetA = where_is[iA];
1855 NNBJ * jetB = where_is[iB];
1856 if (jetA < jetB) std::swap(jetA,jetB);
1857 this->init_jet(jetB, jet, index);
1858 if (index >=
int(where_is.size())) where_is.resize(2*index);
1859 where_is[jetB->index()] = jetB;
1862 where_is[jetA->index()] = jetA;
1863 for (NNBJ * jetI = head; jetI != tail; jetI++) {
1864 if (jetI->NN == jetA || jetI->NN == jetB) {
1865 set_NN_nocross(jetI, head, tail);
1867 double dist = jetI->distance(jetB);
1868 if (dist < jetI->NN_dist) {
1870 jetI->NN_dist = dist;
1874 if (dist < jetB->NN_dist) {
1876 jetB->NN_dist = dist;
1880 if (jetI->NN == tail) {jetI->NN = jetA;}
1884 NNBJ * begin, NNBJ * end) {
1885 double NN_dist = jet->beam_distance();
1887 for (NNBJ * jetB = begin; jetB != end; jetB++) {
1888 double dist = jet->distance(jetB);
1889 if (dist < NN_dist) {
1893 if (dist < jetB->NN_dist) {
1894 jetB->NN_dist = dist;
1899 jet->NN_dist = NN_dist;
1902 NNBJ * jet, NNBJ * begin, NNBJ * end) {
1903 double NN_dist = jet->beam_distance();
1906 for (NNBJ * jetB = begin; jetB != jet; jetB++) {
1907 double dist = jet->distance(jetB);
1908 if (dist < NN_dist) {
1915 for (NNBJ * jetB = jet+1; jetB != end; jetB++) {
1916 double dist = jet->distance (jetB);
1917 if (dist < NN_dist) {
1924 jet->NN_dist = NN_dist;
1926 FJCORE_END_NAMESPACE
1927 #endif // __FJCORE_NNH_HH__
static const T value
the value (only member carrying info)
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
integral_type< T, _t > type
a typedef for the whole structure