2 #include "StConeJetFinder.h"
4 #include "StJetSpliterMerger.h"
9 using namespace StSpinJet;
11 StConeJetFinder::StConeJetFinder(
const StConePars& pars)
15 mMerger->setSplitFraction(mPars.splitFraction());
18 StConeJetFinder::~StConeJetFinder()
28 void StConeJetFinder::findJets(JetList& protoJetList,
const FourVecList& particleList)
32 CellList orderedCellList = generateEtOrderedCellList(particleList);
34 CellList toSearchCellList = generateToSearchListFrom(orderedCellList);
36 CellList protoJetCellList = findProtoJetsAroundCells(toSearchCellList);
38 if (mPars.addMidpoints()) {
39 CellList midpointList = generateMidpointList(protoJetCellList);
41 CellList midpointProtoJetCellList = findProtoJetsAroundMidpoints(midpointList);
43 protoJetCellList.insert(protoJetCellList.end(), midpointProtoJetCellList.begin(), midpointProtoJetCellList.end());
46 if (mPars.doSplitMerge()) {
50 storeTheResults(protoJetList, protoJetCellList);
54 StEtaPhiCell::CellList StConeJetFinder::generateEtOrderedCellList(
const FourVecList& particleList)
58 for(FourVecList::const_iterator particle = particleList.begin(); particle != particleList.end(); ++particle) {
62 _cellGrid.fillGridWith(protoJetList);
63 return _cellGrid.EtSortedCellList();
66 StEtaPhiCell::CellList StConeJetFinder::findProtoJetsAroundCells(CellList& toSearchList)
68 CellList protoJetCellList;
70 for (CellList::iterator cell = toSearchList.begin(); cell != toSearchList.end(); ++cell) {
72 if (shouldNotSearchForJetAroundThis((*cell)))
continue;
75 protoJetCellList.push_back(jetCell);
79 return protoJetCellList;
85 initializeWorkCell(cell);
87 if (mPars.performMinimization()) {
88 return findJetWithStableCone();
99 for(CellList::iterator etCell = cell.cellList().begin(); etCell != cell.cellList().end(); ++etCell) {
101 cell.setEt(cell.Et() + (*etCell)->eT());
104 _toDelete.push_back(ret);
108 void StConeJetFinder::deleteToDelete()
110 for(vector<StEtaPhiCell*>::iterator it = _toDelete.begin(); it != _toDelete.end(); ++it)
117 bool StConeJetFinder::shouldNotSearchForJetAroundThis(
const StEtaPhiCell* cell)
const
119 if (cell->empty())
return true;
124 StEtaPhiCell::CellList StConeJetFinder::generateMidpointList(
const CellList& protoJetCellList)
126 CellList midpointList;
128 for (CellList::const_iterator pj1 = protoJetCellList.begin(); pj1 != protoJetCellList.end(); ++pj1) {
129 for (CellList::const_iterator pj2 = pj1; pj2 != protoJetCellList.end(); ++pj2) {
131 if ((*pj1)->isSamePosition(**pj2))
continue;
133 if ((*pj1)->distance(**pj2) > 2.0*mPars.coneRadius())
continue;
135 midpointList.push_back(_cellGrid.findMidpointCell(**pj1, **pj2));
142 StEtaPhiCell::CellList StConeJetFinder::findProtoJetsAroundMidpoints(CellList& midpointList)
145 for (CellList::iterator it = midpointList.begin(); it != midpointList.end(); ++it) {
147 initializeWorkCell(*it);
150 if (mPars.requiredStableMidpoints()) {
152 if (isInTheVolume(centroid.eta(), centroid.phi())) {
153 if(areTheyInTheSameCell(
mWorkCell->eta(),
mWorkCell->phi(), centroid.eta(), centroid.phi())) {
154 ret.push_back(createJetCellFor(*
mWorkCell));
158 ret.push_back(createJetCellFor(*
mWorkCell));
166 if (otherCell.empty())
return true;
167 if (otherCell.eT() <= mPars.assocEtMin())
return true;
171 void StConeJetFinder::storeTheResults(JetList& protoJetList,
const CellList& protoJetCellList)
173 protoJetList.clear();
175 for (CellList::const_iterator jet = protoJetCellList.begin(); jet != protoJetCellList.end(); ++jet) {
177 if ((*jet)->cellList().size() == 0)
continue;
179 protoJetList.push_back( collectCell(*jet) );
187 static const int maxAttempt = 100;
189 int _searchCounter = 0;
193 if (++_searchCounter > maxAttempt)
break;
199 if (!isInTheVolume(centroid.eta(), centroid.phi()))
break;
201 if(areTheyInTheSameCell(
mWorkCell->eta(),
mWorkCell->phi(), centroid.eta(), centroid.phi())) {
207 if (!newCenterCell)
break;
209 initializeWorkCell(newCenterCell);
217 bool StConeJetFinder::isInTheVolume(
double eta,
double phi)
219 return (_cellGrid.Cell(eta, phi)) ?
true :
false;
222 bool StConeJetFinder::areTheyInTheSameCell(
double eta1,
double phi1,
double eta2,
double phi2)
224 return(_cellGrid.Cell(eta1, phi1)->isSamePosition(*_cellGrid.Cell(eta2, phi2)));
void splitMerge(CellList &jets)
action
StEtaPhiCell * mWorkCell
run-time pars