CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Attributes
PFJetAlgorithm Class Reference

#include <PFJetAlgorithm.h>

Classes

class  Jet
 

Public Types

typedef std::map< double,
PFJetAlgorithm::Jet,
std::greater< double >
>::iterator 
IJ
 
typedef std::map< double, int,
std::greater< double >
>::const_iterator 
IV
 

Public Member Functions

void CleanUp ()
 
void Clear ()
 
const std::vector
< PFJetAlgorithm::Jet > & 
FindJets (const std::vector< TLorentzVector > *vecs)
 
double GetConeAngle () const
 
const std::vector
< PFJetAlgorithm::Jet > & 
GetJets () const
 
void MergeJets (std::map< double, PFJetAlgorithm::Jet, std::greater< double > > &etjets)
 
 PFJetAlgorithm ()
 
 PFJetAlgorithm (double cone, double et, double conemerge)
 
void SetConeAngle (double coneAngle)
 
void SetConeMerge (double coneMerge)
 
void SetSeedEt (double et)
 
void Update ()
 
virtual ~PFJetAlgorithm ()
 

Static Public Member Functions

static double DeltaR (double eta1, double phi1, double eta2, double phi2)
 

Private Attributes

const std::vector
< TLorentzVector > * 
fAllVecs
 
std::vector< int > fAssignedVecs
 
double fConeAngle
 
double fConeMerge
 
std::map< double, int,
std::greater< double > > 
fEtOrderedSeeds
 
std::vector< PFJetAlgorithm::JetfJets
 
double fSeedEt
 

Detailed Description

Definition at line 11 of file PFJetAlgorithm.h.

Member Typedef Documentation

typedef std::map< double, PFJetAlgorithm::Jet, std::greater<double> >::iterator PFJetAlgorithm::IJ

Definition at line 66 of file PFJetAlgorithm.h.

typedef std::map<double, int, std::greater<double> >::const_iterator PFJetAlgorithm::IV

Definition at line 67 of file PFJetAlgorithm.h.

Constructor & Destructor Documentation

PFJetAlgorithm::PFJetAlgorithm ( )
inline

Definition at line 69 of file PFJetAlgorithm.h.

69 : fConeAngle(0.5), fSeedEt(2), fConeMerge(0.5) {}
PFJetAlgorithm::PFJetAlgorithm ( double  cone,
double  et,
double  conemerge 
)
inline

Definition at line 71 of file PFJetAlgorithm.h.

71  :
72  fConeAngle(cone),
73  fSeedEt(et),
74  fConeMerge(conemerge)
75  {}
virtual PFJetAlgorithm::~PFJetAlgorithm ( )
inlinevirtual

Definition at line 77 of file PFJetAlgorithm.h.

77 {}

Member Function Documentation

void PFJetAlgorithm::CleanUp ( )

Definition at line 141 of file PFJetAlgorithm.cc.

References i, and tmp.

