stablejet is hosted by Hepforge, IPPP Durham
StableJet
DiffusionDistFastJet.cc
1 
2 #include <cfloat>
3 #include <iostream>
4 
5 #include "DiffusionDistFastJet.h"
6 
7 #include "fastjet/NNH.hh"
8 
9 namespace stab {
10 
11 class DiffBriefJet {
12 public:
13  void init(const fastjet::PseudoJet &jet ) {
14  pt = jet.pt();
15  eta = jet.eta();
16  phi = jet.phi();
17  }
18 
19  double distance( const DiffBriefJet *jt ) const {
20  double dEta = eta - jt->eta;
21  double dPhi = deltaPhi(phi,jt->phi);
22  double ratio = ( pt < jt->pt ? pt : jt->pt ) / ( pt < jt->pt ? jt->pt : pt );
23  return sqrt(dEta*dEta+dPhi*dPhi) * diffusionFactor2(ratio);
24  }
25 
26  double beam_distance() const {
27  return DBL_MAX;
28  }
29 
30 private:
31  double pt,eta,phi;
32 
33  inline double deltaPhi(const double phi1, const double phi2) const {
34  double dPhi = phi1 - phi2;
35  while ( dPhi < -M_PI )
36  dPhi += 2.*M_PI;
37  while ( dPhi > M_PI )
38  dPhi -= 2.*M_PI;
39 
40  return dPhi;
41  }
42 
43 };
44 
45 void DiffusionDistFastJet::run_clustering(ClusterSequence &seq) const
46 {
47  // This function should fill the rest of the ClusterSequence using it member function
48  // plugin_do_ij_recombination()
49  // plugin_do_iB_recombination()
50 
51  // follow the example of the EECambridgePlugin included in the FastJet package
52 
53  int njets = seq.jets().size();
54  fastjet::NNH<DiffBriefJet> nnh(seq.jets());
55 
56  // the ClusterSequence has already been filled with the initial event
57  const std::vector<PseudoJet> & initialEvent = seq.jets();
58 
59  double dij=-1;
60  while ( njets > 1 ) {
61  int i,j,k;
62  dij = nnh.dij_min(i,j); // i,j are return values
63 
64  if ( j >=0 ) {
65  seq.plugin_record_ij_recombination(i,j,dij,k);
66  nnh.merge_jets(i,j,seq.jets()[k],k);
67  njets--;
68  } else {
69  seq.plugin_record_iB_recombination(i,dij);
70  nnh.remove_jet(i);
71  }
72 
73  }
74 
75  const std::vector<fastjet::ClusterSequence::history_element> & history = seq.history();
76  const unsigned histSize = history.size();
77  for ( unsigned h=0; h != histSize; h++ ) {
78  const fastjet::ClusterSequence::history_element & el = history[h];
79 
80  // if child node is < 0, marke as final state jet by doing a beam merge
81  if ( el.child < 0 ) {
82  seq.plugin_record_iB_recombination(h,DBL_MAX);
83  nnh.remove_jet(h);
84  }
85 
86  }
87 
88 
89 }
90 
91 
92 } // end stab namespace