FEDRA emulsion software from the OPERA Collaboration
EdbH2 Class Reference

fast 2-dim histogram class (used as a basis for EdbCell2) More...

#include <EdbCell2.h>

Inheritance diagram for EdbH2:
Collaboration diagram for EdbH2:

Public Member Functions

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 DrawSpectrun")
 
 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 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 ()
 

Protected Attributes

Float_t eBin [2]
 bin size More...
 
Float_t eMax [2]
 max More...
 
Float_t eMin [2]
 min More...
 
Int_t eN [2]
 divisions More...
 
Int_t * eNC
 [eNcell] number of objects/cell More...
 
Int_t eNcell
 eNx*eNy More...
 

Detailed Description

fast 2-dim histogram class (used as a basis for EdbCell2)

//////////////////////////////////////////////////////////////////////// // EdbCell2 // // class to group 2-dim objects for the fast access // // ////////////////////////////////////////////////////////////////////////

Constructor & Destructor Documentation

◆ EdbH2() [1/3]

EdbH2::EdbH2 ( )
25{
26 Set0();
27}
void Set0()
Definition: EdbCell2.cpp:30

◆ EdbH2() [2/3]

EdbH2::EdbH2 ( int  nx,
float  minx,
float  maxx,
int  ny,
float  miny,
float  maxy 
)
inline
33{ Set0(); InitH2(nx, minx, maxx, ny, miny, maxy); }
int InitH2(const EdbH2 &h)
Definition: EdbCell2.cpp:78

◆ EdbH2() [3/3]

EdbH2::EdbH2 ( const EdbH2 h)
39{
40 Set0();
41 Copy(h);
42}
void Copy(const EdbH2 &h)
Definition: EdbCell2.cpp:45

◆ ~EdbH2()

EdbH2::~EdbH2 ( )
63{
64 Delete();
65}
void Delete()
Definition: EdbCell2.cpp:68

Member Function Documentation

◆ AddBin()

void EdbH2::AddBin ( int  jcell,
int  n 
)
inline
87{ if(jcell>=0&&jcell<eNcell) eNC[jcell]+=n; }
Int_t * eNC
[eNcell] number of objects/cell
Definition: EdbCell2.h:29
Int_t eNcell
eNx*eNy
Definition: EdbCell2.h:28

◆ Bin() [1/4]

int EdbH2::Bin ( float  x,
float  y 
) const
inline
80{return (Jcell(x,y)>-1)? eNC[Jcell(x,y)] : 0; }
int Jcell(int ix, int iy) const
Definition: EdbCell2.h:57

◆ Bin() [2/4]

int EdbH2::Bin ( int  iv[2]) const
inline
82{return Bin(iv[0],iv[1]);}
int Bin(float x, float y) const
Definition: EdbCell2.h:80

◆ Bin() [3/4]

int EdbH2::Bin ( int  ix,
int  iy 
) const
inline
81{return (Jcell(ix,iy)>-1)? eNC[Jcell(ix,iy)] : 0; }

◆ Bin() [4/4]

int EdbH2::Bin ( int  j) const
inline
83{if(j>-1||j<eNcell) return eNC[j]; else return 0; }

◆ CleanCells()

void EdbH2::CleanCells ( )
115{
116 if(eNC) memset(eNC,'\0',eNcell*sizeof(Int_t));
117}

◆ Copy()

void EdbH2::Copy ( const EdbH2 h)
46{
47 Delete();
48 for(int i=0; i<2; i++) {
49 eN[i]=h.eN[i];
50 eMin[i]=h.eMin[i];
51 eMax[i]=h.eMax[i];
52 eBin[i]=h.eBin[i];
53 }
54 eNcell=h.eNcell;
55 if(h.eNC) {
56 eNC = new Int_t[eNcell];
57 memcpy( eNC, h.eNC, sizeof(Int_t)*eNcell );
58 }
59}
Float_t eMin[2]
min
Definition: EdbCell2.h:24
Float_t eBin[2]
bin size
Definition: EdbCell2.h:26
Int_t eN[2]
divisions
Definition: EdbCell2.h:23
Float_t eMax[2]
max
Definition: EdbCell2.h:25

