FEDRA emulsion software from the OPERA Collaboration
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EdbH1 Class Reference

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

#include <EdbCell1.h>

Inheritance diagram for EdbH1:
Collaboration diagram for EdbH1:

Public Member Functions

void AddBin (int jcell, int n)
 
int Bin (int ix) const
 
void CleanCells ()
 
void Copy (const EdbH1 &h)
 
void Delete ()
 
int DiscardHighCells (int nmax)
 
TH1F * DrawH1 (const char *name="EdbH1plot", const char *title="EdbH1plot1D")
 
TH1I * DrawSpectrum (const char *name="EdbH1spectrun")
 
 EdbH1 ()
 
 EdbH1 (const EdbH1 &h)
 
 EdbH1 (int n, float min, float max)
 
int Fill (float x)
 
int Fill (float x, int n)
 
int InitH1 (const EdbH1 &h)
 
int InitH1 (int n, float min, float max)
 
Long_t Integral ()
 
Long_t Integral (int iv, int ir)
 
int IX (float x) const
 
int Jcell (float x) const
 
int Jcell (int ix) const
 
int MaxBin ()
 
Float_t Mean ()
 
int N () const
 
int Ncell () const
 
void Print ()
 
void PrintStat ()
 
void Set0 ()
 
void SetBin (int ix, int n)
 
float X (int i) const
 
float Xbin () const
 
float Xmax () const
 
float XmaxA (float level=0)
 
float Xmin () const
 
float XminA (float level=0)
 
 ~EdbH1 ()
 

Protected Attributes

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

Detailed Description

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

//////////////////////////////////////////////////////////////////////// // EdbCell1 // // class to group 1-dim objects for the fast access // // ////////////////////////////////////////////////////////////////////////

Constructor & Destructor Documentation

◆ EdbH1() [1/3]

EdbH1::EdbH1 ( )
24{
25 Set0();
26}
void Set0()
Definition: EdbCell1.cpp:28

◆ EdbH1() [2/3]

EdbH1::EdbH1 ( int  n,
float  min,
float  max 
)
inline
31{ Set0(); InitH1(n,min,max); }
float min(TClonesArray *t)
Definition: bitview.cxx:275
int InitH1(const EdbH1 &h)
Definition: EdbCell1.h:38
int max
Definition: check_shower.C:41

◆ EdbH1() [3/3]

EdbH1::EdbH1 ( const EdbH1 h)
37{
38 eNC = 0;
39 Copy(h);
40}
Int_t * eNC
[eNcell] number of objects/cell
Definition: EdbCell1.h:27
void Copy(const EdbH1 &h)
Definition: EdbCell1.cpp:43

◆ ~EdbH1()

EdbH1::~EdbH1 ( )
59{
60 Delete();
61}
void Delete()
Definition: EdbCell1.cpp:64

Member Function Documentation

◆ AddBin()

void EdbH1::AddBin ( int  jcell,
int  n 
)
inline
62{ if(jcell>=0&&jcell<eNcell) eNC[jcell]+=n; }
Int_t eNcell
eN
Definition: EdbCell1.h:26

◆ Bin()

int EdbH1::Bin ( int  ix) const
inline
57{ if(Jcell(ix)>-1) return eNC[Jcell(ix)]; else return 0; }
int Jcell(int ix) const
Definition: EdbCell1.h:51

◆ CleanCells()

void EdbH1::CleanCells ( )
86{
87 if(eNC) memset(eNC,'\0',eNcell*sizeof(Int_t));
88}

◆ Copy()

void EdbH1::Copy ( const EdbH1 h)
44{
45 Delete();
46 eN=h.eN;
47 eMin=h.eMin;
48 eMax=h.eMax;
49 eBin=h.eBin;
50 eNcell=h.eNcell;
51 if(h.eNC) {
52 eNC = new Int_t[eNcell];
53 memcpy( eNC, h.eNC, sizeof(Int_t)*eNcell );
54 }
55}
Float_t eBin
bin size
Definition: EdbCell1.h:24
Float_t eMax
max
Definition: EdbCell1.h:23
Float_t eMin
min
Definition: EdbCell1.h:22
Int_t eN
divisions
Definition: EdbCell1.h:21

◆ Delete()

void EdbH1::Delete ( )
65{
66 if(eNC) { delete [] eNC; eNC = 0; }
67}

◆ DiscardHighCells()

int EdbH1::DiscardHighCells ( int  nmax)
101{
102 int ic=0;
103 for(int i=0; i<eNcell; i++)
104 if(eNC[i]>nmax) { eNC[i]=0; ic++; }
105 return ic;
106}

◆ DrawH1()

TH1F * EdbH1::DrawH1 ( const char *  name = "EdbH1plot",
const char *  title = "EdbH1plot1D" 
)
137{
138 TObject *obj=0;
139 if((obj=gDirectory->FindObject(name))) delete obj;
140 TH1F *h = new TH1F(name, title, eN,eMin,eMax);
141 for(int i=0; i<eN; i++) h->Fill( X(i), eNC[Jcell(i)] );
142 return h;
143}
float X(int i) const
Definition: EdbCell1.h:53
const char * name
Definition: merge_Energy_SytematicSources_Electron.C:24

◆ DrawSpectrum()

TH1I * EdbH1::DrawSpectrum ( const char *  name = "EdbH1spectrun")
128{
129 int imax = MaxBin();
130 TH1I *h = new TH1I(name,"EdbH1 spectrum plot", imax,0,imax);
131 for(int i=0; i<eNcell; i++) h->Fill( eNC[i] );
132 return h;
133}
int MaxBin()
Definition: EdbCell1.cpp:187

