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