45 ClassImp(TMVA::PDEFoamKernelLinN);
50 TMVA::PDEFoamKernelLinN::PDEFoamKernelLinN()
58 TMVA::PDEFoamKernelLinN::PDEFoamKernelLinN(
const PDEFoamKernelLinN &other)
59 : PDEFoamKernelBase(other)
77 Float_t TMVA::PDEFoamKernelLinN::Estimate(PDEFoam *foam, std::vector<Float_t> &txvec, ECellValue cv)
80 Log() << kFATAL <<
"<PDEFoamKernelLinN::Estimate>: PDEFoam not set!" << Endl;
82 return WeightLinNeighbors(foam, txvec, cv, kTRUE);
106 Float_t TMVA::PDEFoamKernelLinN::WeightLinNeighbors(PDEFoam *foam, std::vector<Float_t> &txvec, ECellValue cv, Bool_t treatEmptyCells)
110 const Float_t xoffset = 1.e-6;
112 if (txvec.size() != UInt_t(foam->GetTotDim()))
113 Log() << kFATAL <<
"Wrong dimension of event variable!" << Endl;
116 PDEFoamCell *cell = foam->FindCell(txvec);
117 PDEFoamVect cellSize(foam->GetTotDim());
118 PDEFoamVect cellPosi(foam->GetTotDim());
119 cell->GetHcub(cellPosi, cellSize);
122 if (!(treatEmptyCells && foam->CellValueIsUndefined(cell)))
124 cellval = foam->GetCellValue(cell, cv);
128 cellval = GetAverageNeighborsValue(foam, txvec, cv);
131 for (Int_t dim = 0; dim < foam->GetTotDim(); dim++) {
132 std::vector<Float_t> ntxvec(txvec);
134 PDEFoamCell *mindistcell = 0;
136 mindist = (txvec[dim] - cellPosi[dim]) / cellSize[dim];
138 ntxvec[dim] = cellPosi[dim] - xoffset;
139 mindistcell = foam->FindCell(ntxvec);
141 mindist = 1 - mindist;
142 ntxvec[dim] = cellPosi[dim] + cellSize[dim] + xoffset;
143 mindistcell = foam->FindCell(ntxvec);
146 Float_t mindistcellval = foam->GetCellValue(mindistcell, cv);
149 if (!(treatEmptyCells && foam->CellValueIsUndefined(mindistcell))) {
150 result += cellval * (0.5 + mindist);
151 result += mindistcellval * (0.5 - mindist);
155 if (norm == 0)
return cellval;
156 else return result / norm;
170 Float_t TMVA::PDEFoamKernelLinN::GetAverageNeighborsValue(PDEFoam *foam,
171 std::vector<Float_t> &txvec,
174 const Float_t xoffset = 1.e-6;
178 PDEFoamCell *cell = foam->FindCell(txvec);
179 PDEFoamVect cellSize(foam->GetTotDim());
180 PDEFoamVect cellPosi(foam->GetTotDim());
181 cell->GetHcub(cellPosi, cellSize);
184 for (Int_t dim = 0; dim < foam->GetTotDim(); dim++) {
185 std::vector<Float_t> ntxvec(txvec);
186 PDEFoamCell* left_cell = 0;
187 PDEFoamCell* right_cell = 0;
190 ntxvec[dim] = cellPosi[dim] - xoffset;
191 left_cell = foam->FindCell(ntxvec);
192 if (!foam->CellValueIsUndefined(left_cell)) {
194 result += foam->GetCellValue(left_cell, cv);
198 ntxvec[dim] = cellPosi[dim] + cellSize[dim] + xoffset;
199 right_cell = foam->FindCell(ntxvec);
200 if (!foam->CellValueIsUndefined(right_cell)) {
202 result += foam->GetCellValue(right_cell, cv);
206 if (norm > 0) result /= norm;