51 #ifndef ROOT_TMVA_PDEFoamDiscriminant
60 TMVA::PDEFoamDiscriminant::PDEFoamDiscriminant()
80 Log() <<
kFATAL <<
"COPY CONSTRUCTOR NOT IMPLEMENTED" <<
Endl;
91 std::vector<Float_t> values = ev->
GetValues();
92 std::vector<Float_t> tvalues = VarTransform(values);
98 SetCellElement(cell, 0, GetCellElement(cell, 0) + wt);
100 SetCellElement(cell, 1, GetCellElement(cell, 1) + wt);
110 for (
Long_t iCell = 0; iCell <= fLastCe; iCell++) {
111 if (!(fCells[iCell]->GetStat()))
114 Double_t n_sig = GetCellElement(fCells[iCell], 0);
115 Double_t n_bg = GetCellElement(fCells[iCell], 1);
118 Log() <<
kWARNING <<
"Negative number of signal events in cell " << iCell
119 <<
": " << n_sig <<
". Set to 0." <<
Endl;
123 Log() <<
kWARNING <<
"Negative number of background events in cell " << iCell
124 <<
": " << n_bg <<
". Set to 0." <<
Endl;
129 if (n_sig + n_bg > 0) {
131 SetCellElement(fCells[iCell], 0, n_sig / (n_sig + n_bg));
133 SetCellElement(fCells[iCell], 1,
TMath::Sqrt(Sqr(n_sig / Sqr(n_sig + n_bg))*n_sig +
134 Sqr(n_bg / Sqr(n_sig + n_bg))*n_bg));
137 SetCellElement(fCells[iCell], 0, 0.5);
138 SetCellElement(fCells[iCell], 1, 1.);
170 if ((idim1 >= GetTotDim()) || (idim1 < 0) ||
171 (idim2 >= GetTotDim()) || (idim2 < 0) ||
173 Log() <<
kFATAL <<
"<Project2>: wrong dimensions given: "
174 << idim1 <<
", " << idim2 <<
Endl;
180 Log() <<
kWARNING <<
"Warning: number of bins too big: " << nbin
181 <<
" Using 1000 bins for each dimension instead." <<
Endl;
183 }
else if (nbin < 1) {
185 <<
"; set nbin=50" <<
Endl;
195 h1 =
new TH2D(hname.
Data(),
Form(
"var%d vs var%d", idim1, idim2), nbin, fXmin[idim1], fXmax[idim1], nbin, fXmin[idim2], fXmax[idim2]);
197 if (!h1)
Log() <<
kFATAL <<
"ERROR: Can not create histo" << hname <<
Endl;
208 std::map<Int_t, Float_t> txvec;
214 std::vector<TMVA::PDEFoamCell*> cells = FindCells(txvec);
219 for (std::vector<TMVA::PDEFoamCell*>::const_iterator it = cells.begin();
220 it != cells.end(); ++it) {
222 PDEFoamVect cellPosi(GetTotDim()), cellSize(GetTotDim());
223 (*it)->GetHcub(cellPosi, cellSize);
226 std::vector<Float_t> tvec;
227 for (
Int_t i = 0; i < GetTotDim(); ++i) {
228 if (i != idim1 && i != idim2)
229 tvec.push_back(cellPosi[i] + 0.5 * cellSize[i]);
231 tvec.push_back(txvec[i]);
235 if (kernel !=
NULL) {
236 cv = kernel->
Estimate(
this, tvec, cell_value);
238 cv = GetCellValue(FindCell(tvec), cell_value);
240 if (cell_value ==
kValue) {
244 for (
Int_t d1 = 0; d1 < GetTotDim(); ++d1) {
245 if ((d1 != idim1) && (d1 != idim2))
246 area_cell *= cellSize[d1];
MsgLogger & Endl(MsgLogger &ml)
ClassImp(TMVA::PDEFoamDiscriminant) TMVA
Default constructor for streamer, user should not use it.
virtual TH2D * Project2(Int_t, Int_t, ECellValue, PDEFoamKernelBase *, UInt_t)
Project foam variable idim1 and variable idim2 to histogram.
virtual Int_t GetNbinsX() const
const char * Data() const
virtual void SetRangeUser(Double_t ufirst, Double_t ulast)
Set the viewing range for the axis from ufirst to ulast (in user coordinates).
virtual Float_t Estimate(PDEFoam *, std::vector< Float_t > &, ECellValue)=0
TClass * fClass
pointer to the foreign object
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
char * Form(const char *fmt,...)
virtual void Finalize()
Calc discriminator and its error for every cell and save it to the cell.
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
virtual void FillFoamCells(const Event *ev, Float_t wt)
This function fills an event into the discriminant PDEFoam.
virtual Int_t GetNbinsY() const
Abstract ClassifierFactory template that handles arbitrary types.
std::vector< Float_t > & GetValues()
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content.
Double_t Sqrt(Double_t x)
2-D histogram with a double per channel (see TH1 documentation)}