PDEFoamCell.cxx

Go to the documentation of this file.
00001 
00002 /**********************************************************************************
00003  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis       *
00004  * Package: TMVA                                                                  *
00005  * Classes: PDEFoamCell                                                           *
00006  * Web    : http://tmva.sourceforge.net                                           *
00007  *                                                                                *
00008  * Description:                                                                   *
00009  *      Objects of this class are hyperrectangular cells organized in             *
00010  *      the binary tree. Special algoritm for encoding relalive                   *
00011  *      positioning of the cells saves total memory allocation needed             *
00012  *      for the system of cells.                                                  *
00013  *                                                                                *
00014  * Authors (alphabetical):                                                        *
00015  *      S. Jadach        - Institute of Nuclear Physics, Cracow, Poland           *
00016  *      Tancredi Carli   - CERN, Switzerland                                      *
00017  *      Dominik Dannheim - CERN, Switzerland                                      *
00018  *      Alexander Voigt  - CERN, Switzerland                                      *
00019  *                                                                                *
00020  * Copyright (c) 2008:                                                            *
00021  *      CERN, Switzerland                                                         *
00022  *      MPI-K Heidelberg, Germany                                                 *
00023  *                                                                                *
00024  * Redistribution and use in source and binary forms, with or without             *
00025  * modification, are permitted according to the terms listed in LICENSE           *
00026  * (http://tmva.sourceforge.net/LICENSE)                                          *
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    // Default constructor for streamer
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    // User constructor allocating single empty Cell
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    // Copy constructor
00097    Error( "PDEFoamCell", "COPY CONSTRUCTOR NOT IMPLEMENTED" );
00098 }
00099 
00100 //_____________________________________________________________________
00101 TMVA::PDEFoamCell::~PDEFoamCell()
00102 {
00103    // Destructor
00104 }
00105 
00106 //_____________________________________________________________________
00107 void TMVA::PDEFoamCell::Fill(Int_t Status, PDEFoamCell *Parent, PDEFoamCell *Daugh1, PDEFoamCell *Daugh2)
00108 {
00109    // Fills in certain data into newly allocated cell
00110 
00111    fStatus  = Status;
00112    fParent  = Parent;
00113    fDaught0 = Daugh1;
00114    fDaught1 = Daugh2;
00115 }
00116 
00117 ////////////////////////////////////////////////////////////////////////////////
00118 //              GETTERS/SETTERS
00119 ////////////////////////////////////////////////////////////////////////////////
00120 
00121 //_____________________________________________________________________
00122 void    TMVA::PDEFoamCell::GetHcub( PDEFoamVect &cellPosi, PDEFoamVect &cellSize)  const
00123 {
00124    // Provides size and position of the cell
00125    // These parameter are calculated by analyzing information in all parents
00126    // cells up to the root cell. It takes time but saves memory.
00127    if(fDim<1) return;
00128    const PDEFoamCell *pCell,*dCell;
00129    cellPosi = 0.0; cellSize=1.0; // load all components
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    }//while
00147 }//GetHcub
00148 
00149 //_____________________________________________________________________
00150 void    TMVA::PDEFoamCell::GetHSize( PDEFoamVect &cellSize)  const
00151 {
00152    // Provides size of the cell
00153    // Size parameters are calculated by analyzing information in all parents
00154    // cells up to the root cell. It takes time but saves memory.
00155    if(fDim<1) return;
00156    const PDEFoamCell *pCell,*dCell;
00157    cellSize=1.0; // load all components
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    }//while
00173 }//GetHSize
00174 
00175 //_____________________________________________________________________
00176 void TMVA::PDEFoamCell::CalcVolume(void)
00177 {
00178    // Calculates volume of the cell using size params which are calculated
00179 
00180    Int_t k;
00181    Double_t volu=1.0;
00182    if(fDim>0) {         // h-cubical subspace
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    // Get depth of cell in binary tree, where the root cell has depth
00194    // 1
00195 
00196    // check wheter we are in the root cell
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    // Printout of the cell geometry parameters for the debug purpose
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) <<"} "; // extra DEBUG
00223    cout <<  " Daught0= {"<< (GetDau0() ? GetDau0()->GetSerial() : -1 )<<"} "; // extra DEBUG
00224    cout <<  " Daught1= {"<< (GetDau1() ? GetDau1()->GetSerial()  : -1 )<<"} "; // extra DEBUG
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 }

Generated on Tue Jul 5 15:25:13 2011 for ROOT_528-00b_version by  doxygen 1.5.1