FEDRA emulsion software from the OPERA Collaboration
EdbCell2 Class Reference

#include <EdbCell2.h>

Inheritance diagram for EdbCell2:
Collaboration diagram for EdbCell2:

Public Member Functions

bool AddObject (float v[2], TObject *obj)
 
bool AddObject (float x, float y, TObject *obj)
 
bool AddObject (int ix, int iy, TObject *obj)
 
bool AddObject (int j, TObject *obj)
 
int AddObjectOverlap (float x, float y, float dx, float dy, TObject *obj)
 
int CellLim ()
 
void Copy (const EdbCell2 &cell)
 
void Delete ()
 
 EdbCell2 ()
 [eNcell] pointers to cells More...
 
 EdbCell2 (const EdbCell2 &cell)
 
TObject * GetObject (float x, float y, int ientr) const
 
TObject * GetObject (int ix, int iy, int ientr) const
 
TObject * GetObject (int j, int ientr) const
 
int InitCell (EdbCell2 &c)
 
int InitCell (int maxpercell, int n[2], float min[2], float max[2])
 
int InitCell (int nx, float minx, float maxx, int ny, float miny, float maxy, int maxpercell)
 
void InitEPC ()
 
void PrintStat ()
 
void Reset ()
 
int SelectObjects (float min[2], float max[2], TObjArray &arr)
 
int SelectObjects (int min[2], int max[2], TObjArray &arr)
 
int SelectObjects (TObjArray &arr)
 
int SelectObjectsC (float v[2], float r, TObjArray &arr)
 
int SelectObjectsC (float v[2], int ir[2], TObjArray &arr)
 
int SelectObjectsC (int iv[2], int ir[2], TObjArray &arr)
 
int SelectObjectsCJ (int j, int ir, TObjArray &arr)
 
void Set0 ()
 
 ~EdbCell2 ()
 
- Public Member Functions inherited from EdbH2
void AddBin (int jcell, int n)
 
int Bin (float x, float y) const
 
int Bin (int iv[2]) const
 
int Bin (int ix, int iy) const
 
int Bin (int j) const
 
void CleanCells ()
 
void Copy (const EdbH2 &h)
 
void Delete ()
 
int DiscardHighCells (int nmax)
 
TH2F * DrawH2 (const char *name="plot2d", const char *title="EdbH2plot2D")
 
TH1I * DrawSpectrum (const char *name="plot1d", const char *title="EdbH2 DrawSpectrum")
 
 EdbH2 ()
 
 EdbH2 (const EdbH2 &h)
 
 EdbH2 (int nx, float minx, float maxx, int ny, float miny, float maxy)
 
int Fill (float x, float y)
 
int Fill (float x, float y, int n)
 
int Fill (int j, int n=1)
 
int InitH2 (const EdbH2 &h)
 
int InitH2 (int n[2], float min[2], float max[2])
 
int InitH2 (int nx, float minx, float maxx, int ny, float miny, float maxy)
 
Long_t Integral ()
 
Long_t Integral (int iv[2], int ir[2])
 
int IX (float x) const
 
int IX (int jcell) const
 
int IY (float y) const
 
int IY (int jcell) const
 
int Jcell (float v[2]) const
 
int Jcell (float x, float y) const
 
int Jcell (int ix, int iy) const
 
int MaxBin ()
 
Float_t Mean ()
 
int Ncell () const
 
int NX () const
 
int NY () const
 
void PrintStat ()
 
EdbH1ProjectionX ()
 
EdbH1ProjectionY ()
 
void Set0 ()
 
void SetBin (int ix, int iy, int n)
 
void SetBin (int j, int n)
 
float X (int ix) const
 
float Xbin () const
 
float Xj (int j) const
 
float Xmax () const
 
float XmaxA (float level=0)
 
float Xmin () const
 
float XminA (float level=0)
 
float Y (int iy) const
 
float Ybin () const
 
float Yj (int j) const
 
float Ymax () const
 
float YmaxA (float level=0)
 
float Ymin () const
 
float YminA (float level=0)
 
 ~EdbH2 ()
 

Private Attributes

