#ifndef ROOT_TMVA_PDEFoamKernelLinN
#include "TMVA/PDEFoamKernelLinN.h"
#endif
ClassImp(TMVA::PDEFoamKernelLinN)
TMVA::PDEFoamKernelLinN::PDEFoamKernelLinN()
: PDEFoamKernelBase()
{
}
TMVA::PDEFoamKernelLinN::PDEFoamKernelLinN(const PDEFoamKernelLinN &other)
: PDEFoamKernelBase(other)
{
}
Float_t TMVA::PDEFoamKernelLinN::Estimate(PDEFoam *foam, std::vector<Float_t> &txvec, ECellValue cv)
{
if (foam == NULL)
Log() << kFATAL << "<PDEFoamKernelLinN::Estimate>: PDEFoam not set!" << Endl;
return WeightLinNeighbors(foam, txvec, cv, kTRUE);
}
Float_t TMVA::PDEFoamKernelLinN::WeightLinNeighbors(PDEFoam *foam, std::vector<Float_t> &txvec, ECellValue cv, Bool_t treatEmptyCells)
{
Float_t result = 0.;
UInt_t norm = 0;
const Float_t xoffset = 1.e-6;
if (txvec.size() != UInt_t(foam->GetTotDim()))
Log() << kFATAL << "Wrong dimension of event variable!" << Endl;
PDEFoamCell *cell = foam->FindCell(txvec);
PDEFoamVect cellSize(foam->GetTotDim());
PDEFoamVect cellPosi(foam->GetTotDim());
cell->GetHcub(cellPosi, cellSize);
Float_t cellval = 0;
if (!(treatEmptyCells && foam->CellValueIsUndefined(cell)))
cellval = foam->GetCellValue(cell, cv);
else
cellval = GetAverageNeighborsValue(foam, txvec, cv);
for (Int_t dim = 0; dim < foam->GetTotDim(); dim++) {
std::vector<Float_t> ntxvec(txvec);
Float_t mindist;
PDEFoamCell *mindistcell = 0;
mindist = (txvec[dim] - cellPosi[dim]) / cellSize[dim];
if (mindist < 0.5) {
ntxvec[dim] = cellPosi[dim] - xoffset;
mindistcell = foam->FindCell(ntxvec);
} else {
mindist = 1 - mindist;
ntxvec[dim] = cellPosi[dim] + cellSize[dim] + xoffset;
mindistcell = foam->FindCell(ntxvec);
}
Float_t mindistcellval = foam->GetCellValue(mindistcell, cv);
if (!(treatEmptyCells && foam->CellValueIsUndefined(mindistcell))) {
result += cellval * (0.5 + mindist);
result += mindistcellval * (0.5 - mindist);
norm++;
}
}
if (norm == 0) return cellval;
else return result / norm;
}
Float_t TMVA::PDEFoamKernelLinN::GetAverageNeighborsValue(PDEFoam *foam,
std::vector<Float_t> &txvec,
ECellValue cv)
{
const Float_t xoffset = 1.e-6;
Float_t norm = 0;
Float_t result = 0;
PDEFoamCell *cell = foam->FindCell(txvec);
PDEFoamVect cellSize(foam->GetTotDim());
PDEFoamVect cellPosi(foam->GetTotDim());
cell->GetHcub(cellPosi, cellSize);
for (Int_t dim = 0; dim < foam->GetTotDim(); dim++) {
std::vector<Float_t> ntxvec(txvec);
PDEFoamCell* left_cell = 0;
PDEFoamCell* right_cell = 0;
ntxvec[dim] = cellPosi[dim] - xoffset;
left_cell = foam->FindCell(ntxvec);
if (!foam->CellValueIsUndefined(left_cell)) {
result += foam->GetCellValue(left_cell, cv);
norm++;
}
ntxvec[dim] = cellPosi[dim] + cellSize[dim] + xoffset;
right_cell = foam->FindCell(ntxvec);
if (!foam->CellValueIsUndefined(right_cell)) {
result += foam->GetCellValue(right_cell, cv);
norm++;
}
}
if (norm > 0) result /= norm;
else result = 0;
return result;
}
PDEFoamKernelLinN.cxx:100 PDEFoamKernelLinN.cxx:101 PDEFoamKernelLinN.cxx:102 PDEFoamKernelLinN.cxx:103 PDEFoamKernelLinN.cxx:104 PDEFoamKernelLinN.cxx:105 PDEFoamKernelLinN.cxx:106 PDEFoamKernelLinN.cxx:107 PDEFoamKernelLinN.cxx:108 PDEFoamKernelLinN.cxx:109 PDEFoamKernelLinN.cxx:110 PDEFoamKernelLinN.cxx:111 PDEFoamKernelLinN.cxx:112 PDEFoamKernelLinN.cxx:113 PDEFoamKernelLinN.cxx:114 PDEFoamKernelLinN.cxx:115 PDEFoamKernelLinN.cxx:116 PDEFoamKernelLinN.cxx:117 PDEFoamKernelLinN.cxx:118 PDEFoamKernelLinN.cxx:119 PDEFoamKernelLinN.cxx:120 PDEFoamKernelLinN.cxx:121 PDEFoamKernelLinN.cxx:122 PDEFoamKernelLinN.cxx:123 PDEFoamKernelLinN.cxx:124 PDEFoamKernelLinN.cxx:125 PDEFoamKernelLinN.cxx:126 PDEFoamKernelLinN.cxx:127 PDEFoamKernelLinN.cxx:128 PDEFoamKernelLinN.cxx:129 PDEFoamKernelLinN.cxx:130 PDEFoamKernelLinN.cxx:131 PDEFoamKernelLinN.cxx:132 PDEFoamKernelLinN.cxx:133 PDEFoamKernelLinN.cxx:134 PDEFoamKernelLinN.cxx:135 PDEFoamKernelLinN.cxx:136 PDEFoamKernelLinN.cxx:137 PDEFoamKernelLinN.cxx:138 PDEFoamKernelLinN.cxx:139 PDEFoamKernelLinN.cxx:140 PDEFoamKernelLinN.cxx:141 PDEFoamKernelLinN.cxx:142 PDEFoamKernelLinN.cxx:143 PDEFoamKernelLinN.cxx:144 PDEFoamKernelLinN.cxx:145 PDEFoamKernelLinN.cxx:146 PDEFoamKernelLinN.cxx:147 PDEFoamKernelLinN.cxx:148 PDEFoamKernelLinN.cxx:149 PDEFoamKernelLinN.cxx:150 PDEFoamKernelLinN.cxx:151 PDEFoamKernelLinN.cxx:152 PDEFoamKernelLinN.cxx:153 PDEFoamKernelLinN.cxx:154 PDEFoamKernelLinN.cxx:155 PDEFoamKernelLinN.cxx:156 PDEFoamKernelLinN.cxx:157 PDEFoamKernelLinN.cxx:158 PDEFoamKernelLinN.cxx:159 PDEFoamKernelLinN.cxx:160 PDEFoamKernelLinN.cxx:161 PDEFoamKernelLinN.cxx:162 PDEFoamKernelLinN.cxx:163 PDEFoamKernelLinN.cxx:164 PDEFoamKernelLinN.cxx:165 PDEFoamKernelLinN.cxx:166 PDEFoamKernelLinN.cxx:167 PDEFoamKernelLinN.cxx:168 PDEFoamKernelLinN.cxx:169 PDEFoamKernelLinN.cxx:170 PDEFoamKernelLinN.cxx:171 PDEFoamKernelLinN.cxx:172 PDEFoamKernelLinN.cxx:173 PDEFoamKernelLinN.cxx:174 PDEFoamKernelLinN.cxx:175 PDEFoamKernelLinN.cxx:176 PDEFoamKernelLinN.cxx:177 PDEFoamKernelLinN.cxx:178 PDEFoamKernelLinN.cxx:179 PDEFoamKernelLinN.cxx:180 PDEFoamKernelLinN.cxx:181 PDEFoamKernelLinN.cxx:182 PDEFoamKernelLinN.cxx:183 PDEFoamKernelLinN.cxx:184 PDEFoamKernelLinN.cxx:185 PDEFoamKernelLinN.cxx:186 PDEFoamKernelLinN.cxx:187 PDEFoamKernelLinN.cxx:188 PDEFoamKernelLinN.cxx:189 PDEFoamKernelLinN.cxx:190 PDEFoamKernelLinN.cxx:191 PDEFoamKernelLinN.cxx:192 PDEFoamKernelLinN.cxx:193 PDEFoamKernelLinN.cxx:194 PDEFoamKernelLinN.cxx:195 PDEFoamKernelLinN.cxx:196 PDEFoamKernelLinN.cxx:197 PDEFoamKernelLinN.cxx:198 PDEFoamKernelLinN.cxx:199 PDEFoamKernelLinN.cxx:200 PDEFoamKernelLinN.cxx:201 PDEFoamKernelLinN.cxx:202 PDEFoamKernelLinN.cxx:203