141  {
142 
143  // cout<<"CleanUp : -----------------------------------------"<<endl;
144 
145  // for(unsigned i=0; i<fJets.size(); i++) {
146  // cout<<fJets[i]<<endl;
147  // }
148 
149  vector< PFJetAlgorithm::Jet > tmp = fJets;
150 
151  map< double, PFJetAlgorithm::Jet, greater<double> > etjets;
152  // typedef map< double, PFJetAlgorithm::Jet, greater<double> >::iterator IJ;
153 
154  vector< PFJetAlgorithm::Jet > tmp2;
155  fJets.clear();
156 
157  for(unsigned i=0; i<tmp.size(); i++) {
158  if( tmp[i].GetMomentum().Et() > 0 )
159  // tmp2.push_back( tmp[i]);
160  etjets.insert( make_pair(tmp[i].GetMomentum().Et(), tmp[i]) );
161  }
162 
163  // cout<<"et map : "<<endl;
164  // for(IJ ij = etjets.begin(); ij != etjets.end(); ij++) {
165  // cout<<ij->second<<endl;
166  // }
167 
168  MergeJets( etjets );
169 
170  // for(IJ ij = etjets.begin(); ij != etjets.end(); ij++) {
171 
172  // const TLorentzVector& mom1 = ij->second.GetMomentum();
173 
174  // double eta1 = mom1.Eta();
175  // double phi1 = mom1.Phi();
176 
177  // IJ closest = etjets.end();
178  // double drmin = 99999;
179  // for(IJ jj = etjets.begin(); jj != etjets.end(); jj++) {
180 
181  // if( jj == ij ) continue;
182 
183  // const TLorentzVector& mom2 = jj->second.GetMomentum();
184 
185  // double eta2 = mom2.Eta();
186  // double phi2 = mom2.Phi();
187 
188  // double dr = DeltaR(eta1, phi1, eta2, phi2);
189 
190  // if(dr<drmin) {
191  // drmin = dr;
192  // closest = jj;
193  // }
194 
195  // if(closest != etjets.end() ) {
196  // if ( dr < fConeMerge ) {
197  // ij->second += jj->second;
198  // }
199  // }
200  // }
201  // }
202 
203  // cout<<"et map 2: "<<endl;
204  for(IJ ij = etjets.begin(); ij != etjets.end(); ij++) {
205  // cout<<ij->second<<endl;
206  fJets.push_back(ij->second);
207  }
208 
209  // set<int> used;
210  // for(unsigned i=0; i<tmp2.size(); i++) {
211 
212 
213  // set<int>::iterator isused = used.find(i);
214  // if( isused != used.end() ) continue;
215 
216  // Jet& jet1 = tmp2[i];
217 
218  // // cout<<"\t jet "<<jet1<<endl;
219 
220 
221  // TLorentzVector mom1 = jet1.GetMomentum();
222 
223  // double eta1 = mom1.Eta();
224  // double phi1 = mom1.Phi();
225 
226  // // merge close jets
227  // for(unsigned j=0; j<tmp2.size(); j++) {
228  // if(i==j) continue;
229  // Jet& jet2 = tmp2[j];
230 
231 
232  // TLorentzVector mom2 = jet2.GetMomentum();
233 
234  // double eta2 = mom2.Eta();
235  // double phi2 = mom2.Phi();
236 
237  // double dr = DeltaR(eta1, phi1, eta2, phi2);
238 
239  // // cout<<"\t\t test merge with "<<jet2<<", dr = "<<dr<<endl;
240 
241  // if ( dr < fConeMerge ) {
242  // jet1 += jet2;
243  // used.insert( j );
244  // // cout<<"\t\t yes "<<endl;
245  // }
246  // else {
247  // // cout<<"\t\t no "<<endl;
248  // }
249  // }
250 
251  // used.insert( i );
252  // fJets.push_back(jet1);
253  // }
254 }
int i
Definition: DBlmapReader.cc:9
void MergeJets(std::map< double, PFJetAlgorithm::Jet, std::greater< double > > &etjets)
std::vector< PFJetAlgorithm::Jet > fJets
std::map< double, PFJetAlgorithm::Jet, std::greater< double > >::iterator IJ
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
void PFJetAlgorithm::Clear ( )
inline

Definition at line 92 of file PFJetAlgorithm.h.

References fAssignedVecs, fEtOrderedSeeds, and fJets.

Referenced by PFRootEventManager::tauBenchmark().

92  {
93  fJets.clear();
94  fAssignedVecs.clear();
95  fEtOrderedSeeds.clear();
96  }
std::map< double, int, std::greater< double > > fEtOrderedSeeds
std::vector< PFJetAlgorithm::Jet > fJets
std::vector< int > fAssignedVecs
double PFJetAlgorithm::DeltaR ( double  eta1,
double  phi1,
double  eta2,
double  phi2 
)
static

Definition at line 78 of file PFJetAlgorithm.cc.

References Phi_mpi_pi(), and mathSSE::sqrt().

78  {
79  double deta = eta1 - eta2;
80  double dphi = TVector2::Phi_mpi_pi(phi1 - phi2);
81  return sqrt(deta*deta + dphi*dphi);
82 }
double Phi_mpi_pi(double x)
Definition: JetUtil.h:24
T sqrt(T t)
Definition: SSEVec.h:46
const vector< PFJetAlgorithm::Jet > & PFJetAlgorithm::FindJets ( const std::vector< TLorentzVector > *  vecs)

Definition at line 18 of file PFJetAlgorithm.cc.

References PFJetAlgorithm::Jet::Add(), reco::tau::disc::Eta(), PFJetAlgorithm::Jet::GetMomentum(), i, and colinearityKinematic::Phi.

Referenced by PFRootEventManager::tauBenchmark().

