19 int iNBins,
double iXMin,
double iXMax ) {
22 fprintf ( stderr,
" %d bins, not valid value \n", (
int)iNBins );
25 header.nBins = iNBins ;
26 if ( iXMin > iXMax ) {
27 fprintf ( stderr,
" xMin %e xMax %e, not valid values \n", iXMin, iXMax );
30 strcpy ( header.id, iId ) ;
31 strcpy ( header.title, iTitle ) ;
32 header.nBins = iNBins ;
37 header.yMin = header.yMax = 0. ;
38 header.xStep = (header.xMax-header.xMin)/
float(header.nBins);
41 info =
new double[header.nBins+2];
42 memset ( info, 0, (header.nBins+2)*
sizeof(
double) ) ;
48 if ( info )
delete[] info ;
54 int iBin = (int)((x-header.xMin)/header.xStep)+1 ;
55 if ( iBin < 1 ) iBin = 0 ;
56 else if ( iBin > header.nBins ) iBin = header.nBins + 1 ;
58 info[iBin] += weight ;
59 if ( iBin > 1 && iBin < header.nBins + 1 ) {
60 if ( info[iBin] > header.yMax ) {
61 header.yMax = info[iBin] ;
64 if ( info[iBin] < header.yMin ) header.yMin = info[iBin] ;
66 header.sum += weight ;
76 if ( iBin < 0 || iBin > header.nBins+2 ) {
77 printf(
"out of range\n");
86 printf (
"gl3Histo::Print: id \"%s\" title \"%s\" nBins %d nEntries %d\n",
87 header.id, header.title,
88 (
int)header.nBins, (
int)header.nEntries ) ;
104 if ( info )
delete info ;
105 info =
new double[header.nBins+2];
108 (header.nBins+2)*
sizeof(
double) ) ;
122 header.nEntries = 0 ;
127 memset ( info, 0, (header.nBins+2)*
sizeof(
double) ) ;
139 printf(
"gl3Histo::Write %d bytes in buffer not enough \n", maxBytes);
145 (header.nBins+2)*
sizeof(
double) );
168 return header.maxBin;
176 return(header.xMin+(
float(Bin-0.5)*header.xStep)) ;
189 if(minBin>=0 && maxBin<header.nBins) {
190 for(
int cnt=minBin; cnt<=maxBin; cnt++) sum +=
GetY(cnt);
201 double gl3Histo::getWeightedMean(
double sigmaWidthBins)
211 double SigmaHalfL =
Integral((
int)(HistoMaxBin-sigmaWidthBins),HistoMaxBin-1);
212 double SigmaHalfR =
Integral(HistoMaxBin+1,(
int)(HistoMaxBin+sigmaWidthBins));
213 double SigmaHalfLCenter=0;
215 for(
int cnt=HistoMaxBin-1; cnt>=(HistoMaxBin-sigmaWidthBins); cnt--) {
216 SigmaHalfLCenter = SigmaHalfLCenter +
GetBinCenter(cnt);
218 SigmaHalfLCenter=SigmaHalfLCenter/sigmaWidthBins;
220 double SigmaHalfRCenter=0;
221 for(
int cnt=HistoMaxBin+1; cnt<=(HistoMaxBin+sigmaWidthBins); cnt++) {
224 SigmaHalfRCenter=SigmaHalfRCenter/sigmaWidthBins;
227 if((SigmaHalfL+HistoMax+SigmaHalfR)>0) {
228 weightedMean = ( (SigmaHalfL * SigmaHalfLCenter) +
229 (HistoMax * HistoMaxCenter) +
230 (SigmaHalfR * SigmaHalfRCenter) )
231 / (SigmaHalfL+HistoMax+SigmaHalfR);
233 else weightedMean=0.0;
235 return(weightedMean);
double GetMaximum()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ...
int Reset()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
double GetBinCenter(int Bin)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ...
int Write(unsigned int maxBytes, char *output)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
double Integral(int minBin, int maxBin)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ...
~gl3Histo()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ...
double GetY(int iBin)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ...
int Print(short Level=1)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ...
gl3Histo(char iId[10]="id", char iTitle[100]="name", int iNBins=100, double iXMin=0., double iXMax=100.)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ...
int GetMaximumBin()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ...
int Read(char *input)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
int Fill(double x, double weight=1)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ...