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 
4 
5 #include <list>
6 
11 using namespace std;
12 using namespace reco;
13 using namespace JetReco;
14 
15 
16 
17 // Run the algorithm
18 // ------------------
20  if (!fOutput) return;
21  //make a list of input objects ordered by ET
22  list<InputItem> input;
23  for (InputCollection::const_iterator towerIter = fInput.begin();
24  towerIter != fInput.end(); ++towerIter) {
25  input.push_back(*towerIter);
26  }
27  GreaterByEtRef <InputItem> compCandidate;
28  input.sort(compCandidate);
29 
30  //find jets
31  while( !input.empty() && input.front()->et() > theSeedThreshold ) {
32  //cone centre
33  double eta0=input.front()->eta();
34  double phi0=input.front()->phi();
35  //protojet properties
36  double eta=0;
37  double phi=0;
38  double et=0;
39  //list of towers in cone
40  list< list<InputItem>::iterator> cone;
41  for(int iteration=0;iteration<100;iteration++){
42  cone.clear();
43  eta=0;
44  phi=0;
45  et=0;
46  for(list<InputItem>::iterator inp=input.begin();
47  inp!=input.end();inp++){
48  InputItem tower = *inp;
49  if( deltaR2(eta0,phi0,tower->eta(),tower->phi()) <
50  theConeRadius*theConeRadius) {
51  cone.push_back(inp);
52  eta+= tower->et()*tower->eta();
53  double dphi=tower->phi()-phi0;
54  if(dphi>M_PI) dphi-=2*M_PI;
55  else if(dphi<=-M_PI) dphi+=2*M_PI;
56  phi+=tower->et()*dphi;
57  et +=tower->et();
58  }
59  }
60  eta=eta/et;
61  phi=phi0+phi/et;
62  if(phi>M_PI)phi-=2*M_PI;
63  else if(phi<=-M_PI)phi+=2*M_PI;
64 
65  if(fabs(eta-eta0)<.001 && fabs(phi-phi0)<.001) break;//stable cone found
66  eta0=eta;
67  phi0=phi;
68  }
69 
70  //make a final jet and remove the jet constituents from the input list
71  InputCollection jetConstituents;
72  list< list<InputItem>::iterator>::const_iterator inp;
73  for(inp=cone.begin();inp!=cone.end();inp++) {
74  jetConstituents.push_back(**inp);
75  input.erase(*inp);
76  }
77  fOutput->push_back (ProtoJet (jetConstituents));
78 
79  } //loop over seeds ended
80  GreaterByPt<ProtoJet> compJets;
81  sort (fOutput->begin (), fOutput->end (), compJets);
82 }
83 
std::vector< ProtoJet > OutputCollection
Definition: JetRecoTypes.h:62
virtual double et() const =0
transverse energy
virtual float eta() const =0
momentum pseudorapidity
std::vector< InputItem > InputCollection
Definition: JetRecoTypes.h:61
virtual float phi() const =0
momentum azimuthal angle
Transient Jet class used by the reconstruction algorithms.
Definition: ProtoJet.h:25
T eta() const
static std::string const input
Definition: EdmProvDump.cc:44
tuple iteration
Definition: align_cfg.py:5
double deltaR2(const Vector1 &v1, const Vector2 &v2)
Definition: VectorUtil.h:78
#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.
Definition: DDAxes.h:10