#include <ostream>
#ifndef ROOT_TMVA_PDEFoamCell
#include "TMVA/PDEFoamCell.h"
#endif
using namespace std;
ClassImp(TMVA::PDEFoamCell)
TMVA::PDEFoamCell::PDEFoamCell()
: TObject(),
fDim(0),
fStatus(1),
fParent(0),
fDaught0(0),
fDaught1(0),
fXdiv(0.0),
fBest(0),
fVolume(0.0),
fIntegral(0.0),
fDrive(0.0),
fElement(0)
{
}
TMVA::PDEFoamCell::PDEFoamCell(Int_t kDim)
: TObject(),
fDim(kDim),
fStatus(1),
fParent(0),
fDaught0(0),
fDaught1(0),
fXdiv(0.0),
fBest(0),
fVolume(0.0),
fIntegral(0.0),
fDrive(0.0),
fElement(0)
{
if ( kDim <= 0 )
Error( "PDEFoamCell", "Dimension has to be >0" );
}
TMVA::PDEFoamCell::PDEFoamCell(const PDEFoamCell &cell)
: TObject(),
fDim (cell.fDim),
fStatus (cell.fStatus),
fParent (cell.fParent),
fDaught0 (cell.fDaught0),
fDaught1 (cell.fDaught1),
fXdiv (cell.fXdiv),
fBest (cell.fBest),
fVolume (cell.fVolume),
fIntegral(cell.fIntegral),
fDrive (cell.fDrive),
fElement (cell.fElement)
{
Error( "PDEFoamCell", "COPY CONSTRUCTOR NOT IMPLEMENTED" );
}
TMVA::PDEFoamCell::~PDEFoamCell()
{
}
void TMVA::PDEFoamCell::Fill(Int_t Status, PDEFoamCell *Parent, PDEFoamCell *Daugh1, PDEFoamCell *Daugh2)
{
fStatus = Status;
fParent = Parent;
fDaught0 = Daugh1;
fDaught1 = Daugh2;
}
void TMVA::PDEFoamCell::GetHcub( PDEFoamVect &cellPosi, PDEFoamVect &cellSize) const
{
if(fDim<1) return;
const PDEFoamCell *pCell,*dCell;
cellPosi = 0.0; cellSize=1.0;
dCell = this;
while(dCell != 0) {
pCell = dCell->GetPare();
if( pCell== 0) break;
Int_t kDiv = pCell->fBest;
Double_t xDivi = pCell->fXdiv;
if(dCell == pCell->GetDau0() ) {
cellSize[kDiv] *=xDivi;
cellPosi[kDiv] *=xDivi;
} else if( dCell == pCell->GetDau1() ) {
cellSize[kDiv] *=(1.0-xDivi);
cellPosi[kDiv] =cellPosi[kDiv]*(1.0-xDivi)+xDivi;
} else {
Error( "GetHcub ","Something wrong with linked tree \n");
}
dCell=pCell;
}
}
void TMVA::PDEFoamCell::GetHSize( PDEFoamVect &cellSize) const
{
if(fDim<1) return;
const PDEFoamCell *pCell,*dCell;
cellSize=1.0;
dCell = this;
while(dCell != 0) {
pCell = dCell->GetPare();
if( pCell== 0) break;
Int_t kDiv = pCell->fBest;
Double_t xDivi = pCell->fXdiv;
if(dCell == pCell->GetDau0() ) {
cellSize[kDiv]=cellSize[kDiv]*xDivi;
} else if(dCell == pCell->GetDau1() ) {
cellSize[kDiv]=cellSize[kDiv]*(1.0-xDivi);
} else {
Error( "GetHSize ","Something wrong with linked tree \n");
}
dCell=pCell;
}
}
void TMVA::PDEFoamCell::CalcVolume(void)
{
Int_t k;
Double_t volu=1.0;
if(fDim>0) {
PDEFoamVect cellSize(fDim);
GetHSize(cellSize);
for(k=0; k<fDim; k++) volu *= cellSize[k];
}
fVolume =volu;
}
void TMVA::PDEFoamCell::Print(Option_t *option) const
{
if (!option) Error( "Print", "No option set\n");
cout << " Status= "<< fStatus <<",";
cout << " Volume= "<< fVolume <<",";
cout << " TrueInteg= " << fIntegral <<",";
cout << " DriveInteg= "<< fDrive <<",";
cout << endl;
cout << " Xdiv= "<<fXdiv<<",";
cout << " Best= "<<fBest<<",";
cout << " Parent= {"<< (GetPare() ? GetPare()->GetSerial() : -1) <<"} ";
cout << " Daught0= {"<< (GetDau0() ? GetDau0()->GetSerial() : -1 )<<"} ";
cout << " Daught1= {"<< (GetDau1() ? GetDau1()->GetSerial() : -1 )<<"} ";
cout << endl;
if (fDim>0 ) {
PDEFoamVect cellPosi(fDim); PDEFoamVect cellSize(fDim);
GetHcub(cellPosi,cellSize);
cout <<" Posi= "; cellPosi.Print("1"); cout<<","<< endl;
cout <<" Size= "; cellSize.Print("1"); cout<<","<< endl;
}
}