4 #ifndef TRIGTOOLS_TRIG_VSI_VTXMAP
5 #define TRIGTOOLS_TRIG_VSI_VTXMAP
24 #include <unordered_set>
39 template<
typename WrkVrt,
typename Cord>
108 for (
auto& cell_ptr :
v ) n_vtx += cell_ptr->
nVtx();
109 std::vector<const WrkVrt*> tmp_vtx_cls;
110 tmp_vtx_cls.reserve(n_vtx);
113 TVector3 tmp_vec(0.,0.,0.);
114 for (
auto& cell_ptr :
v ) {
115 std::vector<const WrkVrt*> tmp_vtx_cell = cell_ptr->getVtxList();
116 tmp_vtx_cls.insert( tmp_vtx_cls.end(), tmp_vtx_cell.begin(), tmp_vtx_cell.end() );
118 tmp_vec += cell_ptr->getWeight() * cell_ptr->getPosVect();
119 w += cell_ptr->getWeight();
159 void Fill(
const WrkVrt*);
166 inline int getVtxNum(
double,
double,
double)
const;
206 void Fill(
double,
double,
double);
218 template<
typename WrkVrt,
typename Cord>
232 template<
typename WrkVrt,
typename Cord>
235 if ( m_mapHist->GetXaxis()->FindFixBin(
x1) < 1 || m_mapHist->GetXaxis()->FindFixBin(
x1) > m_mapHist->GetNbinsX() )
return false;
236 if ( m_mapHist->GetYaxis()->FindFixBin(
x2) < 1 || m_mapHist->GetYaxis()->FindFixBin(
x2) > m_mapHist->GetNbinsY() )
return false;
237 if ( m_mapHist->GetZaxis()->FindFixBin(x3) < 1 || m_mapHist->GetZaxis()->FindFixBin(x3) > m_mapHist->GetNbinsZ() )
return false;
248 template<
typename WrkVrt,
typename Cord>
251 if ( ibinx < 1 || ibinx > m_mapHist->GetNbinsX() )
return false;
252 if ( ibiny < 1 || ibiny > m_mapHist->GetNbinsY() )
return false;
253 if ( ibinz < 1 || ibinz > m_mapHist->GetNbinsZ() )
return false;
262 template<
typename WrkVrt,
typename Cord>
265 if ( !isInMapVolume(
x,
y,
z) )
return -1;
266 int ibin = m_mapHist->FindFixBin(
x,
y,
z);
267 return m_mapHist->GetBinContent(ibin);
274 template<
typename WrkVrt,
typename Cord>
277 int xbin;
int ybin;
int zbin;
278 m_mapHist->GetBinXYZ(ibin, xbin, ybin, zbin);
279 double x = m_mapHist->GetXaxis()->GetBinCenter(xbin);
280 double y = m_mapHist->GetYaxis()->GetBinCenter(ybin);
281 double z = m_mapHist->GetZaxis()->GetBinCenter(zbin);
293 template<
typename WrkVrt,
typename Cord>
296 if (m_locked)
return;
297 m_mapHist->Fill(
x,
y,
z);
298 m_activeCells.emplace( m_mapHist->FindFixBin(
x,
y,
z) );
307 template<
typename WrkVrt,
typename Cord>
310 if (m_locked)
return;
313 TVector3
vec( vtx_ptr->x(), vtx_ptr->y(), vtx_ptr->z() );
319 if ( !isInMapVolume(
x,
y,
z) )
return;
323 size_t ibin = m_mapHist->FindFixBin(
x,
y,
z);
324 auto cell_itr = m_cellVtxDict.find( ibin );
325 if ( cell_itr != m_cellVtxDict.end() && cell_itr->second.getId() ==
static_cast<int>(ibin) ) {
326 cell_itr->second.emplace_back( vtx_ptr );
329 m_cellVtxDict.emplace( ibin,
Cell(ibin, getBinCenter(ibin), vtx_ptr) );
341 template<
typename WrkVrt,
typename Cord>
347 return getNeighborCells_(glob_bin, eps);
349 m_dbscan =
DBScan<int>(m_activeCells, region_query);
350 m_dbscan.clusterize(eps, minN);
357 template<
typename WrkVrt,
typename Cord>
360 std::vector<int>
tmp;
361 int d =
static_cast<int>(eps);
366 m_mapHist->GetBinXYZ(glob_bin, binx, biny, binz);
370 if ( !(isInMapVolume(binx, biny, binz)) )
return tmp;
372 for (
int ix = binx -
d; ix <= binx +
d; ix++) {
373 for (
int iy = biny -
d; iy <= biny +
d; iy++) {
374 for (
int iz = binz -
d; iz <= binz +
d; iz++) {
376 v_ibin[0] = ix; v_ibin[1] = iy; v_ibin[2] = iz;
379 v_ibin = Cord::ProjBin(v_ibin, m_mapHist);
382 if ( v_ibin[0] == binx && v_ibin[1] == biny && v_ibin[2] == binz )
continue;
385 if ( !(isInMapVolume(v_ibin[0], v_ibin[1], v_ibin[2])) )
continue;
388 if ( m_mapHist->GetBinContent(m_mapHist->GetBin(v_ibin[0], v_ibin[1], v_ibin[2])) < 1. )
continue;
389 tmp.emplace_back(m_mapHist->GetBin(v_ibin[0], v_ibin[1], v_ibin[2]));
402 template<
typename WrkVrt,
typename Cord>
407 std::vector<const WrkVrt*> v_tmp;
408 for (
const auto& ibin :
cls.Points()) {
409 std::vector<const WrkVrt*> v_vtx = m_cellVtxDict[ibin].getVtxList();
410 v_tmp.insert( v_tmp.end(), v_vtx.begin(), v_vtx.end() );
419 template<
typename WrkVrt,
typename Cord>
423 std::vector<Cell*> v_tmp;
425 std::vector<int> cell_ids =
cls.getPoints();
426 for (
const auto ibin : cell_ids) {
428 if ( ibin !=
cell.getId() )
continue;
429 v_tmp.emplace_back( &
cell );