18  {
19 
20 
21  fAllVecs = vecs;
22 
23  fAssignedVecs.clear();
24  fAssignedVecs.reserve( vecs->size() );
25 
26  fEtOrderedSeeds.clear();
27 
28  for(unsigned i = 0; i<vecs->size(); i++) {
29  // cout<<"i = "<<i<<endl;
30  double et = (*vecs)[i].Et();
31 
32  int assigned = -1;
33  if( et >= fSeedEt) {
34  fJets.push_back( Jet(i, fAllVecs) );
35  fEtOrderedSeeds.insert( make_pair(et, fJets.size()-1) );
36  assigned = i;
37  }
38  fAssignedVecs.push_back(assigned);
39  }
40 
41 
42  // loop on seeds
43  for(IV iv = fEtOrderedSeeds.begin(); iv != fEtOrderedSeeds.end(); iv++ ) {
44 
45  Jet& currentjet = fJets[iv->second];
46 
47  double etaseed = currentjet.GetMomentum().Eta();
48  double phiseed = currentjet.GetMomentum().Phi();
49 
50 
51  // adding particles
52  for(unsigned i = 0; i<fAllVecs->size(); i++) {
53 
54  if( fAssignedVecs[i] > -1 ) continue;
55 
56  double dr = DeltaR(etaseed, phiseed,
57  (*fAllVecs)[i].Eta(), (*fAllVecs)[i].Phi());
58  // cout<<"\t\tparticle "<<i<<" "<<dr<<" "<<(*fAllVecs)[i].Et()<<endl;
59 
60  if( dr < fConeAngle) {
61  // cout<<"\t\tadding"<<endl;
62  currentjet.Add(i);
63  fAssignedVecs[i] = iv->second;
64  }
65  }
66 
67  // cout<<"\t seed processed"<<endl;
68  }
69  // cout<<"end find jets"<<endl;
70 
71  Update();
72  CleanUp();
73 
74  return fJets;
75 }
int i
Definition: DBlmapReader.cc:9
std::map< double, int, std::greater< double > >::const_iterator IV
std::map< double, int, std::greater< double > > fEtOrderedSeeds
const std::vector< TLorentzVector > * fAllVecs
std::vector< PFJetAlgorithm::Jet > fJets
std::vector< int > fAssignedVecs
static double DeltaR(double eta1, double phi1, double eta2, double phi2)
double PFJetAlgorithm::GetConeAngle ( ) const
inline

Definition at line 103 of file PFJetAlgorithm.h.

References fConeAngle.

103 { return fConeAngle;}
const std::vector< PFJetAlgorithm::Jet >& PFJetAlgorithm::GetJets ( ) const
inline

Definition at line 104 of file PFJetAlgorithm.h.

References fJets.

104 { return fJets;}
std::vector< PFJetAlgorithm::Jet > fJets
void PFJetAlgorithm::MergeJets ( std::map< double, PFJetAlgorithm::Jet, std::greater< double > > &  etjets)

Definition at line 257 of file PFJetAlgorithm.cc.

References findQualityFiles::jj.

257  {
258 
259  // look for smallest distance between 2 jets :
260 
261  IJ j1 = etjets.end();
262  IJ j2 = etjets.end();
263  double smallestdistance = 999999;
264 
265  for(IJ ij = etjets.begin(); ij != etjets.end(); ij++) {
266 
267  const TLorentzVector& mom1 = ij->second.GetMomentum();
268 
269  double eta1 = mom1.Eta();
270  double phi1 = mom1.Phi();
271 
272  for(IJ jj = etjets.begin(); jj != etjets.end(); jj++) {
273 
274  if( jj == ij ) continue;
275 
276  const TLorentzVector& mom2 = jj->second.GetMomentum();
277 
278  double eta2 = mom2.Eta();
279  double phi2 = mom2.Phi();
280 
281  double dr = DeltaR(eta1, phi1, eta2, phi2);
282 
283  if(dr<smallestdistance) {
284  smallestdistance = dr;
285  j1 = ij;
286  j2 = jj;
287  }
288  }
289  }
290 
291  // cout<<"smallest distance is between : "<<endl;
292  // cout<<j1->second<<endl;
293  // cout<<j2->second<<endl;
294 
295  if( smallestdistance < fConeMerge ) {
296  j1->second += j2->second;
297  etjets.erase(j2);
298 
299  MergeJets( etjets );
300  }
301 }
void MergeJets(std::map< double, PFJetAlgorithm::Jet, std::greater< double > > &etjets)
std::map< double, PFJetAlgorithm::Jet, std::greater< double > >::iterator IJ
static double DeltaR(double eta1, double phi1, double eta2, double phi2)
void PFJetAlgorithm::SetConeAngle ( double  coneAngle)
inline

Definition at line 83 of file PFJetAlgorithm.h.

References fConeAngle.

Referenced by PFRootEventManager::readOptions().

