45 ClassImp(TMVA::PDEFoamKernelGauss);
50 TMVA::PDEFoamKernelGauss::PDEFoamKernelGauss(Float_t sigma)
59 TMVA::PDEFoamKernelGauss::PDEFoamKernelGauss(
const PDEFoamKernelGauss &other)
60 : PDEFoamKernelBase(other)
61 , fSigma(other.fSigma)
79 Float_t TMVA::PDEFoamKernelGauss::Estimate(PDEFoam *foam, std::vector<Float_t> &txvec, ECellValue cv)
82 Log() << kFATAL <<
"<PDEFoamKernelGauss::Estimate>: PDEFoam not set!" << Endl;
84 Float_t result = 0, norm = 0;
86 for (Long_t iCell = 0; iCell <= foam->fLastCe; iCell++) {
87 if (!(foam->fCells[iCell]->GetStat()))
continue;
91 if (!foam->CellValueIsUndefined(foam->fCells[iCell]))
93 cell_val = foam->GetCellValue(foam->fCells[iCell], cv);
96 cell_val = GetAverageNeighborsValue(foam, txvec, cv);
99 Float_t gau = WeightGaus(foam, foam->fCells[iCell], txvec);
101 result += gau * cell_val;
105 return (norm != 0 ? result / norm : 0);
119 Float_t TMVA::PDEFoamKernelGauss::GetAverageNeighborsValue(PDEFoam *foam,
120 std::vector<Float_t> &txvec,
123 const Float_t xoffset = 1.e-6;
127 PDEFoamCell *cell = foam->FindCell(txvec);
128 PDEFoamVect cellSize(foam->GetTotDim());
129 PDEFoamVect cellPosi(foam->GetTotDim());
130 cell->GetHcub(cellPosi, cellSize);
133 for (Int_t dim = 0; dim < foam->GetTotDim(); dim++) {
134 std::vector<Float_t> ntxvec(txvec);
135 PDEFoamCell* left_cell = 0;
136 PDEFoamCell* right_cell = 0;
139 ntxvec[dim] = cellPosi[dim] - xoffset;
140 left_cell = foam->FindCell(ntxvec);
141 if (!foam->CellValueIsUndefined(left_cell)) {
143 result += foam->GetCellValue(left_cell, cv);
147 ntxvec[dim] = cellPosi[dim] + cellSize[dim] + xoffset;
148 right_cell = foam->FindCell(ntxvec);
149 if (!foam->CellValueIsUndefined(right_cell)) {
151 result += foam->GetCellValue(right_cell, cv);
155 if (norm > 0) result /= norm;
182 Float_t TMVA::PDEFoamKernelGauss::WeightGaus(PDEFoam *foam, PDEFoamCell* cell,
183 std::vector<Float_t> &txvec)
186 PDEFoamVect cellSize(foam->GetTotDim());
187 PDEFoamVect cellPosi(foam->GetTotDim());
188 cell->GetHcub(cellPosi, cellSize);
191 std::vector<Float_t> cell_center;
192 cell_center.reserve(foam->GetTotDim());
193 for (Int_t i = 0; i < foam->GetTotDim(); ++i) {
194 if (txvec[i] < 0.) txvec[i] = 0.;
195 if (txvec[i] > 1.) txvec[i] = 1.;
197 if (cellPosi[i] > txvec.at(i))
198 cell_center.push_back(cellPosi[i]);
199 else if (cellPosi[i] + cellSize[i] < txvec.at(i))
200 cell_center.push_back(cellPosi[i] + cellSize[i]);
202 cell_center.push_back(txvec.at(i));
205 Float_t distance = 0;
206 for (Int_t i = 0; i < foam->GetTotDim(); ++i)
207 distance += Sqr(txvec.at(i) - cell_center.at(i));
208 distance = TMath::Sqrt(distance);
211 return TMath::Gaus(distance, 0, fSigma, kFALSE);