Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TFoamCell.cxx
Go to the documentation of this file.
1// @(#)root/foam:$Id$
2// Author: S. Jadach <mailto:Stanislaw.jadach@ifj.edu.pl>, P.Sawicki <mailto:Pawel.Sawicki@ifj.edu.pl>
3
4/** \class TFoamCell
5
6Used by TFoam
7
8Objects of this class are hyper-rectangular cells organized in the binary tree.
9Special algorithm for encoding relative positioning of the cells
10allow to save total memory allocation needed for the system of cells.
11*/
12
13
14#include <iostream>
15#include "TFoamCell.h"
16#include "TFoamVect.h"
17
18
20
21////////////////////////////////////////////////////////////////////////////////
22/// Default constructor for streamer
23
25{
26}
27
28////////////////////////////////////////////////////////////////////////////////
29/// User constructor allocating single empty Cell
30
32{
33 if ( kDim >0) {
34 //---------=========----------
35 fDim = kDim;
36 fSerial = 0;
37 fStatus = 1;
38 fXdiv = 0.0;
39 fBest = 0;
40 fVolume = 0.0;
41 fIntegral = 0.0;
42 fDrive = 0.0;
43 fPrimary = 0.0;
44 } else
45 Error("TFoamCell","Dimension has to be >0 \n ");
46}
47
48////////////////////////////////////////////////////////////////////////////////
49/// Destructor
50
52{
53}
54
55////////////////////////////////////////////////////////////////////////////////
56/// Fills in certain data into newly allocated cell
57
58void TFoamCell::Fill(Int_t Status, TFoamCell *Parent, TFoamCell *Daugh1, TFoamCell *Daugh2)
59{
60 fStatus = Status;
61 fParentIdx = Parent ? Parent->fSerial : -1;
62 fDaught0Idx = Daugh1 ? Daugh1->fSerial : -1;
63 fDaught1Idx = Daugh2 ? Daugh2->fSerial : -1;
64}
65
66////////////////////////////////////////////////////////////////////////////////
67/// Provides size and position of the cell
68/// These parameter are calculated by analyzing information in all parents
69/// cells up to the root cell. It takes time but saves memory.
70
71void TFoamCell::GetHcub( TFoamVect &cellPosi, TFoamVect &cellSize) const
72{
73 if(fDim<1) return;
74 const TFoamCell *pCell,*dCell;
75 cellPosi = 0.0; cellSize=1.0; // load all components
76 dCell = this;
77 while(dCell != nullptr) {
78 pCell = dCell->GetPare();
79 if( pCell== nullptr) break;
80 Int_t kDiv = pCell->fBest;
81 Double_t xDivi = pCell->fXdiv;
82 if(dCell == pCell->GetDau0() ) {
83 cellSize[kDiv] *=xDivi;
84 cellPosi[kDiv] *=xDivi;
85 } else if( dCell == pCell->GetDau1() ) {
86 cellSize[kDiv] *=(1.0-xDivi);
87 cellPosi[kDiv] =cellPosi[kDiv]*(1.0-xDivi)+xDivi;
88 } else {
89 Error("GetHcub ","Something wrong with linked tree \n");
90 }
91 dCell=pCell;
92 }//while
93}
94
95////////////////////////////////////////////////////////////////////////////////
96/// Provides size of the cell
97/// Size parameters are calculated by analyzing information in all parents
98/// cells up to the root cell. It takes time but saves memory.
99
100void TFoamCell::GetHSize( TFoamVect &cellSize) const
101{
102 if(fDim<1) return;
103 const TFoamCell *pCell,*dCell;
104 cellSize=1.0; // load all components
105 dCell = this;
106 while(dCell != nullptr) {
107 pCell = dCell->GetPare();
108 if( pCell== nullptr) break;
109 Int_t kDiv = pCell->fBest;
110 Double_t xDivi = pCell->fXdiv;
111 if(dCell == pCell->GetDau0() ) {
112 cellSize[kDiv]=cellSize[kDiv]*xDivi;
113 } else if(dCell == pCell->GetDau1() ) {
114 cellSize[kDiv]=cellSize[kDiv]*(1.0-xDivi);
115 } else {
116 Error("GetHSize ","Something wrong with linked tree \n");
117 }
118 dCell=pCell;
119 }//while
120}
121
122////////////////////////////////////////////////////////////////////////////////
123/// Calculates volume of the cell using size params which are calculated
124
126{
127 Int_t k;
128 Double_t volu=1.0;
129 if(fDim>0) { // h-cubical subspace
130 TFoamVect cellSize(fDim);
131 GetHSize(cellSize);
132 for(k=0; k<fDim; k++) volu *= cellSize[k];
133 }
134 fVolume =volu;
135}
136
137////////////////////////////////////////////////////////////////////////////////
138/// Printout of the cell geometry parameters for the debug purpose
139
141{
142 if(!option) Error("Print", "No option set\n");
143
144 std::cout << " Status= "<< fStatus <<",";
145 std::cout << " Volume= "<< fVolume <<",";
146 std::cout << " TrueInteg= " << fIntegral <<",";
147 std::cout << " DriveInteg= "<< fDrive <<",";
148 std::cout << " PrimInteg= " << fPrimary <<",";
149 std::cout<< std::endl;
150 std::cout << " Xdiv= "<<fXdiv<<",";
151 std::cout << " Best= "<<fBest<<",";
152 std::cout << " Parent= {"<< (GetPare() ? GetPare()->GetSerial() : -1) <<"} "; // extra DEBUG
153 std::cout << " Daught0= {"<< (GetDau0() ? GetDau0()->GetSerial() : -1 )<<"} "; // extra DEBUG
154 std::cout << " Daught1= {"<< (GetDau1() ? GetDau1()->GetSerial() : -1 )<<"} "; // extra DEBUG
155 std::cout<< std::endl;
156 //
157 //
158 if(fDim>0 ) {
159 TFoamVect cellPosi(fDim); TFoamVect cellSize(fDim);
160 GetHcub(cellPosi,cellSize);
161 std::cout <<" Posi= "; cellPosi.Print("1"); std::cout<<","<< std::endl;
162 std::cout <<" Size= "; cellSize.Print("1"); std::cout<<","<< std::endl;
163 }
164}
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:382
Option_t Option_t option
const Int_t kDiv
Definition TPCON.h:30
Used by TFoam.
Definition TFoamCell.h:12
Double_t fXdiv
Factor for division.
Definition TFoamCell.h:38
TFoamCell * GetDau1() const
Definition TFoamCell.h:78
void CalcVolume()
Calculates volume of the cell using size params which are calculated.
Int_t GetSerial() const
Definition TFoamCell.h:83
Double_t fIntegral
Integral over cell (estimate from exploration)
Definition TFoamCell.h:42
Int_t fStatus
Status (active, inactive)
Definition TFoamCell.h:20
TFoamCell * GetDau0() const
Definition TFoamCell.h:77
Double_t fVolume
Cartesian Volume of cell.
Definition TFoamCell.h:41
Int_t fDaught0Idx
Serial number of daughter 1.
Definition TFoamCell.h:31
void Print(Option_t *option) const override
Printout of the cell geometry parameters for the debug purpose.
void GetHcub(TFoamVect &, TFoamVect &) const
Provides size and position of the cell These parameter are calculated by analyzing information in all...
Definition TFoamCell.cxx:71
TFoamCell * GetPare() const
Definition TFoamCell.h:76
Double_t fDrive
Driver integral, only for cell build-up.
Definition TFoamCell.h:43
Short_t fDim
Dimension of the vector space.
Definition TFoamCell.h:15
Double_t fPrimary
Primary integral, only for MC generation.
Definition TFoamCell.h:44
TFoamCell()
Default constructor for streamer.
Definition TFoamCell.cxx:24
Int_t fDaught1Idx
Serial number of daughter 2.
Definition TFoamCell.h:32
void Fill(Int_t, TFoamCell *, TFoamCell *, TFoamCell *)
Fills in certain data into newly allocated cell.
Definition TFoamCell.cxx:58
~TFoamCell() override
Destructor.
Definition TFoamCell.cxx:51
Int_t fBest
Best Edge for division.
Definition TFoamCell.h:39
Int_t fSerial
Serial number.
Definition TFoamCell.h:19
void GetHSize(TFoamVect &) const
Provides size of the cell Size parameters are calculated by analyzing information in all parents cell...
Int_t fParentIdx
Serial number of parent cell.
Definition TFoamCell.h:30
Auxiliary class TFoamVect of n-dimensional vector, with dynamic allocation used for the cartesian geo...
Definition TFoamVect.h:10
void Print(Option_t *option) const override
Printout of all vector components on "std::cout".
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1005