11 return _merged_jets.find(num) == _merged_jets.end();
15 return JetUnmerged(jd.
j1) && JetUnmerged(jd.
j2);
19 vector< pair<JetDistance, double> > popped_distances;
28 while(!_distances.empty()){
31 if(JetsUnmerged(dist)){
37 popped_distances.push_back(make_pair(dist,weight));
39 if(weight/norm < _truncation_fctr)
44 double rand(Rand()), tot_weight(0.);
45 for(vector<pair<JetDistance, double> >::iterator it = popped_distances.begin(); it != popped_distances.end(); it++){
46 tot_weight += (*it).second/norm;
47 if(tot_weight >=
rand){
49 omega *= ((*it).second);
55 for(vector<pair<JetDistance, double> >::reverse_iterator it = popped_distances.rbegin(); it != popped_distances.rend(); it++)
56 if(JetsUnmerged((*it).first))
57 _distances.push((*it).first);
68 ComputeAllDistances(cs.jets());
71 while(!_distances.empty() && jd.dij != -1.){
75 _merged_jets[jd.j1] =
true;
76 _merged_jets[jd.j2] =
true;
79 cs.plugin_record_ij_recombination(jd.j1, jd.j2, 1., new_jet);
80 if(!JetUnmerged(new_jet))
81 edm::LogError(
"QJets Clustering") <<
"Problem with FastJet::plugin_record_ij_recombination";
82 ComputeNewDistanceMeasures(cs,new_jet);
84 double j1pt = cs.jets()[jd.j1].perp();
85 double j2pt = cs.jets()[jd.j2].perp();
88 _merged_jets[jd.j2] =
true;
89 cs.plugin_record_iB_recombination(jd.j2, 1.);
92 _merged_jets[jd.j1] =
true;
93 cs.plugin_record_iB_recombination(jd.j1, 1.);
96 jd = GetNextDistance();
100 cs.plugin_associate_extras(extras);
103 int num_merged_final(0);
104 for(
unsigned int i = 0 ;
i < cs.jets().size();
i++)
107 cs.plugin_record_iB_recombination(
i,1.);
110 if(!(num_merged_final < 2))
111 edm::LogError(
"QJets Clustering") <<
"More than 1 jet remains after reclustering";
116 fastjet::PseudoJet sum(0.,0.,0.,0.);
117 for(vector<fastjet::PseudoJet>::const_iterator it = cs.jets().begin(); it != cs.jets().end(); it++)
119 _dcut = 2. * _dcut_fctr * sum.m()/sum.perp();
123 double pt1 = cs.jets()[jd.
j1].perp();
124 double pt2 = cs.jets()[jd.
j2].perp();
125 fastjet::PseudoJet sum_jet = cs.jets()[jd.
j1]+cs.jets()[jd.
j2];
126 double sum_pt = sum_jet.perp();
127 double z =
min(pt1,pt2)/sum_pt;
128 double d2 = cs.jets()[jd.
j1].plain_distance(cs.jets()[jd.
j2]);
129 return (d2 > _dcut*_dcut) && (z < _zcut);
133 for(
unsigned int i = 0 ;
i < inp.size()-1;
i++){
135 for(
unsigned int j =
i+1 ; j < inp.size(); j++){
140 jd.
dij = d_ij(inp[
i],inp[j]);
149 for(
unsigned int i = 0;
i < cs.jets().size();
i++)
150 if(JetUnmerged(
i) &&
i != new_jet){
154 jd.
dij = d_ij(cs.jets()[jd.
j1], cs.jets()[jd.
j2]);
159 double Qjets::d_ij(
const fastjet::PseudoJet& v1,
const fastjet::PseudoJet& v2)
const{
160 double p1 = v1.perp();
161 double p2 = v2.perp();
162 double ret =
pow(
min(p1,p2),_exp_min) *
pow(
max(p1,p2),_exp_max) * v1.squared_distance(v2);
174 ret = _rnEngine->flat();
void ComputeNewDistanceMeasures(fastjet::ClusterSequence &cs, unsigned int new_jet)
void Cluster(fastjet::ClusterSequence &cs)
bool JetUnmerged(int num) const
void SetRandSeed(unsigned int seed)
constexpr bool isNotFinite(T x)
unique_ptr< ClusterSequence > cs
bool Prune(JetDistance &jd, fastjet::ClusterSequence &cs)
void computeDCut(fastjet::ClusterSequence &cs)
JetDistance GetNextDistance()
double d_ij(const fastjet::PseudoJet &v1, const fastjet::PseudoJet &v2) const
void ComputeAllDistances(const std::vector< fastjet::PseudoJet > &inp)
Power< A, B >::type pow(const A &a, const B &b)
bool JetsUnmerged(const JetDistance &jd) const