64 ClassImp(TMVA::PDEFoamDecisionTree);
69 TMVA::PDEFoamDecisionTree::PDEFoamDecisionTree()
70 : PDEFoamDiscriminant()
85 TMVA::PDEFoamDecisionTree::PDEFoamDecisionTree(
const TString& name, SeparationBase *sepType, UInt_t cls)
86 : PDEFoamDiscriminant(name, cls)
94 TMVA::PDEFoamDecisionTree::PDEFoamDecisionTree(
const PDEFoamDecisionTree &from)
95 : PDEFoamDiscriminant(from)
96 , fSepType(from.fSepType)
98 Log() << kFATAL <<
"COPY CONSTRUCTOR NOT IMPLEMENTED" << Endl;
105 TMVA::PDEFoamDecisionTree::~PDEFoamDecisionTree()
125 void TMVA::PDEFoamDecisionTree::Explore(PDEFoamCell *cell)
128 Log() << kFATAL <<
"<DTExplore> Null pointer given!" << Endl;
131 std::vector<TH1D*> hsig, hbkg, hsig_unw, hbkg_unw;
134 hsig_unw.reserve(fDim);
135 hbkg_unw.reserve(fDim);
136 for (Int_t idim = 0; idim < fDim; idim++) {
137 hsig.push_back(
new TH1D(Form(
"hsig_%i", idim),
138 Form(
"signal[%i]", idim), fNBin, fXmin[idim], fXmax[idim]));
139 hbkg.push_back(
new TH1D(Form(
"hbkg_%i", idim),
140 Form(
"background[%i]", idim), fNBin, fXmin[idim], fXmax[idim]));
141 hsig_unw.push_back(
new TH1D(Form(
"hsig_unw_%i", idim),
142 Form(
"signal_unw[%i]", idim), fNBin, fXmin[idim], fXmax[idim]));
143 hbkg_unw.push_back(
new TH1D(Form(
"hbkg_unw_%i", idim),
144 Form(
"background_unw[%i]", idim), fNBin, fXmin[idim], fXmax[idim]));
148 PDEFoamVect cellSize(GetTotDim()), cellPosi(GetTotDim());
149 cell->GetHcub(cellPosi, cellSize);
152 std::vector<Double_t> lb(GetTotDim());
153 std::vector<Double_t> ub(GetTotDim());
154 for (Int_t idim = 0; idim < GetTotDim(); idim++) {
155 lb[idim] = VarTransformInvers(idim, cellPosi[idim] - std::numeric_limits<float>::epsilon());
156 ub[idim] = VarTransformInvers(idim, cellPosi[idim] + cellSize[idim] + std::numeric_limits<float>::epsilon());
160 PDEFoamDecisionTreeDensity *distr =
dynamic_cast<PDEFoamDecisionTreeDensity*
>(fDistr);
162 Log() << kFATAL <<
"<PDEFoamDecisionTree::Explore>: cast failed: "
163 <<
"PDEFoamDensityBase* --> PDEFoamDecisionTreeDensity*" << Endl;
166 TMVA::Volume volume(&lb, &ub);
169 distr->FillHistograms(volume, hsig, hbkg, hsig_unw, hbkg_unw);
172 Double_t xBest = 0.5;
174 Double_t maxGain = -1.0;
175 Double_t nTotS = hsig.at(0)->Integral(0, hsig.at(0)->GetNbinsX() + 1);
176 Double_t nTotB = hbkg.at(0)->Integral(0, hbkg.at(0)->GetNbinsX() + 1);
177 Double_t nTotS_unw = hsig_unw.at(0)->Integral(0, hsig_unw.at(0)->GetNbinsX() + 1);
178 Double_t nTotB_unw = hbkg_unw.at(0)->Integral(0, hbkg_unw.at(0)->GetNbinsX() + 1);
180 for (Int_t idim = 0; idim < fDim; ++idim) {
181 Double_t nSelS = hsig.at(idim)->GetBinContent(0);
182 Double_t nSelB = hbkg.at(idim)->GetBinContent(0);
183 Double_t nSelS_unw = hsig_unw.at(idim)->GetBinContent(0);
184 Double_t nSelB_unw = hbkg_unw.at(idim)->GetBinContent(0);
185 for (Int_t jLo = 1; jLo < fNBin; jLo++) {
186 nSelS += hsig.at(idim)->GetBinContent(jLo);
187 nSelB += hbkg.at(idim)->GetBinContent(jLo);
188 nSelS_unw += hsig_unw.at(idim)->GetBinContent(jLo);
189 nSelB_unw += hbkg_unw.at(idim)->GetBinContent(jLo);
193 if (!((nSelS_unw + nSelB_unw) >= GetNmin() &&
194 (nTotS_unw - nSelS_unw + nTotB_unw - nSelB_unw) >= GetNmin()))
197 Double_t xLo = 1.0 * jLo / fNBin;
200 Double_t gain = fSepType->GetSeparationGain(nSelS, nSelB, nTotS, nTotB);
202 if (gain >= maxGain) {
210 if (kBest >= fDim || kBest < 0) {
219 cell->SetBest(kBest);
220 cell->SetXdiv(xBest);
221 if (nTotB + nTotS > 0)
222 cell->SetIntg(nTotS / (nTotB + nTotS));
225 cell->SetDriv(maxGain);
231 SetCellElement(cell, 0, nTotS + nTotB);
234 for (UInt_t ih = 0; ih < hsig.size(); ih++)
delete hsig.at(ih);
235 for (UInt_t ih = 0; ih < hbkg.size(); ih++)
delete hbkg.at(ih);
236 for (UInt_t ih = 0; ih < hsig_unw.size(); ih++)
delete hsig_unw.at(ih);
237 for (UInt_t ih = 0; ih < hbkg_unw.size(); ih++)
delete hbkg_unw.at(ih);