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