Go to the documentation of this file.00001
00002
00003
00004 #include "RecoParticleFlow/PFRootEvent/interface/CMSIterativeConeAlgorithm.h"
00005
00006 #include <list>
00007
00008 #include "DataFormats/Candidate/interface/Candidate.h"
00009 #include "DataFormats/Math/interface/deltaR.h"
00010 #include "RecoParticleFlow/PFRootEvent/interface/ProtoJet.h"
00011 #include "RecoParticleFlow/PFRootEvent/interface/JetAlgoHelper.h"
00012 using namespace std;
00013 using namespace reco;
00014 using namespace JetReco;
00015
00016
00017
00018
00019
00020 void CMSIterativeConeAlgorithm::run(const InputCollection& fInput, OutputCollection* fOutput) const {
00021 if (!fOutput) return;
00022
00023 list<InputItem> input;
00024 for (InputCollection::const_iterator towerIter = fInput.begin();
00025 towerIter != fInput.end(); ++towerIter) {
00026 input.push_back(*towerIter);
00027 }
00028 GreaterByEtRef <InputItem> compCandidate;
00029 input.sort(compCandidate);
00030
00031
00032 while( !input.empty() && input.front()->et() > theSeedThreshold ) {
00033
00034 double eta0=input.front()->eta();
00035 double phi0=input.front()->phi();
00036
00037 double eta=0;
00038 double phi=0;
00039 double et=0;
00040
00041 list< list<InputItem>::iterator> cone;
00042 for(int iteration=0;iteration<100;iteration++){
00043 cone.clear();
00044 eta=0;
00045 phi=0;
00046 et=0;
00047 for(list<InputItem>::iterator inp=input.begin();
00048 inp!=input.end();inp++){
00049 InputItem tower = *inp;
00050 if( deltaR2(eta0,phi0,tower->eta(),tower->phi()) <
00051 theConeRadius*theConeRadius) {
00052 cone.push_back(inp);
00053 eta+= tower->et()*tower->eta();
00054 double dphi=tower->phi()-phi0;
00055 if(dphi>M_PI) dphi-=2*M_PI;
00056 else if(dphi<=-M_PI) dphi+=2*M_PI;
00057 phi+=tower->et()*dphi;
00058 et +=tower->et();
00059 }
00060 }
00061 eta=eta/et;
00062 phi=phi0+phi/et;
00063 if(phi>M_PI)phi-=2*M_PI;
00064 else if(phi<=-M_PI)phi+=2*M_PI;
00065
00066 if(fabs(eta-eta0)<.001 && fabs(phi-phi0)<.001) break;
00067 eta0=eta;
00068 phi0=phi;
00069 }
00070
00071
00072 InputCollection jetConstituents;
00073 list< list<InputItem>::iterator>::const_iterator inp;
00074 for(inp=cone.begin();inp!=cone.end();inp++) {
00075 jetConstituents.push_back(**inp);
00076 input.erase(*inp);
00077 }
00078 fOutput->push_back (ProtoJet (jetConstituents));
00079
00080 }
00081 GreaterByPt<ProtoJet> compJets;
00082 sort (fOutput->begin (), fOutput->end (), compJets);
00083 }
00084