ROOT  6.06/09
Reference Guide
PDEFoamCell.cxx
Go to the documentation of this file.
1 // @(#)root/tmva $Id$
2 // Author: S.Jadach, Tancredi Carli, Dominik Dannheim, Alexander Voigt
3 
4 /**********************************************************************************
5  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6  * Package: TMVA *
7  * Classes: PDEFoamCell *
8  * Web : http://tmva.sourceforge.net *
9  * *
10  * Description: *
11  * Objects of this class are hyperrectangular cells organized in *
12  * the binary tree. Special algoritm for encoding relalive *
13  * positioning of the cells saves total memory allocation needed *
14  * for the system of cells. *
15  * *
16  * Authors (alphabetical): *
17  * S. Jadach - Institute of Nuclear Physics, Cracow, Poland *
18  * Tancredi Carli - CERN, Switzerland *
19  * Dominik Dannheim - CERN, Switzerland *
20  * Alexander Voigt - TU Dresden, Germany *
21  * *
22  * Copyright (c) 2008: *
23  * CERN, Switzerland *
24  * MPI-K Heidelberg, Germany *
25  * *
26  * Redistribution and use in source and binary forms, with or without *
27  * modification, are permitted according to the terms listed in LICENSE *
28  * (http://tmva.sourceforge.net/LICENSE) *
29  **********************************************************************************/
30 
31 #include <iostream>
32 #include <ostream>
33 
34 #ifndef ROOT_TMVA_PDEFoamCell
35 #include "TMVA/PDEFoamCell.h"
36 #endif
37 
38 using namespace std;
39 
41 
42 ////////////////////////////////////////////////////////////////////////////////
43 /// Default constructor for streamer
44 
45 TMVA::PDEFoamCell::PDEFoamCell()
46  : TObject(),
47  fDim(0),
48  fSerial(0),
49  fStatus(1),
50  fParent(0),
51  fDaught0(0),
52  fDaught1(0),
53  fXdiv(0.0),
54  fBest(0),
55  fVolume(0.0),
56  fIntegral(0.0),
57  fDrive(0.0),
58  fElement(0)
59 {
60 }
61 
62 ////////////////////////////////////////////////////////////////////////////////
63 /// User constructor allocating single empty Cell
64 
66  : TObject(),
67  fDim(kDim),
68  fSerial(0),
69  fStatus(1),
70  fParent(0),
71  fDaught0(0),
72  fDaught1(0),
73  fXdiv(0.0),
74  fBest(0),
75  fVolume(0.0),
76  fIntegral(0.0),
77  fDrive(0.0),
78  fElement(0)
79 {
80  if ( kDim <= 0 )
81  Error( "PDEFoamCell", "Dimension has to be >0" );
82 }
83 
84 ////////////////////////////////////////////////////////////////////////////////
85 /// Copy constructor
86 
88  : TObject(),
89  fDim (cell.fDim),
90  fSerial (cell.fSerial),
91  fStatus (cell.fStatus),
92  fParent (cell.fParent),
93  fDaught0 (cell.fDaught0),
94  fDaught1 (cell.fDaught1),
95  fXdiv (cell.fXdiv),
96  fBest (cell.fBest),
97  fVolume (cell.fVolume),
98  fIntegral(cell.fIntegral),
99  fDrive (cell.fDrive),
100  fElement (cell.fElement)
101 {
102  Error( "PDEFoamCell", "COPY CONSTRUCTOR NOT IMPLEMENTED" );
103 }
104 
105 ////////////////////////////////////////////////////////////////////////////////
106 /// Destructor
107 
109 {
110 }
111 
112 ////////////////////////////////////////////////////////////////////////////////
113 /// Fills in certain data into newly allocated cell
114 
116 {
117  fStatus = status;
118  fParent = parent;
119  fDaught0 = daugh1;
120  fDaught1 = daugh2;
121 }
122 
123 ////////////////////////////////////////////////////////////////////////////////
124 // GETTERS/SETTERS
125 ////////////////////////////////////////////////////////////////////////////////
126 
127 ////////////////////////////////////////////////////////////////////////////////
128 /// Provides size and position of the cell
129 /// These parameter are calculated by analyzing information in all parents
130 /// cells up to the root cell. It takes time but saves memory.
131 
132 void TMVA::PDEFoamCell::GetHcub( PDEFoamVect &cellPosi, PDEFoamVect &cellSize) const
133 {
134  if(fDim<1) return;
135  const PDEFoamCell *pCell,*dCell;
136  cellPosi = 0.0; cellSize=1.0; // load all components
137  dCell = this;
138  while(dCell != 0) {
139  pCell = dCell->GetPare();
140  if( pCell== 0) break;
141  Int_t kDiv = pCell->fBest;
142  Double_t xDivi = pCell->fXdiv;
143  if(dCell == pCell->GetDau0() ) {
144  cellSize[kDiv] *=xDivi;
145  cellPosi[kDiv] *=xDivi;
146  } else if( dCell == pCell->GetDau1() ) {
147  cellSize[kDiv] *=(1.0-xDivi);
148  cellPosi[kDiv] =cellPosi[kDiv]*(1.0-xDivi)+xDivi;
149  } else {
150  Error( "GetHcub ","Something wrong with linked tree \n");
151  }
152  dCell=pCell;
153  }//while
154 }//GetHcub
155 
156 ////////////////////////////////////////////////////////////////////////////////
157 /// Provides size of the cell
158 /// Size parameters are calculated by analyzing information in all parents
159 /// cells up to the root cell. It takes time but saves memory.
160 
162 {
163  if(fDim<1) return;
164  const PDEFoamCell *pCell,*dCell;
165  cellSize=1.0; // load all components
166  dCell = this;
167  while(dCell != 0) {
168  pCell = dCell->GetPare();
169  if( pCell== 0) break;
170  Int_t kDiv = pCell->fBest;
171  Double_t xDivi = pCell->fXdiv;
172  if(dCell == pCell->GetDau0() ) {
173  cellSize[kDiv]=cellSize[kDiv]*xDivi;
174  } else if(dCell == pCell->GetDau1() ) {
175  cellSize[kDiv]=cellSize[kDiv]*(1.0-xDivi);
176  } else {
177  Error( "GetHSize ","Something wrong with linked tree \n");
178  }
179  dCell=pCell;
180  }//while
181 }//GetHSize
182 
183 ////////////////////////////////////////////////////////////////////////////////
184 /// Calculates volume of the cell using size params which are calculated
185 
187 {
188  Int_t k;
189  Double_t volu=1.0;
190  if(fDim>0) { // h-cubical subspace
191  PDEFoamVect cellSize(fDim);
192  GetHSize(cellSize);
193  for(k=0; k<fDim; k++) volu *= cellSize[k];
194  }
195  fVolume =volu;
196 }
197 
198 ////////////////////////////////////////////////////////////////////////////////
199 /// Get depth of cell in binary tree, where the root cell has depth
200 /// 1
201 
203 {
204  // check wheter we are in the root cell
205  if (fParent == 0)
206  return 1;
207 
208  UInt_t depth = 1;
209  PDEFoamCell *cell = this;
210  while ((cell=cell->GetPare()) != 0){
211  ++depth;
212  }
213  return depth;
214 }
215 
216 ////////////////////////////////////////////////////////////////////////////////
217 /// Get depth of cell tree, starting at this cell.
218 
220 {
221  if (GetStat() == 1) // this is an active cell
222  return depth + 1;
223 
224  UInt_t depth0 = 0, depth1 = 0;
225  if (GetDau0() != NULL)
226  depth0 = GetDau0()->GetTreeDepth(depth+1);
227  if (GetDau1() != NULL)
228  depth1 = GetDau1()->GetTreeDepth(depth+1);
229 
230  return (depth0 > depth1 ? depth0 : depth1);
231 }
232 
233 ////////////////////////////////////////////////////////////////////////////////
234 /// Printout of the cell geometry parameters for the debug purpose
235 
237 {
238  if (!option) Error( "Print", "No option set\n");
239 
240  std::cout << " Status= "<< fStatus <<",";
241  std::cout << " Volume= "<< fVolume <<",";
242  std::cout << " TrueInteg= " << fIntegral <<",";
243  std::cout << " DriveInteg= "<< fDrive <<",";
244  std::cout << std::endl;;
245  std::cout << " Xdiv= "<<fXdiv<<",";
246  std::cout << " Best= "<<fBest<<",";
247  std::cout << " Parent= {"<< (GetPare() ? GetPare()->GetSerial() : -1) <<"} "; // extra DEBUG
248  std::cout << " Daught0= {"<< (GetDau0() ? GetDau0()->GetSerial() : -1 )<<"} "; // extra DEBUG
249  std::cout << " Daught1= {"<< (GetDau1() ? GetDau1()->GetSerial() : -1 )<<"} "; // extra DEBUG
250  std::cout << std::endl;;
251  //
252  //
253  if (fDim>0 ) {
254  PDEFoamVect cellPosi(fDim); PDEFoamVect cellSize(fDim);
255  GetHcub(cellPosi,cellSize);
256  std::cout <<" Posi= "; cellPosi.Print("1"); std::cout<<","<< std::endl;;
257  std::cout <<" Size= "; cellSize.Print("1"); std::cout<<","<< std::endl;;
258  }
259 }
const char Option_t
Definition: RtypesCore.h:62
void Fill(Int_t, PDEFoamCell *, PDEFoamCell *, PDEFoamCell *)
Fills in certain data into newly allocated cell.
TAlienJobStatus * status
Definition: TAlienJob.cxx:51
int Int_t
Definition: RtypesCore.h:41
virtual ~PDEFoamCell()
Destructor.
STL namespace.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:918
const Int_t kDiv
Definition: TPCON.h:32
void Error(const char *location, const char *msgfmt,...)
void Print(Option_t *option) const
Printout of the cell geometry parameters for the debug purpose.
void Print(Option_t *option) const
Printout of all vector components.
PDEFoamCell * GetPare() const
Definition: PDEFoamCell.h:99
UInt_t GetTreeDepth(UInt_t depth=0)
Get depth of cell tree, starting at this cell.
void CalcVolume()
Calculates volume of the cell using size params which are calculated.
unsigned int UInt_t
Definition: RtypesCore.h:42
UInt_t GetDepth()
Get depth of cell in binary tree, where the root cell has depth 1.
double Double_t
Definition: RtypesCore.h:55
void GetHSize(PDEFoamVect &) const
Provides size of the cell Size parameters are calculated by analyzing information in all parents cell...
ClassImp(TMVA::PDEFoamCell) TMVA
Default constructor for streamer.
Definition: PDEFoamCell.cxx:40
Mother of all ROOT objects.
Definition: TObject.h:58
Abstract ClassifierFactory template that handles arbitrary types.
PDEFoamCell * GetDau1() const
Definition: PDEFoamCell.h:101
#define NULL
Definition: Rtypes.h:82
void GetHcub(PDEFoamVect &, PDEFoamVect &) const
Provides size and position of the cell These parameter are calculated by analyzing information in all...
PDEFoamCell * GetDau0() const
Definition: PDEFoamCell.h:100