FEDRA emulsion software from the OPERA Collaboration
EdbH1 Class Reference

#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 ()
 [eNcell] number of objects/cell More...
 
 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
 
Float_t eMax
 
Float_t eMin
 
Int_t eN
 
Int_t * eNC
 
Int_t eNcell
 

Constructor & Destructor Documentation

◆ EdbH1() [1/3]

EdbH1::EdbH1 ( )

[eNcell] number of objects/cell

23 {
24  Set0();
25 }
void Set0()
Definition: EdbCell1.cpp:27

◆ 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 max
Definition: check_shower.C:41
int InitH1(const EdbH1 &h)
Definition: EdbCell1.h:38

◆ EdbH1() [3/3]

EdbH1::EdbH1 ( const EdbH1 h)
36 {
37  eNC = 0;
38  Copy(h);
39 }
Int_t * eNC
Definition: EdbCell1.h:27
void Copy(const EdbH1 &h)
Definition: EdbCell1.cpp:42

◆ ~EdbH1()

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

Member Function Documentation

◆ AddBin()

void EdbH1::AddBin ( int  jcell,
int  n 
)
inline
62 { if(jcell>=0&&jcell<eNcell) eNC[jcell]+=n; }
Int_t eNcell
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 ( )
85 {
86  if(eNC) memset(eNC,'\0',eNcell*sizeof(Int_t));
87 }

◆ Copy()

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

◆ Delete()

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

◆ DiscardHighCells()

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

◆ DrawH1()

TH1F * EdbH1::DrawH1 ( const char *  name = "EdbH1plot",
const char *  title = "EdbH1plot1D" 
)
136 {
137  TObject *obj=0;
138  if((obj=gDirectory->FindObject(name))) delete obj;
139  TH1F *h = new TH1F(name, title, eN,eMin,eMax);
140  for(int i=0; i<eN; i++) h->Fill( X(i), eNC[Jcell(i)] );
141  return h;
142 }
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")
127 {
128  int imax = MaxBin();
129  TH1I *h = new TH1I(name,"EdbH1 spectrum plot", imax,0,imax);
130  for(int i=0; i<eNcell; i++) h->Fill( eNC[i] );
131  return h;
132 }
int MaxBin()
Definition: EdbCell1.cpp:186

◆ 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 
)
91 {
92  int j = Jcell(x);
93  if(j<0) return 0;
94  eNC[j] += n;
95  return n;
96 }

◆ 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 
)
70 {
71  if(n<1) return 0;
72  eN=n;
73  eMin = min;
74  eMax = max;
75  eBin = (eMax-eMin)/eN;
76  eNcell = eN;
77  if(eNC) delete [] eNC;
78  eNC = new Int_t[eNcell];
79  CleanCells();
80  return eNcell;
81 }
void CleanCells()
Definition: EdbCell1.cpp:84

◆ Integral() [1/2]

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

◆ Integral() [2/2]

Long_t EdbH1::Integral ( int  iv,
int  ir 
)
178 {
179  Long_t ntot=0, nbin=0;
180  for(int ix=iv-ir; ix<=iv+ir; ix++)
181  {ntot+=Bin(ix); nbin++;}
182  return ntot;
183 }
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 ( )
187 {
188  int peak=0;
189  for(int i=0; i<eNcell; i++) if(eNC[i]>peak) peak =eNC[i];
190  return peak;
191 }

◆ Mean()

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

◆ N()

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

◆ Ncell()

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

◆ Print()

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

◆ PrintStat()

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

◆ Set0()

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

◆ 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)
118 {
119  // return X of the last bin >= given ratio in respect to the maximum amplitude (level range: [0:1] )
120  float thres = MaxBin()*level;
121  for(int i=eNcell-1; i>=0; i--) if( eNC[i] >= thres ) return X(i);
122  return 0;
123 }

◆ Xmin()

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

◆ XminA()

float EdbH1::XminA ( float  level = 0)
109 {
110 // return X of the first bin >= given ratio in respect to the maximum amplitude (level range: [0:1] )
111  float thres = MaxBin()*level;
112  for(int i=0; i<eNcell; i++) if( eNC[i] >= thres ) return X(i);
113  return 0;
114 }

Member Data Documentation

◆ eBin

Float_t EdbH1::eBin
protected

◆ eMax

Float_t EdbH1::eMax
protected

◆ eMin

Float_t EdbH1::eMin
protected

◆ eN

Int_t EdbH1::eN
protected

◆ eNC

Int_t* EdbH1::eNC
protected

◆ eNcell

Int_t EdbH1::eNcell
protected

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