#include <iostream>
#include <ostream>
#ifndef ROOT_TMVA_PDEFoamCell
#include "TMVA/PDEFoamCell.h"
#endif
using namespace std;
ClassImp(TMVA::PDEFoamCell)
TMVA::PDEFoamCell::PDEFoamCell()
: TObject(),
fDim(0),
fSerial(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),
fSerial(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)
{
if ( kDim <= 0 )
Error( "PDEFoamCell", "Dimension has to be >0" );
}
TMVA::PDEFoamCell::PDEFoamCell(const PDEFoamCell &cell)
: TObject(),
fDim (cell.fDim),
fSerial (cell.fSerial),
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;
}
UInt_t TMVA::PDEFoamCell::GetDepth()
{
if (fParent == 0)
return 1;
UInt_t depth = 1;
PDEFoamCell *cell = this;
while ((cell=cell->GetPare()) != 0){
++depth;
}
return depth;
}
UInt_t TMVA::PDEFoamCell::GetTreeDepth(UInt_t depth)
{
if (GetStat() == 1)
return depth + 1;
UInt_t depth0 = 0, depth1 = 0;
if (GetDau0() != NULL)
depth0 = GetDau0()->GetTreeDepth(depth+1);
if (GetDau1() != NULL)
depth1 = GetDau1()->GetTreeDepth(depth+1);
return (depth0 > depth1 ? depth0 : depth1);
}
void TMVA::PDEFoamCell::Print(Option_t *option) const
{
if (!option) Error( "Print", "No option set\n");
std::cout << " Status= "<< fStatus <<",";
std::cout << " Volume= "<< fVolume <<",";
std::cout << " TrueInteg= " << fIntegral <<",";
std::cout << " DriveInteg= "<< fDrive <<",";
std::cout << std::endl;;
std::cout << " Xdiv= "<<fXdiv<<",";
std::cout << " Best= "<<fBest<<",";
std::cout << " Parent= {"<< (GetPare() ? GetPare()->GetSerial() : -1) <<"} ";
std::cout << " Daught0= {"<< (GetDau0() ? GetDau0()->GetSerial() : -1 )<<"} ";
std::cout << " Daught1= {"<< (GetDau1() ? GetDau1()->GetSerial() : -1 )<<"} ";
std::cout << std::endl;;
if (fDim>0 ) {
PDEFoamVect cellPosi(fDim); PDEFoamVect cellSize(fDim);
GetHcub(cellPosi,cellSize);
std::cout <<" Posi= "; cellPosi.Print("1"); std::cout<<","<< std::endl;;
std::cout <<" Size= "; cellSize.Print("1"); std::cout<<","<< std::endl;;
}
}