00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "Riostream.h"
00015 #include "TFoamCell.h"
00016 #include "TFoamVect.h"
00017
00018
00019 ClassImp(TFoamCell);
00020
00021
00022 TFoamCell::TFoamCell()
00023 {
00024
00025
00026 fParent = 0;
00027 fDaught0 = 0;
00028 fDaught1 = 0;
00029 }
00030
00031
00032 TFoamCell::TFoamCell(Int_t kDim)
00033 {
00034
00035 if ( kDim >0) {
00036
00037 fDim = kDim;
00038 fSerial = 0;
00039 fStatus = 1;
00040 fParent = 0;
00041 fDaught0 = 0;
00042 fDaught1 = 0;
00043 fXdiv = 0.0;
00044 fBest = 0;
00045 fVolume = 0.0;
00046 fIntegral = 0.0;
00047 fDrive = 0.0;
00048 fPrimary = 0.0;
00049 } else
00050 Error("TFoamCell","Dimension has to be >0 \n ");
00051 }
00052
00053
00054 TFoamCell::TFoamCell(TFoamCell &From): TObject(From)
00055 {
00056
00057
00058 Error("TFoamCell", "+++++ NEVER USE Copy constructor for TFoamCell \n");
00059 fStatus = From.fStatus;
00060 fParent = From.fParent;
00061 fDaught0 = From.fDaught0;
00062 fDaught1 = From.fDaught1;
00063 fXdiv = From.fXdiv;
00064 fBest = From.fBest;
00065 fVolume = From.fVolume;
00066 fIntegral = From.fIntegral;
00067 fDrive = From.fDrive;
00068 fPrimary = From.fPrimary;
00069 }
00070
00071
00072 TFoamCell::~TFoamCell()
00073 {
00074
00075 }
00076
00077
00078 TFoamCell& TFoamCell::operator=(const TFoamCell &From)
00079 {
00080
00081
00082 Info("TFoamCell", "operator=\n ");
00083 if (&From == this) return *this;
00084 fStatus = From.fStatus;
00085 fParent = From.fParent;
00086 fDaught0 = From.fDaught0;
00087 fDaught1 = From.fDaught1;
00088 fXdiv = From.fXdiv;
00089 fBest = From.fBest;
00090 fVolume = From.fVolume;
00091 fIntegral = From.fIntegral;
00092 fDrive = From.fDrive;
00093 fPrimary = From.fPrimary;
00094 return *this;
00095 }
00096
00097
00098
00099 void TFoamCell::Fill(Int_t Status, TFoamCell *Parent, TFoamCell *Daugh1, TFoamCell *Daugh2)
00100 {
00101
00102
00103 fStatus = Status;
00104 fParent = Parent;
00105 fDaught0 = Daugh1;
00106 fDaught1 = Daugh2;
00107 }
00108
00109
00110
00111
00112
00113
00114 void TFoamCell::GetHcub( TFoamVect &cellPosi, TFoamVect &cellSize) const
00115 {
00116
00117
00118
00119 if(fDim<1) return;
00120 const TFoamCell *pCell,*dCell;
00121 cellPosi = 0.0; cellSize=1.0;
00122 dCell = this;
00123 while(dCell != 0) {
00124 pCell = dCell->GetPare();
00125 if( pCell== 0) break;
00126 Int_t kDiv = pCell->fBest;
00127 Double_t xDivi = pCell->fXdiv;
00128 if(dCell == pCell->GetDau0() ) {
00129 cellSize[kDiv] *=xDivi;
00130 cellPosi[kDiv] *=xDivi;
00131 } else if( dCell == pCell->GetDau1() ) {
00132 cellSize[kDiv] *=(1.0-xDivi);
00133 cellPosi[kDiv] =cellPosi[kDiv]*(1.0-xDivi)+xDivi;
00134 } else {
00135 Error("GetHcub ","Something wrong with linked tree \n");
00136 }
00137 dCell=pCell;
00138 }
00139 }
00140
00141
00142 void TFoamCell::GetHSize( TFoamVect &cellSize) const
00143 {
00144
00145
00146
00147 if(fDim<1) return;
00148 const TFoamCell *pCell,*dCell;
00149 cellSize=1.0;
00150 dCell = this;
00151 while(dCell != 0) {
00152 pCell = dCell->GetPare();
00153 if( pCell== 0) break;
00154 Int_t kDiv = pCell->fBest;
00155 Double_t xDivi = pCell->fXdiv;
00156 if(dCell == pCell->GetDau0() ) {
00157 cellSize[kDiv]=cellSize[kDiv]*xDivi;
00158 } else if(dCell == pCell->GetDau1() ) {
00159 cellSize[kDiv]=cellSize[kDiv]*(1.0-xDivi);
00160 } else {
00161 Error("GetHSize ","Something wrong with linked tree \n");
00162 }
00163 dCell=pCell;
00164 }
00165 }
00166
00167
00168 void TFoamCell::CalcVolume(void)
00169 {
00170
00171
00172 Int_t k;
00173 Double_t volu=1.0;
00174 if(fDim>0) {
00175 TFoamVect cellSize(fDim);
00176 GetHSize(cellSize);
00177 for(k=0; k<fDim; k++) volu *= cellSize[k];
00178 }
00179 fVolume =volu;
00180 }
00181
00182
00183 void TFoamCell::Print(Option_t *option) const
00184 {
00185
00186
00187 if(!option) Error("Print", "No option set\n");
00188
00189 cout << " Status= "<< fStatus <<",";
00190 cout << " Volume= "<< fVolume <<",";
00191 cout << " TrueInteg= " << fIntegral <<",";
00192 cout << " DriveInteg= "<< fDrive <<",";
00193 cout << " PrimInteg= " << fPrimary <<",";
00194 cout<< endl;
00195 cout << " Xdiv= "<<fXdiv<<",";
00196 cout << " Best= "<<fBest<<",";
00197 cout << " Parent= {"<< (GetPare() ? GetPare()->GetSerial() : -1) <<"} ";
00198 cout << " Daught0= {"<< (GetDau0() ? GetDau0()->GetSerial() : -1 )<<"} ";
00199 cout << " Daught1= {"<< (GetDau1() ? GetDau1()->GetSerial() : -1 )<<"} ";
00200 cout<< endl;
00201
00202
00203 if(fDim>0 ) {
00204 TFoamVect cellPosi(fDim); TFoamVect cellSize(fDim);
00205 GetHcub(cellPosi,cellSize);
00206 cout <<" Posi= "; cellPosi.Print("1"); cout<<","<< endl;
00207 cout <<" Size= "; cellSize.Print("1"); cout<<","<< endl;
00208 }
00209 }
00210
00211
00212