FEDRA emulsion software from the OPERA Collaboration
EdbH2 Class Reference

#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 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 ()
 

Protected Attributes

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

◆ EdbH2() [1/3]

EdbH2::EdbH2 ( )
26 {
27  Set0();
28 }
void Set0()
Definition: EdbCell2.cpp:31

◆ 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:79
int nx
Definition: emthickness.cpp:60
int ny
Definition: emthickness.cpp:62

◆ EdbH2() [3/3]

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

◆ ~EdbH2()

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

Member Function Documentation

◆ AddBin()

void EdbH2::AddBin ( int  jcell,
int  n 
)
inline
87 { if(jcell>=0&&jcell<eNcell) eNC[jcell]+=n; }
Int_t * eNC
Definition: EdbCell2.h:29
Int_t eNcell
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 ( )
116 {
117  if(eNC) memset(eNC,'\0',eNcell*sizeof(Int_t));
118 }

◆ Copy()

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

◆ Delete()

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

◆ DiscardHighCells()

int EdbH2::DiscardHighCells ( int  nmax)
143 {
144  int ic=0;
145  for(int i=0; i<eNcell; i++)
146  if(eNC[i]>nmax) { eNC[i]=0; ic++; }
147  return ic;
148 }

◆ DrawH2()

TH2F * EdbH2::DrawH2 ( const char *  name = "plot2d",
const char *  title = "EdbH2plot2D" 
)
198 {
199  TObject *obj=0;
200  if((obj=gDirectory->FindObject(name))) delete obj;
201  TH2F *h = new TH2F(name, title, eN[0],eMin[0],eMax[0],eN[1],eMin[1],eMax[1]);
202  for(int i=0; i<eN[0]; i++)
203  for(int j=0; j<eN[1]; j++)
204  h->Fill( X(i), Y(j), Bin(i,j) );
205  return h;
206 }
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 DrawSpectrum" 
)
189 {
190  int imax = MaxBin();
191  TH1I *h = new TH1I(name, title, imax,0,imax);
192  for(int i=0; i<eNcell; i++) h->Fill( eNC[i] );
193  return h;
194 }
int MaxBin()
Definition: EdbCell2.cpp:244

◆ Fill() [1/3]

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/3]

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

◆ Fill() [3/3]

int EdbH2::Fill ( int  j,
int  n = 1 
)
132 {
133  if( j>-1 && j<eNcell)
134  {
135  eNC[j] += n;
136  return n;
137  }
138  return 0;
139 }

◆ InitH2() [1/3]

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

◆ InitH2() [2/3]

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

◆ InitH2() [3/3]

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

◆ Integral() [1/2]

Long_t EdbH2::Integral ( )
227 {
228  Long_t ntot=0;
229  for(int i=0; i<eNcell; i++) ntot+=eNC[i];
230  return ntot;
231 }

◆ Integral() [2/2]

Long_t EdbH2::Integral ( int  iv[2],
int  ir[2] 
)
235 {
236  Long_t ntot=0, nbin=0;
237  for(int ix=iv[0]-ir[0]; ix<=iv[0]+ir[0]; ix++)
238  for(int iy=iv[1]-ir[1]; iy<=iv[1]+ir[1]; iy++)
239  {ntot+=Bin(ix,iy); nbin++;}
240  return ntot;
241 }

◆ 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 ( )
245 {
246  int peak=0;
247  for(int i=0; i<eNcell; i++) if(eNC[i]>peak) peak =eNC[i];
248  return peak;
249 }

◆ Mean()

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

◆ 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 ( )
210 {
211  printf("X:%5d cells in range (%10.2f %10.2f) with bin %10.2f \n", eN[0],eMin[0],eMax[0],eBin[0]);
212  printf("Y:%5d cells in range (%10.2f %10.2f) with bin %10.2f \n", eN[1],eMin[1],eMax[1],eBin[1]);
213  if(!eNC) return;
214  int nmax=0, ntot=0;
215  int nmin=kMaxInt;
216  for(int i=0; i<eNcell; i++) {
217  if( eNC[i]>nmax ) nmax=eNC[i];
218  if( eNC[i]<nmin ) nmin=eNC[i];
219  ntot += eNC[i];
220  }
221  printf("%d objects in %d cells filled as: (%d:%d) with mean= %f\n",
222  ntot, eNcell, nmin, nmax, 1.*ntot/eNcell);
223 }

◆ ProjectionX()

EdbH1 * EdbH2::ProjectionX ( )
152 {
153  EdbH1 *h = new EdbH1(eN[0],eMin[0],eMax[0]);
154  for(int i=0; i<eNcell; i++) h->Fill( X(IX(i)), eNC[i] );
155  return h;
156 }
Definition: EdbCell1.h:17
int Fill(float x)
Definition: EdbCell1.h:63

◆ ProjectionY()

EdbH1 * EdbH2::ProjectionY ( )
160 {
161  EdbH1 *h = new EdbH1(eN[1],eMin[1],eMax[1]);
162  for(int i=0; i<eNcell; i++) h->Fill( Y(IY(i)), eNC[i] );
163  return h;
164 }

◆ Set0()

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

◆ SetBin() [1/2]

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

◆ SetBin() [2/2]

void EdbH2::SetBin ( int  j,
int  n 
)
inline
92 { 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)
173 {
174  EdbH1 *h = ProjectionX(); return h->XmaxA(level); SafeDelete(h);
175 }
float XmaxA(float level=0)
Definition: EdbCell1.cpp:117
EdbH1 * ProjectionX()
Definition: EdbCell2.cpp:151

◆ Xmin()

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

◆ XminA()

float EdbH2::XminA ( float  level = 0)
168 {
169  EdbH1 *h = ProjectionX(); return h->XminA(level); SafeDelete(h);
170 }
float XminA(float level=0)
Definition: EdbCell1.cpp:108

◆ 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)
183 {
184  EdbH1 *h = ProjectionY(); return h->XmaxA(level); SafeDelete(h);
185 }
EdbH1 * ProjectionY()
Definition: EdbCell2.cpp:159

◆ Ymin()

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

◆ YminA()

float EdbH2::YminA ( float  level = 0)
178 {
179  EdbH1 *h = ProjectionY(); return h->XminA(level); SafeDelete(h);
180 }

Member Data Documentation

◆ eBin

Float_t EdbH2::eBin[2]
protected

◆ eMax

Float_t EdbH2::eMax[2]
protected

◆ eMin

Float_t EdbH2::eMin[2]
protected

◆ eN

Int_t EdbH2::eN[2]
protected

◆ eNC

Int_t* EdbH2::eNC
protected

◆ eNcell

Int_t EdbH2::eNcell
protected

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