83 {fConeAngle = coneAngle;}
void PFJetAlgorithm::SetConeMerge ( double  coneMerge)
inline

Definition at line 85 of file PFJetAlgorithm.h.

References fConeMerge.

Referenced by PFRootEventManager::readOptions().

85 {fConeMerge = coneMerge;}
void PFJetAlgorithm::SetSeedEt ( double  et)
inline

Definition at line 84 of file PFJetAlgorithm.h.

References fSeedEt.

Referenced by PFRootEventManager::readOptions().

84 {fSeedEt = et;}
void PFJetAlgorithm::Update ( )

Definition at line 85 of file PFJetAlgorithm.cc.

References PFJetAlgorithm::Jet::Add(), PFJetAlgorithm::Jet::Clear(), reco::tau::disc::Eta(), PFJetAlgorithm::Jet::GetMomentum(), i, and colinearityKinematic::Phi.

85  {
86  // use existing jets as seeds
87  // cout<<"clearing seeds"<<endl;
88  fEtOrderedSeeds.clear();
89  for(unsigned ij = 0; ij<fJets.size(); ij++ ) {
90  double et = fJets[ij].GetMomentum().Et();
91  if(et >= fSeedEt)
92  fEtOrderedSeeds.insert( make_pair(et, ij) );
93  }
94 
95  // loop on seeds and add particles
96  // cout<<"clearing assigned"<<endl;
97  for(unsigned i = 0; i<fAssignedVecs.size(); i++) {
98  fAssignedVecs[i] = -1;
99  }
100 
101  // cout<<"loop on seeds"<<endl;
102  bool needupdate = false;
103  for(IV iv = fEtOrderedSeeds.begin(); iv != fEtOrderedSeeds.end(); iv++ ) {
104 
105  Jet& currentjet = fJets[iv->second];
106 
107  TLorentzVector seedmom = currentjet.GetMomentum();
108 
109  double etaseed = seedmom.Eta();
110  double phiseed = seedmom.Phi();
111  // cout<<"SEED\t"<<etaseed<<" "<<phiseed<<endl;
112 
113  currentjet.Clear();
114 
115  // adding particles
116  for(unsigned i = 0; i<fAllVecs->size(); i++) {
117 
118  if( fAssignedVecs[i] > -1 ) continue;
119 
120  double dr = DeltaR(etaseed, phiseed,
121  (*fAllVecs)[i].Eta(), (*fAllVecs)[i].Phi());
122  // cout<<"\t\tparticle "<<i<<" "<<dr<<" "<<(*fAllVecs)[i].Et()<<endl;
123 
124  if( dr < fConeAngle) {
125  // cout<<"\t\tadding"<<endl;
126  currentjet.Add(i);
127  fAssignedVecs[i] = iv->second;
128  }
129  }
130 
131  TLorentzVector deltav = currentjet.GetMomentum();
132  deltav -= seedmom;
133  if(deltav.M() > 0.001) needupdate = true;
134  }
135 
136  if(needupdate) Update();
137 }
int i
Definition: DBlmapReader.cc:9
std::map< double, int, std::greater< double > >::const_iterator IV
std::map< double, int, std::greater< double > > fEtOrderedSeeds
const std::vector< TLorentzVector > * fAllVecs
std::vector< PFJetAlgorithm::Jet > fJets
std::vector< int > fAssignedVecs
static double DeltaR(double eta1, double phi1, double eta2, double phi2)

Member Data Documentation

const std::vector<TLorentzVector>* PFJetAlgorithm::fAllVecs
private

Definition at line 52 of file PFJetAlgorithm.h.

std::vector< int > PFJetAlgorithm::fAssignedVecs
private

Definition at line 54 of file PFJetAlgorithm.h.

Referenced by Clear().

double PFJetAlgorithm::fConeAngle
private

Definition at line 58 of file PFJetAlgorithm.h.

Referenced by GetConeAngle(), and SetConeAngle().

double PFJetAlgorithm::fConeMerge
private

Definition at line 60 of file PFJetAlgorithm.h.

Referenced by SetConeMerge().

std::map<double, int, std::greater<double> > PFJetAlgorithm::fEtOrderedSeeds
private

Definition at line 55 of file PFJetAlgorithm.h.

Referenced by Clear().

std::vector< PFJetAlgorithm::Jet > PFJetAlgorithm::fJets
private

Definition at line 53 of file PFJetAlgorithm.h.

Referenced by Clear(), and GetJets().

double PFJetAlgorithm::fSeedEt
private

Definition at line 59 of file PFJetAlgorithm.h.

Referenced by SetSeedEt().