Int_t eCapacity
 
Int_t eCellLim
 
TObject *** epC
 
TObject ** epO
 

Additional Inherited Members

- Protected Attributes inherited from EdbH2
Float_t eBin [2]
 
Float_t eMax [2]
 
Float_t eMin [2]
 
Int_t eN [2]
 
Int_t * eNC
 
Int_t eNcell
 

Constructor & Destructor Documentation

◆ EdbCell2() [1/2]

EdbCell2::EdbCell2 ( )

[eNcell] pointers to cells

605 {
606  Set0();
607 }
void Set0()
Definition: EdbCell2.cpp:610

◆ EdbCell2() [2/2]

EdbCell2::EdbCell2 ( const EdbCell2 cell)
inline
162 { Set0(); Copy(cell); }
void Copy(const EdbCell2 &cell)
Definition: EdbCell2.cpp:665

◆ ~EdbCell2()

EdbCell2::~EdbCell2 ( )
620 {
621  Delete();
622 }
void Delete()
Definition: EdbCell2.cpp:625

Member Function Documentation

◆ AddObject() [1/4]

bool EdbCell2::AddObject ( float  v[2],
TObject *  obj 
)
inline
176 { return AddObject(v[0],v[1],obj); }
bool AddObject(float v[2], TObject *obj)
Definition: EdbCell2.h:176

◆ AddObject() [2/4]

bool EdbCell2::AddObject ( float  x,
float  y,
TObject *  obj 
)
726 {
727  int j = Jcell(x,y);
728  return AddObject(j, obj);
729 }
int Jcell(int ix, int iy) const
Definition: EdbCell2.h:57

◆ AddObject() [3/4]

bool EdbCell2::AddObject ( int  ix,
int  iy,
TObject *  obj 
)
719 {
720  int j = Jcell(ix,iy);
721  return AddObject(j, obj);
722 }

◆ AddObject() [4/4]

bool EdbCell2::AddObject ( int  j,
TObject *  obj 
)
755 {
756  if(!obj) return 0;
757  if(j>=eNcell) return 0;
758  if(j<0) return 0;
759  if( eNC[j] >= eCellLim ) return 0;
760  epC[j][eNC[j]] = obj;
761  eNC[j]++;
762  return 1;
763 }
TObject *** epC
Definition: EdbCell2.h:158
Int_t eCellLim
Definition: EdbCell2.h:155
Int_t * eNC
Definition: EdbCell2.h:29
Int_t eNcell
Definition: EdbCell2.h:28

◆ AddObjectOverlap()

int EdbCell2::AddObjectOverlap ( float  x,
float  y,
float  dx,
float  dy,
TObject *  obj 
)
733 {
734  // works correctly if overlap less then the cell size
735  int cnt=0;
736  std::vector<int> J;
737  J.push_back( Jcell(x,y) );
738  J.push_back( Jcell(x+dx,y) );
739  J.push_back( Jcell(x-dx,y) );
740  J.push_back( Jcell(x,y+dy) );
741  J.push_back( Jcell(x,y-dy) );
742  std::sort(J.begin(), J.end());
743  std::vector<int>::iterator ip = std::unique( J.begin(), J.end() );
744  J.resize( std::distance(J.begin(), ip) );
745  for (ip=J.begin(); ip!=J.end(); ++ip)
746  {
747  AddObject(*ip,obj);
748  cnt++;
749  }
750  return cnt;
751 }
RelationIterator iterator
Definition: VtRelationList.hh:53
double distance(const Track &t, const Vertex &v)
spatial distance track - vertex
Definition: VtDistance.C:49

◆ CellLim()

int EdbCell2::CellLim ( )
inline
169 { return eCellLim; }

◆ Copy()

void EdbCell2::Copy ( const EdbCell2 cell)
666 {
667  EdbH2::Copy(cell);
668  eCellLim = cell.eCellLim;
669  eCapacity = cell.eCapacity;
670  for(int i=0; i<eNcell; i++)
671  for(int j=0; i<eCellLim; i++) AddObject(i, GetObject(i,j));
672 }
Int_t eCapacity
Definition: EdbCell2.h:156
TObject * GetObject(float x, float y, int ientr) const
Definition: EdbCell2.h:199
void Copy(const EdbH2 &h)
Definition: EdbCell2.cpp:46

