4 #ifndef TRIGTOOLS_TRIG_VSI_VTXMAP 
    5 #define TRIGTOOLS_TRIG_VSI_VTXMAP 
   21 #include <unordered_set> 
   24 #include <type_traits> 
   37 template<
typename WrkVrt, 
typename Cord>
 
  106                for ( 
auto& cell_ptr : 
v ) n_vtx += cell_ptr->
nVtx();
 
  107                std::vector<const WrkVrt*> tmp_vtx_cls;
 
  108                tmp_vtx_cls.reserve(n_vtx);
 
  111                TVector3 tmp_vec(0.,0.,0.);
 
  112                for ( 
auto& cell_ptr : 
v ) {
 
  113                   std::vector<const WrkVrt*> tmp_vtx_cell = cell_ptr->getVtxList();
 
  114                   tmp_vtx_cls.insert( tmp_vtx_cls.end(), tmp_vtx_cell.begin(), tmp_vtx_cell.end() );
 
  116                   tmp_vec += cell_ptr->getWeight() * cell_ptr->getPosVect();
 
  117                   w += cell_ptr->getWeight();
 
  157       void          Fill(
const WrkVrt*);
 
  164       inline int  getVtxNum(
double, 
double, 
double) 
const;
 
  204       void  Fill(
double, 
double, 
double);
 
  216 template<
typename WrkVrt, 
typename Cord>
 
  230 template<
typename WrkVrt, 
typename Cord>
 
  233    if ( m_mapHist->GetXaxis()->FindFixBin(
x1) < 1 || m_mapHist->GetXaxis()->FindFixBin(
x1) > m_mapHist->GetNbinsX() ) 
return false;
 
  234    if ( m_mapHist->GetYaxis()->FindFixBin(
x2) < 1 || m_mapHist->GetYaxis()->FindFixBin(
x2) > m_mapHist->GetNbinsY() ) 
return false;
 
  235    if ( m_mapHist->GetZaxis()->FindFixBin(x3) < 1 || m_mapHist->GetZaxis()->FindFixBin(x3) > m_mapHist->GetNbinsZ() ) 
return false;
 
  246 template<
typename WrkVrt, 
typename Cord>
 
  249    if ( ibinx < 1 || ibinx > m_mapHist->GetNbinsX() ) 
return false;
 
  250    if ( ibiny < 1 || ibiny > m_mapHist->GetNbinsY() ) 
return false;
 
  251    if ( ibinz < 1 || ibinz > m_mapHist->GetNbinsZ() ) 
return false;
 
  260 template<
typename WrkVrt, 
typename Cord>
 
  263    if ( !isInMapVolume(
x, 
y, 
z) ) 
return -1;
 
  264    int ibin = m_mapHist->FindFixBin(
x, 
y, 
z);
 
  265    return m_mapHist->GetBinContent(ibin);
 
  272 template<
typename WrkVrt, 
typename Cord>
 
  275    int xbin; 
int ybin; 
int zbin;
 
  276    m_mapHist->GetBinXYZ(ibin, xbin, ybin, zbin);
 
  277    double x = m_mapHist->GetXaxis()->GetBinCenter(xbin);
 
  278    double y = m_mapHist->GetYaxis()->GetBinCenter(ybin);
 
  279    double z = m_mapHist->GetZaxis()->GetBinCenter(zbin);
 
  291 template<
typename WrkVrt, 
typename Cord>
 
  294    if (m_locked)  
return;
 
  295    m_mapHist->Fill(
x, 
y, 
z);
 
  296    m_activeCells.emplace( m_mapHist->FindFixBin(
x, 
y, 
z) );
 
  305 template<
typename WrkVrt, 
typename Cord>
 
  308    if (m_locked)  
return;
 
  311    TVector3 
vec( vtx_ptr->x(), vtx_ptr->y(), vtx_ptr->z() );
 
  317    if ( !isInMapVolume(
x,
y,
z) ) 
return;
 
  321    size_t ibin = m_mapHist->FindFixBin(
x, 
y, 
z);
 
  322    auto cell_itr = m_cellVtxDict.find( ibin );
 
  323    if ( cell_itr != m_cellVtxDict.end() && cell_itr->second.getId() == 
static_cast<int>(ibin) ) {
 
  324       cell_itr->second.emplace_back( vtx_ptr );
 
  327       m_cellVtxDict.emplace( ibin, 
Cell(ibin, getBinCenter(ibin), vtx_ptr) );
 
  339 template<
typename WrkVrt, 
typename Cord>
 
  345                                              return getNeighborCells_(glob_bin, eps);
 
  347    m_dbscan = 
DBScan<int>(m_activeCells, region_query);
 
  348    m_dbscan.clusterize(eps, minN);
 
  355 template<
typename WrkVrt, 
typename Cord>
 
  358    std::vector<int> 
tmp;
 
  359    int d = 
static_cast<int>(eps);
 
  364    m_mapHist->GetBinXYZ(glob_bin, binx, biny, binz);
 
  368    if ( !(isInMapVolume(binx, biny, binz)) ) 
return tmp;
 
  370    for (
int ix = binx - 
d; ix <= binx + 
d; ix++) {
 
  371       for (
int iy = biny - 
d; iy <= biny + 
d; iy++) {
 
  372          for (
int iz = binz - 
d; iz <= binz + 
d; iz++) {
 
  374             v_ibin[0] = ix; v_ibin[1] = iy; v_ibin[2] = iz;
 
  377             v_ibin = Cord::ProjBin(v_ibin, m_mapHist);
 
  380             if ( v_ibin[0] == binx && v_ibin[1] == biny && v_ibin[2] == binz ) 
continue;
 
  383             if ( !(isInMapVolume(v_ibin[0], v_ibin[1], v_ibin[2])) ) 
continue;
 
  386             if ( m_mapHist->GetBinContent(m_mapHist->GetBin(v_ibin[0], v_ibin[1], v_ibin[2])) < 1. ) 
continue;
 
  387             tmp.emplace_back(m_mapHist->GetBin(v_ibin[0], v_ibin[1], v_ibin[2]));
 
  400 template<
typename WrkVrt, 
typename Cord>
 
  405    std::vector<const WrkVrt*> v_tmp;
 
  406    for (
const auto& ibin : 
cls.Points()) {
 
  407       std::vector<const WrkVrt*> v_vtx = m_cellVtxDict[ibin].getVtxList();
 
  408       v_tmp.insert( v_tmp.end(), v_vtx.begin(), v_vtx.end() );
 
  417 template<
typename WrkVrt, 
typename Cord>
 
  421    std::vector<Cell*> v_tmp;
 
  423    std::vector<int> cell_ids = 
cls.getPoints();
 
  424    for (
const auto ibin : cell_ids) {
 
  426       if ( ibin != 
cell.getId() ) 
continue;
 
  427       v_tmp.emplace_back( &
cell );