00001
00002 #include "StKtCluJetFinder.h"
00003
00004
00005 #include <cmath>
00006 #include <float.h>
00007
00008
00009 #include "TObject.h"
00010
00011
00012 #include "FourVec.h"
00013 #include "StProtoJet.h"
00014 #include "StProtoJetPair.h"
00015 #include "StJetFinder.h"
00016
00017
00018 using namespace std;
00019
00020
00021 StKtCluJetFinder::StKtCluJetFinder(const StKtCluPars& pars) : mPars(pars)
00022 {
00023 cout <<"StKtCluJetFinder::StKtCluJetFinder()"<<endl;
00024 }
00025
00026 StKtCluJetFinder::~StKtCluJetFinder()
00027 {
00028 cout <<"StKtCluJetFinder::~StKtCluJetFinder()"<<endl;
00029 }
00030
00031 void StKtCluJetFinder::Init()
00032 {
00033
00034 }
00035
00036 void StKtCluJetFinder::findJets(JetList& pj, const FourVecList& particleList)
00037 {
00038 pj.clear();
00039
00040 for(FourVecList::const_iterator particle = particleList.begin(); particle != particleList.end(); ++particle) {
00041 pj.push_back(StProtoJet(*particle));
00042 }
00043
00044 if (pj.size()<2) return;
00045
00046 mJets.clear();
00047 int nSteps = 0;
00048
00049 while (pj.empty()==false) {
00050
00051 if ( mPars.debug() ) {
00052 cout <<"\n --- protojets after clustering "<<nSteps<<" steps"<<endl;
00053 for (JetList::const_iterator it3=pj.begin(); it3!=pj.end(); ++it3) {
00054 cout <<*it3<<endl;
00055 }
00056 cout <<" --- jets after clustering "<<nSteps<<" steps"<<endl;
00057 for (JetList::const_iterator it4=mJets.begin(); it4!=mJets.end(); ++it4) {
00058 cout <<*it4<<endl;
00059 }
00060
00061 }
00062
00063
00064 double d_min_pj = DBL_MAX;
00065 JetList::iterator bestProto=pj.end();
00066
00067
00068 for (JetList::iterator protoIt=pj.begin(); protoIt!=pj.end(); ++protoIt) {
00069 double d = (*protoIt).d();
00070 if (d<d_min_pj) {
00071 bestProto = protoIt;
00072 d_min_pj = d;
00073 }
00074 }
00075
00076
00077 double d_min_jets = DBL_MAX;
00078 JetList::iterator bestJet1=pj.end();
00079 JetList::iterator bestJet2=pj.end();
00080
00081 for (JetList::iterator jetIt1=pj.begin(); jetIt1!=pj.end(); ++jetIt1) {
00082 for (JetList::iterator jetIt2=jetIt1; jetIt2!=pj.end(); ++jetIt2) {
00083 if (jetIt1!=jetIt2) {
00084 StProtoJetPair myPair(*jetIt1, *jetIt2, mPars.r());
00085 double d = myPair.d();
00086 if (d < d_min_jets) {
00087 d_min_jets=d;
00088 bestJet1 = jetIt1;
00089 bestJet2 = jetIt2;
00090 }
00091 }
00092 }
00093 }
00094
00095
00096
00097 if (d_min_pj < d_min_jets) {
00098
00099
00100
00101 if (bestProto==pj.end()) {
00102 cout <<"StJetFinder::findJets(). ERROR:\t"
00103 <<"Trying to use protojet iterator that doesn't exist"<<endl;
00104 }
00105 (*bestProto).update();
00106 mJets.push_back(*bestProto);
00107 pj.erase(bestProto);
00108 }
00109
00110
00111 else {
00112
00113
00114 if (bestJet1==pj.end() || bestJet2==pj.end()) {
00115 cout <<"StJetFinder::findJets(). ERROR:\t"
00116 <<"Trying to use 2 protojet iterators, one doesn't exist"<<endl;
00117 }
00118 (*bestJet1).merge(*bestJet2);
00119 pj.erase(bestJet2);
00120 }
00121
00122
00123
00124
00125
00126
00127 ++nSteps;
00128 }
00129
00130
00131 for (JetList::iterator it=mJets.begin(); it!=mJets.end(); ++it) {
00132 pj.push_back(*it);
00133 }
00134
00135 }