FEDRA emulsion software from the OPERA Collaboration
TIndexCellIterV Class Reference

IndexCell volume iterator. More...

#include <TIndexCell.h>

Inheritance diagram for TIndexCellIterV:
Collaboration diagram for TIndexCellIterV:

Public Member Functions

const TIndexCellGetCell () const
 
int LevelDown ()
 
TIndexCell const * Next ()
 
TIndexCell const * NextAll ()
 
void Reset ()
 
void Test ()
 
 TIndexCellIterV (const TIndexCell *cell, int level, long vcent[], long vdiff[], Bool_t dir=kIterForward)
 
 ~TIndexCellIterV ()
 

Private Member Functions

 TIndexCellIterV ()
 

Private Attributes

const TIndexCellfCell
 cell being iterated More...
 
Bool_t fDirection
 iteration direction More...
 
Int_t fLevel
 current level More...
 
Int_t fLevel0
 level to be iterated on More...
 
Int_t fPass
 number of cells iterated More...
 
Long_t * fVcent
 central subcell More...
 
Long_t * fVdiff
 volume to be iterated around Vcent More...
 
Int_t * fVind
 current position in array More...
 
Long_t * fVval
 values corresponding to Vind More...
 

Detailed Description

IndexCell volume iterator.

Constructor & Destructor Documentation

◆ TIndexCellIterV() [1/2]

TIndexCellIterV::TIndexCellIterV ( )
inlineprivate
157: fCell(0) { }
const TIndexCell * fCell
cell being iterated
Definition: TIndexCell.h:146

◆ TIndexCellIterV() [2/2]

TIndexCellIterV::TIndexCellIterV ( const TIndexCell cell,
int  level,
long  vcent[],
long  vdiff[],
Bool_t  dir = kIterForward 
)

Create cell iterator. By default the iteration direction is kIterForward. To go backward use kIterBackward.

734{
737
738 fPass = 0;
739 fCell = cell;
740 fDirection = dir;
741 if( level > fCell->Nlevels() ) level=0;
742 if( level < 1 ) level=0;
743 fLevel = fLevel0 = level;
744
745 if(fLevel0 >= 0) {
746 fVind = new Int_t[ fLevel0 ];
747 fVval = new Long_t[ fLevel0 ];
748 Reset();
749 }
750
751 fVcent = new Long_t[level];
752 fVdiff = new Long_t[level];
753
754 for(int i=0; i<level; i++) {
755 fVcent[i] = vcent[i];
756 fVdiff[i] = vdiff[i];
757 }
758}
void Reset()
Definition: TIndexCell.cpp:761
Long_t * fVval
values corresponding to Vind
Definition: TIndexCell.h:152
Int_t fLevel0
level to be iterated on
Definition: TIndexCell.h:147
Int_t fLevel
current level
Definition: TIndexCell.h:153
Int_t * fVind
current position in array
Definition: TIndexCell.h:151
Int_t fPass
number of cells iterated
Definition: TIndexCell.h:154
Long_t * fVdiff
volume to be iterated around Vcent
Definition: TIndexCell.h:149
Long_t * fVcent
central subcell
Definition: TIndexCell.h:148
Bool_t fDirection
iteration direction
Definition: TIndexCell.h:155
Int_t Nlevels() const
Definition: TIndexCell.cpp:328

◆ ~TIndexCellIterV()

TIndexCellIterV::~TIndexCellIterV ( )
inline
167{ }

Member Function Documentation

◆ GetCell()

const TIndexCell * TIndexCellIterV::GetCell ( ) const
inline
169{ return fCell; }

◆ LevelDown()

int TIndexCellIterV::LevelDown ( )
819{
820 if(fLevel<2) return 0;
821 fLevel--;
822 fVind[fLevel] = 0;
823 int nent = fCell->At(fLevel-1,fVind)->GetEntries();
824 //printf("LevelDown: level = %d, nent= %d fVind= %d\n",fLevel, nent,fVind[fLevel-1]);
825 if( fVind[fLevel-1] < nent-1 ) {
826 fVind[fLevel-1]++;
828 fVind[fLevel0-1]=-1;
829 return 1;
830 } else return LevelDown();
831 return 0;
832}
int LevelDown()
Definition: TIndexCell.cpp:818
Int_t GetEntries() const
Definition: TIndexCell.h:82
TIndexCell const * At(Int_t narg, Int_t vind[]) const
Definition: TIndexCell.cpp:519

◆ Next()

TIndexCell const * TIndexCellIterV::Next ( )

Return next object in the defined volume.
Returns 0 when no more objects in the cell.

TODO: inefficient cycle ! put here find...

774{
777
779
780 TIndexCell const *b=0;
781
782 while( (b=NextAll()) ) {
784 //printf("flevel0: %d fVind[0]: %d, fVval[1]: %ld \n",fLevel0, fVind[0], fVval[1]);
785 for(int lev=0; lev<fLevel0; lev++) {
786 if( TMath::Abs( fVval[lev]-fVcent[lev] ) > fVdiff[lev] ) break;
787 if( lev == fLevel0-1 ) return b;
788 }
789 }
790 return 0;
791}
TIndexCell const * NextAll()
Definition: TIndexCell.cpp:794
sort collection with attributes
Definition: TIndexCell.h:19
Int_t GetValues(Int_t level, Int_t vind[], Long_t val[]) const
Definition: TIndexCell.cpp:505

◆ NextAll()

TIndexCell const * TIndexCellIterV::NextAll ( )

Return next object in cell. Returns 0 when no more objects in cell.

795{
797
798 if( fLevel0 <0 ) return 0;
799
800 START:
801
802 if( fLevel != fLevel0 ) return 0;
803
804 int nent = fCell->At(fLevel-1,fVind)->GetEntries();
805 //printf("Next: nent= %d fPass= %d\n",nent,fPass);
806
807 if( fVind[fLevel-1] < nent-1 ) {
808 fVind[fLevel-1]++;
809 fPass++;
810 return fCell->At(fLevel,fVind);
811 } else {
812 if( LevelDown() ) goto START;
813 }
814 return 0;
815}

◆ Reset()

void TIndexCellIterV::Reset ( )

Reset array iterator.

762{
764 if (fDirection == kIterForward) {
765 fLevel = fLevel0;
766 for(int i=0; i<fLevel0; i++ ) fVind[i]=0;
767 fVind[fLevel0-1]=-1;
768 }
769 else {}
770}

◆ Test()

void TIndexCellIterV::Test ( )
836{
837 int count=0;
838 while( NextAll() ) count++;
839 printf("count = %d\n",count);
840}

Member Data Documentation

◆ fCell

const TIndexCell* TIndexCellIterV::fCell
private

cell being iterated

◆ fDirection

Bool_t TIndexCellIterV::fDirection
private

iteration direction

◆ fLevel

Int_t TIndexCellIterV::fLevel
private

current level

◆ fLevel0

Int_t TIndexCellIterV::fLevel0
private

level to be iterated on

◆ fPass

Int_t TIndexCellIterV::fPass
private

number of cells iterated

◆ fVcent

Long_t* TIndexCellIterV::fVcent
private

central subcell

◆ fVdiff

Long_t* TIndexCellIterV::fVdiff
private

volume to be iterated around Vcent

◆ fVind

Int_t* TIndexCellIterV::fVind
private

current position in array

◆ fVval

Long_t* TIndexCellIterV::fVval
private

values corresponding to Vind


The documentation for this class was generated from the following files: