From 5cc48fe539b9d759c2ee38b9af2657750e84b84f Mon Sep 17 00:00:00 2001 From: adrien-matta <a.matta@surrey.ac.uk> Date: Wed, 27 Jan 2016 17:30:01 +0000 Subject: [PATCH] * Fixing binning issue in NPFunction --- NPLib/Physics/NPFunction.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/NPLib/Physics/NPFunction.cxx b/NPLib/Physics/NPFunction.cxx index 94c82778a..c542eab80 100644 --- a/NPLib/Physics/NPFunction.cxx +++ b/NPLib/Physics/NPFunction.cxx @@ -66,7 +66,7 @@ TH1F* Read1DProfile(string filename,string HistName) // read the file Double_t xmin = 200; Double_t xmax = -200; - Double_t size = 0; + int mysize = 0; while (getline(ASCII, LineBuffer)) { stringstream iss(LineBuffer); if (!(iss >> xb >> wb)) {continue;} // skip comment lines @@ -77,16 +77,16 @@ TH1F* Read1DProfile(string filename,string HistName) // compute xmin / xmax / size of x array if (xb > xmax) xmax = xb; if (xb < xmin) xmin = xb; - size++; + mysize++; } - Double_t dx = (xmax - xmin) / (size - 1); + Double_t dx = (xmax - xmin) / (mysize); // cout << xmin << "\t" << xmax << "\t" << size << "\t" << dx << endl; // fill histo // h = new TH1F(HistName.c_str(), HistName.c_str(), size, xmin-dx/2, xmax+dx/2); - h = new TH1F(HistName.c_str(), HistName.c_str(), size, xmin, xmax+dx); + h = new TH1F(HistName.c_str(), HistName.c_str(), mysize, xmin, xmax+dx); // h = new TH1F(HistName.c_str(), HistName.c_str(), size, xmin, xmax); - for (unsigned int i = 0; i < size; i++) { + for (unsigned int i = 0; i < mysize; i++) { int bin = h->FindBin(x[i]); h->SetBinContent(bin,w[i]); // cout << i << "\t" << x[i] << "\t" << bin << "\t" << w[i] << "\t" << h->GetBinContent(bin) << endl; -- GitLab