CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CMSIterativeConeAlgorithm.cc
Go to the documentation of this file.
1 // Original author: A. Ulyanov
2 // $Id: CMSIterativeConeAlgorithm.cc,v 1.14 2008/02/29 01:02:30 fedor Exp $
3 
5 
6 #include <list>
7 
12 using namespace std;
13 using namespace reco;
14 using namespace JetReco;
15 
16 
17 
18 // Run the algorithm
19 // ------------------
21  if (!fOutput) return;
22  //make a list of input objects ordered by ET
23  list<InputItem> input;
24  for (InputCollection::const_iterator towerIter = fInput.begin();
25  towerIter != fInput.end(); ++towerIter) {
26  input.push_back(*towerIter);
27  }
28  GreaterByEtRef <InputItem> compCandidate;
29  input.sort(compCandidate);
30 
31  //find jets
32  while( !input.empty() && input.front()->et() > theSeedThreshold ) {
33  //cone centre
34  double eta0=input.front()->eta();
35  double phi0=input.front()->phi();
36  //protojet properties
37  double eta=0;
38  double phi=0;
39  double et=0;
40  //list of towers in cone
41  list< list<InputItem>::iterator> cone;
42  for(int iteration=0;iteration<100;iteration++){
43  cone.clear();
44  eta=0;
45  phi=0;
46  et=0;
47  for(list<InputItem>::iterator inp=input.begin();
48  inp!=input.end();inp++){
49  InputItem tower = *inp;
50  if( deltaR2(eta0,phi0,tower->eta(),tower->phi()) <
51  theConeRadius*theConeRadius) {
52  cone.push_back(inp);
53  eta+= tower->et()*tower->eta();
54  double dphi=tower->phi()-phi0;
55  if(dphi>M_PI) dphi-=2*M_PI;
56  else if(dphi<=-M_PI) dphi+=2*M_PI;
57  phi+=tower->et()*dphi;
58  et +=tower->et();
59  }
60  }
61  eta=eta/et;
62  phi=phi0+phi/et;
63  if(phi>M_PI)phi-=2*M_PI;
64  else if(phi<=-M_PI)phi+=2*M_PI;
65 
66  if(fabs(eta-eta0)<.001 && fabs(phi-phi0)<.001) break;//stable cone found
67  eta0=eta;
68  phi0=phi;
69  }
70 
71  //make a final jet and remove the jet constituents from the input list
72  InputCollection jetConstituents;
73  list< list<InputItem>::iterator>::const_iterator inp;
74  for(inp=cone.begin();inp!=cone.end();inp++) {
75  jetConstituents.push_back(**inp);
76  input.erase(*inp);
77  }
78  fOutput->push_back (ProtoJet (jetConstituents));
79 
80  } //loop over seeds ended
81  GreaterByPt<ProtoJet> compJets;
82  sort (fOutput->begin (), fOutput->end (), compJets);
83 }
84 
std::vector< ProtoJet > OutputCollection
Definition: JetRecoTypes.h:63
virtual double et() const =0
transverse energy
std::vector< InputItem > InputCollection
Definition: JetRecoTypes.h:62
Transient Jet class used by the reconstruction algorithms.
Definition: ProtoJet.h:25
T eta() const
tuple iteration
Definition: align_cfg.py:5
double deltaR2(const Vector1 &v1, const Vector2 &v2)
Definition: VectorUtil.h:78
tuple input
Definition: collect_tpl.py:10
#define M_PI
Definition: BFit3D.cc:3
void run(const JetReco::InputCollection &fInput, JetReco::OutputCollection *fOutput) const
Find the ProtoJets from the collection of input Candidates.
virtual double phi() const =0
momentum azimuthal angle
virtual double eta() const =0
momentum pseudorapidity
Definition: DDAxes.h:10