◆ Delete()

void EdbCell2::Delete ( )
626 {
627  if(epC) { delete [] epC; epC = 0; }
628  if(epO) { delete [] epO; epO = 0; }
629 }
TObject ** epO
Definition: EdbCell2.h:157

◆ GetObject() [1/3]

TObject* EdbCell2::GetObject ( float  x,
float  y,
int  ientr 
) const
inline
199 { return GetObject( Jcell(x,y), ientr); }

◆ GetObject() [2/3]

TObject* EdbCell2::GetObject ( int  ix,
int  iy,
int  ientr 
) const
inline
200 { return GetObject( Jcell(ix,iy), ientr); }

◆ GetObject() [3/3]

TObject* EdbCell2::GetObject ( int  j,
int  ientr 
) const
inline
201  {
202  if(j>=0&&j<eNcell&&ientr>=0&&ientr<eCellLim) return epC[j][ientr];
203  else return 0;
204  }

◆ InitCell() [1/3]

int EdbCell2::InitCell ( EdbCell2 c)
inline
170 { return InitCell(c.NX(),c.Xmin(),c.Xmax(),c.NY(),c.Ymin(),c.Ymax(), c.CellLim() ); }
int CellLim()
Definition: EdbCell2.h:169
int InitCell(EdbCell2 &c)
Definition: EdbCell2.h:170
float Xmax() const
Definition: EdbCell2.h:65
int NX() const
Definition: EdbCell2.h:50
float Ymin() const
Definition: EdbCell2.h:66
int NY() const
Definition: EdbCell2.h:51
float Xmin() const
Definition: EdbCell2.h:64
float Ymax() const
Definition: EdbCell2.h:67

◆ InitCell() [2/3]

int EdbCell2::InitCell ( int  maxpercell,
int  n[2],
float  min[2],
float  max[2] 
)
642 {
643  Log(3,"EdbCell2::InitCell","%d %f %f %d %f %f", n[0],min[0],max[0],n[1],min[1],max[1] );
644  Delete();
645  InitH2(n, min, max);
646  Log(3,"EdbCell2::InitCell","reserve space for maxpercell(%d) * eNcell(%d) = %d objects",
647  maxpercell, eNcell, maxpercell*eNcell);
648  eCellLim = maxpercell;
650  epO = new TObject*[eCapacity]; //- pointers to objects
651  epC = new TObject**[eNcell]; //- pointers to cells
652  InitEPC();
653  return eNcell;
654 }
bool Log(int level, const char *location, const char *fmt,...)
Definition: EdbLog.cxx:75
float min(TClonesArray *t)
Definition: bitview.cxx:275
int max
Definition: check_shower.C:41
void InitEPC()
Definition: EdbCell2.cpp:657
int InitH2(const EdbH2 &h)
Definition: EdbCell2.cpp:79

◆ InitCell() [3/3]

int EdbCell2::InitCell ( int  nx,
float  minx,
float  maxx,
int  ny,
float  miny,
float  maxy,
int  maxpercell 
)
633 {
634  int n[2] = {nx,ny};
635  float min[2] = {minx,miny};
636  float max[2] = {maxx,maxy};
637  return InitCell(maxpercell, n, min, max);
638 }
int nx
Definition: emthickness.cpp:60
int ny
Definition: emthickness.cpp:62

◆ InitEPC()

void EdbCell2::InitEPC ( )
658 {
659  TObject **po = epO;
660  epC[0]=po;
661  for(int i=1; i<eNcell; i++) {po+=eCellLim; epC[i]=po;}
662 }
TProfile * po
Definition: testChi2Ordering.C:29

◆ PrintStat()

void EdbCell2::PrintStat ( )
712 {
713  printf("EdbCell2 limit = %4d\n",eCellLim);
714  ((EdbH2*)this)->PrintStat();
715 }
Definition: EdbCell2.h:19

◆ Reset()

