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__
171 #define FJCORE_BEGIN_NAMESPACE namespace fjcore {
172 #define FJCORE_END_NAMESPACE }
173 #ifdef FJCORE_HAVE_OVERRIDE
174 # define FJCORE_OVERRIDE override
176 # define FJCORE_OVERRIDE
178 #endif // __FJCORE_FASTJET_BASE_HH__
179 #ifndef __FJCORE_NUMCONSTS__
180 #define __FJCORE_NUMCONSTS__
182 const double pi = 3.141592653589793238462643383279502884197;
183 const double twopi = 6.283185307179586476925286766559005768394;
184 const double pisq = 9.869604401089358618834490999876151135314;
185 const double zeta2 = 1.644934066848226436472415166646025189219;
186 const double zeta3 = 1.202056903159594285399738161511449990765;
187 const double eulergamma = 0.577215664901532860606512090082402431042;
188 const double ln2 = 0.693147180559945309417232121458176568076;
190 #endif // __FJCORE_NUMCONSTS__
191 #ifndef __FJCORE_INTERNAL_IS_BASE_HH__
192 #define __FJCORE_INTERNAL_IS_BASE_HH__
194 template<
typename T, T _t>
200 template<
typename T, T _t>
206 template<
typename B,
typename D>
208 #if !((_MSC_VER !=0 ) && (_MSC_VER == 1310)) // MSVC 7.1
209 template <
typename T>
216 template<
typename B,
typename D>
218 #if ((_MSC_FULL_VER != 0) && (_MSC_FULL_VER >= 140050000))
219 #pragma warning(push)
220 #pragma warning(disable:6334)
223 #if !((_MSC_VER !=0 ) && (_MSC_VER == 1310))
224 operator B
const volatile *()
const;
226 operator B
const volatile *
const&()
const;
228 operator D const volatile *();
230 static const bool value = ((
sizeof(B)!=0) &&
233 #if ((_MSC_FULL_VER != 0) && (_MSC_FULL_VER >= 140050000))
237 template<
class B,
class D>
242 #endif // __IS_BASE_OF_HH__
243 #ifndef __FJCORE_FJCORE_DEPRECATED_HH__
244 #define __FJCORE_FJCORE_DEPRECATED_HH__
245 #if defined(FJCORE_HAVE_CXX14_DEPRECATED)
246 # define FJCORE_DEPRECATED [[deprecated]]
247 # define FJCORE_DEPRECATED_MSG(message) [[deprecated(message)]]
248 #elif defined(FJCORE_HAVE_GNUCXX_DEPRECATED)
249 # define FJCORE_DEPRECATED __attribute__((__deprecated__))
250 # define FJCORE_DEPRECATED_MSG(message) __attribute__((__deprecated__))
252 # define FJCORE_DEPRECATED
253 # define FJCORE_DEPRECATED_MSG(message)
255 #endif // __FJCORE_FJCORE_DEPRECATED_HH__
256 #ifndef __FJCORE_SHARED_PTR_HH__
257 #define __FJCORE_SHARED_PTR_HH__
259 #ifdef __FJCORE_USETR1SHAREDPTR
260 #include <tr1/memory>
261 #endif // __FJCORE_USETR1SHAREDPTR
263 #ifdef __FJCORE_USETR1SHAREDPTR
265 class SharedPtr :
public std::tr1::shared_ptr<T> {
267 SharedPtr() : std::tr1::shared_ptr<T>() {}
270 #ifdef FJCORE_HAVE_EXPLICIT_FOR_OPERATORS
273 inline operator bool()
const {
return (this->
get()!=NULL);}
278 #else // __FJCORE_USETR1SHAREDPTR
285 _ptr =
new __SharedCountingPtr(ptr);
288 if (
_ptr!=NULL) ++(*_ptr);
291 if (
_ptr==NULL)
return;
306 if (
_ptr!=NULL) ++(*_ptr);
317 T* operator ()()
const{
318 if (
_ptr==NULL)
return NULL;
325 if (
_ptr==NULL)
return NULL;
328 inline T*
get()
const{
329 if (
_ptr==NULL)
return NULL;
336 if (
_ptr==NULL)
return 0;
339 #ifdef FJCORE_HAVE_EXPLICIT_FOR_OPERATORS
342 inline operator bool()
const{
343 return (
get()!=NULL);
346 __SharedCountingPtr* share_container = share.
_ptr;
348 _ptr = share_container;
351 if (
_ptr==NULL)
return;
361 inline T*
get()
const {
return _ptr;}
385 template<
class T,
class U>
387 return t.
get() == u.
get();
389 template<
class T,
class U>
391 return t.
get() != u.
get();
393 template<
class T,
class U>
395 return t.get() <
u.get();
405 #endif // __FJCORE_USETR1SHAREDPTR
407 #endif // __FJCORE_SHARED_PTR_HH__
408 #ifndef __FJCORE_LIMITEDWARNING_HH__
409 #define __FJCORE_LIMITEDWARNING_HH__
420 void warn(
const char * warning, std::ostream * ostr);
435 typedef std::pair<std::string, unsigned int>
Summary;
440 #endif // __FJCORE_LIMITEDWARNING_HH__
441 #ifndef __FJCORE_ERROR_HH__
442 #define __FJCORE_ERROR_HH__
445 #if (!defined(FJCORE_HAVE_EXECINFO_H)) || defined(__FJCORE__)
464 #if (!defined(FJCORE_HAVE_EXECINFO_H)) || defined(__FJCORE__)
473 #endif // __FJCORE_ERROR_HH__
474 #ifndef __FJCORE_PSEUDOJET_STRUCTURE_BASE_HH__
475 #define __FJCORE_PSEUDOJET_STRUCTURE_BASE_HH__
508 #endif // __FJCORE_PSEUDOJET_STRUCTURE_BASE_HH__
509 #ifndef __FJCORE_PSEUDOJET_HH__
510 #define __FJCORE_PSEUDOJET_HH__
523 PseudoJet(
const double px,
const double py,
const double pz,
const double E);
524 template <
class L>
PseudoJet(
const L & some_four_vector);
527 inline double E()
const {
return _E;}
528 inline double e()
const {
return _E;}
529 inline double px()
const {
return _px;}
530 inline double py()
const {
return _py;}
531 inline double pz()
const {
return _pz;}
540 inline double rap()
const {
548 inline double pt()
const {
return sqrt(
_kt2);}
553 inline double m()
const;
557 inline double mt()
const {
return sqrt(std::abs(
mperp2()));}
573 std::valarray<double>
four_mom()
const;
581 inline void reset(
double px,
double py,
double pz,
double E);
585 template <
class L>
inline void reset(
const L & some_four_vector) {
586 const PseudoJet * pj = fjcore::cast_if_derived<const PseudoJet>(&some_four_vector);
590 reset(some_four_vector[0], some_four_vector[1],
591 some_four_vector[2], some_four_vector[3]);
603 some_four_vector[2], some_four_vector[3]);
658 template<
typename StructureType>
660 template<
typename TransformerType>
662 template<
typename TransformerType>
663 const typename TransformerType::StructureType &
structure_of()
const;
679 virtual std::vector<PseudoJet>
pieces()
const;
714 return a.
E()*b.
E() - a.
px()*b.
px() - a.
py()*b.
py() - a.
pz()*b.
pz();
718 std::vector<PseudoJet>
sorted_by_pt(
const std::vector<PseudoJet> & jets);
720 std::vector<PseudoJet>
sorted_by_E(
const std::vector<PseudoJet> & jets);
721 std::vector<PseudoJet>
sorted_by_pz(
const std::vector<PseudoJet> & jets);
723 const std::vector<double> &
values);
725 const std::vector<double> &
values) {
726 if (objects.size() != values.size()){
727 throw Error(
"fjcore::objects_sorted_by_values(...): the size of the 'objects' vector must match the size of the 'values' vector");
729 std::vector<int> indices(values.size());
730 for (
size_t i = 0;
i < indices.size();
i++) {indices[
i] =
i;}
732 std::vector<T> objects_sorted(objects.size());
733 for (
size_t i = 0;
i < indices.size();
i++) {
734 objects_sorted[
i] = objects[indices[
i]];
736 return objects_sorted;
750 reset(some_four_vector);
760 return mm < 0.0 ? -std::sqrt(-mm) : std::sqrt(mm);
786 template<
typename StructureType>
790 template<
typename TransformerType>
793 return dynamic_cast<const typename TransformerType::StructureType *
>(
_structure.
get()) != 0;
795 template<
typename TransformerType>
798 throw Error(
"Trying to access the structure of a PseudoJet without an associated structure");
799 return dynamic_cast<const typename TransformerType::StructureType &
>(*_structure);
807 #endif // __FJCORE_PSEUDOJET_HH__
808 #ifndef __FJCORE_FUNCTION_OF_PSEUDOJET_HH__
809 #define __FJCORE_FUNCTION_OF_PSEUDOJET_HH__
811 template<
typename TOut>
819 std::vector<TOut>
operator()(
const std::vector<PseudoJet> &pjs)
const {
820 std::vector<TOut> res(pjs.size());
821 for (
unsigned int i=0;
i<pjs.size();
i++)
827 #endif // __FJCORE_FUNCTION_OF_PSEUDOJET_HH__
828 #ifndef __FJCORE_SELECTOR_HH__
829 #define __FJCORE_SELECTOR_HH__
838 virtual void terminator(std::vector<const PseudoJet *> & jets)
const {
839 for (
unsigned i = 0;
i < jets.size();
i++) {
840 if (jets[
i] && !
pass(*jets[
i])) jets[i] = NULL;
847 throw Error(
"set_reference(...) cannot be used for a selector worker that does not take a reference");
850 throw Error(
"this SelectorWorker has nothing to copy");
853 rapmax = std::numeric_limits<double>::infinity();
860 throw Error(
"this selector has no computable area");
870 throw Error(
"Cannot apply this selector to an individual jet");
877 unsigned int count(
const std::vector<PseudoJet> & jets)
const;
878 PseudoJet sum(
const std::vector<PseudoJet> & jets)
const;
879 double scalar_pt_sum(
const std::vector<PseudoJet> & jets)
const;
880 void sift(
const std::vector<PseudoJet> & jets,
881 std::vector<PseudoJet> & jets_that_pass,
882 std::vector<PseudoJet> & jets_that_fail)
const;
886 std::vector<PseudoJet>
operator()(
const std::vector<PseudoJet> & jets)
const;
925 InvalidArea() :
Error(
"Attempt to obtain area from Selector for which this is not meaningful") {}
976 #endif // __FJCORE_SELECTOR_HH__
977 #ifndef __FJCORE_JETDEFINITION_HH__
978 #define __FJCORE_JETDEFINITION_HH__
1040 *
this =
JetDefinition(jet_algorithm_in, R_in, recomb_scheme_in, strategy_in, 1);
1045 double dummyR = 0.0;
1046 *
this =
JetDefinition(jet_algorithm_in, dummyR, recomb_scheme_in, strategy_in, 0);
1050 double xtra_param_in,
1053 *
this =
JetDefinition(jet_algorithm_in, R_in, recomb_scheme_in, strategy_in, 2);
1071 double xtra_param_in,
1092 int nparameters_in);
1093 FJCORE_DEPRECATED_MSG(
"This argument ordering is deprecated. Use JetDefinition(alg, R, strategy, scheme[, n_parameters]) instead")
1098 int nparameters_in = 1){
1099 (*this) =
JetDefinition(jet_algorithm_in,R_in,recomb_scheme_in,strategy_in,nparameters_in);
1162 virtual double R()
const = 0;
1191 #endif // __FJCORE_JETDEFINITION_HH__
1192 #ifndef __FJCORE_COMPOSITEJET_STRUCTURE_HH__
1193 #define __FJCORE_COMPOSITEJET_STRUCTURE_HH__
1212 template<
typename T>
PseudoJet join(
const std::vector<PseudoJet> & pieces){
1214 for (
unsigned int i=0;
i<pieces.size();
i++){
1218 T *cj_struct =
new T(pieces);
1223 return join<T>(std::vector<PseudoJet>(1,j1));
1226 std::vector<PseudoJet> pieces;
1227 pieces.push_back(j1);
1228 pieces.push_back(j2);
1229 return join<T>(pieces);
1233 std::vector<PseudoJet> pieces;
1234 pieces.push_back(j1);
1235 pieces.push_back(j2);
1236 pieces.push_back(j3);
1237 return join<T>(pieces);
1241 std::vector<PseudoJet> pieces;
1242 pieces.push_back(j1);
1243 pieces.push_back(j2);
1244 pieces.push_back(j3);
1245 pieces.push_back(j4);
1246 return join<T>(pieces);
1248 template<
typename T>
PseudoJet join(
const std::vector<PseudoJet> & pieces,
1251 if (pieces.size()>0){
1253 for (
unsigned int i=1;
i<pieces.size();
i++){
1257 T *cj_struct =
new T(pieces, &recombiner);
1263 return join<T>(std::vector<PseudoJet>(1,j1), recombiner);
1267 std::vector<PseudoJet> pieces;
1269 pieces.push_back(j1);
1270 pieces.push_back(j2);
1271 return join<T>(pieces, recombiner);
1276 std::vector<PseudoJet> pieces;
1278 pieces.push_back(j1);
1279 pieces.push_back(j2);
1280 pieces.push_back(j3);
1281 return join<T>(pieces, recombiner);
1286 std::vector<PseudoJet> pieces;
1288 pieces.push_back(j1);
1289 pieces.push_back(j2);
1290 pieces.push_back(j3);
1291 pieces.push_back(j4);
1292 return join<T>(pieces, recombiner);
1295 #endif // __FJCORE_MERGEDJET_STRUCTURE_HH__
1296 #ifndef __FJCORE_CLUSTER_SEQUENCE_STRUCTURE_HH__
1297 #define __FJCORE_CLUSTER_SEQUENCE_STRUCTURE_HH__
1308 return "PseudoJet with an associated ClusterSequence";
1330 virtual std::vector<
PseudoJet> pieces(const
PseudoJet &reference) const FJCORE_OVERRIDE;
1335 #endif // __FJCORE_CLUSTER_SEQUENCE_STRUCTURE_HH__
1336 #ifndef __FJCORE_CLUSTERSEQUENCE_HH__
1337 #define __FJCORE_CLUSTERSEQUENCE_HH__
1353 const std::vector<L> & pseudojets,
1355 const bool & writeout_combinations =
false);
1357 transfer_from_sequence(cs);
1361 std::vector<PseudoJet> inclusive_jets (
const double ptmin = 0.0)
const;
1362 int n_exclusive_jets (
const double dcut)
const;
1363 std::vector<PseudoJet> exclusive_jets (
const double dcut)
const;
1364 std::vector<PseudoJet> exclusive_jets (
const int njets)
const;
1365 std::vector<PseudoJet> exclusive_jets_up_to (
const int njets)
const;
1366 double exclusive_dmerge (
const int njets)
const;
1367 double exclusive_dmerge_max (
const int njets)
const;
1372 int njets = n_exclusive_jets_ycut(ycut);
1373 return exclusive_jets(njets);
1376 const double dcut)
const;
1378 const double dcut)
const;
1385 double Q()
const {
return _Qtot;}
1386 double Q2()
const {
return _Qtot*_Qtot;}
1394 void print_jets_for_root(
const std::vector<PseudoJet> & jets,
1395 std::ostream & ostr = std::cout)
const;
1396 void print_jets_for_root(
const std::vector<PseudoJet> & jets,
1399 void add_constituents (
const PseudoJet & jet,
1400 std::vector<PseudoJet> & subjet_vector)
const;
1405 void delete_self_when_unused();
1407 void signal_imminent_self_deletion()
const;
1408 double jet_scale_for_algorithm(
const PseudoJet & jet)
const;
1409 void plugin_record_ij_recombination(
int jet_i,
int jet_j,
double dij,
1411 assert(plugin_activated());
1412 _do_ij_recombination_step(jet_i, jet_j, dij, newjet_k);
1414 void plugin_record_ij_recombination(
int jet_i,
int jet_j,
double dij,
1418 assert(plugin_activated());
1419 _do_iB_recombination_step(jet_i, diB);
1424 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";}
1427 _extras.reset(extras_in);
1429 #ifdef FJCORE_HAVE_AUTO_PTR_INTERFACE
1430 FJCORE_DEPRECATED_MSG(
"Please use ClusterSequence::plugin_associate_extras(Extras * extras_in)) instead")
1431 inline
void plugin_associate_extras(std::auto_ptr<Extras> extras_in){
1432 _extras.reset(extras_in.release());
1438 assert(plugin_activated());
1439 _simple_N2_cluster<GBJ>();
1456 const std::vector<PseudoJet> & jets()
const;
1457 const std::vector<history_element> & history()
const;
1458 unsigned int n_particles()
const;
1459 std::vector<int> particle_jet_indices(
const std::vector<PseudoJet> &)
const;
1460 std::vector<int> unique_history_order()
const;
1461 std::vector<PseudoJet> unclustered_particles()
const;
1462 std::vector<PseudoJet> childless_pseudojets()
const;
1463 bool contains(
const PseudoJet &
object)
const;
1467 return _structure_shared_ptr;
1477 template<
class L>
void _transfer_input_jets(
1478 const std::vector<L> & pseudojets);
1480 const bool & writeout_combinations);
1481 void _initialise_and_run_no_decant();
1483 const bool & writeout_combinations);
1484 void _decant_options_partial();
1485 void _fill_initial_history();
1486 void _do_ij_recombination_step(
const int jet_i,
const int jet_j,
1487 const double dij,
int & newjet_k);
1488 void _do_iB_recombination_step(
const int jet_i,
const double diB);
1489 void _set_structure_shared_ptr(
PseudoJet &
j);
1490 void _update_structure_use_count();
1495 inline double operator()(
const double R)
const {
return _c*(_a*R*R + _b*R + 1);}
1508 void get_subhist_set(std::set<const history_element*> & subhist,
1509 const PseudoJet & jet,
double dcut,
int maxjet)
const;
1522 void _really_dumb_cluster ();
1523 void _delaunay_cluster ();
1524 template<
class BJ>
void _simple_N2_cluster ();
1525 void _tiled_N2_cluster ();
1526 void _faster_tiled_N2_cluster ();
1527 void _minheap_faster_tiled_N2_cluster();
1528 void _CP2DChan_cluster();
1529 void _CP2DChan_cluster_2pi2R ();
1530 void _CP2DChan_cluster_2piMultD ();
1531 void _CP2DChan_limited_cluster(
double D);
1532 void _do_Cambridge_inclusive_jets();
1533 void _fast_NsqrtN_cluster();
1534 void _add_step_to_history(
1536 const int parent2,
const int jetp_index,
1538 void _extract_tree_children(
int pos, std::valarray<bool> &,
1539 const std::valarray<int> &, std::vector<int> &)
const;
1540 void _extract_tree_parents (
int pos, std::valarray<bool> &,
1541 const std::valarray<int> &, std::vector<int> &)
const;
1544 typedef std::multimap<double,TwoVertices>
DistMap;
1545 void _add_ktdistance_to_map(
const int ii,
1565 template <
class J>
void _bj_set_jetinfo(
J *
const jet,
1566 const int _jets_index)
const;
1567 void _bj_remove_from_tiles(
TiledJet *
const jet)
const;
1568 template <
class J>
double _bj_dist(
const J *
const jeta,
1569 const J *
const jetb)
const;
1570 template <
class J>
double _bj_diJ(
const J *
const jeta)
const;
1571 template <
class J>
inline J * _bj_of_hindex(
1572 const int hist_index,
1573 J *
const head,
J *
const tail)
1576 for(res = head; res<tail; res++) {
1577 if (_jets[res->_jets_index].cluster_hist_index() == hist_index) {
break;}
1581 template <
class J>
void _bj_set_NN_nocross(
J *
const jeta,
1582 J *
const head,
const J *
const tail)
const;
1583 template <
class J>
void _bj_set_NN_crosscheck(
J *
const jeta,
1584 J *
const head,
const J *
const tail)
const;
1599 return (ieta-_tiles_ieta_min)*_n_tiles_phi
1600 + (iphi+_n_tiles_phi) % _n_tiles_phi;
1602 int _tile_index(
const double eta,
const double phi)
const;
1603 void _tj_set_jetinfo (
TiledJet *
const jet,
const int _jets_index);
1604 void _bj_remove_from_tiles(
TiledJet *
const jet);
1605 void _initialise_tiles();
1606 void _print_tiles(
TiledJet * briefjets )
const;
1607 void _add_neighbours_to_tile_union(
const int tile_index,
1608 std::vector<int> & tile_union,
int & n_near_tiles)
const;
1609 void _add_untagged_neighbours_to_tile_union(
const int tile_index,
1610 std::vector<int> & tile_union,
int & n_near_tiles);
1618 void _simple_N2_cluster_BriefJet();
1619 void _simple_N2_cluster_EEBriefJet();
1622 const std::vector<L> & pseudojets) {
1623 _jets.reserve(pseudojets.size()*2);
1624 for (
unsigned int i = 0;
i < pseudojets.size();
i++) {
1625 _jets.push_back(pseudojets[
i]);}
1628 const std::vector<L> & pseudojets,
1630 const bool & writeout_combinations) :
1631 _jet_def(jet_def_in), _writeout_combinations(writeout_combinations),
1649 std::vector<PseudoJet> jets;
1655 if (jets.size() != 0) {
1664 J *
const jetA,
const int _jets_index)
const {
1665 jetA->eta =
_jets[_jets_index].rap();
1666 jetA->phi =
_jets[_jets_index].phi_02pi();
1668 jetA->_jets_index = _jets_index;
1669 jetA->NN_dist =
_R2;
1673 const J *
const jetA,
const J *
const jetB)
const {
1674 #ifndef FJCORE_NEW_DELTA_PHI
1675 double dphi = std::abs(jetA->phi - jetB->phi);
1676 double deta = (jetA->eta - jetB->eta);
1679 double dphi =
pi-std::abs(
pi-std::abs(jetA->phi - jetB->phi));
1680 double deta = (jetA->eta - jetB->eta);
1682 return dphi*dphi + deta*deta;
1685 double kt2 = jet->kt2;
1686 if (jet->NN != NULL) {
if (jet->NN->kt2 < kt2) {kt2 = jet->NN->kt2;}}
1687 return jet->NN_dist * kt2;
1690 J *
const jet,
J *
const head,
const J *
const tail)
const {
1691 double NN_dist =
_R2;
1694 for (
J * jetB = head; jetB != jet; jetB++) {
1696 if (dist < NN_dist) {
1703 for (
J * jetB = jet+1; jetB != tail; jetB++) {
1705 if (dist < NN_dist) {
1712 jet->NN_dist = NN_dist;
1715 J *
const head,
const J *
const tail)
const {
1716 double NN_dist =
_R2;
1718 for (
J * jetB = head; jetB != tail; jetB++) {
1720 if (dist < NN_dist) {
1724 if (dist < jetB->NN_dist) {
1725 jetB->NN_dist =
dist;
1730 jet->NN_dist = NN_dist;
1733 #endif // __FJCORE_CLUSTERSEQUENCE_HH__
1734 #ifndef __FJCORE_NNBASE_HH__
1735 #define __FJCORE_NNBASE_HH__
1742 template<
class BJ>
void init_jet(BJ * briefjet,
const fjcore::PseudoJet & jet,
int index) { briefjet->init(jet, index,
_info);}
1750 template<
class BJ>
void init_jet(BJ * briefjet,
const fjcore::PseudoJet & jet,
int index) { briefjet->init(jet, index);}
1756 virtual void start(
const std::vector<PseudoJet> & jets) = 0;
1757 virtual double dij_min(
int & iA,
int & iB) = 0;
1763 #endif // __FJCORE_NNBASE_HH__
1764 #ifndef __FJCORE_NNH_HH__
1765 #define __FJCORE_NNH_HH__
1767 template<
class BJ,
class I = _NoInfo>
class NNH :
public NNBase<I> {
1771 void start(
const std::vector<PseudoJet> & jets);
1772 double dij_min(
int & iA,
int & iB);
1798 NN_dist = BJ::beam_distance();
1810 briefjets =
new NNBJ[
n];
1811 where_is.resize(2*
n);
1812 NNBJ * jetA = briefjets;
1813 for (
int i = 0;
i<
n;
i++) {
1814 this->init_jet(jetA, jets[
i], i);
1820 for (jetA = head + 1; jetA != tail; jetA++) {
1821 set_NN_crosscheck(jetA, head, jetA);
1825 double diJ_min = briefjets[0].NN_dist;
1826 int diJ_min_jet = 0;
1827 for (
int i = 1;
i <
n;
i++) {
1828 if (briefjets[
i].NN_dist < diJ_min) {
1830 diJ_min = briefjets[
i].NN_dist;
1833 NNBJ * jetA = & briefjets[diJ_min_jet];
1839 NNBJ * jetA = where_is[iA];
1842 where_is[jetA->
index()] = jetA;
1843 for (
NNBJ * jetI = head; jetI != tail; jetI++) {
1844 if (jetI->NN == jetA) set_NN_nocross(jetI, head, tail);
1845 if (jetI->NN == tail) {jetI->NN = jetA;}
1850 NNBJ * jetA = where_is[iA];
1851 NNBJ * jetB = where_is[iB];
1853 this->init_jet(jetB, jet, index);
1854 if (index >=
int(where_is.size())) where_is.resize(2*index);
1855 where_is[jetB->
index()] = jetB;
1858 where_is[jetA->
index()] = jetA;
1859 for (
NNBJ * jetI = head; jetI != tail; jetI++) {
1860 if (jetI->NN == jetA || jetI->
NN == jetB) {
1861 set_NN_nocross(jetI, head, tail);
1863 double dist = jetI->distance(jetB);
1864 if (dist < jetI->NN_dist) {
1866 jetI->NN_dist =
dist;
1870 if (dist < jetB->NN_dist) {
1876 if (jetI->NN == tail) {jetI->
NN = jetA;}
1881 double NN_dist = jet->beam_distance();
1883 for (
NNBJ * jetB = begin; jetB !=
end; jetB++) {
1884 double dist = jet->distance(jetB);
1885 if (dist < NN_dist) {
1889 if (dist < jetB->NN_dist) {
1899 double NN_dist = jet->beam_distance();
1902 for (
NNBJ * jetB = begin; jetB != jet; jetB++) {
1903 double dist = jet->distance(jetB);
1904 if (dist < NN_dist) {
1911 for (
NNBJ * jetB = jet+1; jetB !=
end; jetB++) {
1912 double dist = jet->distance (jetB);
1913 if (dist < NN_dist) {
1923 #endif // __FJCORE_NNH_HH__