◆ Fill() [1/2]

int EdbH1::Fill ( float  x)
inline
63{ return Fill(x,1); }
int Fill(float x)
Definition: EdbCell1.h:63

◆ Fill() [2/2]

int EdbH1::Fill ( float  x,
int  n 
)
92{
93 int j = Jcell(x);
94 if(j<0) return 0;
95 eNC[j] += n;
96 return n;
97}

◆ InitH1() [1/2]

int EdbH1::InitH1 ( const EdbH1 h)
inline
38{return InitH1( h.N(), h.Xmin(), h.Xmax() ); }
int N() const
Definition: EdbCell1.h:48
float Xmax() const
Definition: EdbCell1.h:55
float Xmin() const
Definition: EdbCell1.h:54

◆ InitH1() [2/2]

int EdbH1::InitH1 ( int  n,
float  min,
float  max 
)
71{
72 if(n<1) return 0;
73 eN=n;
74 eMin = min;
75 eMax = max;
76 eBin = (eMax-eMin)/eN;
77 eNcell = eN;
78 if(eNC) delete [] eNC;
79 eNC = new Int_t[eNcell];
80 CleanCells();
81 return eNcell;
82}
void CleanCells()
Definition: EdbCell1.cpp:85

◆ Integral() [1/2]

Long_t EdbH1::Integral ( )
171{
172 Long_t ntot=0;
173 for(int i=0; i<eNcell; i++) ntot+=eNC[i];
174 return ntot;
175}

◆ Integral() [2/2]

Long_t EdbH1::Integral ( int  iv,
int  ir 
)
179{
180 Long_t ntot=0, nbin=0;
181 for(int ix=iv-ir; ix<=iv+ir; ix++)
182 {ntot+=Bin(ix); nbin++;}
183 return ntot;
184}
int Bin(int ix) const
Definition: EdbCell1.h:57

◆ IX()

int EdbH1::IX ( float  x) const
inline
50{ return (int)((x-eMin)/eBin); }

◆ Jcell() [1/2]

int EdbH1::Jcell ( float  x) const
inline
52{ return Jcell( IX(x) ); }
int IX(float x) const
Definition: EdbCell1.h:50

◆ Jcell() [2/2]

int EdbH1::Jcell ( int  ix) const
inline
51{ if(ix>=0&&ix<eN) return ix; else return -1;}

◆ MaxBin()

int EdbH1::MaxBin ( )
188{
189 int peak=0;
190 for(int i=0; i<eNcell; i++) if(eNC[i]>peak) peak =eNC[i];
191 return peak;
192}

◆ Mean()

Float_t EdbH1::Mean ( )
inline
70{ return 1.*Integral()/eNcell; }
Long_t Integral()
Definition: EdbCell1.cpp:170

◆ N()

int EdbH1::N ( ) const
inline
48{return eN;}

◆ Ncell()

int EdbH1::Ncell ( ) const
inline
47{return eNcell;}

◆ Print()

void EdbH1::Print ( )
162{
163 PrintStat();
164 for(int i=0; i<N(); i++)
165 printf("%d (%f) = %d\n", i, X(i), Bin(i) );
166}
void PrintStat()
Definition: EdbCell1.cpp:146

◆ PrintStat()

void EdbH1::PrintStat ( )
147{
148 printf("X:%5d cells in range (%10.2f %10.2f) with bin %10.2f \n", eN,eMin,eMax,eBin);
149 if(!eNC) return;
150 int nmax=0, ntot=0;
151 int nmin=kMaxInt;
152 for(int i=0; i<eNcell; i++) {
153 if( eNC[i]>nmax ) nmax=eNC[i];
154 if( eNC[i]<nmin ) nmin=eNC[i];
155 ntot += eNC[i];
156 }
157 printf("%d entries in %d bins in the range: (%d:%d) with mean occupancy= %f\n",
158 ntot, eNcell, nmin, nmax, 1.*ntot/eNcell);
159}

◆ Set0()

void EdbH1::Set0 ( )
29{
30 eN=0;
31 eNcell=0;
32 eNC=0;
33}

◆ SetBin()

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

◆ X()

float EdbH1::X ( int  i) const
inline
53{ return eMin+eBin*(i+0.5); }

◆ Xbin()

float EdbH1::Xbin ( ) const
inline
56{ return eBin; }

◆ Xmax()

float EdbH1::Xmax ( ) const
inline
55{ return eMax; }

◆ XmaxA()

float EdbH1::XmaxA ( float  level = 0)

return X of the last bin >= given ratio in respect to the maximum amplitude (level range: [0:1] )

119{
121 float thres = MaxBin()*level;
122 for(int i=eNcell-1; i>=0; i--) if( eNC[i] >= thres ) return X(i);
123 return 0;
124}

◆ Xmin()

float EdbH1::Xmin ( ) const
inline
54{ return eMin; }

◆ XminA()

float EdbH1::XminA ( float  level = 0)

return X of the first bin >= given ratio in respect to the maximum amplitude (level range: [0:1] )

110{
112 float thres = MaxBin()*level;
113 for(int i=0; i<eNcell; i++) if( eNC[i] >= thres ) return X(i);
114 return 0;
115}

Member Data Documentation

◆ eBin

Float_t EdbH1::eBin
protected

bin size

◆ eMax

Float_t EdbH1::eMax
protected

max

◆ eMin

Float_t EdbH1::eMin
protected

min

◆ eN

Int_t EdbH1::eN
protected

divisions

◆ eNC

Int_t* EdbH1::eNC
protected

[eNcell] number of objects/cell

◆ eNcell

Int_t EdbH1::eNcell
protected

eN


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