◆ Delete()

void EdbH2::Delete ( )
69{
70 if(eNC) { delete [] eNC; eNC = 0; }
71 eNcell=0;
72 eN[0] = eN[1] = 0;
73 eMin[0] = eMin[1] = 0;
74 eMax[0] = eMax[1] = 0;
75}

◆ DiscardHighCells()

int EdbH2::DiscardHighCells ( int  nmax)
133{
134 int ic=0;
135 for(int i=0; i<eNcell; i++)
136 if(eNC[i]>nmax) { eNC[i]=0; ic++; }
137 return ic;
138}

◆ DrawH2()

TH2F * EdbH2::DrawH2 ( const char *  name = "plot2d",
const char *  title = "EdbH2plot2D" 
)
188{
189 TObject *obj=0;
190 if((obj=gDirectory->FindObject(name))) delete obj;
191 TH2F *h = new TH2F(name, title, eN[0],eMin[0],eMax[0],eN[1],eMin[1],eMax[1]);
192 for(int i=0; i<eN[0]; i++)
193 for(int j=0; j<eN[1]; j++)
194 h->Fill( X(i), Y(j), Bin(i,j) );
195 return h;
196}
float X(int ix) const
Definition: EdbCell2.h:60
float Y(int iy) const
Definition: EdbCell2.h:61
const char * name
Definition: merge_Energy_SytematicSources_Electron.C:24

◆ DrawSpectrum()

TH1I * EdbH2::DrawSpectrum ( const char *  name = "plot1d",
const char *  title = "EdbH2 DrawSpectrun" 
)
179{
180 int imax = MaxBin();
181 TH1I *h = new TH1I(name, title, imax,0,imax);
182 for(int i=0; i<eNcell; i++) h->Fill( eNC[i] );
183 return h;
184}
int MaxBin()
Definition: EdbCell2.cpp:234

◆ Fill() [1/2]

int EdbH2::Fill ( float  x,
float  y 
)
inline
88{ return Fill(x,y,1); }
int Fill(float x, float y)
Definition: EdbCell2.h:88

◆ Fill() [2/2]

int EdbH2::Fill ( float  x,
float  y,
int  n 
)
121{
122 if(x>eMin[0]&&x<eMax[0]&&y>eMin[1]&&y<eMax[1]) {
123 int j = Jcell(x,y);
124 if(j<0) return 0;
125 eNC[j] += n;
126 return n;
127 }
128 return 0;
129}

◆ InitH2() [1/3]

int EdbH2::InitH2 ( const EdbH2 h)
79{
80 int n[2]={h.NX(),h.NY()};
81 float min[2]={h.Xmin(),h.Ymin()};
82 float max[2]={h.Xmax(),h.Ymax()};
83 return InitH2(n,min,max);
84}
float min(TClonesArray *t)
Definition: bitview.cxx:275
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
int max
Definition: check_shower.C:41

◆ InitH2() [2/3]

int EdbH2::InitH2 ( int  n[2],
float  min[2],
float  max[2] 
)
97{
98 Delete();
99 for(int i=0; i<2; i++) {
100 if(n[i]<1) return 0;
101 eN[i]=n[i];
102 eMin[i] = min[i];
103 eMax[i] = max[i];
104 eBin[i] = (eMax[i]-eMin[i])/eN[i];
105 // if(eBin[i]<0.00000001) return 0;
106 }
107 eNcell = eN[0]*eN[1];
108 eNC = new Int_t[eNcell];
109 CleanCells();
110 return eNcell;
111}
void CleanCells()
Definition: EdbCell2.cpp:114

◆ InitH2() [3/3]

