1 #include "../interface/PFJetAlgorithm.h"
17 const vector< PFJetAlgorithm::Jet >&
23 fAssignedVecs.clear();
24 fAssignedVecs.reserve( vecs->size() );
26 fEtOrderedSeeds.clear();
28 for(
unsigned i = 0;
i<vecs->size();
i++) {
30 double et = (*vecs)[
i].Et();
34 fJets.push_back(
Jet(
i, fAllVecs) );
35 fEtOrderedSeeds.insert( make_pair(et, fJets.size()-1) );
38 fAssignedVecs.push_back(assigned);
43 for(
IV iv = fEtOrderedSeeds.begin(); iv != fEtOrderedSeeds.end(); iv++ ) {
45 Jet& currentjet = fJets[iv->second];
52 for(
unsigned i = 0;
i<fAllVecs->size();
i++) {
54 if( fAssignedVecs[
i] > -1 )
continue;
56 double dr =
DeltaR(etaseed, phiseed,
57 (*fAllVecs)[
i].
Eta(), (*fAllVecs)[
i].
Phi());
60 if( dr < fConeAngle) {
63 fAssignedVecs[
i] = iv->second;
79 double deta = eta1 - eta2;
81 return sqrt(deta*deta + dphi*dphi);
88 fEtOrderedSeeds.clear();
89 for(
unsigned ij = 0; ij<fJets.size(); ij++ ) {
90 double et = fJets[ij].GetMomentum().Et();
92 fEtOrderedSeeds.insert( make_pair(et, ij) );
97 for(
unsigned i = 0;
i<fAssignedVecs.size();
i++) {
98 fAssignedVecs[
i] = -1;
102 bool needupdate =
false;
103 for(
IV iv = fEtOrderedSeeds.begin(); iv != fEtOrderedSeeds.end(); iv++ ) {
105 Jet& currentjet = fJets[iv->second];
109 double etaseed = seedmom.Eta();
110 double phiseed = seedmom.Phi();
116 for(
unsigned i = 0;
i<fAllVecs->size();
i++) {
118 if( fAssignedVecs[
i] > -1 )
continue;
120 double dr =
DeltaR(etaseed, phiseed,
121 (*fAllVecs)[
i].
Eta(), (*fAllVecs)[
i].
Phi());
124 if( dr < fConeAngle) {
127 fAssignedVecs[
i] = iv->second;
133 if(deltav.M() > 0.001) needupdate =
true;
136 if(needupdate) Update();
149 vector< PFJetAlgorithm::Jet >
tmp = fJets;
151 map< double, PFJetAlgorithm::Jet, greater<double> > etjets;
154 vector< PFJetAlgorithm::Jet > tmp2;
157 for(
unsigned i=0;
i<tmp.size();
i++) {
158 if( tmp[
i].GetMomentum().Et() > 0 )
160 etjets.insert( make_pair(tmp[
i].GetMomentum().Et(), tmp[
i]) );
204 for(
IJ ij = etjets.begin(); ij != etjets.end(); ij++) {
206 fJets.push_back(ij->second);
261 IJ j1 = etjets.end();
262 IJ j2 = etjets.end();
263 double smallestdistance = 999999;
265 for(
IJ ij = etjets.begin(); ij != etjets.end(); ij++) {
267 const TLorentzVector& mom1 = ij->second.GetMomentum();
269 double eta1 = mom1.Eta();
270 double phi1 = mom1.Phi();
272 for(
IJ jj = etjets.begin();
jj != etjets.end();
jj++) {
274 if(
jj == ij )
continue;
276 const TLorentzVector& mom2 =
jj->second.GetMomentum();
278 double eta2 = mom2.Eta();
279 double phi2 = mom2.Phi();
281 double dr =
DeltaR(eta1, phi1, eta2, phi2);
283 if(dr<smallestdistance) {
284 smallestdistance = dr;
295 if( smallestdistance < fConeMerge ) {
296 j1->second += j2->second;
void MergeJets(std::map< double, PFJetAlgorithm::Jet, std::greater< double > > &etjets)
std::map< double, int, std::greater< double > >::const_iterator IV
double Phi_mpi_pi(double x)
ostream & operator<<(std::ostream &o, vector< std::string > const &iValue)
const std::vector< PFJetAlgorithm::Jet > & FindJets(const std::vector< TLorentzVector > *vecs)
std::map< double, PFJetAlgorithm::Jet, std::greater< double > >::iterator IJ
const TLorentzVector & GetMomentum() const
std::vector< std::vector< double > > tmp
std::vector< int > fVecIndexes
static double DeltaR(double eta1, double phi1, double eta2, double phi2)