void EdbCell2::Reset ( )
inline
174 {CleanCells(); Delete();}
void CleanCells()
Definition: EdbCell2.cpp:115

◆ SelectObjects() [1/3]

int EdbCell2::SelectObjects ( float  min[2],
float  max[2],
TObjArray &  arr 
)
775 {
776  int mi[2] = { IX(min[0]), IY(min[1]) };
777  int ma[2] = { IX(max[0]), IY(max[1]) };
778  return SelectObjects(mi,ma, arr);
779 }
int SelectObjects(TObjArray &arr)
Definition: EdbCell2.cpp:797
int IX(float x) const
Definition: EdbCell2.h:52
int IY(float y) const
Definition: EdbCell2.h:53

◆ SelectObjects() [2/3]

int EdbCell2::SelectObjects ( int  min[2],
int  max[2],
TObjArray &  arr 
)
783 {
784  int nobj = 0;
785  int jcell = 0;
786  for(int ix = Max(0,min[0]); ix<=Min(eN[0]-1,max[0]); ix++)
787  for(int iy = Max(0,min[1]); iy<=Min(eN[1]-1,max[1]); iy++)
788  {
789  jcell = Jcell(ix,iy);
790  if(eNC[jcell]<1) continue;
791  for(int k=0; k<eNC[jcell]; k++) { arr.Add( epC[jcell][k] ); nobj++; }
792  }
793  return nobj;
794 }
Int_t eN[2]
Definition: EdbCell2.h:23

◆ SelectObjects() [3/3]

int EdbCell2::SelectObjects ( TObjArray &  arr)
798 {
799  // select all objects
800  int nobj = 0;
801  for(int jcell=0; jcell<eNcell; jcell++) {
802  if(eNC[jcell]<1) continue;
803  for(int k=0; k<eNC[jcell]; k++) { arr.Add( epC[jcell][k] ); nobj++; }
804  }
805  return nobj;
806 }

◆ SelectObjectsC() [1/3]

int EdbCell2::SelectObjectsC ( float  v[2],
float  r,
TObjArray &  arr 
)
inline
195  {
196  int ir[2] = { (int)(r/Xbin()) + 1, (int)(r/Ybin()) + 1 };
197  return SelectObjectsC(v, ir, arr);
198  };
int SelectObjectsC(int iv[2], int ir[2], TObjArray &arr)
Definition: EdbCell2.cpp:766
float Ybin() const
Definition: EdbCell2.h:78
float Xbin() const
Definition: EdbCell2.h:77
void r(int rid=2)
Definition: test.C:201

◆ SelectObjectsC() [2/3]

int EdbCell2::SelectObjectsC ( float  v[2],
int  ir[2],
TObjArray &  arr 
)
inline
191  {
192  int iv[2] = { IX(v[0]), IY(v[1]) };
193  return SelectObjectsC(iv, ir, arr);
194  }

◆ SelectObjectsC() [3/3]

int EdbCell2::SelectObjectsC ( int  iv[2],
int  ir[2],
TObjArray &  arr 
)
767 {
768  int min[2] = {vcent[0]-vdiff[0],vcent[1]-vdiff[1]};
769  int max[2] = {vcent[0]+vdiff[0],vcent[1]+vdiff[1]};
770  return SelectObjects(min,max, arr);
771 }

◆ SelectObjectsCJ()

int EdbCell2::SelectObjectsCJ ( int  j,
int  ir,
TObjArray &  arr 
)
inline
185  {
186  int iv[2] = { IX(j), IY(j) };
187  int irr[2] = { ir, ir };
188  return SelectObjectsC(iv, irr, arr);
189  }

◆ Set0()

void EdbCell2::Set0 ( )
611 {
612  eCellLim=0;
613  eCapacity=0;
614  epO=0;
615  epC=0;
616 }

Member Data Documentation

◆ eCapacity

Int_t EdbCell2::eCapacity
private

◆ eCellLim

Int_t EdbCell2::eCellLim
private

◆ epC

TObject*** EdbCell2::epC
private

◆ epO

TObject** EdbCell2::epO
private

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