int EdbH2::InitH2 ( int  nx,
float  minx,
float  maxx,
int  ny,
float  miny,
float  maxy 
)
88{
89 int n[2]={nx,ny};
90 float min[2]={minx,miny};
91 float max[2]={maxx,maxy};
92 return InitH2(n,min,max);
93}

◆ Integral() [1/2]

Long_t EdbH2::Integral ( )
217{
218 Long_t ntot=0;
219 for(int i=0; i<eNcell; i++) ntot+=eNC[i];
220 return ntot;
221}

◆ Integral() [2/2]

Long_t EdbH2::Integral ( int  iv[2],
int  ir[2] 
)
225{
226 Long_t ntot=0, nbin=0;
227 for(int ix=iv[0]-ir[0]; ix<=iv[0]+ir[0]; ix++)
228 for(int iy=iv[1]-ir[1]; iy<=iv[1]+ir[1]; iy++)
229 {ntot+=Bin(ix,iy); nbin++;}
230 return ntot;
231}

◆ IX() [1/2]

int EdbH2::IX ( float  x) const
inline
52{return (int)((x-eMin[0])/eBin[0]); }

◆ IX() [2/2]

int EdbH2::IX ( int  jcell) const
inline
54{return jcell%eN[0]; }

◆ IY() [1/2]

int EdbH2::IY ( float  y) const
inline
53{return (int)((y-eMin[1])/eBin[1]); }

◆ IY() [2/2]

int EdbH2::IY ( int  jcell) const
inline
55{return jcell/eN[0]; }

◆ Jcell() [1/3]

int EdbH2::Jcell ( float  v[2]) const
inline
59{return Jcell(IX(v[0]),IY(v[1])); }
int IX(float x) const
Definition: EdbCell2.h:52
int IY(float y) const
Definition: EdbCell2.h:53

◆ Jcell() [2/3]

int EdbH2::Jcell ( float  x,
float  y 
) const
inline
58{return Jcell( IX(x), IY(y)); }

◆ Jcell() [3/3]

int EdbH2::Jcell ( int  ix,
int  iy 
) const
inline
57{if(ix>=0&&ix<eN[0]&&iy>=0&&iy<eN[1]) return iy*eN[0]+ix; else return -1;}

◆ MaxBin()

int EdbH2::MaxBin ( )
235{
236 int peak=0;
237 for(int i=0; i<eNcell; i++) if(eNC[i]>peak) peak =eNC[i];
238 return peak;
239}

◆ Mean()

Float_t EdbH2::Mean ( )
inline
96{ return 1.*Integral()/eNcell; }
Long_t Integral()
Definition: EdbCell2.cpp:216

◆ Ncell()

int EdbH2::Ncell ( ) const
inline
49{return eN[0]*eN[1];}

◆ NX()

int EdbH2::NX ( ) const
inline
50{return eN[0];}

◆ NY()

int EdbH2::NY ( ) const
inline
51{return eN[1];}

◆ PrintStat()

void EdbH2::PrintStat ( )
200{
201 printf("X:%5d cells in range (%10.2f %10.2f) with bin %10.2f \n", eN[0],eMin[0],eMax[0],eBin[0]);
202 printf("Y:%5d cells in range (%10.2f %10.2f) with bin %10.2f \n", eN[1],eMin[1],eMax[1],eBin[1]);
203 if(!eNC) return;
204 int nmax=0, ntot=0;
205 int nmin=kMaxInt;
206 for(int i=0; i<eNcell; i++) {
207 if( eNC[i]>nmax ) nmax=eNC[i];
208 if( eNC[i]<nmin ) nmin=eNC[i];
209 ntot += eNC[i];
210 }
211 printf("%d objects in %d cells filled as: (%d:%d) with mean= %f\n",
212 ntot, eNcell, nmin, nmax, 1.*ntot/eNcell);
213}

◆ ProjectionX()

