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
19
20////////////////////////////////////////////////////////////////////////////////
21/// Default constructor for streamer
22
26
27////////////////////////////////////////////////////////////////////////////////
28/// User constructor allocating single empty Cell
29
31{
32 if ( kDim >0) {
33 //---------=========----------
34 fDim = kDim;
35 fSerial = 0;
36 fStatus = 1;
37 fXdiv = 0.0;
38 fBest = 0;
39 fVolume = 0.0;
40 fIntegral = 0.0;
41 fDrive = 0.0;
42 fPrimary = 0.0;
43 } else
44 Error("TFoamCell","Dimension has to be >0 \n ");
45}
46
47////////////////////////////////////////////////////////////////////////////////
48/// Destructor
49
53
54////////////////////////////////////////////////////////////////////////////////
55/// Fills in certain data into newly allocated cell
56
58{
59 fStatus = Status;
60 fParentIdx = Parent ? Parent->fSerial : -1;
61 fDaught0Idx = Daugh1 ? Daugh1->fSerial : -1;
62 fDaught1Idx = Daugh2 ? Daugh2->fSerial : -1;
63}
64
65////////////////////////////////////////////////////////////////////////////////
66/// Provides size and position of the cell
67/// These parameter are calculated by analyzing information in all parents
68/// cells up to the root cell. It takes time but saves memory.
69
71{
72 if(fDim<1) return;
73 const TFoamCell *pCell,*dCell;
74 cellPosi = 0.0; cellSize=1.0; // load all components
75 dCell = this;
76 while(dCell != nullptr) {
77 pCell = dCell->GetPare();
78 if( pCell== nullptr) break;
79 Int_t kDiv = pCell->fBest;
80 Double_t xDivi = pCell->fXdiv;
81 if(dCell == pCell->GetDau0() ) {
82 cellSize[kDiv] *=xDivi;
84 } else if( dCell == pCell->GetDau1() ) {
85 cellSize[kDiv] *=(1.0-xDivi);
87 } else {
88 Error("GetHcub ","Something wrong with linked tree \n");
89 }
91 }//while
92}
93
94////////////////////////////////////////////////////////////////////////////////
95/// Provides size of the cell
96/// Size parameters are calculated by analyzing information in all parents
97/// cells up to the root cell. It takes time but saves memory.
98
99void TFoamCell::GetHSize( TFoamVect &cellSize) const
100{
101 if(fDim<1) return;
102 const TFoamCell *pCell,*dCell;
103 cellSize=1.0; // load all components
104 dCell = this;
105 while(dCell != nullptr) {
106 pCell = dCell->GetPare();
107 if( pCell== nullptr) break;
108 Int_t kDiv = pCell->fBest;
109 Double_t xDivi = pCell->fXdiv;
110 if(dCell == pCell->GetDau0() ) {
111 cellSize[kDiv]=cellSize[kDiv]*xDivi;
112 } else if(dCell == pCell->GetDau1() ) {
113 cellSize[kDiv]=cellSize[kDiv]*(1.0-xDivi);
114 } else {
115 Error("GetHSize ","Something wrong with linked tree \n");
116 }
117 dCell=pCell;
118 }//while
119}
120
121////////////////////////////////////////////////////////////////////////////////
122/// Calculates volume of the cell using size params which are calculated
123
125{
126 Int_t k;
127 Double_t volu=1.0;
128 if(fDim>0) { // h-cubical subspace
129 TFoamVect cellSize(fDim);
130 GetHSize(cellSize);
131 for(k=0; k<fDim; k++) volu *= cellSize[k];
132 }
133 fVolume =volu;
134}
135
136////////////////////////////////////////////////////////////////////////////////
137/// Printout of the cell geometry parameters for the debug purpose
138
140{
141 if(!option) Error("Print", "No option set\n");
142
143 std::cout << " Status= "<< fStatus <<",";
144 std::cout << " Volume= "<< fVolume <<",";
145 std::cout << " TrueInteg= " << fIntegral <<",";
146 std::cout << " DriveInteg= "<< fDrive <<",";
147 std::cout << " PrimInteg= " << fPrimary <<",";
148 std::cout<< std::endl;
149 std::cout << " Xdiv= "<<fXdiv<<",";
150 std::cout << " Best= "<<fBest<<",";
151 std::cout << " Parent= {"<< (GetPare() ? GetPare()->GetSerial() : -1) <<"} "; // extra DEBUG
152 std::cout << " Daught0= {"<< (GetDau0() ? GetDau0()->GetSerial() : -1 )<<"} "; // extra DEBUG
153 std::cout << " Daught1= {"<< (GetDau1() ? GetDau1()->GetSerial() : -1 )<<"} "; // extra DEBUG
154 std::cout<< std::endl;
155 //
156 //
157 if(fDim>0 ) {
159 GetHcub(cellPosi,cellSize);
160 std::cout <<" Posi= "; cellPosi.Print("1"); std::cout<<","<< std::endl;
161 std::cout <<" Size= "; cellSize.Print("1"); std::cout<<","<< std::endl;
162 }
163}
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.
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:70
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:23
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:57
~TFoamCell() override
Destructor.
Definition TFoamCell.cxx:50
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...
Definition TFoamCell.cxx:99
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:1071