3 #include "StHbtMaker/Infrastructure/franks1HistoD.hh"
9 franks1HistoD::franks1HistoD(
const char* c1,
const char* c2,
int bins,
double xmin,
double xmax) {
15 mStep = (xmax-xmin)/bins;
16 vec =
new double[bins];
21 franks1HistoD::~franks1HistoD() {
30 for (
int i=0; i < mBins; i++) {
31 vec[i] = h1->vec[i]*w1 + h2->vec[i]*w2;
36 for (
int i=0; i < mBins; i++) {
37 if (h2->vec[i]*w2 !=0 )
38 vec[i] = h1->vec[i]*w1 / h2->vec[i]*w2;
44 void franks1HistoD::Draw(
const char* c) {
45 cout << c <<
" " << mC1 <<
" " << endl;
46 double min=GetMinimum();
47 double max=GetMaximum();
48 double step = (max-min)/50.;
49 cout <<
" minimum=" << min <<
" maximum=" << max <<
" step=" << step << endl;
50 for (
int i=0; i < mBins; i++) {
51 printf(
" (%3i) %+e %+e ",i, GetBinCenter(i), vec[i]);
52 for (
int j=0; j < floor( (vec[i]-min)/step ); j++) {
59 int franks1HistoD::GetBin(
double value) {
60 int bin = (int) floor( (value-mXmin)/mStep );
61 if( !(bin >=0 && bin < mBins) ) bin=-1;
65 double franks1HistoD::GetBinCenter(
int bin) {
67 if ( bin >=0 && bin < mBins)
68 center= mXmin + (0.5+bin)*mStep;
72 double franks1HistoD::GetMean() {
74 for (
int i=0; i< mBins; i++)
75 mean+=vec[i]*GetBinCenter(i);
80 double franks1HistoD::GetMaximum() {
82 for (
int i=0; i< mBins; i++) {
89 double franks1HistoD::GetMinimum() {
91 for (
int i=0; i< mBins; i++) {
98 double franks1HistoD::GetRMS() {
99 double mean = GetMean();
100 for (
int i=0; i< mBins; i++)
101 mean+=vec[i]*GetBinCenter(i);
106 void franks1HistoD::Reset(
const char*) {
107 for (
int i=0; i < mBins; i++)
111 void franks1HistoD::Scale(
double scale) {
112 for (
int i=0; i < mBins; i++)
116 double franks1HistoD::Integral() {
118 for (
int i=0; i < mBins; i++) {
125 double franks1HistoD::GetEntries() {
129 void franks1HistoD::Fill(
double value) {
130 mPos = (int) fabs( (value-mXmin)/mStep );
131 if ( mPos>=0 && mPos < mBins)
135 void franks1HistoD::Fill(
double value,
double weight) {
136 mPos = (int) fabs( (value-mXmin)/mStep );
137 if ( mPos>=0 && mPos < mBins)
138 vec[mPos] = vec[mPos] + weight;