00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include <iostream>
00030 #include <ostream>
00031
00032 #ifndef ROOT_TMVA_PDEFoamCell
00033 #include "TMVA/PDEFoamCell.h"
00034 #endif
00035
00036 using namespace std;
00037
00038 ClassImp(TMVA::PDEFoamCell)
00039
00040
00041 TMVA::PDEFoamCell::PDEFoamCell()
00042 : TObject(),
00043 fDim(0),
00044 fSerial(0),
00045 fStatus(1),
00046 fParent(0),
00047 fDaught0(0),
00048 fDaught1(0),
00049 fXdiv(0.0),
00050 fBest(0),
00051 fVolume(0.0),
00052 fIntegral(0.0),
00053 fDrive(0.0),
00054 fElement(0)
00055 {
00056
00057 }
00058
00059
00060 TMVA::PDEFoamCell::PDEFoamCell(Int_t kDim)
00061 : TObject(),
00062 fDim(kDim),
00063 fSerial(0),
00064 fStatus(1),
00065 fParent(0),
00066 fDaught0(0),
00067 fDaught1(0),
00068 fXdiv(0.0),
00069 fBest(0),
00070 fVolume(0.0),
00071 fIntegral(0.0),
00072 fDrive(0.0),
00073 fElement(0)
00074 {
00075
00076 if ( kDim <= 0 )
00077 Error( "PDEFoamCell", "Dimension has to be >0" );
00078 }
00079
00080
00081 TMVA::PDEFoamCell::PDEFoamCell(const PDEFoamCell &cell)
00082 : TObject(),
00083 fDim (cell.fDim),
00084 fSerial (cell.fSerial),
00085 fStatus (cell.fStatus),
00086 fParent (cell.fParent),
00087 fDaught0 (cell.fDaught0),
00088 fDaught1 (cell.fDaught1),
00089 fXdiv (cell.fXdiv),
00090 fBest (cell.fBest),
00091 fVolume (cell.fVolume),
00092 fIntegral(cell.fIntegral),
00093 fDrive (cell.fDrive),
00094 fElement (cell.fElement)
00095 {
00096
00097 Error( "PDEFoamCell", "COPY CONSTRUCTOR NOT IMPLEMENTED" );
00098 }
00099
00100
00101 TMVA::PDEFoamCell::~PDEFoamCell()
00102 {
00103
00104 }
00105
00106
00107 void TMVA::PDEFoamCell::Fill(Int_t Status, PDEFoamCell *Parent, PDEFoamCell *Daugh1, PDEFoamCell *Daugh2)
00108 {
00109
00110
00111 fStatus = Status;
00112 fParent = Parent;
00113 fDaught0 = Daugh1;
00114 fDaught1 = Daugh2;
00115 }
00116
00117
00118
00119
00120
00121
00122 void TMVA::PDEFoamCell::GetHcub( PDEFoamVect &cellPosi, PDEFoamVect &cellSize) const
00123 {
00124
00125
00126
00127 if(fDim<1) return;
00128 const PDEFoamCell *pCell,*dCell;
00129 cellPosi = 0.0; cellSize=1.0;
00130 dCell = this;
00131 while(dCell != 0) {
00132 pCell = dCell->GetPare();
00133 if( pCell== 0) break;
00134 Int_t kDiv = pCell->fBest;
00135 Double_t xDivi = pCell->fXdiv;
00136 if(dCell == pCell->GetDau0() ) {
00137 cellSize[kDiv] *=xDivi;
00138 cellPosi[kDiv] *=xDivi;
00139 } else if( dCell == pCell->GetDau1() ) {
00140 cellSize[kDiv] *=(1.0-xDivi);
00141 cellPosi[kDiv] =cellPosi[kDiv]*(1.0-xDivi)+xDivi;
00142 } else {
00143 Error( "GetHcub ","Something wrong with linked tree \n");
00144 }
00145 dCell=pCell;
00146 }
00147 }
00148
00149
00150 void TMVA::PDEFoamCell::GetHSize( PDEFoamVect &cellSize) const
00151 {
00152
00153
00154
00155 if(fDim<1) return;
00156 const PDEFoamCell *pCell,*dCell;
00157 cellSize=1.0;
00158 dCell = this;
00159 while(dCell != 0) {
00160 pCell = dCell->GetPare();
00161 if( pCell== 0) break;
00162 Int_t kDiv = pCell->fBest;
00163 Double_t xDivi = pCell->fXdiv;
00164 if(dCell == pCell->GetDau0() ) {
00165 cellSize[kDiv]=cellSize[kDiv]*xDivi;
00166 } else if(dCell == pCell->GetDau1() ) {
00167 cellSize[kDiv]=cellSize[kDiv]*(1.0-xDivi);
00168 } else {
00169 Error( "GetHSize ","Something wrong with linked tree \n");
00170 }
00171 dCell=pCell;
00172 }
00173 }
00174
00175
00176 void TMVA::PDEFoamCell::CalcVolume(void)
00177 {
00178
00179
00180 Int_t k;
00181 Double_t volu=1.0;
00182 if(fDim>0) {
00183 PDEFoamVect cellSize(fDim);
00184 GetHSize(cellSize);
00185 for(k=0; k<fDim; k++) volu *= cellSize[k];
00186 }
00187 fVolume =volu;
00188 }
00189
00190
00191 UInt_t TMVA::PDEFoamCell::GetDepth()
00192 {
00193
00194
00195
00196
00197 if (fParent == 0)
00198 return 1;
00199
00200 UInt_t depth = 1;
00201 PDEFoamCell *cell = this;
00202 while ((cell=cell->GetPare()) != 0){
00203 ++depth;
00204 }
00205 return depth;
00206 }
00207
00208
00209 void TMVA::PDEFoamCell::Print(Option_t *option) const
00210 {
00211
00212
00213 if (!option) Error( "Print", "No option set\n");
00214
00215 cout << " Status= "<< fStatus <<",";
00216 cout << " Volume= "<< fVolume <<",";
00217 cout << " TrueInteg= " << fIntegral <<",";
00218 cout << " DriveInteg= "<< fDrive <<",";
00219 cout << endl;
00220 cout << " Xdiv= "<<fXdiv<<",";
00221 cout << " Best= "<<fBest<<",";
00222 cout << " Parent= {"<< (GetPare() ? GetPare()->GetSerial() : -1) <<"} ";
00223 cout << " Daught0= {"<< (GetDau0() ? GetDau0()->GetSerial() : -1 )<<"} ";
00224 cout << " Daught1= {"<< (GetDau1() ? GetDau1()->GetSerial() : -1 )<<"} ";
00225 cout << endl;
00226
00227
00228 if (fDim>0 ) {
00229 PDEFoamVect cellPosi(fDim); PDEFoamVect cellSize(fDim);
00230 GetHcub(cellPosi,cellSize);
00231 cout <<" Posi= "; cellPosi.Print("1"); cout<<","<< endl;
00232 cout <<" Size= "; cellSize.Print("1"); cout<<","<< endl;
00233 }
00234 }