Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 relative *
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/*! \class TMVA::PDEFoamCell
32\ingroup TMVA
33
34*/
35#include "TMVA/PDEFoamCell.h"
36
37#include "TMVA/PDEFoamVect.h"
38
39#include <iostream>
40#include <ostream>
41
42#include "Rtypes.h"
43#include "TObject.h"
44#include "TRef.h"
45
46using namespace std;
47
49
50////////////////////////////////////////////////////////////////////////////////
51/// Default constructor for streamer
52
54: TObject(),
55 fDim(0),
56 fSerial(0),
57 fStatus(1),
58 fParent(0),
59 fDaught0(0),
60 fDaught1(0),
61 fXdiv(0.0),
62 fBest(0),
63 fVolume(0.0),
64 fIntegral(0.0),
65 fDrive(0.0),
66 fElement(0)
67{
68}
69
70////////////////////////////////////////////////////////////////////////////////
71/// User constructor allocating single empty Cell
72
74 : TObject(),
75 fDim(kDim),
76 fSerial(0),
77 fStatus(1),
78 fParent(0),
79 fDaught0(0),
80 fDaught1(0),
81 fXdiv(0.0),
82 fBest(0),
83 fVolume(0.0),
84 fIntegral(0.0),
85 fDrive(0.0),
86 fElement(0)
87{
88 if ( kDim <= 0 )
89 Error( "PDEFoamCell", "Dimension has to be >0" );
90}
91
92////////////////////////////////////////////////////////////////////////////////
93/// Copy constructor
94
96 : TObject(),
97 fDim (cell.fDim),
98 fSerial (cell.fSerial),
99 fStatus (cell.fStatus),
100 fParent (cell.fParent),
101 fDaught0 (cell.fDaught0),
102 fDaught1 (cell.fDaught1),
103 fXdiv (cell.fXdiv),
104 fBest (cell.fBest),
105 fVolume (cell.fVolume),
106 fIntegral(cell.fIntegral),
107 fDrive (cell.fDrive),
108 fElement (cell.fElement)
109{
110 Error( "PDEFoamCell", "COPY CONSTRUCTOR NOT IMPLEMENTED" );
111}
112
113////////////////////////////////////////////////////////////////////////////////
114/// Destructor
115
117{
118}
119
120////////////////////////////////////////////////////////////////////////////////
121/// Fills in certain data into newly allocated cell
122
123void TMVA::PDEFoamCell::Fill(Int_t status, PDEFoamCell *parent, PDEFoamCell *daugh1, PDEFoamCell *daugh2)
124{
125 fStatus = status;
126 fParent = parent;
127 fDaught0 = daugh1;
128 fDaught1 = daugh2;
129}
130
131////////////////////////////////////////////////////////////////////////////////
132// GETTERS/SETTERS
133////////////////////////////////////////////////////////////////////////////////
134
135////////////////////////////////////////////////////////////////////////////////
136/// Provides size and position of the cell
137/// These parameter are calculated by analyzing information in all parents
138/// cells up to the root cell. It takes time but saves memory.
139
140void TMVA::PDEFoamCell::GetHcub( PDEFoamVect &cellPosi, PDEFoamVect &cellSize) const
141{
142 if(fDim<1) return;
143 const PDEFoamCell *pCell,*dCell;
144 cellPosi = 0.0; cellSize=1.0; // load all components
145 dCell = this;
146 while(dCell != 0) {
147 pCell = dCell->GetPare();
148 if( pCell== 0) break;
149 Int_t kDiv = pCell->fBest;
150 Double_t xDivi = pCell->fXdiv;
151 if(dCell == pCell->GetDau0() ) {
152 cellSize[kDiv] *=xDivi;
153 cellPosi[kDiv] *=xDivi;
154 } else if( dCell == pCell->GetDau1() ) {
155 cellSize[kDiv] *=(1.0-xDivi);
156 cellPosi[kDiv] =cellPosi[kDiv]*(1.0-xDivi)+xDivi;
157 } else {
158 Error( "GetHcub ","Something wrong with linked tree \n");
159 }
160 dCell=pCell;
161 }//while
162}//GetHcub
163
164////////////////////////////////////////////////////////////////////////////////
165/// Provides size of the cell
166/// Size parameters are calculated by analyzing information in all parents
167/// cells up to the root cell. It takes time but saves memory.
168
170{
171 if(fDim<1) return;
172 const PDEFoamCell *pCell,*dCell;
173 cellSize=1.0; // load all components
174 dCell = this;
175 while(dCell != 0) {
176 pCell = dCell->GetPare();
177 if( pCell== 0) break;
178 Int_t kDiv = pCell->fBest;
179 Double_t xDivi = pCell->fXdiv;
180 if(dCell == pCell->GetDau0() ) {
181 cellSize[kDiv]=cellSize[kDiv]*xDivi;
182 } else if(dCell == pCell->GetDau1() ) {
183 cellSize[kDiv]=cellSize[kDiv]*(1.0-xDivi);
184 } else {
185 Error( "GetHSize ","Something wrong with linked tree \n");
186 }
187 dCell=pCell;
188 }//while
189}//GetHSize
190
191////////////////////////////////////////////////////////////////////////////////
192/// Calculates volume of the cell using size params which are calculated
193
195{
196 Int_t k;
197 Double_t volu=1.0;
198 if(fDim>0) { // h-cubical subspace
199 PDEFoamVect cellSize(fDim);
200 GetHSize(cellSize);
201 for(k=0; k<fDim; k++) volu *= cellSize[k];
202 }
203 fVolume =volu;
204}
205
206////////////////////////////////////////////////////////////////////////////////
207/// Get depth of cell in binary tree, where the root cell has depth
208/// 1
209
211{
212 // check whether we are in the root cell
213 if (fParent == 0)
214 return 1;
215
216 UInt_t depth = 1;
217 PDEFoamCell *cell = this;
218 while ((cell=cell->GetPare()) != 0){
219 ++depth;
220 }
221 return depth;
222}
223
224////////////////////////////////////////////////////////////////////////////////
225/// Get depth of cell tree, starting at this cell.
226
228{
229 if (GetStat() == 1) // this is an active cell
230 return depth + 1;
231
232 UInt_t depth0 = 0, depth1 = 0;
233 if (GetDau0() != NULL)
234 depth0 = GetDau0()->GetTreeDepth(depth+1);
235 if (GetDau1() != NULL)
236 depth1 = GetDau1()->GetTreeDepth(depth+1);
237
238 return (depth0 > depth1 ? depth0 : depth1);
239}
240
241////////////////////////////////////////////////////////////////////////////////
242/// Printout of the cell geometry parameters for the debug purpose
243
245{
246 if (!option) Error( "Print", "No option set\n");
247
248 std::cout << " Status= "<< fStatus <<",";
249 std::cout << " Volume= "<< fVolume <<",";
250 std::cout << " TrueInteg= " << fIntegral <<",";
251 std::cout << " DriveInteg= "<< fDrive <<",";
252 std::cout << std::endl;;
253 std::cout << " Xdiv= "<<fXdiv<<",";
254 std::cout << " Best= "<<fBest<<",";
255 std::cout << " Parent= {"<< (GetPare() ? GetPare()->GetSerial() : -1) <<"} "; // extra DEBUG
256 std::cout << " Daught0= {"<< (GetDau0() ? GetDau0()->GetSerial() : -1 )<<"} "; // extra DEBUG
257 std::cout << " Daught1= {"<< (GetDau1() ? GetDau1()->GetSerial() : -1 )<<"} "; // extra DEBUG
258 std::cout << std::endl;;
259 //
260 //
261 if (fDim>0 ) {
262 PDEFoamVect cellPosi(fDim); PDEFoamVect cellSize(fDim);
263 GetHcub(cellPosi,cellSize);
264 std::cout <<" Posi= "; cellPosi.Print("1"); std::cout<<","<< std::endl;;
265 std::cout <<" Size= "; cellSize.Print("1"); std::cout<<","<< std::endl;;
266 }
267}
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:377
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:197
Option_t Option_t option
const Int_t kDiv
Definition TPCON.h:30
void Fill(Int_t, PDEFoamCell *, PDEFoamCell *, PDEFoamCell *)
Fills in certain data into newly allocated cell.
void Print(Option_t *option) const
Printout of the cell geometry parameters for the debug purpose.
void CalcVolume()
Calculates volume of the cell using size params which are calculated.
UInt_t GetTreeDepth(UInt_t depth=0)
Get depth of cell tree, starting at this cell.
Double_t fXdiv
Factor for division.
Definition PDEFoamCell.h:58
Int_t fBest
Best Edge for division.
Definition PDEFoamCell.h:59
PDEFoamCell * GetPare() const
Definition PDEFoamCell.h:93
PDEFoamCell * GetDau1() const
Definition PDEFoamCell.h:95
void GetHSize(PDEFoamVect &) const
Provides size of the cell Size parameters are calculated by analyzing information in all parents cell...
PDEFoamCell * GetDau0() const
Definition PDEFoamCell.h:94
PDEFoamCell()
Default constructor for streamer.
virtual ~PDEFoamCell()
Destructor.
void GetHcub(PDEFoamVect &, PDEFoamVect &) const
Provides size and position of the cell These parameter are calculated by analyzing information in all...
UInt_t GetDepth()
Get depth of cell in binary tree, where the root cell has depth 1.
void Print(Option_t *option) const
Printout of all vector components.
Mother of all ROOT objects.
Definition TObject.h:41
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:970