3 #include "StEtaPhiGrid.h"
5 #include "StConePars.h"
6 #include "StJetEtCellFactory.h"
14 StEtaPhiGrid::~StEtaPhiGrid()
16 for (CellList::iterator cell = _EtCellList.begin(); cell != _EtCellList.end(); ++cell)
22 for(
int i = 0; i < _pars.Neta(); ++i){
24 double etaMin = _pars.EtaMin() +
static_cast<double>(i)*_pars.etaWidth();
25 double etaMax = etaMin + _pars.etaWidth();
27 for(
int j = 0; j < _pars.Nphi(); ++j){
29 double phiMin = _pars.PhiMin() +
static_cast<double>(j)*_pars.phiWidth();
30 double phiMax = phiMin + _pars.phiWidth();
32 StEtaPhiCell* cell = cellFactory->create(etaMin, etaMax, phiMin, phiMax);
34 _EtCellList.push_back(cell);
36 _EtCellMap.insert(CellMapValType(findKey(cell->eta(), cell->phi()), cell));
42 void StEtaPhiGrid::fillGridWith(JetList& protoJetList)
44 for(CellList::iterator etCell = _EtCellList.begin(); etCell != _EtCellList.end(); ++etCell) {
48 for (JetList::iterator protoJet = protoJetList.begin(); protoJet != protoJetList.end(); ++protoJet) {
49 CellMap::iterator where = _EtCellMap.find(findKey((*protoJet).eta(), (*protoJet).phi()));
50 if (where != _EtCellMap.end())
51 (*where).second->addProtoJet(*protoJet);
56 for(CellList::iterator etCell = _EtCellList.begin(); etCell != _EtCellList.end(); ++etCell) {
61 StEtaPhiGrid::CellList StEtaPhiGrid::EtSortedCellList()
67 StEtaPhiGrid::CellList StEtaPhiGrid::WithinTheConeRadiusCellList(
const StEtaPhiCell& theCell)
const
71 StEtGridKey centerKey = findKey(theCell.eta(), theCell.phi());
73 int iEtaMin = centerKey.eta() - _pars.deltaEta();
74 if (iEtaMin < 0) iEtaMin = 0 ;
76 for(
int iEta = iEtaMin; (iEta <= centerKey.eta() + _pars.deltaEta()) && (iEta < _pars.Neta()); ++iEta) {
77 for (
int iPhi = centerKey.phi() - _pars.deltaPhi(); iPhi <= centerKey.phi() + _pars.deltaPhi(); ++iPhi) {
80 if (iModPhi < 0) iModPhi = iModPhi + _pars.Nphi();
81 if (iModPhi >= _pars.Nphi()) iModPhi = iModPhi - _pars.Nphi();
85 if(theCell.distance(*otherCell) >= _pars.coneRadius())
continue;
87 ret.push_back(otherCell);
97 CellMap::iterator it = _EtCellMap.find(findKey(eta, phi));
98 return (it != _EtCellMap.end()) ? (*it).second : 0;
101 StEtaPhiCell* StEtaPhiGrid::CellI(
int iEta,
int iPhi)
const
103 CellMap::const_iterator it = _EtCellMap.find(
StEtGridKey(iEta, iPhi));
104 return (it != _EtCellMap.end()) ? (*it).second : 0;
107 StEtGridKey StEtaPhiGrid::findKey(
double eta,
double phi)
const
109 int iEta = findEtaKey(eta);
110 int iPhi = findPhiKey(phi);
111 if (iEta < 0 || iPhi < 0) {
120 int StEtaPhiGrid::findEtaKey(
double eta)
const
122 return int((_pars.Neta()/(_pars.EtaMax() - _pars.EtaMin()))*(eta - _pars.EtaMin()));
125 int StEtaPhiGrid::findPhiKey(
double phi)
const
127 while(phi > M_PI) phi -= 2*M_PI;
128 while(phi < -M_PI) phi += 2*M_PI;
129 return int( _pars.Nphi()*((phi - _pars.PhiMin())/(_pars.PhiMax() - _pars.PhiMin())));
132 double StEtaPhiGrid::midpoint(
double v1,
double v2)
143 return (high - low)/2. + low;
149 return Cell(midpoint(cell1.eta(), cell2.eta()), midpoint(cell1.phi(), cell2.phi()));