EdbH1 * EdbH2::ProjectionX ( )
142{
143 EdbH1 *h = new EdbH1(eN[0],eMin[0],eMax[0]);
144 for(int i=0; i<eNcell; i++) h->Fill( X(IX(i)), eNC[i] );
145 return h;
146}
fast 2-dim histogram class (used as a basis for EdbCell1)
Definition: EdbCell1.h:17
int Fill(float x)
Definition: EdbCell1.h:63

◆ ProjectionY()

EdbH1 * EdbH2::ProjectionY ( )
150{
151 EdbH1 *h = new EdbH1(eN[1],eMin[1],eMax[1]);
152 for(int i=0; i<eNcell; i++) h->Fill( Y(IY(i)), eNC[i] );
153 return h;
154}

◆ Set0()

void EdbH2::Set0 ( )
31{
32 for(int i=0; i<2; i++) { eN[i]=0; eMin[i]=0; eMax[i]=0; eBin[i]=0; }
33 eNcell=0;
34 eNC=0;
35}

◆ SetBin() [1/2]

void EdbH2::SetBin ( int  ix,
int  iy,
int  n 
)
inline
90{ if(Jcell(ix,iy)>-1) eNC[Jcell(ix,iy)] = n; }

◆ SetBin() [2/2]

void EdbH2::SetBin ( int  j,
int  n 
)
inline
91{ if(j>-1||j<eNcell) eNC[j] = n; }

◆ X()

float EdbH2::X ( int  ix) const
inline
60{return eMin[0]+eBin[0]*(ix+0.5);}

◆ Xbin()

float EdbH2::Xbin ( ) const
inline
77{return eBin[0];}

◆ Xj()

float EdbH2::Xj ( int  j) const
inline
62{return X(IX(j));}

◆ Xmax()

float EdbH2::Xmax ( ) const
inline
65{return eMax[0];}

◆ XmaxA()

float EdbH2::XmaxA ( float  level = 0)
163{
164 EdbH1 *h = ProjectionX(); return h->XmaxA(level); SafeDelete(h);
165}
float XmaxA(float level=0)
Definition: EdbCell1.cpp:118
EdbH1 * ProjectionX()
Definition: EdbCell2.cpp:141

◆ Xmin()

float EdbH2::Xmin ( ) const
inline
64{return eMin[0];}

◆ XminA()

float EdbH2::XminA ( float  level = 0)
158{
159 EdbH1 *h = ProjectionX(); return h->XminA(level); SafeDelete(h);
160}
float XminA(float level=0)
Definition: EdbCell1.cpp:109

◆ Y()

float EdbH2::Y ( int  iy) const
inline
61{return eMin[1]+eBin[1]*(iy+0.5);}

◆ Ybin()

float EdbH2::Ybin ( ) const
inline
78{return eBin[1];}

◆ Yj()

float EdbH2::Yj ( int  j) const
inline
63{return Y(IY(j));}

◆ Ymax()

float EdbH2::Ymax ( ) const
inline
67{return eMax[1];}

◆ YmaxA()

float EdbH2::YmaxA ( float  level = 0)
173{
174 EdbH1 *h = ProjectionY(); return h->XmaxA(level); SafeDelete(h);
175}
EdbH1 * ProjectionY()
Definition: EdbCell2.cpp:149

◆ Ymin()

float EdbH2::Ymin ( ) const
inline
66{return eMin[1];}

◆ YminA()

float EdbH2::YminA ( float  level = 0)
168{
169 EdbH1 *h = ProjectionY(); return h->XminA(level); SafeDelete(h);
170}

Member Data Documentation

◆ eBin

Float_t EdbH2::eBin[2]
protected

bin size

◆ eMax

Float_t EdbH2::eMax[2]
protected

max

◆ eMin

Float_t EdbH2::eMin[2]
protected

min

◆ eN

Int_t EdbH2::eN[2]
protected

divisions

◆ eNC

Int_t* EdbH2::eNC
protected

[eNcell] number of objects/cell

◆ eNcell

Int_t EdbH2::eNcell
protected

eNx*eNy


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